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/session/stateless/Hello.java | 13 ++++++++ .../src/examples/session/stateless/HelloBean.java | 16 ++++++++++ .../examples/session/stateless/HelloClient.java | 35 ++++++++++++++++++++++ .../session/stateless/META-INF/ejb-jar.xml | 5 ++++ .../src/examples/session/stateless/build.xml | 32 ++++++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/Hello.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloBean.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/META-INF/ejb-jar.xml create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/build.xml (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless') diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/Hello.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/Hello.java new file mode 100644 index 0000000..fa4648b --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/Hello.java @@ -0,0 +1,13 @@ +package examples.session.stateless; + +/** + * This is the Hello business interface. + */ + +public interface Hello { + + /** + * @return a greeting to the client. + */ + public String hello(); +} diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloBean.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloBean.java new file mode 100644 index 0000000..10e6baf --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloBean.java @@ -0,0 +1,16 @@ +package examples.session.stateless; + +import javax.ejb.Remote; +import javax.ejb.Stateless; + +/** + * Demonstration stateless session bean. + */ +@Stateless +@Remote(Hello.class) +public class HelloBean implements Hello { + public String hello() { + System.out.println("hello()"); + return "Hello, World!"; + } +} diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java new file mode 100644 index 0000000..29ebd03 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/HelloClient.java @@ -0,0 +1,35 @@ +package examples.session.stateless; + +import javax.naming.Context; +import javax.naming.InitialContext; + +/** + * This class is an example of client code which invokes + * methods on a simple, remote stateless session bean. + */ +public class HelloClient { + + public static void main(String[] args) throws Exception { + /* + * Obtain the JNDI initial context. + * + * The initial context is a starting point for + * connecting to a JNDI tree. We choose our JNDI + * driver, the network location of the server, etc + * by passing in the environment properties. + */ + Context ctx = new InitialContext(System.getProperties()); + + /* + * Get a reference to a bean instance, looked up by class name + */ + Hello hello = (Hello) ctx.lookup(Hello.class.getName()); + + /* + * Call the hello() method on the bean. + * We then print the result to the screen. + */ + System.out.println(hello.hello()); + + } +} diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/META-INF/ejb-jar.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/META-INF/ejb-jar.xml new file mode 100644 index 0000000..9503e74 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/META-INF/ejb-jar.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/build.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/build.xml new file mode 100644 index 0000000..33b4751 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/session/stateless/build.xml @@ -0,0 +1,32 @@ + + ]> + + + + + + + + + + + + + + + + + &include; + + + + + + + + + + + + -- cgit v1.2.3