summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java')
-rw-r--r--Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java
new file mode 100644
index 0000000..eeb08cb
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java
@@ -0,0 +1,29 @@
+package examples.jndi;
+
+import java.rmi.RemoteException;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * The implementation of a remote object which generates primary keys
+ */
+public class PrimaryKeyGeneratorImpl
+ extends PortableRemoteObject
+ implements PrimaryKeyGenerator {
+
+ private static long i = System.currentTimeMillis();
+
+ public PrimaryKeyGeneratorImpl() throws Exception, RemoteException {
+ /*
+ * Since we extend PortableRemoteObject, the super
+ * class will export our remote object here.
+ */
+ super();
+ }
+
+ /**
+ * Generates a unique primary key
+ */
+ public synchronized long generate() throws RemoteException {
+ return i++;
+ }
+} \ No newline at end of file