Take advantage of our new "one constructor to rule them all" capabilities in

various base classes. This allows us to use final fields in some cases, which
I've done (though our naughty penchant for mutation forced me to roll back a
bunch of other spots where I would have liked to make fields final).

This is going to break a few things in dependents, because said dependents will
have zero argument constructors of their own which will need to be removed.
I'll be tracking those down and cleaning them up as build failures provide me
with infos.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6575 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2011-04-01 22:06:42 +00:00
parent 61de392df9
commit b986464ee7
39 changed files with 127 additions and 511 deletions
@@ -32,9 +32,4 @@ public class BureauAuthName extends Name
{ {
super(bureauId); super(bureauId);
} }
// used when unserializing
public BureauAuthName ()
{
}
} }
@@ -47,13 +47,6 @@ public abstract class ChatMessage
@ActionScript(type="int") @ActionScript(type="int")
public transient long timestamp; public transient long timestamp;
/**
* For all your unserialization needs.
*/
public ChatMessage ()
{
}
/** /**
* Construct a ChatMessage. * Construct a ChatMessage.
*/ */
@@ -40,11 +40,6 @@ public class SystemMessage extends ChatMessage
/** The attention level of this message. */ /** The attention level of this message. */
public byte attentionLevel; public byte attentionLevel;
// documentation inherited
public SystemMessage ()
{
}
/** /**
* Construct a SystemMessage. * Construct a SystemMessage.
*/ */
@@ -35,10 +35,12 @@ public class UserMessage extends ChatMessage
public byte mode; public byte mode;
/** /**
* For unserialization. * Constructs a user message for a player originated tell (which has no bundle and is in the
* default mode).
*/ */
public UserMessage () public static UserMessage create (Name speaker, String message)
{ {
return new UserMessage(speaker, null, message, ChatCodes.DEFAULT_MODE);
} }
/** /**
@@ -51,17 +53,6 @@ public class UserMessage extends ChatMessage
this.mode = mode; this.mode = mode;
} }
/**
* Constructs a user message for a player originated tell (which has no bundle and is in the
* default mode).
*/
public UserMessage (Name speaker, String message)
{
super(message, null);
this.speaker = speaker;
this.mode = ChatCodes.DEFAULT_MODE;
}
/** /**
* Returns the name to display for the speaker. Some types of messages may wish to not use the * Returns the name to display for the speaker. Some types of messages may wish to not use the
* canonical name for the speaker and should thus override this function. * canonical name for the speaker and should thus override this function.
@@ -32,17 +32,12 @@ public class UserSystemMessage extends SystemMessage
/** The "speaker" of this message, the user that triggered that this message be sent to us. */ /** The "speaker" of this message, the user that triggered that this message be sent to us. */
public Name speaker; public Name speaker;
/** Suitable for unserialization. */
public UserSystemMessage ()
{
}
/** /**
* Construct a INFO-level UserSystemMessage. * Construct a INFO-level UserSystemMessage.
*/ */
public UserSystemMessage (Name sender, String message, String bundle) public static UserSystemMessage create (Name sender, String message, String bundle)
{ {
this(sender, message, bundle, INFO); return new UserSystemMessage(sender, message, bundle, INFO);
} }
/** /**
@@ -54,26 +54,16 @@ public class ChatHistory
* {@link #record(ChatChannel, UserMessage, Name...)}, * {@link #record(ChatChannel, UserMessage, Name...)},
* {@link #get(Name)}, and {@link #clear(Name)}. * {@link #get(Name)}, and {@link #clear(Name)}.
*/ */
public static class Entry public static class Entry implements Streamable
implements Streamable
{ {
/** The channel on which the message was sent, of null if the channel manager was not /** The channel on which the message was sent, of null if the channel manager was not
* used. */ * used. */
public ChatChannel channel; public final ChatChannel channel;
/** The message sent. */ /** The message sent. */
public ChatMessage message; public final ChatMessage message;
/** For deserialization. */ public Entry (ChatChannel channel, ChatMessage message) {
public Entry ()
{
}
/**
* Creates a new history entry.
*/
public Entry (ChatChannel channel, ChatMessage message)
{
this.channel = channel; this.channel = channel;
this.message = message; this.message = message;
} }
@@ -271,7 +271,7 @@ public class ChatProvider
*/ */
protected UserMessage createTellMessage (BodyObject source, String message) protected UserMessage createTellMessage (BodyObject source, String message)
{ {
return new UserMessage(source.getVisibleName(), message); return UserMessage.create(source.getVisibleName(), message);
} }
/** /**
@@ -245,5 +245,5 @@ public class BodyObject extends ClientObject
} }
/** The default (no tokens) access control. */ /** The default (no tokens) access control. */
protected static final TokenRing EMPTY_TOKENS = new TokenRing(); protected static final TokenRing EMPTY_TOKENS = new TokenRing(0);
} }
@@ -89,7 +89,7 @@ public class OccupantInfo extends SimpleStreamableObject
} }
/** The body object id of this occupant (and our entry key). */ /** The body object id of this occupant (and our entry key). */
public Integer bodyOid; public final Integer bodyOid;
/** The username of this occupant. */ /** The username of this occupant. */
public Name username; public Name username;
@@ -107,11 +107,6 @@ public class OccupantInfo extends SimpleStreamableObject
status = body.status; status = body.status;
} }
/** A blank constructor used for unserialization. */
public OccupantInfo ()
{
}
/** Access to the body object id as an int. */ /** Access to the body object id as an int. */
public int getBodyOid () public int getBodyOid ()
{ {
@@ -29,12 +29,7 @@ import com.threerings.io.SimpleStreamableObject;
public class Place extends SimpleStreamableObject public class Place extends SimpleStreamableObject
{ {
/** The oid of this place's {@link PlaceObject}. */ /** The oid of this place's {@link PlaceObject}. */
public int placeOid; public final int placeOid;
/** Used when unserializing. */
public Place ()
{
}
/** /**
* Creates a place with the supplied oid. * Creates a place with the supplied oid.
@@ -33,13 +33,6 @@ public class TokenRing extends SimpleStreamableObject
/** Indicates that this user is an administrator. */ /** Indicates that this user is an administrator. */
public static final int ADMIN = (1 << 0); public static final int ADMIN = (1 << 0);
/**
* A default constructor, used when unserializing token rings.
*/
public TokenRing ()
{
}
/** /**
* Constructs a token ring with the supplied set of tokens. * Constructs a token ring with the supplied set of tokens.
*/ */
@@ -36,14 +36,6 @@ import com.threerings.presents.net.Transport;
*/ */
public class AttributeChangedEvent extends NamedEvent public class AttributeChangedEvent extends NamedEvent
{ {
/**
* Constructs a blank instance of this event in preparation for unserialization from the
* network.
*/
public AttributeChangedEvent ()
{
}
/** /**
* Returns the new value of the attribute. * Returns the new value of the attribute.
*/ */
@@ -150,21 +142,6 @@ public class AttributeChangedEvent extends NamedEvent
return true; return true;
} }
/**
* Constructs a new attribute changed event on the specified target object with the supplied
* attribute name and value. <em>Do not construct these objects by hand.</em> Use {@link
* DObject#changeAttribute} instead.
*
* @param targetOid the object id of the object whose attribute has changed.
* @param name the name of the attribute (data member) that has changed.
* @param value the new value of the attribute (in the case of primitive types, the
* reflection-defined object-alternative is used).
*/
protected AttributeChangedEvent (int targetOid, String name, Object value, Object oldValue)
{
this(targetOid, name, value, oldValue, Transport.DEFAULT);
}
/** /**
* Constructs a new attribute changed event on the specified target object with the supplied * Constructs a new attribute changed event on the specified target object with the supplied
* attribute name and value. <em>Do not construct these objects by hand.</em> Use {@link * attribute name and value. <em>Do not construct these objects by hand.</em> Use {@link
@@ -35,19 +35,12 @@ import com.threerings.presents.net.Transport;
*/ */
public class CompoundEvent extends DEvent public class CompoundEvent extends DEvent
{ {
/**
* Constructs a blank compound event in preparation for unserialization.
*/
public CompoundEvent ()
{
}
/** /**
* Constructs a compound event and prepares it for operation. * Constructs a compound event and prepares it for operation.
*/ */
public CompoundEvent (DObject target, DObjectManager omgr) public CompoundEvent (DObject target, DObjectManager omgr)
{ {
super(target.getOid()); super(target.getOid(), Transport.DEFAULT);
// sanity check // sanity check
if (omgr == null) { if (omgr == null) {
@@ -36,21 +36,6 @@ public abstract class DEvent implements Streamable
* increasing fashion when the event is posted to the event dispatch queue. */ * increasing fashion when the event is posted to the event dispatch queue. */
public transient long eventId; public transient long eventId;
/**
* A zero argument constructor for unserialization from yon network.
*/
public DEvent ()
{
}
/**
* Constructs a new distributed object event that pertains to the specified distributed object.
*/
public DEvent (int targetOid)
{
this(targetOid, Transport.DEFAULT);
}
/** /**
* Constructs a new distributed object event that pertains to the specified distributed object. * Constructs a new distributed object event that pertains to the specified distributed object.
* *
@@ -903,7 +903,7 @@ public class DObject
if (applyImmediately) { if (applyImmediately) {
list.add(oid); list.add(oid);
} }
postEvent(new ObjectAddedEvent(_oid, name, oid, applyImmediately)); postEvent(new ObjectAddedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately));
} }
/** /**
@@ -917,19 +917,19 @@ public class DObject
list.remove(oid); list.remove(oid);
} }
// dispatch an object removed event // dispatch an object removed event
postEvent(new ObjectRemovedEvent(_oid, name, oid, applyImmediately)); postEvent(new ObjectRemovedEvent(_oid, name, oid).setAlreadyApplied(applyImmediately));
} }
/** @deprecated Regenerate your DObject to remove this warning. */ /** @deprecated Regenerate your DObject to remove this warning. */
@Deprecated protected void requestOidAdd (String name, int oid) @Deprecated protected void requestOidAdd (String name, int oid)
{ {
postEvent(new ObjectAddedEvent(_oid, name, oid, false)); postEvent(new ObjectAddedEvent(_oid, name, oid));
} }
/** @deprecated Regenerate your DObject to remove this warning. */ /** @deprecated Regenerate your DObject to remove this warning. */
@Deprecated protected void requestOidRemove (String name, int oid) @Deprecated protected void requestOidRemove (String name, int oid)
{ {
postEvent(new ObjectRemovedEvent(_oid, name, oid, false)); postEvent(new ObjectRemovedEvent(_oid, name, oid));
} }
/** /**
@@ -943,7 +943,7 @@ public class DObject
set.add(entry); set.add(entry);
} }
// dispatch an entry added event // dispatch an entry added event
postEvent(new EntryAddedEvent<T>(_oid, name, entry, applyImmediately)); postEvent(new EntryAddedEvent<T>(_oid, name, entry).setAlreadyApplied(applyImmediately));
} }
/** /**
@@ -37,23 +37,6 @@ import com.threerings.presents.net.Transport;
*/ */
public class ElementUpdatedEvent extends NamedEvent public class ElementUpdatedEvent extends NamedEvent
{ {
/**
* Constructs a new element updated event on the specified target object with the supplied
* attribute name, element and index.
*
* @param targetOid the object id of the object whose attribute has changed.
* @param name the name of the attribute (data member) for which an element has changed.
* @param value the new value of the element (in the case of primitive types, the
* reflection-defined object-alternative is used).
* @param ovalue the previous value of the element (in the case of primitive types, the
* reflection-defined object-alternative is used).
* @param index the index in the array of the updated element.
*/
public ElementUpdatedEvent (int targetOid, String name, Object value, Object ovalue, int index)
{
this(targetOid, name, value, ovalue, index, Transport.DEFAULT);
}
/** /**
* Constructs a new element updated event on the specified target object with the supplied * Constructs a new element updated event on the specified target object with the supplied
* attribute name, element and index. * attribute name, element and index.
@@ -76,14 +59,6 @@ public class ElementUpdatedEvent extends NamedEvent
_index = index; _index = index;
} }
/**
* Constructs a blank instance of this event in preparation for unserialization from the
* network.
*/
public ElementUpdatedEvent ()
{
}
/** /**
* Returns the new value of the element. * Returns the new value of the element.
*/ */
@@ -23,6 +23,8 @@ package com.threerings.presents.dobj;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.presents.net.Transport;
/** /**
* An entry added event is dispatched when an entry is added to a {@link DSet} attribute of a * An entry added event is dispatched when an entry is added to a {@link DSet} attribute of a
* distributed entry. It can also be constructed to request the addition of an entry to a set and * distributed entry. It can also be constructed to request the addition of an entry to a set and
@@ -45,25 +47,8 @@ public class EntryAddedEvent<T extends DSet.Entry> extends EntryEvent<T>
*/ */
public EntryAddedEvent (int targetOid, String name, T entry) public EntryAddedEvent (int targetOid, String name, T entry)
{ {
this(targetOid, name, entry, false); super(targetOid, name, Transport.DEFAULT);
}
/**
* Used when the distributed object already added the entry before generating the event.
*/
public EntryAddedEvent (int targetOid, String name, T entry, boolean alreadyApplied)
{
super(targetOid, name);
_entry = entry; _entry = entry;
_alreadyApplied = alreadyApplied;
}
/**
* Constructs a blank instance of this event in preparation for unserialization from the
* network.
*/
public EntryAddedEvent ()
{
} }
@Override @Override
@@ -128,6 +113,13 @@ public class EntryAddedEvent<T extends DSet.Entry> extends EntryEvent<T>
StringUtil.toString(buf, _entry); StringUtil.toString(buf, _entry);
} }
/** Used by {@link DObject} to note if this event has already been applied locally. */
protected EntryAddedEvent setAlreadyApplied (boolean alreadyApplied)
{
_alreadyApplied = alreadyApplied;
return this;
}
protected T _entry; protected T _entry;
/** Used when this event is generated on the authoritative server where object changes are made /** Used when this event is generated on the authoritative server where object changes are made
@@ -28,17 +28,6 @@ import com.threerings.presents.net.Transport;
*/ */
public abstract class EntryEvent<T extends DSet.Entry> extends NamedEvent public abstract class EntryEvent<T extends DSet.Entry> extends NamedEvent
{ {
/**
* Constructs a new event for the specified target object with the supplied attribute name.
*
* @param targetOid the object id of the object in question.
* @param name the name associated with this event.
*/
public EntryEvent (int targetOid, String name)
{
super(targetOid, name);
}
/** /**
* Constructs a new event for the specified target object with the supplied attribute name. * Constructs a new event for the specified target object with the supplied attribute name.
* *
@@ -51,11 +40,6 @@ public abstract class EntryEvent<T extends DSet.Entry> extends NamedEvent
super(targetOid, name, transport); super(targetOid, name, transport);
} }
/** For unserialization. */
public EntryEvent ()
{
}
/** /**
* Return the key that identifies the entry related to this event. * Return the key that identifies the entry related to this event.
* Never returns <code>null</code>. * Never returns <code>null</code>.
@@ -21,6 +21,8 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
/** /**
@@ -46,19 +48,11 @@ public class EntryRemovedEvent<T extends DSet.Entry> extends EntryEvent<T>
*/ */
public EntryRemovedEvent (int targetOid, String name, Comparable<?> key, T oldEntry) public EntryRemovedEvent (int targetOid, String name, Comparable<?> key, T oldEntry)
{ {
super(targetOid, name); super(targetOid, name, Transport.DEFAULT);
_key = key; _key = key;
_oldEntry = oldEntry; _oldEntry = oldEntry;
} }
/**
* Constructs a blank instance of this event in preparation for unserialization from the
* network.
*/
public EntryRemovedEvent ()
{
}
@Override @Override
public Comparable<?> getKey () public Comparable<?> getKey ()
{ {
@@ -38,20 +38,6 @@ import static com.threerings.presents.Log.log;
*/ */
public class EntryUpdatedEvent<T extends DSet.Entry> extends EntryEvent<T> public class EntryUpdatedEvent<T extends DSet.Entry> extends EntryEvent<T>
{ {
/**
* Constructs a new entry updated event on the specified target object for the specified set
* name and with the supplied updated entry.
*
* @param targetOid the object id of the object to whose set we will add an entry.
* @param name the name of the attribute in which to update the specified entry.
* @param entry the entry to update.
* @param oldEntry the previous value of the entry.
*/
public EntryUpdatedEvent (int targetOid, String name, T entry, T oldEntry)
{
this(targetOid, name, entry, oldEntry, Transport.DEFAULT);
}
/** /**
* Constructs a new entry updated event on the specified target object for the specified set * Constructs a new entry updated event on the specified target object for the specified set
* name and with the supplied updated entry. * name and with the supplied updated entry.
@@ -69,14 +55,6 @@ public class EntryUpdatedEvent<T extends DSet.Entry> extends EntryEvent<T>
_oldEntry = oldEntry; _oldEntry = oldEntry;
} }
/**
* Constructs a blank instance of this event in preparation for unserialization from the
* network.
*/
public EntryUpdatedEvent ()
{
}
@Override @Override
public Comparable<?> getKey () public Comparable<?> getKey ()
{ {
@@ -26,44 +26,21 @@ import com.samskivert.util.StringUtil;
import com.threerings.presents.net.Transport; import com.threerings.presents.net.Transport;
/** /**
* Used to dispatch an invocation notification from the server to a * Used to dispatch an invocation notification from the server to a client.
* client.
* *
* @see DObjectManager#postEvent * @see DObjectManager#postEvent
*/ */
public class InvocationNotificationEvent extends DEvent public class InvocationNotificationEvent extends DEvent
{ {
/** /**
* Constructs a new invocation notification event on the specified * Constructs a new invocation notification event on the specified target object with the
* target object with the supplied receiver id, method id and * supplied receiver id, method id and arguments.
* arguments.
* *
* @param targetOid the object id of the object on which the event is * @param targetOid the object id of the object on which the event is to be dispatched.
* to be dispatched. * @param receiverId identifies the receiver to which this notification is being dispatched.
* @param receiverId identifies the receiver to which this notification
* is being dispatched.
* @param methodId the id of the method to be invoked. * @param methodId the id of the method to be invoked.
* @param args the arguments for the method. This array should contain * @param args the arguments for the method. This array should contain only values of valid
* only values of valid distributed object types. * distributed object types.
*/
public InvocationNotificationEvent (
int targetOid, short receiverId, int methodId, Object[] args)
{
this(targetOid, receiverId, methodId, args, Transport.DEFAULT);
}
/**
* Constructs a new invocation notification event on the specified
* target object with the supplied receiver id, method id and
* arguments.
*
* @param targetOid the object id of the object on which the event is
* to be dispatched.
* @param receiverId identifies the receiver to which this notification
* is being dispatched.
* @param methodId the id of the method to be invoked.
* @param args the arguments for the method. This array should contain
* only values of valid distributed object types.
* @param transport a hint as to the type of transport desired for the event. * @param transport a hint as to the type of transport desired for the event.
*/ */
public InvocationNotificationEvent ( public InvocationNotificationEvent (
@@ -75,14 +52,6 @@ public class InvocationNotificationEvent extends DEvent
_args = args; _args = args;
} }
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public InvocationNotificationEvent ()
{
}
/** /**
* Returns the receiver id associated with this notification. * Returns the receiver id associated with this notification.
*/ */
@@ -33,32 +33,14 @@ import com.threerings.presents.net.Transport;
public class InvocationRequestEvent extends DEvent public class InvocationRequestEvent extends DEvent
{ {
/** /**
* Constructs a new invocation request event on the specified target * Constructs a new invocation request event on the specified target object with the supplied
* object with the supplied code, method and arguments. * code, method and arguments.
* *
* @param targetOid the object id of the object on which the event is * @param targetOid the object id of the object on which the event is to be dispatched.
* to be dispatched.
* @param invCode the invocation provider identification code. * @param invCode the invocation provider identification code.
* @param methodId the id of the method to be invoked. * @param methodId the id of the method to be invoked.
* @param args the arguments for the method. This array should contain * @param args the arguments for the method. This array should contain only values of valid
* only values of valid distributed object types. * distributed object types.
*/
public InvocationRequestEvent (
int targetOid, int invCode, int methodId, Object[] args)
{
this(targetOid, invCode, methodId, args, Transport.DEFAULT);
}
/**
* Constructs a new invocation request event on the specified target
* object with the supplied code, method and arguments.
*
* @param targetOid the object id of the object on which the event is
* to be dispatched.
* @param invCode the invocation provider identification code.
* @param methodId the id of the method to be invoked.
* @param args the arguments for the method. This array should contain
* only values of valid distributed object types.
* @param transport a hint as to the type of transport desired for the event. * @param transport a hint as to the type of transport desired for the event.
*/ */
public InvocationRequestEvent ( public InvocationRequestEvent (
@@ -70,14 +52,6 @@ public class InvocationRequestEvent extends DEvent
_args = args; _args = args;
} }
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public InvocationRequestEvent ()
{
}
/** /**
* Returns the invocation code associated with this request. * Returns the invocation code associated with this request.
*/ */
@@ -33,32 +33,14 @@ import com.threerings.presents.net.Transport;
public class InvocationResponseEvent extends DEvent public class InvocationResponseEvent extends DEvent
{ {
/** /**
* Constructs a new invocation response event on the specified target * Constructs a new invocation response event on the specified target object with the supplied
* object with the supplied code, method and arguments. * code, method and arguments.
* *
* @param targetOid the object id of the object on which the event is * @param targetOid the object id of the object on which the event is to be dispatched.
* to be dispatched.
* @param requestId the id of the request to which we are responding. * @param requestId the id of the request to which we are responding.
* @param methodId the method to be invoked. * @param methodId the method to be invoked.
* @param args the arguments for the method. This array should contain * @param args the arguments for the method. This array should contain only values of valid
* only values of valid distributed object types. * distributed object types.
*/
public InvocationResponseEvent (
int targetOid, int requestId, int methodId, Object[] args)
{
this(targetOid, requestId, methodId, args, Transport.DEFAULT);
}
/**
* Constructs a new invocation response event on the specified target
* object with the supplied code, method and arguments.
*
* @param targetOid the object id of the object on which the event is
* to be dispatched.
* @param requestId the id of the request to which we are responding.
* @param methodId the method to be invoked.
* @param args the arguments for the method. This array should contain
* only values of valid distributed object types.
* @param transport a hint as to the type of transport desired for the event. * @param transport a hint as to the type of transport desired for the event.
*/ */
public InvocationResponseEvent ( public InvocationResponseEvent (
@@ -70,14 +52,6 @@ public class InvocationResponseEvent extends DEvent
_args = args; _args = args;
} }
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public InvocationResponseEvent ()
{
}
/** /**
* Returns the invocation request id associated with this response. * Returns the invocation request id associated with this response.
*/ */
@@ -26,10 +26,9 @@ import com.samskivert.util.StringUtil;
import com.threerings.presents.net.Transport; import com.threerings.presents.net.Transport;
/** /**
* A message event is used to dispatch a message to all subscribers of a * A message event is used to dispatch a message to all subscribers of a distributed object without
* distributed object without actually changing any of the fields of the * actually changing any of the fields of the object. A message has a name, by which different
* object. A message has a name, by which different subscribers of the * subscribers of the same object can distinguish their different messages, and an array of
* same object can distinguish their different messages, and an array of
* arguments by which any contents of the message can be delivered. * arguments by which any contents of the message can be delivered.
* *
* @see DObjectManager#postEvent * @see DObjectManager#postEvent
@@ -37,29 +36,13 @@ import com.threerings.presents.net.Transport;
public class MessageEvent extends NamedEvent public class MessageEvent extends NamedEvent
{ {
/** /**
* Constructs a new message event on the specified target object with * Constructs a new message event on the specified target object with the supplied name and
* the supplied name and arguments. * arguments.
* *
* @param targetOid the object id of the object whose attribute has * @param targetOid the object id of the object whose attribute has changed.
* changed.
* @param name the name of the message event. * @param name the name of the message event.
* @param args the arguments for this message. This array should * @param args the arguments for this message. This array should contain only values of valid
* contain only values of valid distributed object types. * distributed object types.
*/
public MessageEvent (int targetOid, String name, Object[] args)
{
this(targetOid, name, args, Transport.DEFAULT);
}
/**
* Constructs a new message event on the specified target object with
* the supplied name and arguments.
*
* @param targetOid the object id of the object whose attribute has
* changed.
* @param name the name of the message event.
* @param args the arguments for this message. This array should
* contain only values of valid distributed object types.
* @param transport a hint as to the type of transport desired for the event. * @param transport a hint as to the type of transport desired for the event.
*/ */
public MessageEvent (int targetOid, String name, Object[] args, Transport transport) public MessageEvent (int targetOid, String name, Object[] args, Transport transport)
@@ -68,14 +51,6 @@ public class MessageEvent extends NamedEvent
_args = args; _args = args;
} }
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public MessageEvent ()
{
}
/** /**
* Returns the arguments to this message. * Returns the arguments to this message.
*/ */
@@ -85,9 +60,8 @@ public class MessageEvent extends NamedEvent
} }
/** /**
* Replaces the arguments associated with this message event. * Replaces the arguments associated with this message event. <em>Note:</em> this should only
* <em>Note:</em> this should only be called on events that have not * be called on events that have not yet been dispatched into the distributed object system.
* yet been dispatched into the distributed object system.
*/ */
public void setArgs (Object[] args) public void setArgs (Object[] args)
{ {
@@ -29,18 +29,6 @@ import com.threerings.presents.net.Transport;
*/ */
public abstract class NamedEvent extends DEvent public abstract class NamedEvent extends DEvent
{ {
/**
* Constructs a new named event for the specified target object with
* the supplied attribute name.
*
* @param targetOid the object id of the object in question.
* @param name the name associated with this event.
*/
public NamedEvent (int targetOid, String name)
{
this(targetOid, name, Transport.DEFAULT);
}
/** /**
* Constructs a new named event for the specified target object with * Constructs a new named event for the specified target object with
* the supplied attribute name. * the supplied attribute name.
@@ -55,14 +43,6 @@ public abstract class NamedEvent extends DEvent
_name = name; _name = name;
} }
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public NamedEvent ()
{
}
/** /**
* Returns the name of the attribute to which this event pertains. * Returns the name of the attribute to which this event pertains.
*/ */
@@ -21,10 +21,11 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
/** /**
* An object added event is dispatched when an object is added to an * An object added event is dispatched when an object is added to an <code>OidList</code> attribute
* <code>OidList</code> attribute of a distributed object. It can also be * of a distributed object. It can also be constructed to request the addition of an oid to an
* constructed to request the addition of an oid to an
* <code>OidList</code> attribute of an object and posted to the dobjmgr. * <code>OidList</code> attribute of an object and posted to the dobjmgr.
* *
* @see DObjectManager#postEvent * @see DObjectManager#postEvent
@@ -32,33 +33,17 @@ package com.threerings.presents.dobj;
public class ObjectAddedEvent extends NamedEvent public class ObjectAddedEvent extends NamedEvent
{ {
/** /**
* Constructs a new object added event on the specified target object * Constructs a new object added event on the specified target object with the supplied oid
* with the supplied oid list attribute name and object id to add. * list attribute name and object id to add.
* *
* @param targetOid the object id of the object to whose oid list we * @param targetOid the object id of the object to whose oid list we will add an oid.
* will add an oid. * @param name the name of the attribute (data member) to which to add the specified oid.
* @param name the name of the attribute (data member) to which to add
* the specified oid.
* @param oid the oid to add to the oid list attribute. * @param oid the oid to add to the oid list attribute.
*/ */
public ObjectAddedEvent (int targetOid, String name, int oid) public ObjectAddedEvent (int targetOid, String name, int oid)
{ {
this(targetOid, name, oid, false); super(targetOid, name, Transport.DEFAULT);
}
protected ObjectAddedEvent (int targetOid, String name, int oid, boolean alreadyApplied)
{
super(targetOid, name);
_oid = oid; _oid = oid;
_alreadyApplied = alreadyApplied;
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ObjectAddedEvent ()
{
} }
/** /**
@@ -102,6 +87,13 @@ public class ObjectAddedEvent extends NamedEvent
buf.append(", oid=").append(_oid); buf.append(", oid=").append(_oid);
} }
/** Used by {@link DObject} to note if this event has already been applied locally. */
protected ObjectAddedEvent setAlreadyApplied (boolean alreadyApplied)
{
_alreadyApplied = alreadyApplied;
return this;
}
protected int _oid; protected int _oid;
protected transient boolean _alreadyApplied; protected transient boolean _alreadyApplied;
} }
@@ -21,6 +21,8 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
/** /**
* An object destroyed event is dispatched when an object has been removed * An object destroyed event is dispatched when an object has been removed
* from the distributed object system. It can also be constructed to * from the distributed object system. It can also be constructed to
@@ -31,22 +33,13 @@ package com.threerings.presents.dobj;
public class ObjectDestroyedEvent extends DEvent public class ObjectDestroyedEvent extends DEvent
{ {
/** /**
* Constructs a new object destroyed event for the specified * Constructs a new object destroyed event for the specified distributed object.
* distributed object.
* *
* @param targetOid the object id of the object that will be destroyed. * @param targetOid the object id of the object that will be destroyed.
*/ */
public ObjectDestroyedEvent (int targetOid) public ObjectDestroyedEvent (int targetOid)
{ {
super(targetOid); super(targetOid, Transport.DEFAULT);
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ObjectDestroyedEvent ()
{
} }
@Override @Override
@@ -21,45 +21,29 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
/** /**
* An object removed event is dispatched when an object is removed from an * An object removed event is dispatched when an object is removed from an <code>OidList</code>
* <code>OidList</code> attribute of a distributed object. It can also be * attribute of a distributed object. It can also be constructed to request the removal of an oid
* constructed to request the removal of an oid from an * from an <code>OidList</code> attribute of an object and posted to the dobjmgr.
* <code>OidList</code> attribute of an object and posted to the dobjmgr.
* *
* @see DObjectManager#postEvent * @see DObjectManager#postEvent
*/ */
public class ObjectRemovedEvent extends NamedEvent public class ObjectRemovedEvent extends NamedEvent
{ {
/** /**
* Constructs a new object removed event on the specified target * Constructs a new object removed event on the specified target object with the supplied oid
* object with the supplied oid list attribute name and object id to * list attribute name and object id to remove.
* remove.
* *
* @param targetOid the object id of the object from whose oid list we * @param targetOid the object id of the object from whose oid list we will remove an oid.
* will remove an oid. * @param name the name of the attribute (data member) from which to remove the specified oid.
* @param name the name of the attribute (data member) from which to
* remove the specified oid.
* @param oid the oid to remove from the oid list attribute. * @param oid the oid to remove from the oid list attribute.
*/ */
public ObjectRemovedEvent (int targetOid, String name, int oid) public ObjectRemovedEvent (int targetOid, String name, int oid)
{ {
this (targetOid, name, oid, false); super(targetOid, name, Transport.DEFAULT);
}
protected ObjectRemovedEvent (int targetOid, String name, int oid, boolean alreadyApplied)
{
super(targetOid, name);
_oid = oid; _oid = oid;
_alreadyApplied = alreadyApplied;
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ObjectRemovedEvent ()
{
} }
/** /**
@@ -103,6 +87,13 @@ public class ObjectRemovedEvent extends NamedEvent
buf.append(", oid=").append(_oid); buf.append(", oid=").append(_oid);
} }
/** Used by {@link DObject} to note if this event has already been applied locally. */
protected ObjectRemovedEvent setAlreadyApplied (boolean alreadyApplied)
{
_alreadyApplied = alreadyApplied;
return this;
}
protected int _oid; protected int _oid;
protected transient boolean _alreadyApplied; protected transient boolean _alreadyApplied;
} }
@@ -21,37 +21,30 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
/** /**
* A release lock event is dispatched at the end of a chain of events to * A release lock event is dispatched at the end of a chain of events to release a lock that is
* release a lock that is intended to prevent some application defined * intended to prevent some application defined activity from happening until those events have
* activity from happening until those events have been processed. This is * been processed. This is an entirely cooperative locking system, meaning that the application
* an entirely cooperative locking system, meaning that the application * will have to explicitly attempt acquisition of the lock to find out if the lock has yet been
* will have to explicitly attempt acquisition of the lock to find out if * released. These locks don't actually prevent any of the distributed object machinery from
* the lock has yet been released. These locks don't actually prevent any * functioning.
* of the distributed object machinery from functioning.
* *
* @see DObjectManager#postEvent * @see DObjectManager#postEvent
*/ */
public class ReleaseLockEvent extends NamedEvent public class ReleaseLockEvent extends NamedEvent
{ {
/** /**
* Constructs a new release lock event for the specified target object * Constructs a new release lock event for the specified target object with the supplied lock
* with the supplied lock name. * name.
* *
* @param targetOid the object id of the object in question. * @param targetOid the object id of the object in question.
* @param name the name of the lock to release. * @param name the name of the lock to release.
*/ */
public ReleaseLockEvent (int targetOid, String name) public ReleaseLockEvent (int targetOid, String name)
{ {
super(targetOid, name); super(targetOid, name, Transport.DEFAULT);
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public ReleaseLockEvent ()
{
} }
@Override @Override
@@ -21,6 +21,8 @@
package com.threerings.presents.dobj; package com.threerings.presents.dobj;
import com.threerings.presents.net.Transport;
/** /**
* A message event that only goes to the server. If generated on the server then it never leaves * A message event that only goes to the server. If generated on the server then it never leaves
* the server. * the server.
@@ -28,25 +30,17 @@ package com.threerings.presents.dobj;
public class ServerMessageEvent extends MessageEvent public class ServerMessageEvent extends MessageEvent
{ {
/** /**
* Constructs a new message event on the specified target object with * Constructs a new message event on the specified target object with the supplied name and
* the supplied name and arguments. * arguments.
* *
* @param targetOid the object id of the object whose attribute has * @param targetOid the object id of the object whose attribute has changed.
* changed.
* @param name the name of the message event. * @param name the name of the message event.
* @param args the arguments for this message. This array should * @param args the arguments for this message. This array should contain only values of valid
* contain only values of valid distributed object types. * distributed object types.
*/ */
public ServerMessageEvent (int targetOid, String name, Object[] args) public ServerMessageEvent (int targetOid, String name, Object[] args)
{ {
super(targetOid, name, args); super(targetOid, name, args, Transport.DEFAULT);
}
/**
* Suitable for unserialization.
*/
public ServerMessageEvent ()
{
} }
@Override @Override
@@ -31,9 +31,6 @@ import com.threerings.io.Streamable;
public class SimpleEntry<T extends Comparable<?>> public class SimpleEntry<T extends Comparable<?>>
implements DSet.Entry implements DSet.Entry
{ {
// Zero arg constructor for unserialization
public SimpleEntry () { }
public SimpleEntry (T key) { public SimpleEntry (T key) {
_key = key; _key = key;
} }
@@ -29,7 +29,11 @@ import com.threerings.io.SimpleStreamableObject;
*/ */
public class DObjectAddress extends SimpleStreamableObject public class DObjectAddress extends SimpleStreamableObject
{ {
public DObjectAddress () {} // Deserialization /** The node on which this object lives.*/
public final String nodeName;
/** This object's oid in its node's oid space. */
public final int oid;
public DObjectAddress (String nodeName, int oid) public DObjectAddress (String nodeName, int oid)
{ {
@@ -37,10 +41,6 @@ public class DObjectAddress extends SimpleStreamableObject
this.oid = oid; this.oid = oid;
} }
public String nodeName;
public int oid;
@Override @Override
public int hashCode () public int hashCode ()
{ {
@@ -75,14 +75,10 @@ public class NodeObject extends DObject
implements Comparable<Lock>, DSet.Entry implements Comparable<Lock>, DSet.Entry
{ {
/** The resource type. Only resources of the same type will have their ids compared. */ /** The resource type. Only resources of the same type will have their ids compared. */
public String type; public final String type;
/** The resource identifier, which can be <code>null</code> for singleton resources. */ /** The resource identifier, which can be <code>null</code> for singleton resources. */
public Comparable<?> id; public final Comparable<?> id;
public Lock ()
{
}
public Lock (String type, Comparable<?> id) public Lock (String type, Comparable<?> id)
{ {
@@ -124,14 +120,10 @@ public class NodeObject extends DObject
public static class CacheData extends SimpleStreamableObject public static class CacheData extends SimpleStreamableObject
{ {
/** The cache that should be purged. */ /** The cache that should be purged. */
public String cache; public final String cache;
/** The stale data in the cache. */ /** The stale data in the cache. */
public Streamable data; public final Streamable data;
public CacheData ()
{
}
public CacheData (String cache, Streamable data) public CacheData (String cache, Streamable data)
{ {
@@ -32,9 +32,4 @@ public class PeerAuthName extends Name
{ {
super(nodeName); super(nodeName);
} }
// used when unserializing
public PeerAuthName ()
{
}
} }
@@ -53,6 +53,7 @@ import com.threerings.presents.dobj.ObjectRemovedEvent;
import com.threerings.presents.dobj.OidList; import com.threerings.presents.dobj.OidList;
import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.net.Transport;
import static com.threerings.presents.Log.log; import static com.threerings.presents.Log.log;
@@ -926,7 +927,7 @@ public class PresentsDObjectMgr
public AccessObjectEvent (int oid, Subscriber<T> target, int action) public AccessObjectEvent (int oid, Subscriber<T> target, int action)
{ {
super(DUMMY_OID); // target the bogus object super(DUMMY_OID, Transport.DEFAULT); // target the bogus object
_oid = oid; _oid = oid;
_target = target; _target = target;
_action = action; _action = action;
@@ -47,11 +47,6 @@ public class Name extends SimpleStreamableObject
return (name == null || name.toString().equals(BLANK.toString())); return (name == null || name.toString().equals(BLANK.toString()));
} }
/** Creates a blank instance for unserialization. */
public Name ()
{
}
/** /**
* Creates a name instance with the supplied name. * Creates a name instance with the supplied name.
*/ */
@@ -142,13 +142,6 @@ public class StreamableEnumSet<E extends Enum<E>> extends AbstractSet<E>
initContents(); initContents();
} }
/**
* No-arg constructor for deserialization.
*/
public StreamableEnumSet ()
{
}
@Override @Override
public Iterator<E> iterator () public Iterator<E> iterator ()
{ {
@@ -51,12 +51,4 @@ public class StreamableTuple<L, R> extends Tuple<L, R>
{ {
super(left, right); super(left, right);
} }
/**
* Don't use this constructor! It's only for unstreaming.
*/
public StreamableTuple ()
{
super(null, null);
}
} }
@@ -345,9 +345,6 @@ public class StreamableTest
this.strizzing = (s == null) ? null : (s + "-izzle"); this.strizzing = (s == null) ? null : (s + "-izzle");
} }
/** Unserialize like the Dickens. */
public Wacket () {}
// from Wackable // from Wackable
public void wack () public void wack ()
{ {