Permalink
Browse files

more jid actor singletons

  • Loading branch information...
1 parent e3e553a commit 5eec0f1e729796408b42d4a1be5045324570dfec @laforge49 committed Apr 21, 2012
View
4 src/main/java/org/agilewiki/jid/JidFactories.java
@@ -322,8 +322,8 @@ public void setParent(Actor parent) throws Exception {
factory.registerActorFactory(DoubleJidFactory.fac);
factory.registerActorFactory(ActorJidFactory.fac);
- factory.registerActorFactory(new RootJidFactory());
- factory.registerActorFactory(new StringJidFactory());
+ factory.registerActorFactory(RootJidFactory.fac);
+ factory.registerActorFactory(StringJidFactory.fac);
factory.registerActorFactory(new BytesJidFactory());
factory.registerActorFactory(new TupleJidFactory());
View
9 src/main/java/org/agilewiki/jid/collection/flenc/StringStringTupleFactories.java
@@ -24,14 +24,15 @@
package org.agilewiki.jid.collection.flenc;
import org.agilewiki.jactor.Mailbox;
+import org.agilewiki.jactor.factory.ActorFactory;
import org.agilewiki.jid.JidFactory;
import org.agilewiki.jid.scalar.vlens.string.StringJidFactory;
/**
* Defines (StringJidC, StringJidC) tuples.
*/
public class StringStringTupleFactories extends BaseTupleFactories {
- private JidFactory[] tupleFactories;
+ private ActorFactory[] tupleFactories;
/**
* Create a LiteActor
@@ -42,12 +43,12 @@ public StringStringTupleFactories(Mailbox mailbox) {
super(mailbox);
}
- private JidFactory[] tupleFactories()
+ private ActorFactory[] tupleFactories()
throws Exception {
if (tupleFactories != null)
return tupleFactories;
tupleFactories = new JidFactory[2];
- JidFactory jf = new StringJidFactory();
+ ActorFactory jf = StringJidFactory.fac;
tupleFactories[0] = jf;
tupleFactories[1] = jf;
return tupleFactories;
@@ -59,7 +60,7 @@ public StringStringTupleFactories(Mailbox mailbox) {
* @return An array of JidFactory.
*/
@Override
- public JidFactory[] getTupleFactories()
+ public ActorFactory[] getTupleFactories()
throws Exception {
return tupleFactories();
}
View
2 src/main/java/org/agilewiki/jid/collection/vlenc/StringListJid.java
@@ -47,6 +47,6 @@ public StringListJid(Mailbox mailbox) {
@Override
final protected StringJidFactory getListFactory()
throws Exception {
- return new StringJidFactory();
+ return StringJidFactory.fac;
}
}
View
2 src/main/java/org/agilewiki/jid/collection/vlenc/map/integer/IntegerStringMapJid.java
@@ -46,6 +46,6 @@ public IntegerStringMapJid(Mailbox mailbox) {
*/
protected StringJidFactory getValueFactory()
throws Exception {
- return new StringJidFactory();
+ return StringJidFactory.fac;
}
}
View
2 src/main/java/org/agilewiki/jid/collection/vlenc/map/lng/LongStringMapJid.java
@@ -46,6 +46,6 @@ public LongStringMapJid(Mailbox mailbox) {
*/
protected StringJidFactory getValueFactory()
throws Exception {
- return new StringJidFactory();
+ return StringJidFactory.fac;
}
}
View
2 src/main/java/org/agilewiki/jid/collection/vlenc/map/string/StringMapJid.java
@@ -96,7 +96,7 @@ public StringMapJid(Mailbox mailbox) {
* @return The JidFactory for the key.
*/
final protected StringJidFactory getKeyFactory() {
- return new StringJidFactory();
+ return StringJidFactory.fac;
}
/**
View
2 src/main/java/org/agilewiki/jid/collection/vlenc/map/string/StringStringMapJid.java
@@ -46,6 +46,6 @@ public StringStringMapJid(Mailbox mailbox) {
*/
protected StringJidFactory getValueFactory()
throws Exception {
- return new StringJidFactory();
+ return StringJidFactory.fac;
}
}
View
5 src/main/java/org/agilewiki/jid/scalar/vlens/actor/ActorJid.java
@@ -26,6 +26,7 @@
import org.agilewiki.jactor.Actor;
import org.agilewiki.jactor.Mailbox;
import org.agilewiki.jactor.RP;
+import org.agilewiki.jactor.factory.ActorFactory;
import org.agilewiki.jid.*;
import org.agilewiki.jid.scalar.vlens.VLenScalarJid;
@@ -224,7 +225,7 @@ protected void setBytes(String jidType, byte[] bytes)
* @param bytes The serialized data.
* @throws Exception Any uncaught exception raised.
*/
- protected void setJidBytes(JidFactory jidFactory, byte[] bytes)
+ protected void setJidBytes(ActorFactory jidFactory, byte[] bytes)
throws Exception {
if (len > -1)
clear();
@@ -254,7 +255,7 @@ protected Boolean makeJidBytes(JidFactory jidFactory, byte[] bytes)
* @param bytes The serialized data.
* @throws Exception Any uncaught exception raised.
*/
- protected void setBytes(JidFactory jidFactory, byte[] bytes)
+ protected void setBytes(ActorFactory jidFactory, byte[] bytes)
throws Exception {
value = createSubordinate(jidFactory, bytes);
int l = Util.stringLength(jidFactory.getActorType()) + value.getSerializedLength();
View
10 src/main/java/org/agilewiki/jid/scalar/vlens/actor/RootJidFactory.java
@@ -1,18 +1,20 @@
package org.agilewiki.jid.scalar.vlens.actor;
import org.agilewiki.jactor.Mailbox;
+import org.agilewiki.jactor.factory.ActorFactory;
import org.agilewiki.jid.JidFactories;
-import org.agilewiki.jid.JidFactory;
/**
* Creates a RootJid.
*/
-public class RootJidFactory extends JidFactory {
+public class RootJidFactory extends ActorFactory {
+ final public static RootJidFactory fac = new RootJidFactory();
+
/**
* Create a JLPCActorFactory.
*/
- public RootJidFactory() {
- actorType = JidFactories.ROOT_JID_TYPE;
+ protected RootJidFactory() {
+ super(JidFactories.ROOT_JID_TYPE);
}
/**
View
8 src/main/java/org/agilewiki/jid/scalar/vlens/actor/SetActorBytes.java
@@ -24,8 +24,8 @@
package org.agilewiki.jid.scalar.vlens.actor;
import org.agilewiki.jactor.Actor;
+import org.agilewiki.jactor.factory.ActorFactory;
import org.agilewiki.jactor.lpc.SynchronousRequest;
-import org.agilewiki.jid.JidFactory;
/**
* Creates a JID actor and loads its serialized data.
@@ -40,7 +40,7 @@
/**
* The jid factory.
*/
- private JidFactory jidFactory;
+ private ActorFactory jidFactory;
/**
* Holds the serialized data.
@@ -66,7 +66,7 @@ public SetActorBytes(String actorType, byte[] bytes) {
* @param jidFactory The jid factory.
* @param bytes The serialized data.
*/
- public SetActorBytes(JidFactory jidFactory, byte[] bytes) {
+ public SetActorBytes(ActorFactory jidFactory, byte[] bytes) {
if (jidFactory == null)
throw new IllegalArgumentException("value may not be null");
this.jidFactory = jidFactory;
@@ -87,7 +87,7 @@ public String getActorType() {
*
* @return The jid factory.
*/
- public JidFactory getJidFactory() {
+ public ActorFactory getJidFactory() {
return jidFactory;
}
View
10 src/main/java/org/agilewiki/jid/scalar/vlens/string/StringJidFactory.java
@@ -1,18 +1,20 @@
package org.agilewiki.jid.scalar.vlens.string;
import org.agilewiki.jactor.Mailbox;
+import org.agilewiki.jactor.factory.ActorFactory;
import org.agilewiki.jid.JidFactories;
-import org.agilewiki.jid.JidFactory;
/**
* Creates a StringJid.
*/
-public class StringJidFactory extends JidFactory {
+public class StringJidFactory extends ActorFactory {
+ final public static StringJidFactory fac = new StringJidFactory();
+
/**
* Create a JLPCActorFactory.
*/
- public StringJidFactory() {
- actorType = JidFactories.STRING_JID_TYPE;
+ protected StringJidFactory() {
+ super(JidFactories.STRING_JID_TYPE);
}
/**
View
2 src/test/java/org/agilewiki/jid/collection/flenc/TupleTest.java
@@ -66,7 +66,7 @@ public void test() {
Actor f1 = (new ResolvePathname("1")).send(future, t1);
assertEquals("Oranges", GetString.req.send(future, f1));
- Actor string1 = (new StringJidFactory()).newActor(sstf.getMailbox(), sstf);
+ Actor string1 = StringJidFactory.fac.newActor(sstf.getMailbox(), sstf);
(new SetString("Peaches")).send(future, string1);
byte[] sb = GetSerializedBytes.req.send(future, string1);
(new ISetBytes(1, sb)).send(future, t1);
View
2 src/test/java/org/agilewiki/jid/scalar/vlens/actor/ActorJidTest.java
@@ -44,7 +44,7 @@ public void test() {
rpa = (new ResolvePathname("0")).send(future, jidJid11);
assertNull(rpa);
- StringJidFactory stringJidAFactory = new StringJidFactory();
+ StringJidFactory stringJidAFactory = StringJidFactory.fac;
Actor string1 = stringJidAFactory.newActor(factory.getMailbox(), factory);
(new SetString("abc")).send(future, string1);
byte[] sb = GetSerializedBytes.req.send(future, string1);
View
2 src/test/java/org/agilewiki/jid/scalar/vlens/actor/RootJidTest.java
@@ -44,7 +44,7 @@ public void test() {
rpa = (new ResolvePathname("0")).send(future, rootJid11);
assertNull(rpa);
- StringJidFactory stringJidAFactory = new StringJidFactory();
+ StringJidFactory stringJidAFactory = StringJidFactory.fac;
Actor string1 = stringJidAFactory.newActor(factory.getMailbox(), factory);
(new SetString("abc")).send(future, string1);
byte[] sb = GetSerializedBytes.req.send(future, string1);

0 comments on commit 5eec0f1

Please sign in to comment.