ZOMG, Narya now perfectly passes our coding standards as enforced by
CheckStyle. The checks are slightly looser than I'd like but way better than nothing and we get a bunch of other useful warnings like shadowed names and other handy bits. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5253 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -27,10 +27,9 @@ import com.threerings.util.StreamableArrayList;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
|
||||
/**
|
||||
* A <code>BootstrapData</code> object is communicated back to the client
|
||||
* after authentication has succeeded and after the server is fully
|
||||
* prepared to deal with the client. It contains information the client
|
||||
* will need to interact with the server.
|
||||
* A <code>BootstrapData</code> object is communicated back to the client after authentication has
|
||||
* succeeded and after the server is fully prepared to deal with the client. It contains
|
||||
* information the client will need to interact with the server.
|
||||
*/
|
||||
public class BootstrapData extends SimpleStreamableObject
|
||||
{
|
||||
|
||||
@@ -193,6 +193,7 @@ public class ClientResolver extends Invoker.Unit
|
||||
/** A place to keep an exception around for a moment. */
|
||||
protected Exception _failure;
|
||||
|
||||
@Inject @MainInvoker Invoker _invoker;
|
||||
@Inject RootDObjectManager _omgr;
|
||||
// dependencies
|
||||
protected @Inject @MainInvoker Invoker _invoker;
|
||||
protected @Inject RootDObjectManager _omgr;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -33,7 +35,6 @@ import com.samskivert.util.LRUHashMap;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller.ListenerMarshaller;
|
||||
@@ -100,7 +101,8 @@ public class InvocationManager
|
||||
*
|
||||
* @param dispatcher the dispatcher to be registered.
|
||||
*/
|
||||
public <T extends InvocationMarshaller> T registerDispatcher (InvocationDispatcher<T> dispatcher)
|
||||
public <T extends InvocationMarshaller> T registerDispatcher (
|
||||
InvocationDispatcher<T> dispatcher)
|
||||
{
|
||||
return registerDispatcher(dispatcher, null);
|
||||
}
|
||||
@@ -139,9 +141,9 @@ public class InvocationManager
|
||||
|
||||
// if it's a bootstrap service, slap it in the list
|
||||
if (group != null) {
|
||||
StreamableArrayList<InvocationMarshaller> list = _bootlists.get(group);
|
||||
List<InvocationMarshaller> list = _bootlists.get(group);
|
||||
if (list == null) {
|
||||
_bootlists.put(group, list = new StreamableArrayList<InvocationMarshaller>());
|
||||
_bootlists.put(group, list = Lists.newArrayList());
|
||||
}
|
||||
list.add(marsh);
|
||||
}
|
||||
@@ -175,12 +177,11 @@ public class InvocationManager
|
||||
/**
|
||||
* Constructs a list of all bootstrap services registered in any of the supplied groups.
|
||||
*/
|
||||
public StreamableArrayList<InvocationMarshaller> getBootstrapServices (String[] bootGroups)
|
||||
public List<InvocationMarshaller> getBootstrapServices (String[] bootGroups)
|
||||
{
|
||||
StreamableArrayList<InvocationMarshaller> services =
|
||||
new StreamableArrayList<InvocationMarshaller>();
|
||||
List<InvocationMarshaller> services = Lists.newArrayList();
|
||||
for (String group : bootGroups) {
|
||||
StreamableArrayList<InvocationMarshaller> list = _bootlists.get(group);
|
||||
List<InvocationMarshaller> list = _bootlists.get(group);
|
||||
if (list != null) {
|
||||
services.addAll(list);
|
||||
}
|
||||
@@ -319,10 +320,11 @@ public class InvocationManager
|
||||
protected IntMap<InvocationDispatcher> _dispatchers = IntMaps.newHashIntMap();
|
||||
|
||||
/** Maps bootstrap group to lists of services to be provided to clients at boot time. */
|
||||
protected Map<String,StreamableArrayList<InvocationMarshaller>> _bootlists = Maps.newHashMap();
|
||||
protected Map<String, List<InvocationMarshaller>> _bootlists = Maps.newHashMap();
|
||||
|
||||
// debugging action...
|
||||
protected final Map<Integer,String> _recentRegServices = new LRUHashMap<Integer,String>(10000);
|
||||
protected final Map<Integer, String> _recentRegServices =
|
||||
new LRUHashMap<Integer, String>(10000);
|
||||
|
||||
/** The text appended to the procedure name when generating a failure response. */
|
||||
protected static final String FAILED_SUFFIX = "Failed";
|
||||
|
||||
@@ -538,7 +538,7 @@ public class PresentsClient
|
||||
*/
|
||||
protected void handleThrottleExceeded ()
|
||||
{
|
||||
log.warning("Client sent more than 100 messages in 10 seconds, disconnecting " + this + ".");
|
||||
log.warning("Client sent more than 100 msgs in 10 seconds, disconnecting " + this + ".");
|
||||
safeEndSession();
|
||||
_throttle = null;
|
||||
}
|
||||
@@ -676,11 +676,11 @@ public class PresentsClient
|
||||
data.clientOid = _clobj.getOid();
|
||||
|
||||
// fill in the list of bootstrap services
|
||||
data.services = new StreamableArrayList<InvocationMarshaller>();
|
||||
if (_areq.getBootGroups() == null) {
|
||||
log.warning("Client provided no invocation service boot groups? " + this);
|
||||
data.services = new StreamableArrayList<InvocationMarshaller>();
|
||||
} else {
|
||||
data.services = _invmgr.getBootstrapServices(_areq.getBootGroups());
|
||||
data.services.addAll(_invmgr.getBootstrapServices(_areq.getBootGroups()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,20 +847,20 @@ public class PresentsClient
|
||||
}
|
||||
|
||||
// from interface ProxySubscriber
|
||||
public void objectAvailable (DObject object)
|
||||
public void objectAvailable (DObject dobj)
|
||||
{
|
||||
if (postMessage(new ObjectResponse<DObject>(object))) {
|
||||
if (postMessage(new ObjectResponse<DObject>(dobj))) {
|
||||
_firstEventId = _omgr.getNextEventId(false);
|
||||
this.object = object;
|
||||
object = dobj;
|
||||
synchronized (_subscrips) {
|
||||
// make a note of this new subscription
|
||||
_subscrips.put(object.getOid(), this);
|
||||
_subscrips.put(dobj.getOid(), this);
|
||||
}
|
||||
subscribedToObject(object);
|
||||
subscribedToObject(dobj);
|
||||
|
||||
} else {
|
||||
// if we failed to send the object response, unsubscribe
|
||||
object.removeSubscriber(this);
|
||||
dobj.removeSubscriber(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ public class PresentsClient
|
||||
/**
|
||||
* Dispatch the supplied message for the specified client.
|
||||
*/
|
||||
public void dispatch (PresentsClient client, UpstreamMessage mge);
|
||||
void dispatch (PresentsClient client, UpstreamMessage mge);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1025,7 +1025,7 @@ public class PresentsClient
|
||||
protected int _messagesDropped;
|
||||
|
||||
/** A mapping of message dispatchers. */
|
||||
protected static Map<Class<?>,MessageDispatcher> _disps = Maps.newHashMap();
|
||||
protected static Map<Class<?>, MessageDispatcher> _disps = Maps.newHashMap();
|
||||
|
||||
/** The amount of time after disconnection a user is allowed before their session is forcibly
|
||||
* ended. */
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -39,7 +41,20 @@ import com.samskivert.util.RunQueue;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.samskivert.util.Throttle;
|
||||
|
||||
import com.threerings.presents.dobj.*;
|
||||
import com.threerings.presents.dobj.AccessController;
|
||||
import com.threerings.presents.dobj.CompoundEvent;
|
||||
import com.threerings.presents.dobj.DEvent;
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
import com.threerings.presents.dobj.InvocationRequestEvent;
|
||||
import com.threerings.presents.dobj.NoSuchObjectException;
|
||||
import com.threerings.presents.dobj.ObjectAccessException;
|
||||
import com.threerings.presents.dobj.ObjectAddedEvent;
|
||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||
import com.threerings.presents.dobj.ObjectRemovedEvent;
|
||||
import com.threerings.presents.dobj.OidList;
|
||||
import com.threerings.presents.dobj.RootDObjectManager;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
|
||||
import static com.threerings.presents.Log.log;
|
||||
|
||||
@@ -338,7 +353,7 @@ public class PresentsDObjectMgr
|
||||
*/
|
||||
public void dumpUnitProfiles ()
|
||||
{
|
||||
for (Map.Entry<String,UnitProfile> entry : _profiles.entrySet()) {
|
||||
for (Map.Entry<String, UnitProfile> entry : _profiles.entrySet()) {
|
||||
log.info("P: " + entry.getKey() + " => " + entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -534,7 +549,7 @@ public class PresentsDObjectMgr
|
||||
|
||||
if (UNIT_PROF_ENABLED) {
|
||||
report.append("- Unit profiles: ").append(_profiles.size()).append("\n");
|
||||
for (Map.Entry<String,UnitProfile> entry : _profiles.entrySet()) {
|
||||
for (Map.Entry<String, UnitProfile> entry : _profiles.entrySet()) {
|
||||
report.append(" ").append(entry.getKey());
|
||||
report.append(" ").append(entry.getValue()).append("\n");
|
||||
}
|
||||
@@ -910,15 +925,13 @@ public class PresentsDObjectMgr
|
||||
public String field;
|
||||
public int reffedOid;
|
||||
|
||||
public Reference (int reffingOid, String field, int reffedOid)
|
||||
{
|
||||
public Reference (int reffingOid, String field, int reffedOid) {
|
||||
this.reffingOid = reffingOid;
|
||||
this.field = field;
|
||||
this.reffedOid = reffedOid;
|
||||
}
|
||||
|
||||
public boolean equals (Reference other)
|
||||
{
|
||||
public boolean equals (Reference other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -926,14 +939,15 @@ public class PresentsDObjectMgr
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals (int reffingOid, String field)
|
||||
{
|
||||
return (this.reffingOid == reffingOid && this.field.equals(field));
|
||||
public boolean equals (int oReffingOid, String oField) {
|
||||
return (reffingOid == oReffingOid && field.equals(oField));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
@Override public int hashCode () {
|
||||
return reffingOid ^ field.hashCode();
|
||||
}
|
||||
|
||||
@Override public String toString () {
|
||||
return "[reffingOid=" + reffingOid + ", field=" + field +
|
||||
", reffedOid=" + reffedOid + "]";
|
||||
}
|
||||
@@ -1010,13 +1024,13 @@ public class PresentsDObjectMgr
|
||||
protected long _nextEventId = 1;
|
||||
|
||||
/** Used to profile our events and runnable units. */
|
||||
protected Map<String,UnitProfile> _profiles = Maps.newHashMap();
|
||||
protected Map<String, UnitProfile> _profiles = Maps.newHashMap();
|
||||
|
||||
/** Used to track runtime statistics. */
|
||||
protected Stats _recent = new Stats(), _current = _recent;
|
||||
|
||||
/** Maps event classes to helpers that perform additional processing for particular events. */
|
||||
protected Map<Class,Method> _helpers = Maps.newHashMap();
|
||||
protected Map<Class, Method> _helpers = Maps.newHashMap();
|
||||
|
||||
/** Used to resolve unit names when profiling. Injected by the invmgr when it's created. */
|
||||
protected InvocationManager _invmgr;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class ShutdownManager
|
||||
void shutdown ();
|
||||
}
|
||||
|
||||
/** Constraints for use with {@link #addConstraint}. */
|
||||
public static enum Constraint { RUNS_BEFORE, RUNS_AFTER };
|
||||
|
||||
@Inject ShutdownManager (@EventQueue RunQueue dobjq)
|
||||
@@ -75,7 +76,6 @@ public class ShutdownManager
|
||||
* Adds a constraint that a certain shutdowner must be run before another.
|
||||
*/
|
||||
public void addConstraint (Shutdowner lhs, Constraint constraint, Shutdowner rhs)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (lhs == null || rhs == null) {
|
||||
throw new IllegalArgumentException("Cannot add constraint about null shutdowner.");
|
||||
|
||||
@@ -283,7 +283,7 @@ public class ConnectionManager extends LoopingThread
|
||||
protected void willStart ()
|
||||
{
|
||||
int successes = 0;
|
||||
IOException _failure = null;
|
||||
IOException failure = null;
|
||||
for (int ii = 0; ii < _ports.length; ii++) {
|
||||
try {
|
||||
// create a listening socket and add it to the select set
|
||||
@@ -299,7 +299,7 @@ public class ConnectionManager extends LoopingThread
|
||||
} catch (IOException ioe) {
|
||||
log.warning("Failure listening to socket on port '" +
|
||||
_ports[ii] + "'.", ioe);
|
||||
_failure = ioe;
|
||||
failure = ioe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ public class ConnectionManager extends LoopingThread
|
||||
// if we failed to listen on at least one port, give up the ghost
|
||||
if (successes == 0) {
|
||||
if (_startlist != null) {
|
||||
_startlist.requestFailed(_failure);
|
||||
_startlist.requestFailed(failure);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
// then send any new messages
|
||||
Tuple<Connection,byte[]> tup;
|
||||
Tuple<Connection, byte[]> tup;
|
||||
while ((tup = _outq.getNonBlocking()) != null) {
|
||||
Connection conn = tup.left;
|
||||
|
||||
@@ -882,7 +882,7 @@ public class ConnectionManager extends LoopingThread
|
||||
// log.info("Flattened " + msg + " into " + data.length + " bytes.");
|
||||
|
||||
// and slap both on the queue
|
||||
_outq.append(new Tuple<Connection,byte[]>(conn, data));
|
||||
_outq.append(new Tuple<Connection, byte[]>(conn, data));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warning("Failure flattening message [conn=" + conn +
|
||||
@@ -1017,7 +1017,7 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void handlePartialWrite (Connection conn, ByteBuffer buffer)
|
||||
public void handlePartialWrite (Connection wconn, ByteBuffer buffer)
|
||||
{
|
||||
// set up our _partial buffer
|
||||
_partial = ByteBuffer.allocateDirect(buffer.remaining());
|
||||
@@ -1062,7 +1062,7 @@ public class ConnectionManager extends LoopingThread
|
||||
protected int _runtimeExceptionCount;
|
||||
|
||||
/** Maps selection keys to network event handlers. */
|
||||
protected Map<SelectionKey,NetEventHandler> _handlers = Maps.newHashMap();
|
||||
protected Map<SelectionKey, NetEventHandler> _handlers = Maps.newHashMap();
|
||||
|
||||
/** Connections mapped by identifier. */
|
||||
protected IntMap<Connection> _connections = IntMaps.newHashIntMap();
|
||||
@@ -1070,14 +1070,14 @@ public class ConnectionManager extends LoopingThread
|
||||
protected Queue<Connection> _deathq = new Queue<Connection>();
|
||||
protected Queue<AuthingConnection> _authq = new Queue<AuthingConnection>();
|
||||
|
||||
protected Queue<Tuple<Connection,byte[]>> _outq = new Queue<Tuple<Connection,byte[]>>();
|
||||
protected Queue<Tuple<Connection,byte[]>> _dataq = new Queue<Tuple<Connection,byte[]>>();
|
||||
protected Queue<Tuple<Connection, byte[]>> _outq = new Queue<Tuple<Connection, byte[]>>();
|
||||
protected Queue<Tuple<Connection, byte[]>> _dataq = new Queue<Tuple<Connection, byte[]>>();
|
||||
protected FramingOutputStream _framer;
|
||||
protected ByteArrayOutputStream _flattener;
|
||||
protected ByteBuffer _outbuf = ByteBuffer.allocateDirect(64 * 1024);
|
||||
protected ByteBuffer _databuf = ByteBuffer.allocateDirect(Client.MAX_DATAGRAM_SIZE);
|
||||
|
||||
protected Map<Connection,OverflowQueue> _oflowqs = Maps.newHashMap();
|
||||
protected Map<Connection, OverflowQueue> _oflowqs = Maps.newHashMap();
|
||||
|
||||
protected List<ConnectionObserver> _observers = Lists.newArrayList();
|
||||
|
||||
|
||||
@@ -78,17 +78,18 @@ public class ActionScriptSource
|
||||
definition = definition.substring(0, definition.length()-1) + " = " + initValue + ";";
|
||||
}
|
||||
|
||||
public void setComment (String comment) {
|
||||
if (comment.indexOf("@Override") != -1) {
|
||||
comment = comment.replaceAll("@Override ?", "");
|
||||
comment = comment.replaceFirst("// //", "//"); // handle // @Override // comment
|
||||
public void setComment (String newComment) {
|
||||
if (newComment.indexOf("@Override") != -1) {
|
||||
newComment = newComment.replaceAll("@Override ?", "");
|
||||
// handle // @Override // comment
|
||||
newComment = newComment.replaceFirst("// //", "//");
|
||||
definition = "override " + definition;
|
||||
}
|
||||
// trim blank lines from start
|
||||
while (comment.startsWith("\n")) {
|
||||
comment = comment.substring(1);
|
||||
while (newComment.startsWith("\n")) {
|
||||
newComment = newComment.substring(1);
|
||||
}
|
||||
this.comment = StringUtil.isBlank(comment) ? "" : comment;
|
||||
comment = StringUtil.isBlank(newComment) ? "" : newComment;
|
||||
}
|
||||
|
||||
public void write (PrintWriter writer) {
|
||||
@@ -1035,6 +1036,7 @@ public class ActionScriptSource
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Denotes various phases of class file parsing. */
|
||||
protected static enum Mode { PREAMBLE, IMPORTS, CLASSCOMMENT, CLASSDECL,
|
||||
CLASSBODY, METHODBODY, POSTCLASS, POSTPKG };
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ public class GenActionScriptBundlesTask extends Task
|
||||
|
||||
@Override
|
||||
public void execute ()
|
||||
throws BuildException
|
||||
{
|
||||
// boilerplate
|
||||
for (FileSet fs : _filesets) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public class GenActionScriptTask extends Task
|
||||
* Performs the actual work of the task.
|
||||
*/
|
||||
@Override
|
||||
public void execute () throws BuildException
|
||||
public void execute ()
|
||||
{
|
||||
try {
|
||||
_velocity = VelocityUtil.createEngine();
|
||||
|
||||
@@ -80,7 +80,7 @@ public class GenDObjectTask extends Task
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute () throws BuildException
|
||||
public void execute ()
|
||||
{
|
||||
if (_cloader == null) {
|
||||
String errmsg = "This task requires a 'classpathref' attribute " +
|
||||
|
||||
@@ -101,6 +101,12 @@ public class GenServiceTask extends InvocationTask
|
||||
listener.equals(((ServiceListener)other).listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode ()
|
||||
{
|
||||
return listener.getName().hashCode();
|
||||
}
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
String name = GenUtil.simpleName(listener);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GenStreamableTask extends Task
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute () throws BuildException
|
||||
public void execute ()
|
||||
{
|
||||
for (FileSet fs : _filesets) {
|
||||
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
|
||||
|
||||
@@ -31,17 +31,17 @@ import com.samskivert.util.ComparableArrayList;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Manages a set of strings to be used as a set of imports. Provides useful functions for
|
||||
* Manages a set of strings to be used as a set of imports. Provides useful functions for
|
||||
* manipulating the set and sorts results.
|
||||
*
|
||||
* <p>Some methods in this class use a variable length String parameter 'replace'. This is a
|
||||
* convenience for easily specifying multiple find/replace pairs. For example, to replace "Foo"
|
||||
* with "Bar" and "123" with "ABC", a function can be called with the 4 arguments "Foo", "Bar",
|
||||
*
|
||||
* <p>Some methods in this class use a variable length String parameter 'replace'. This is a
|
||||
* convenience for easily specifying multiple find/replace pairs. For example, to replace "Foo"
|
||||
* with "Bar" and "123" with "ABC", a function can be called with the 4 arguments "Foo", "Bar",
|
||||
* "123", "ABC" for the String... replace argument.
|
||||
*
|
||||
* <p>A few methods also use a "pattern" string parameter that is used to match a class name.
|
||||
* This is a dumbed down regular expression (to avoid many \.) where "*" means .* and no other
|
||||
* characters have special meaning. The pattern is also implicitly enclosed with ^$ so that the
|
||||
*
|
||||
* <p>A few methods also use a "pattern" string parameter that is used to match a class name.
|
||||
* This is a dumbed down regular expression (to avoid many \.) where "*" means .* and no other
|
||||
* characters have special meaning. The pattern is also implicitly enclosed with ^$ so that the
|
||||
* pattern must match the class name in its entirity. Callers will mostly use this to specify a
|
||||
* prefix like "something*" or a suffix like "*something".
|
||||
*/
|
||||
@@ -75,9 +75,9 @@ public class ImportSet
|
||||
{
|
||||
_imports.addAll(other._imports);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a class' name to the imports but first performs the given list of search/replaces as
|
||||
* Adds a class' name to the imports but first performs the given list of search/replaces as
|
||||
* described above.
|
||||
* @param clazz the class whose name is munged and added
|
||||
* @param replace array of pairs to search/replace on the name before adding
|
||||
@@ -85,8 +85,8 @@ public class ImportSet
|
||||
public void addMunged (Class<?> clazz, String... replace)
|
||||
{
|
||||
String name = clazz.getName();
|
||||
for (int i = 0 ; i < replace.length; i+=2) {
|
||||
name = name.replace(replace[i], replace[i + 1]);
|
||||
for (int ii = 0; ii < replace.length; ii += 2) {
|
||||
name = name.replace(replace[ii], replace[ii+1]);
|
||||
}
|
||||
_imports.add(name);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ImportSet
|
||||
newset.addAll(this);
|
||||
return newset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets rid of primitive and java.lang imports.
|
||||
*/
|
||||
@@ -109,13 +109,12 @@ public class ImportSet
|
||||
String name = i.next();
|
||||
if (name.indexOf('.') == -1) {
|
||||
i.remove();
|
||||
}
|
||||
else if (name.startsWith("java.lang")) {
|
||||
} else if (name.startsWith("java.lang")) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets rid of array imports.
|
||||
*/
|
||||
@@ -123,7 +122,7 @@ public class ImportSet
|
||||
{
|
||||
return removeAll("[*");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all classes that are in the same package.
|
||||
* @param pkg package to remove
|
||||
@@ -133,13 +132,13 @@ public class ImportSet
|
||||
Iterator<String> i = _imports.iterator();
|
||||
while (i.hasNext()) {
|
||||
String name = i.next();
|
||||
if (name.startsWith(pkg) &&
|
||||
if (name.startsWith(pkg) &&
|
||||
name.indexOf('.', pkg.length() + 1) == -1) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces inner class imports (those with a '$') with an import of the parent class.
|
||||
*/
|
||||
@@ -155,12 +154,12 @@ public class ImportSet
|
||||
declarers.add(name.substring(0, dollar));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addAll(declarers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all inner classes' separator characters ('$') with an underscore ('_') for use
|
||||
* Replace all inner classes' separator characters ('$') with an underscore ('_') for use
|
||||
* when generating ActionScript.
|
||||
*/
|
||||
public void translateInnerClasses ()
|
||||
@@ -175,10 +174,10 @@ public class ImportSet
|
||||
inner.add(name.replace("$", "_"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addAll(inner);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inserts imports for the non-primitive classes contained in all array imports.
|
||||
*/
|
||||
@@ -194,7 +193,7 @@ public class ImportSet
|
||||
arrayTypes.add(name.substring(bracket + 2, name.length() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addAll(arrayTypes);
|
||||
}
|
||||
|
||||
@@ -220,7 +219,7 @@ public class ImportSet
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-adds the most recently popped import to the set. If a null value was pushed, does
|
||||
* Re-adds the most recently popped import to the set. If a null value was pushed, does
|
||||
* nothing.
|
||||
* @throws IndexOutOfBoundsException if there is nothing to pop
|
||||
*/
|
||||
@@ -231,7 +230,7 @@ public class ImportSet
|
||||
_imports.add(front);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the name of a class from the imports.
|
||||
* @param clazz the class whose name should be removed
|
||||
@@ -240,9 +239,9 @@ public class ImportSet
|
||||
{
|
||||
_imports.remove(clazz.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces any import exactly each find string with the corresponding replace string.
|
||||
* Replaces any import exactly each find string with the corresponding replace string.
|
||||
* See the description above.
|
||||
* @param replace array of pairs for search/replace
|
||||
*/
|
||||
@@ -282,12 +281,12 @@ public class ImportSet
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new munged import for each existing import that matches a pattern. The new entry is
|
||||
* a copy of the old entry but modified according to the given find/replace pairs (see
|
||||
* Adds a new munged import for each existing import that matches a pattern. The new entry is
|
||||
* a copy of the old entry but modified according to the given find/replace pairs (see
|
||||
* description above).
|
||||
* @param pattern to qualify imports to duplicate
|
||||
* @param pattern to qualify imports to duplicate
|
||||
* @param replace pairs to find/replace on the new import
|
||||
*/
|
||||
public void duplicateAndMunge (String pattern, String... replace)
|
||||
@@ -301,7 +300,7 @@ public class ImportSet
|
||||
}
|
||||
for (String name : toMunge) {
|
||||
String newname = name;
|
||||
for (int i = 0; i < replace.length; i+=2) {
|
||||
for (int i = 0; i < replace.length; i += 2) {
|
||||
newname = newname.replace(replace[i], replace[i + 1]);
|
||||
}
|
||||
_imports.add(newname);
|
||||
@@ -336,8 +335,7 @@ public class ImportSet
|
||||
StringBuilder pattern = new StringBuilder();
|
||||
pattern.append("^");
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
String[] parts = _splitter.split(input, 2);
|
||||
pattern.append(Pattern.quote(parts[0]));
|
||||
if (parts.length == 1) {
|
||||
@@ -347,8 +345,7 @@ public class ImportSet
|
||||
String wildcard = input.substring(length, length + 1);
|
||||
if (wildcard.equals("*")) {
|
||||
pattern.append(".*");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.err.println("Bad wildcard " + wildcard);
|
||||
}
|
||||
input = parts[1];
|
||||
@@ -360,6 +357,6 @@ public class ImportSet
|
||||
|
||||
protected HashSet<String> _imports = new HashSet<String>();
|
||||
protected List<String> _pushed = new ArrayList<String>();
|
||||
|
||||
|
||||
protected static Pattern _splitter = Pattern.compile("\\*");
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class InstrumentStreamableTask extends Task
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute () throws BuildException
|
||||
public void execute ()
|
||||
{
|
||||
// configure our ClassPool with our classpath
|
||||
for (Path path : _paths) {
|
||||
@@ -311,7 +311,7 @@ public class InstrumentStreamableTask extends Task
|
||||
if (field.getType().isPrimitive()) {
|
||||
return body;
|
||||
} else {
|
||||
return "if (ins.readBoolean()) {\n" +
|
||||
return "if (ins.readBoolean()) {\n" +
|
||||
" " + body + "\n" +
|
||||
" } else {\n" +
|
||||
" " + field.getName() + " = null;\n" +
|
||||
|
||||
@@ -326,7 +326,7 @@ public abstract class InvocationTask extends Task
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute () throws BuildException
|
||||
public void execute ()
|
||||
{
|
||||
if (_cloader == null) {
|
||||
String errmsg = "This task requires a 'classpathref' attribute " +
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
package com.threerings.presents.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.samskivert.util.MethodFinder;
|
||||
import com.samskivert.util.StringUtil;
|
||||
@@ -43,7 +43,7 @@ public class ClassUtil
|
||||
* @return the method with the specified name or null if no method with that name could be
|
||||
* found.
|
||||
*/
|
||||
public static Method getMethod (String name, Object target, HashMap<String,Method> cache)
|
||||
public static Method getMethod (String name, Object target, Map<String, Method> cache)
|
||||
{
|
||||
Class tclass = target.getClass();
|
||||
String key = tclass.getName() + ":" + name;
|
||||
@@ -80,7 +80,7 @@ public class ClassUtil
|
||||
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
// nothing to do here but fall through and return null
|
||||
log.info("No such method [name=" + name + ", tclass=" + tclass.getName() +
|
||||
log.info("No such method [name=" + name + ", tclass=" + tclass.getName() +
|
||||
", args=" + StringUtil.toString(args) + ", error=" + nsme + "].");
|
||||
|
||||
} catch (SecurityException se) {
|
||||
|
||||
@@ -34,6 +34,8 @@ import static com.threerings.presents.Log.log;
|
||||
* result is ignored. If the failure is an instance fo {@link InvocationException} the message will
|
||||
* be passed on to the confirm listener, otherwise they will be provided with {@link
|
||||
* InvocationCodes#INTERNAL_ERROR}.
|
||||
*
|
||||
* @param <T> the type of result expected by the listener.
|
||||
*/
|
||||
public class IgnoreConfirmAdapter<T> implements ResultListener<T>
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class PersistingUnit extends Invoker.Unit
|
||||
* If the listener is known to be a ResultListener, this will cast it and report that the
|
||||
* request was processed.
|
||||
*/
|
||||
protected void reportRequestProcessed (Object result )
|
||||
protected void reportRequestProcessed (Object result)
|
||||
{
|
||||
((InvocationService.ResultListener)_listener).requestProcessed(result);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import static com.threerings.presents.Log.log;
|
||||
* Adapts the response from a {@link ResultListener} to an InvocationService.ResultListener if the
|
||||
* failure is an instance of {@link InvocationException} the message will be passed on to the
|
||||
* result listener, otherwise they will be provided with {@link InvocationCodes#INTERNAL_ERROR}.
|
||||
*
|
||||
* @param <T> the type of result expected by the listener.
|
||||
*/
|
||||
public class ResultAdapter<T> implements ResultListener<T>
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ import static com.threerings.presents.Log.log;
|
||||
* distributed object when it is not know if the subscription will
|
||||
* complete before the subscriber decides they no longer wish to be
|
||||
* subscribed.
|
||||
*
|
||||
* @param <T> the type of object to which we are subscribing.
|
||||
*/
|
||||
public class SafeSubscriber<T extends DObject>
|
||||
implements Subscriber<T>
|
||||
|
||||
@@ -77,7 +77,6 @@ public class DependencyGraph<T>
|
||||
* Records a new dependency of the dependant upon the dependee.
|
||||
*/
|
||||
public void addDependency (T dependant, T dependee)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
_orphans.remove(dependant);
|
||||
DependencyNode<T> dependantNode = _nodes.get(dependant);
|
||||
@@ -132,6 +131,7 @@ public class DependencyGraph<T>
|
||||
/** Nodes in the graph with no parents/dependencies. */
|
||||
protected ArrayList<T> _orphans = new ArrayList<T>();
|
||||
|
||||
/** Represents a node in our dependency graph. */
|
||||
protected class DependencyNode<T>
|
||||
{
|
||||
public T content;
|
||||
|
||||
@@ -325,9 +325,8 @@ public class MessageBundle
|
||||
}
|
||||
}
|
||||
|
||||
return (msg != null) ?
|
||||
MessageFormat.format(MessageUtil.escape(msg), args)
|
||||
: (key + StringUtil.toString(args));
|
||||
return (msg != null) ? MessageFormat.format(MessageUtil.escape(msg), args) :
|
||||
(key + StringUtil.toString(args));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -202,8 +202,7 @@ public class MessageManager
|
||||
protected ClassLoader _loader;
|
||||
|
||||
/** A cache of instantiated message bundles. */
|
||||
protected HashMap<String,MessageBundle> _cache =
|
||||
new HashMap<String,MessageBundle>();
|
||||
protected HashMap<String, MessageBundle> _cache = new HashMap<String, MessageBundle>();
|
||||
|
||||
/** Our top-level message bundle, from which others obtain messages if
|
||||
* they can't find them within themselves. */
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Random;
|
||||
|
||||
/**
|
||||
* Maintained for backwards compatibility with old Game Gardens games.
|
||||
*
|
||||
*
|
||||
* @deprecated moved to {@link com.samskivert.util.RandomUtil}.
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.threerings.io.Streamable;
|
||||
* the list must also be of streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <E> the type of elements stored in this list.
|
||||
*/
|
||||
public class StreamableArrayList<E> extends ArrayList<E>
|
||||
implements Streamable
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.threerings.io.Streamable;
|
||||
* that can be streamed.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <E> the type of enum being stored in this set.
|
||||
*/
|
||||
public class StreamableEnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
implements Cloneable, Streamable
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.threerings.io.Streamable;
|
||||
* values in the map must also be of streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <V> the type of value stored in this map.
|
||||
*/
|
||||
public class StreamableHashIntMap<V> extends HashIntMap<V>
|
||||
implements Streamable
|
||||
|
||||
@@ -34,8 +34,10 @@ import com.threerings.io.Streamable;
|
||||
* in the map must also be of streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <K> the type of key stored in this map.
|
||||
* @param <V> the type of value stored in this map.
|
||||
*/
|
||||
public class StreamableHashMap<K,V> extends HashMap<K,V>
|
||||
public class StreamableHashMap<K, V> extends HashMap<K, V>
|
||||
implements Streamable
|
||||
{
|
||||
/**
|
||||
@@ -64,7 +66,7 @@ public class StreamableHashMap<K,V> extends HashMap<K,V>
|
||||
{
|
||||
int ecount = size();
|
||||
out.writeInt(ecount);
|
||||
for (Map.Entry<K,V> entry : entrySet()) {
|
||||
for (Map.Entry<K, V> entry : entrySet()) {
|
||||
out.writeObject(entry.getKey());
|
||||
out.writeObject(entry.getValue());
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.threerings.io.Streamable;
|
||||
* streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <E> the type of element stored in this set.
|
||||
*/
|
||||
public class StreamableHashSet<E> extends HashSet<E>
|
||||
implements Streamable
|
||||
|
||||
@@ -25,6 +25,9 @@ import java.awt.Point;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
/**
|
||||
* A point that can be sent over the network.
|
||||
*/
|
||||
public class StreamablePoint extends Point
|
||||
implements Streamable
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.threerings.io.Streamable;
|
||||
* must also be of streamable types.
|
||||
*
|
||||
* @see Streamable
|
||||
* @param <L> the type of the left-hand side of this tuple.
|
||||
* @param <R> the type of the right-hand side of this tuple.
|
||||
*/
|
||||
public class StreamableTuple<L, R> extends Tuple<L, R>
|
||||
implements Streamable
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TrackedObject
|
||||
* instances and an <code>int[]</code> array that represent the number
|
||||
* of outstanding instance of all {@link TrackedObject}s in the VM.
|
||||
*/
|
||||
public static Tuple<Class[],int[]> getSnapshot ()
|
||||
public static Tuple<Class[], int[]> getSnapshot ()
|
||||
{
|
||||
Class[] classes = null;
|
||||
int[] counts = null;
|
||||
@@ -98,15 +98,15 @@ public class TrackedObject
|
||||
classes = new Class[_map.size()];
|
||||
counts = new int[_map.size()];
|
||||
int idx = 0;
|
||||
for (Map.Entry<Class,int[]> entry : _map.entrySet()) {
|
||||
for (Map.Entry<Class, int[]> entry : _map.entrySet()) {
|
||||
classes[idx] = entry.getKey();
|
||||
counts[idx] = entry.getValue()[0];
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return new Tuple<Class[],int[]>(classes, counts);
|
||||
return new Tuple<Class[], int[]>(classes, counts);
|
||||
}
|
||||
|
||||
/** Tracks a mapping from {@link Class} object to active count. */
|
||||
protected static HashMap<Class,int[]> _map = new HashMap<Class,int[]>();
|
||||
protected static HashMap<Class, int[]> _map = new HashMap<Class, int[]>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user