* Add a static method to init and run a PresentsServer given guice modules with its configuration.
* Rename PrefixServer.Module classes to PrefixModule. They all implement guice's Module, and it's hard to pass a class around as its interface if they share a name. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6303 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -70,7 +70,7 @@ public class RegistryTester
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Injector injector = Guice.createInjector(new TestServer.Module());
|
||||
Injector injector = Guice.createInjector(new TestServer.PresentsModule());
|
||||
TestServer server = injector.getInstance(TestServer.class);
|
||||
RegistryTester tester = injector.getInstance(RegistryTester.class);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TestServer extends PresentsServer
|
||||
*/
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Injector injector = Guice.createInjector(new Module());
|
||||
Injector injector = Guice.createInjector(new PresentsModule());
|
||||
TestServer server = injector.getInstance(TestServer.class);
|
||||
try {
|
||||
server.init(injector);
|
||||
|
||||
@@ -3,13 +3,10 @@
|
||||
|
||||
package com.threerings.crowd.server;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import com.threerings.crowd.data.JabberConfig;
|
||||
|
||||
import static com.threerings.crowd.Log.log;
|
||||
|
||||
/**
|
||||
* A basic server that creates a single room and sticks everyone in it where they can chat with one
|
||||
* another.
|
||||
@@ -18,15 +15,7 @@ public class JabberServer extends CrowdServer
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Injector injector = Guice.createInjector(new Module());
|
||||
JabberServer server = injector.getInstance(JabberServer.class);
|
||||
|
||||
try {
|
||||
server.init(injector);
|
||||
server.run();
|
||||
} catch (Exception e) {
|
||||
log.warning("Unable to initialize server.", e);
|
||||
}
|
||||
runServer(new CrowdModule(), new PresentsServerModule(JabberServer.class));
|
||||
}
|
||||
|
||||
@Override // from CrowdServer
|
||||
|
||||
@@ -14,7 +14,7 @@ public class PresentsTestBase
|
||||
protected <T> T getInstance (Class<T> clazz)
|
||||
{
|
||||
if (_injector == null) {
|
||||
_injector = Guice.createInjector(new PresentsServer.Module());
|
||||
_injector = Guice.createInjector(new PresentsServer.PresentsModule());
|
||||
}
|
||||
return _injector.getInstance(clazz);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,10 @@
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import com.threerings.presents.data.TestObject;
|
||||
|
||||
import static com.threerings.presents.Log.log;
|
||||
|
||||
public class TestServer extends PresentsServer
|
||||
{
|
||||
public static TestObject testobj;
|
||||
@@ -52,13 +49,6 @@ public class TestServer extends PresentsServer
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Injector injector = Guice.createInjector(new Module());
|
||||
TestServer server = injector.getInstance(TestServer.class);
|
||||
try {
|
||||
server.init(injector);
|
||||
server.run();
|
||||
} catch (Exception e) {
|
||||
log.warning("Unable to initialize server.", e);
|
||||
}
|
||||
runServer(new PresentsModule(), new PresentsServerModule(TestServer.class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user