ClientFactory -> SessionFactory, etc.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5509 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-11-06 18:24:44 +00:00
parent c69630b7e0
commit b81ccde75b
9 changed files with 35 additions and 35 deletions
@@ -120,7 +120,7 @@ public class BureauRegistry
* Provides the Bureau registry with necessary runtime configuration. Inserts the bureau * Provides the Bureau registry with necessary runtime configuration. Inserts the bureau
* client factory into the client manager and registers observers to track the progress * client factory into the client manager and registers observers to track the progress
* of launched bureaus. * of launched bureaus.
* @see BureauClientFactory * @see BureauSessionFactory
*/ */
public void init () public void init ()
{ {
@@ -145,10 +145,10 @@ public class BureauRegistry
* client factories are in place. The installed factory will simply create presents clients and * client factories are in place. The installed factory will simply create presents clients and
* client objects for bureaus. * client objects for bureaus.
*/ */
public void setDefaultClientFactory () public void setDefaultSessionFactory ()
{ {
// add the client factory, but later, after all the other modules have been initialized // add the client factory, but later, after all the other modules have been initialized
_clmgr.setClientFactory(new BureauClientFactory(_clmgr.getClientFactory())); _clmgr.setSessionFactory(new BureauSessionFactory(_clmgr.getSessionFactory()));
} }
/** /**
@@ -24,7 +24,7 @@ package com.threerings.bureau.server;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.SessionFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsSession; import com.threerings.presents.server.PresentsSession;
@@ -34,28 +34,28 @@ import com.threerings.bureau.data.BureauCredentials;
* Handles resolution of bureaus and passes non-bureau resolution requests through to a normal * Handles resolution of bureaus and passes non-bureau resolution requests through to a normal
* factory. For bureaus, creates base class instances {@link PresentsSession} and * factory. For bureaus, creates base class instances {@link PresentsSession} and
* {@link ClientResolver}. * {@link ClientResolver}.
* @see BureauRegistry#setDefaultClientFactory() * @see BureauRegistry#setDefaultSessionFactory()
*/ */
public class BureauClientFactory implements ClientFactory public class BureauSessionFactory implements SessionFactory
{ {
public BureauClientFactory (ClientFactory delegate) public BureauSessionFactory (SessionFactory delegate)
{ {
_delegate = delegate; _delegate = delegate;
} }
// from interface ClientFactory // from interface SessionFactory
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) public Class<? extends PresentsSession> getSessionClass (AuthRequest areq)
{ {
// Just give bureaus a vanilla PresentsSession client for now. // Just give bureaus a vanilla PresentsSession client for now.
// TODO: will bureaus need a more tailored client? // TODO: will bureaus need a more tailored client?
if (areq.getCredentials() instanceof BureauCredentials) { if (areq.getCredentials() instanceof BureauCredentials) {
return PresentsSession.class; return PresentsSession.class;
} else { } else {
return _delegate.getClientClass(areq); return _delegate.getSessionClass(areq);
} }
} }
// from interface ClientFactory // from interface SessionFactory
public Class<? extends ClientResolver> getClientResolverClass (Name username) public Class<? extends ClientResolver> getClientResolverClass (Name username)
{ {
// Just give bureaus a vanilla ClientResolver for now. // Just give bureaus a vanilla ClientResolver for now.
@@ -67,5 +67,5 @@ public class BureauClientFactory implements ClientFactory
} }
} }
protected ClientFactory _delegate; protected SessionFactory _delegate;
} }
@@ -29,7 +29,7 @@ import com.google.inject.Singleton;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.SessionFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsSession; import com.threerings.presents.server.PresentsSession;
import com.threerings.presents.server.PresentsServer; import com.threerings.presents.server.PresentsServer;
@@ -63,8 +63,8 @@ public class CrowdServer extends PresentsServer
super.init(injector); super.init(injector);
// configure the client manager to use our bits // configure the client manager to use our bits
_clmgr.setClientFactory(new ClientFactory() { _clmgr.setSessionFactory(new SessionFactory() {
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) { public Class<? extends PresentsSession> getSessionClass (AuthRequest areq) {
return CrowdSession.class; return CrowdSession.class;
} }
public Class<? extends ClientResolver> getClientResolverClass (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
@@ -197,7 +197,7 @@ public abstract class PeerManager
// wire ourselves into the server // wire ourselves into the server
_conmgr.addChainedAuthenticator(new PeerAuthenticator(this)); _conmgr.addChainedAuthenticator(new PeerAuthenticator(this));
_clmgr.setClientFactory(new PeerClientFactory(_clmgr.getClientFactory())); _clmgr.setSessionFactory(new PeerSessionFactory(_clmgr.getSessionFactory()));
// create our node object // create our node object
_nodeobj = _omgr.registerObject(createNodeObject()); _nodeobj = _omgr.registerObject(createNodeObject());
@@ -40,7 +40,7 @@ public class PeerSession extends PresentsSession
{ {
/** /**
* Creates a peer session and provides it with a reference to the peer manager. This is only * Creates a peer session and provides it with a reference to the peer manager. This is only
* done by the {@link PeerClientFactory}. * done by the {@link PeerSessionFactory}.
*/ */
@Inject public PeerSession (PeerManager peermgr) @Inject public PeerSession (PeerManager peermgr)
{ {
@@ -25,7 +25,7 @@ import com.threerings.util.Name;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.peer.net.PeerCreds; import com.threerings.presents.peer.net.PeerCreds;
import com.threerings.presents.server.ClientFactory; import com.threerings.presents.server.SessionFactory;
import com.threerings.presents.server.ClientResolver; import com.threerings.presents.server.ClientResolver;
import com.threerings.presents.server.PresentsSession; import com.threerings.presents.server.PresentsSession;
@@ -33,24 +33,24 @@ import com.threerings.presents.server.PresentsSession;
* Handles resolution of peer servers and passes non-peer resolution requests through to a normal * Handles resolution of peer servers and passes non-peer resolution requests through to a normal
* factory. * factory.
*/ */
public class PeerClientFactory implements ClientFactory public class PeerSessionFactory implements SessionFactory
{ {
public PeerClientFactory (ClientFactory delegate) public PeerSessionFactory (SessionFactory delegate)
{ {
_delegate = delegate; _delegate = delegate;
} }
// documentation inherited from interface ClientFactory // documentation inherited from interface SessionFactory
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) public Class<? extends PresentsSession> getSessionClass (AuthRequest areq)
{ {
if (areq.getCredentials() instanceof PeerCreds) { if (areq.getCredentials() instanceof PeerCreds) {
return PeerSession.class; return PeerSession.class;
} else { } else {
return _delegate.getClientClass(areq); return _delegate.getSessionClass(areq);
} }
} }
// documentation inherited from interface ClientFactory // documentation inherited from interface SessionFactory
public Class<? extends ClientResolver> getClientResolverClass (Name username) public Class<? extends ClientResolver> getClientResolverClass (Name username)
{ {
if (username.toString().startsWith(PeerCreds.PEER_PREFIX)) { if (username.toString().startsWith(PeerCreds.PEER_PREFIX)) {
@@ -60,5 +60,5 @@ public class PeerClientFactory implements ClientFactory
} }
} }
protected ClientFactory _delegate; protected SessionFactory _delegate;
} }
@@ -149,15 +149,15 @@ public class ClientManager
* Configures the client manager with a factory for creating {@link PresentsSession} and {@link * Configures the client manager with a factory for creating {@link PresentsSession} and {@link
* ClientResolver} classes for authenticated client connections. * ClientResolver} classes for authenticated client connections.
*/ */
public void setClientFactory (ClientFactory factory) public void setSessionFactory (SessionFactory factory)
{ {
_factory = factory; _factory = factory;
} }
/** /**
* Returns the {@link ClientFactory} currently in use. * Returns the {@link SessionFactory} currently in use.
*/ */
public ClientFactory getClientFactory () public SessionFactory getSessionFactory ()
{ {
return _factory; return _factory;
} }
@@ -384,7 +384,7 @@ public class ClientManager
} else { } else {
log.info("Session initiated [username=" + username + ", conn=" + conn + "]."); log.info("Session initiated [username=" + username + ", conn=" + conn + "].");
// create a new client and stick'em in the table // create a new client and stick'em in the table
client = _injector.getInstance(_factory.getClientClass(req)); client = _injector.getInstance(_factory.getSessionClass(req));
client.startSession(req, conn, rsp.authdata); client.startSession(req, conn, rsp.authdata);
// map their client instance // map their client instance
@@ -565,7 +565,7 @@ public class ClientManager
protected Map<Name, ClientResolver> _penders = Maps.newHashMap(); protected Map<Name, ClientResolver> _penders = Maps.newHashMap();
/** Lets us know what sort of client classes to use. */ /** Lets us know what sort of client classes to use. */
protected ClientFactory _factory = ClientFactory.DEFAULT; protected SessionFactory _factory = SessionFactory.DEFAULT;
/** Tracks registered {@link ClientObserver}s. */ /** Tracks registered {@link ClientObserver}s. */
protected ObserverList<ClientObserver> _clobservers = ObserverList.newSafeInOrder(); protected ObserverList<ClientObserver> _clobservers = ObserverList.newSafeInOrder();
@@ -29,11 +29,11 @@ import com.threerings.presents.net.AuthRequest;
* Used to determine what type of {@link PresentsSession} to use to manage an authenticated client * Used to determine what type of {@link PresentsSession} to use to manage an authenticated client
* as well the type of {@link ClientResolver} to use when resolving clients' runtime data. * as well the type of {@link ClientResolver} to use when resolving clients' runtime data.
*/ */
public interface ClientFactory public interface SessionFactory
{ {
/** The default client factory. */ /** The default client factory. */
public static ClientFactory DEFAULT = new ClientFactory() { public static SessionFactory DEFAULT = new SessionFactory() {
public Class<? extends PresentsSession> getClientClass (AuthRequest areq) { public Class<? extends PresentsSession> getSessionClass (AuthRequest areq) {
return PresentsSession.class; return PresentsSession.class;
} }
public Class<? extends ClientResolver> getClientResolverClass (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
@@ -45,7 +45,7 @@ public interface ClientFactory
* Returns the {@link PresentsSession} derived class to use for the session that authenticated * Returns the {@link PresentsSession} derived class to use for the session that authenticated
* with the supplied request. * with the supplied request.
*/ */
Class<? extends PresentsSession> getClientClass (AuthRequest areq); Class<? extends PresentsSession> getSessionClass (AuthRequest areq);
/** /**
* Returns the {@link ClientResolver} derived class to use to resolve a client with the * Returns the {@link ClientResolver} derived class to use to resolve a client with the
@@ -74,7 +74,7 @@ public class TestServer extends PresentsServer
{ {
super.init(injector); super.init(injector);
_bureauReg.init(); _bureauReg.init();
_bureauReg.setDefaultClientFactory(); _bureauReg.setDefaultSessionFactory();
} }
public void setClientTarget (String target) public void setClientTarget (String target)