diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
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.java | 29 |
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 |
