This is an automated email from the ASF dual-hosted git repository. jgallimore pushed a commit to branch tomee-1.7.x in repository https://gitbox.apache.org/repos/asf/tomee.git
commit cb9a12617983d56af1884a62991d7f153fe2e263 Author: Otavio Santana <[email protected]> AuthorDate: Mon Feb 25 12:21:03 2019 -0300 defines new Greeting --- examples/ejb-remote-call-2/pom.xml | 2 +- .../{DefaultCalculator.java => DefaultGreetings.java} | 15 ++++++++------- .../superbiz/remote/{Calculator.java => Greetings.java} | 8 ++++---- .../{BusinessException.java => GreetingsException.java} | 10 +++++----- .../src/main/webapp/WEB-INF/ejb-jar.xml | 10 +++++----- .../src/test/java/org/superbiz/remote/App.java | 16 ++++++++-------- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/examples/ejb-remote-call-2/pom.xml b/examples/ejb-remote-call-2/pom.xml index 60af4ba..1c31c59 100644 --- a/examples/ejb-remote-call-2/pom.xml +++ b/examples/ejb-remote-call-2/pom.xml @@ -23,7 +23,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.superbiz</groupId> - <artifactId>ejb-remote-call</artifactId> + <artifactId>ejb-remote-call-2</artifactId> <packaging>war</packaging> <version>8.0.0-SNAPSHOT</version> <name>OpenEJB :: Web Examples :: EJB Remote Call</name> diff --git a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultCalculator.java b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultGreetings.java similarity index 82% rename from examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultCalculator.java rename to examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultGreetings.java index 3a74aa5..50f6852 100644 --- a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultCalculator.java +++ b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/DefaultGreetings.java @@ -20,22 +20,23 @@ import javax.ejb.EJBException; import javax.ejb.SessionContext; import java.rmi.RemoteException; -public class DefaultCalculator implements Calculator { +public class DefaultGreetings implements Greetings { + @Override - public int sum(int add1, int add2) { - return add1 + add2; + public String morning(String name) { + return "Good Morning: " + name; } @Override - public int multiply(int mul1, int mul2) { - return mul1 * mul2; + public String afternoon(String name) { + return "Good Afternoon: " + name; } @Override - public String echo(final String input) throws BusinessException { + public String hello(final String input) throws GreetingsException { if ("CHECKED".equals(input)) { - throw new BusinessException("This is a checked exception"); + throw new GreetingsException("This is a checked exception"); } if ("RUNTIME".equals(input)) { diff --git a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Calculator.java b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Greetings.java similarity index 81% rename from examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Calculator.java rename to examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Greetings.java index aa10279..0e207c1 100644 --- a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Calculator.java +++ b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/Greetings.java @@ -16,12 +16,12 @@ */ package org.superbiz.remote; -public interface Calculator extends javax.ejb.SessionBean { +public interface Greetings extends javax.ejb.SessionBean { - int sum(int add1, int add2); + String morning(String name); - int multiply(int mul1, int mul2); + String afternoon(String name); - String echo(String input) throws BusinessException; + String hello(String input) throws GreetingsException; } diff --git a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/BusinessException.java b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/GreetingsException.java similarity index 79% rename from examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/BusinessException.java rename to examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/GreetingsException.java index 9257647..6a1813d 100644 --- a/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/BusinessException.java +++ b/examples/ejb-remote-call-2/src/main/java/org/superbiz/remote/GreetingsException.java @@ -16,20 +16,20 @@ */ package org.superbiz.remote; -public class BusinessException extends Exception { +public class GreetingsException extends Exception { - public BusinessException() { + public GreetingsException() { } - public BusinessException(String message) { + public GreetingsException(String message) { super(message); } - public BusinessException(String message, Throwable cause) { + public GreetingsException(String message, Throwable cause) { super(message, cause); } - public BusinessException(Throwable cause) { + public GreetingsException(Throwable cause) { super(cause); } } diff --git a/examples/ejb-remote-call-2/src/main/webapp/WEB-INF/ejb-jar.xml b/examples/ejb-remote-call-2/src/main/webapp/WEB-INF/ejb-jar.xml index 1b9a8ae..6151e7b 100644 --- a/examples/ejb-remote-call-2/src/main/webapp/WEB-INF/ejb-jar.xml +++ b/examples/ejb-remote-call-2/src/main/webapp/WEB-INF/ejb-jar.xml @@ -6,11 +6,11 @@ version="3.0"> <enterprise-beans> <session> - <ejb-name>Calculator</ejb-name> - <mapped-name>ejb/Calculator</mapped-name> - <business-local>org.superbiz.remote.Calculator</business-local> - <business-remote>org.superbiz.remote.Calculator</business-remote> - <ejb-class>org.superbiz.remote.DefaultCalculator</ejb-class> + <ejb-name>Greetings</ejb-name> + <mapped-name>ejb/Greetings</mapped-name> + <business-local>org.superbiz.remote.Greetings</business-local> + <business-remote>org.superbiz.remote.Greetings</business-remote> + <ejb-class>org.superbiz.remote.DefaultGreetings</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> diff --git a/examples/ejb-remote-call-2/src/test/java/org/superbiz/remote/App.java b/examples/ejb-remote-call-2/src/test/java/org/superbiz/remote/App.java index 9998237..4848608 100644 --- a/examples/ejb-remote-call-2/src/test/java/org/superbiz/remote/App.java +++ b/examples/ejb-remote-call-2/src/test/java/org/superbiz/remote/App.java @@ -23,28 +23,28 @@ import java.util.Properties; public class App { - public static void main(String[] args) throws NamingException, BusinessException { + public static void main(String[] args) throws NamingException, GreetingsException { Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); properties.put(Context.PROVIDER_URL, "http://localhost:8080/tomee/ejb"); Context ctx = new InitialContext(properties); - Object ref = ctx.lookup("global/ejb_remote_call_war/Calculator!org.superbiz.remote.Calculator"); + Object ref = ctx.lookup("global/ejb_remote_call_war/Greetings!org.superbiz.remote.Greetings"); - Calculator calculator = Calculator.class.cast(ref); - System.out.println(calculator.sum(1, 2)); + Greetings greetings = Greetings.class.cast(ref); + System.out.println(greetings.sum(1, 2)); - System.out.println("Expecting Hello world: " + calculator.echo("Hello world")); + System.out.println("Expecting Hello world: " + greetings.echo("Hello world")); try { System.out.println("Expecting checked exception: "); - System.out.println(calculator.echo("CHECKED")); - } catch (BusinessException e) { + System.out.println(greetings.echo("CHECKED")); + } catch (GreetingsException e) { e.printStackTrace(); } try { System.out.println("Expecting runtime exception: "); - System.out.println(calculator.echo("RUNTIME")); + System.out.println(greetings.echo("RUNTIME")); } catch (RuntimeException e) { e.printStackTrace(); }
