From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../src/examples/jndi/PrimaryKeyGeneratorImpl.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/PrimaryKeyGeneratorImpl.java') 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 -- cgit v1.2.3