summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java
downloadStudium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz
Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2
add new repoHEADmaster
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