http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java ---------------------------------------------------------------------- diff --git a/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java b/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java index f3ab625..d79e272 100644 --- a/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java +++ b/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java @@ -1,92 +1,92 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.servlet; - -import javax.ejb.EJB; -import javax.ejb.EJBAccessException; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.security.Principal; - -public class SecureServlet extends HttpServlet { - - @EJB - private SecureEJBLocal secureEJBLocal; - - protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setContentType("text/plain"); - final ServletOutputStream out = response.getOutputStream(); - - out.println("Servlet"); - Principal principal = request.getUserPrincipal(); - if (principal != null) { - out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]"); - } else { - out.println("Servlet.getUserPrincipal()=<null>"); - } - out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user")); - out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager")); - out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake")); - out.println(); - - out.println("@EJB=" + secureEJBLocal); - if (secureEJBLocal != null) { - principal = secureEJBLocal.getCallerPrincipal(); - if (principal != null) { - out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]"); - } else { - out.println("@EJB.getCallerPrincipal()=<null>"); - } - out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user")); - out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager")); - out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake")); - - try { - secureEJBLocal.allowUserMethod(); - out.println("@EJB.allowUserMethod() ALLOWED"); - } catch (EJBAccessException e) { - out.println("@EJB.allowUserMethod() DENIED"); - } - - try { - secureEJBLocal.allowManagerMethod(); - out.println("@EJB.allowManagerMethod() ALLOWED"); - } catch (EJBAccessException e) { - out.println("@EJB.allowManagerMethod() DENIED"); - } - - try { - secureEJBLocal.allowFakeMethod(); - out.println("@EJB.allowFakeMethod() ALLOWED"); - } catch (final EJBAccessException e) { - out.println("@EJB.allowFakeMethod() DENIED"); - } - - try { - secureEJBLocal.denyAllMethod(); - out.println("@EJB.denyAllMethod() ALLOWED"); - } catch (EJBAccessException e) { - out.println("@EJB.denyAllMethod() DENIED"); - } - } - out.println(); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.servlet; + +import javax.ejb.EJB; +import javax.ejb.EJBAccessException; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.security.Principal; + +public class SecureServlet extends HttpServlet { + + @EJB + private SecureEJBLocal secureEJBLocal; + + protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/plain"); + final ServletOutputStream out = response.getOutputStream(); + + out.println("Servlet"); + Principal principal = request.getUserPrincipal(); + if (principal != null) { + out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]"); + } else { + out.println("Servlet.getUserPrincipal()=<null>"); + } + out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user")); + out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager")); + out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake")); + out.println(); + + out.println("@EJB=" + secureEJBLocal); + if (secureEJBLocal != null) { + principal = secureEJBLocal.getCallerPrincipal(); + if (principal != null) { + out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]"); + } else { + out.println("@EJB.getCallerPrincipal()=<null>"); + } + out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user")); + out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager")); + out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake")); + + try { + secureEJBLocal.allowUserMethod(); + out.println("@EJB.allowUserMethod() ALLOWED"); + } catch (EJBAccessException e) { + out.println("@EJB.allowUserMethod() DENIED"); + } + + try { + secureEJBLocal.allowManagerMethod(); + out.println("@EJB.allowManagerMethod() ALLOWED"); + } catch (EJBAccessException e) { + out.println("@EJB.allowManagerMethod() DENIED"); + } + + try { + secureEJBLocal.allowFakeMethod(); + out.println("@EJB.allowFakeMethod() ALLOWED"); + } catch (final EJBAccessException e) { + out.println("@EJB.allowFakeMethod() DENIED"); + } + + try { + secureEJBLocal.denyAllMethod(); + out.println("@EJB.denyAllMethod() ALLOWED"); + } catch (EJBAccessException e) { + out.println("@EJB.denyAllMethod() DENIED"); + } + } + out.println(); + } +}
http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java ---------------------------------------------------------------------- diff --git a/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java b/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java index c098ca8..533540c 100644 --- a/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java +++ b/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java @@ -1,37 +1,37 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.servlet; - -import javax.xml.ws.handler.Handler; -import javax.xml.ws.handler.MessageContext; - -public class ServerHandler implements Handler { - - public boolean handleMessage(MessageContext messageContext) { - WebserviceServlet.write(" ServerHandler handleMessage"); - return true; - } - - public void close(MessageContext messageContext) { - WebserviceServlet.write(" ServerHandler close"); - } - - public boolean handleFault(MessageContext messageContext) { - WebserviceServlet.write(" ServerHandler handleFault"); - return true; - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.servlet; + +import javax.xml.ws.handler.Handler; +import javax.xml.ws.handler.MessageContext; + +public class ServerHandler implements Handler { + + public boolean handleMessage(MessageContext messageContext) { + WebserviceServlet.write(" ServerHandler handleMessage"); + return true; + } + + public void close(MessageContext messageContext) { + WebserviceServlet.write(" ServerHandler close"); + } + + public boolean handleFault(MessageContext messageContext) { + WebserviceServlet.write(" ServerHandler handleFault"); + return true; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java ---------------------------------------------------------------------- diff --git a/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java b/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java index ea31abb..1ce9900 100644 --- a/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java +++ b/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java @@ -1,79 +1,79 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.servlet; - -import javax.xml.ws.Service; -import java.io.PrintStream; -import java.net.URL; - -public class WebserviceClient { - - /** - * Unfortunately, to run this example with CXF you need to have a HUGE class path. This - * is just what is required to run CXF: - * <p/> - * jaxb-api-2.0.jar - * jaxb-impl-2.0.3.jar - * <p/> - * saaj-api-1.3.jar - * saaj-impl-1.3.jar - * <p/> - * <p/> - * cxf-api-2.0.2-incubator.jar - * cxf-common-utilities-2.0.2-incubator.jar - * cxf-rt-bindings-soap-2.0.2-incubator.jar - * cxf-rt-core-2.0.2-incubator.jar - * cxf-rt-databinding-jaxb-2.0.2-incubator.jar - * cxf-rt-frontend-jaxws-2.0.2-incubator.jar - * cxf-rt-frontend-simple-2.0.2-incubator.jar - * cxf-rt-transports-http-jetty-2.0.2-incubator.jar - * cxf-rt-transports-http-2.0.2-incubator.jar - * cxf-tools-common-2.0.2-incubator.jar - * <p/> - * geronimo-activation_1.1_spec-1.0.jar - * geronimo-annotation_1.0_spec-1.1.jar - * geronimo-ejb_3.0_spec-1.0.jar - * geronimo-jpa_3.0_spec-1.1.jar - * geronimo-servlet_2.5_spec-1.1.jar - * geronimo-stax-api_1.0_spec-1.0.jar - * jaxws-api-2.0.jar - * axis2-jws-api-1.3.jar - * <p/> - * wsdl4j-1.6.1.jar - * xml-resolver-1.2.jar - * XmlSchema-1.3.1.jar - */ - public static void main(String[] args) throws Exception { - PrintStream out = System.out; - - Service helloPojoService = Service.create(new URL("http://localhost:8080/ejb-examples/hello?wsdl"), null); - HelloPojo helloPojo = helloPojoService.getPort(HelloPojo.class); - out.println(); - out.println("Pojo Webservice"); - out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob")); - out.println(" helloPojo.hello(null)=" + helloPojo.hello(null)); - out.println(); - - Service helloEjbService = Service.create(new URL("http://localhost:8080/HelloEjbService?wsdl"), null); - HelloEjb helloEjb = helloEjbService.getPort(HelloEjb.class); - out.println(); - out.println("EJB Webservice"); - out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob")); - out.println(" helloEjb.hello(null)=" + helloEjb.hello(null)); - out.println(); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.servlet; + +import javax.xml.ws.Service; +import java.io.PrintStream; +import java.net.URL; + +public class WebserviceClient { + + /** + * Unfortunately, to run this example with CXF you need to have a HUGE class path. This + * is just what is required to run CXF: + * <p/> + * jaxb-api-2.0.jar + * jaxb-impl-2.0.3.jar + * <p/> + * saaj-api-1.3.jar + * saaj-impl-1.3.jar + * <p/> + * <p/> + * cxf-api-2.0.2-incubator.jar + * cxf-common-utilities-2.0.2-incubator.jar + * cxf-rt-bindings-soap-2.0.2-incubator.jar + * cxf-rt-core-2.0.2-incubator.jar + * cxf-rt-databinding-jaxb-2.0.2-incubator.jar + * cxf-rt-frontend-jaxws-2.0.2-incubator.jar + * cxf-rt-frontend-simple-2.0.2-incubator.jar + * cxf-rt-transports-http-jetty-2.0.2-incubator.jar + * cxf-rt-transports-http-2.0.2-incubator.jar + * cxf-tools-common-2.0.2-incubator.jar + * <p/> + * geronimo-activation_1.1_spec-1.0.jar + * geronimo-annotation_1.0_spec-1.1.jar + * geronimo-ejb_3.0_spec-1.0.jar + * geronimo-jpa_3.0_spec-1.1.jar + * geronimo-servlet_2.5_spec-1.1.jar + * geronimo-stax-api_1.0_spec-1.0.jar + * jaxws-api-2.0.jar + * axis2-jws-api-1.3.jar + * <p/> + * wsdl4j-1.6.1.jar + * xml-resolver-1.2.jar + * XmlSchema-1.3.1.jar + */ + public static void main(String[] args) throws Exception { + PrintStream out = System.out; + + Service helloPojoService = Service.create(new URL("http://localhost:8080/ejb-examples/hello?wsdl"), null); + HelloPojo helloPojo = helloPojoService.getPort(HelloPojo.class); + out.println(); + out.println("Pojo Webservice"); + out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob")); + out.println(" helloPojo.hello(null)=" + helloPojo.hello(null)); + out.println(); + + Service helloEjbService = Service.create(new URL("http://localhost:8080/HelloEjbService?wsdl"), null); + HelloEjb helloEjb = helloEjbService.getPort(HelloEjb.class); + out.println(); + out.println("EJB Webservice"); + out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob")); + out.println(" helloEjb.hello(null)=" + helloEjb.hello(null)); + out.println(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java ---------------------------------------------------------------------- diff --git a/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java b/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java index 9eaeeab..0050725 100644 --- a/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java +++ b/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java @@ -1,69 +1,69 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.servlet; - -import javax.jws.HandlerChain; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.ws.WebServiceRef; -import java.io.IOException; - -public class WebserviceServlet extends HttpServlet { - - @WebServiceRef - @HandlerChain(file = "client-handlers.xml") - private HelloPojo helloPojo; - - @WebServiceRef - @HandlerChain(file = "client-handlers.xml") - private HelloEjb helloEjb; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setContentType("text/plain"); - ServletOutputStream out = response.getOutputStream(); - - OUT = out; - try { - out.println("Pojo Webservice"); - out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob")); - out.println(); - out.println(" helloPojo.hello(null)=" + helloPojo.hello(null)); - out.println(); - out.println("EJB Webservice"); - out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob")); - out.println(); - out.println(" helloEjb.hello(null)=" + helloEjb.hello(null)); - out.println(); - } finally { - OUT = out; - } - } - - private static ServletOutputStream OUT; - - public static void write(String message) { - try { - ServletOutputStream out = OUT; - out.println(message); - } catch (Exception e) { - e.printStackTrace(); - } - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.servlet; + +import javax.jws.HandlerChain; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.ws.WebServiceRef; +import java.io.IOException; + +public class WebserviceServlet extends HttpServlet { + + @WebServiceRef + @HandlerChain(file = "client-handlers.xml") + private HelloPojo helloPojo; + + @WebServiceRef + @HandlerChain(file = "client-handlers.xml") + private HelloEjb helloEjb; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/plain"); + ServletOutputStream out = response.getOutputStream(); + + OUT = out; + try { + out.println("Pojo Webservice"); + out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob")); + out.println(); + out.println(" helloPojo.hello(null)=" + helloPojo.hello(null)); + out.println(); + out.println("EJB Webservice"); + out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob")); + out.println(); + out.println(" helloEjb.hello(null)=" + helloEjb.hello(null)); + out.println(); + } finally { + OUT = out; + } + } + + private static ServletOutputStream OUT; + + public static void write(String message) { + try { + ServletOutputStream out = OUT; + out.println(message); + } catch (Exception e) { + e.printStackTrace(); + } + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java ---------------------------------------------------------------------- diff --git a/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java b/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java index ac1e584..84ebc0c 100644 --- a/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java +++ b/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java @@ -1,37 +1,37 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.ws; - -import javax.ejb.Stateless; -import javax.jws.WebService; - -@Stateless -@WebService(portName = "CalculatorPort", - serviceName = "CalculatorWebService", - targetNamespace = "http://superbiz.org/wsdl") -public class Calculator { - - public int sum(int add1, int add2) { - return add1 + add2; - } - - public int multiply(int mul1, int mul2) { - return mul1 * mul2; - } - -} - +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.ws; + +import javax.ejb.Stateless; +import javax.jws.WebService; + +@Stateless +@WebService(portName = "CalculatorPort", + serviceName = "CalculatorWebService", + targetNamespace = "http://superbiz.org/wsdl") +public class Calculator { + + public int sum(int add1, int add2) { + return add1 + add2; + } + + public int multiply(int mul1, int mul2) { + return mul1 * mul2; + } + +} + http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java ---------------------------------------------------------------------- diff --git a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java index 1688f2a..17deafb 100644 --- a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java +++ b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java @@ -1,33 +1,33 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.hello; - -import javax.ejb.LocalHome; -import javax.ejb.Stateless; - -/** - * @version $Revision$ $Date$ - */ -@Stateless -@LocalHome(HelloEjbLocalHome.class) -public class HelloBean { - - public String sayHello() { - return "Hello, World!"; - } - -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.hello; + +import javax.ejb.LocalHome; +import javax.ejb.Stateless; + +/** + * @version $Revision$ $Date$ + */ +@Stateless +@LocalHome(HelloEjbLocalHome.class) +public class HelloBean { + + public String sayHello() { + return "Hello, World!"; + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java ---------------------------------------------------------------------- diff --git a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java index c8d3443..d8e12bc 100644 --- a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java +++ b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java @@ -1,28 +1,28 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.hello; - -import javax.ejb.EJBLocalObject; - -/** - * @version $Revision$ $Date$ - */ -public interface HelloEjbLocal extends EJBLocalObject { - - String sayHello(); - -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.hello; + +import javax.ejb.EJBLocalObject; + +/** + * @version $Revision$ $Date$ + */ +public interface HelloEjbLocal extends EJBLocalObject { + + String sayHello(); + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java ---------------------------------------------------------------------- diff --git a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java index a9b6db1..f448a89 100644 --- a/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java +++ b/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java @@ -1,28 +1,28 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.hello; - -import javax.ejb.CreateException; -import javax.ejb.EJBLocalHome; - -/** - * @version $Revision$ $Date$ - */ -public interface HelloEjbLocalHome extends EJBLocalHome { - - HelloEjbLocal create() throws CreateException; -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.hello; + +import javax.ejb.CreateException; +import javax.ejb.EJBLocalHome; + +/** + * @version $Revision$ $Date$ + */ +public interface HelloEjbLocalHome extends EJBLocalHome { + + HelloEjbLocal create() throws CreateException; +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java ---------------------------------------------------------------------- diff --git a/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java b/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java index 7be57dc..d2b4685 100644 --- a/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java +++ b/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java @@ -1,42 +1,42 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.hello; - -import junit.framework.TestCase; - -import javax.naming.Context; -import javax.naming.InitialContext; -import java.util.Properties; - -/** - * @version $Revision$ $Date$ - */ -public class HelloTest extends TestCase { - - public void test() throws Exception { - Properties properties = new Properties(); - properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory"); - InitialContext initialContext = new InitialContext(properties); - - HelloEjbLocalHome localHome = (HelloEjbLocalHome) initialContext.lookup("MyHello"); - HelloEjbLocal helloEjb = localHome.create(); - - String message = helloEjb.sayHello(); - - assertEquals(message, "Hello, World!"); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.hello; + +import junit.framework.TestCase; + +import javax.naming.Context; +import javax.naming.InitialContext; +import java.util.Properties; + +/** + * @version $Revision$ $Date$ + */ +public class HelloTest extends TestCase { + + public void test() throws Exception { + Properties properties = new Properties(); + properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory"); + InitialContext initialContext = new InitialContext(properties); + + HelloEjbLocalHome localHome = (HelloEjbLocalHome) initialContext.lookup("MyHello"); + HelloEjbLocal helloEjb = localHome.create(); + + String message = helloEjb.sayHello(); + + assertEquals(message, "Hello, World!"); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java b/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java index 148f449..d28dfd5 100644 --- a/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java +++ b/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java @@ -1,106 +1,106 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -//START SNIPPET: code -package org.superbiz.injection.jms; - -import javax.annotation.Resource; -import javax.ejb.Stateless; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; - -@Stateless -public class Messages { - - @Resource - private ConnectionFactory connectionFactory; - - @Resource - private Queue chatQueue; - - public void sendMessage(String text) throws JMSException { - - Connection connection = null; - Session session = null; - - try { - connection = connectionFactory.createConnection(); - connection.start(); - - // Create a Session - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Create a MessageProducer from the Session to the Topic or Queue - MessageProducer producer = session.createProducer(chatQueue); - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - - // Create a message - TextMessage message = session.createTextMessage(text); - - // Tell the producer to send the message - producer.send(message); - } finally { - // Clean up - if (session != null) { - session.close(); - } - if (connection != null) { - connection.close(); - } - } - } - - public String receiveMessage() throws JMSException { - - Connection connection = null; - Session session = null; - MessageConsumer consumer = null; - try { - connection = connectionFactory.createConnection(); - connection.start(); - - // Create a Session - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Create a MessageConsumer from the Session to the Topic or Queue - consumer = session.createConsumer(chatQueue); - - // Wait for a message - TextMessage message = (TextMessage) consumer.receive(1000); - - return message.getText(); - } finally { - if (consumer != null) { - consumer.close(); - } - if (session != null) { - session.close(); - } - if (connection != null) { - connection.close(); - } - } - - } -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//START SNIPPET: code +package org.superbiz.injection.jms; + +import javax.annotation.Resource; +import javax.ejb.Stateless; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; + +@Stateless +public class Messages { + + @Resource + private ConnectionFactory connectionFactory; + + @Resource + private Queue chatQueue; + + public void sendMessage(String text) throws JMSException { + + Connection connection = null; + Session session = null; + + try { + connection = connectionFactory.createConnection(); + connection.start(); + + // Create a Session + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + // Create a MessageProducer from the Session to the Topic or Queue + MessageProducer producer = session.createProducer(chatQueue); + producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); + + // Create a message + TextMessage message = session.createTextMessage(text); + + // Tell the producer to send the message + producer.send(message); + } finally { + // Clean up + if (session != null) { + session.close(); + } + if (connection != null) { + connection.close(); + } + } + } + + public String receiveMessage() throws JMSException { + + Connection connection = null; + Session session = null; + MessageConsumer consumer = null; + try { + connection = connectionFactory.createConnection(); + connection.start(); + + // Create a Session + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + // Create a MessageConsumer from the Session to the Topic or Queue + consumer = session.createConsumer(chatQueue); + + // Wait for a message + TextMessage message = (TextMessage) consumer.receive(1000); + + return message.getText(); + } finally { + if (consumer != null) { + consumer.close(); + } + if (session != null) { + session.close(); + } + if (connection != null) { + connection.close(); + } + } + + } +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java b/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java index 9767b4d..eb2abc7 100644 --- a/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java +++ b/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java @@ -1,42 +1,42 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -//START SNIPPET: code -package org.superbiz.injection.jms; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -public class MessagingBeanTest extends TestCase { - - public void test() throws Exception { - - final Context context = EJBContainer.createEJBContainer().getContext(); - - Messages messages = (Messages) context.lookup("java:global/injection-of-connectionfactory/Messages"); - - messages.sendMessage("Hello World!"); - messages.sendMessage("How are you?"); - messages.sendMessage("Still spinning?"); - - assertEquals(messages.receiveMessage(), "Hello World!"); - assertEquals(messages.receiveMessage(), "How are you?"); - assertEquals(messages.receiveMessage(), "Still spinning?"); - } -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//START SNIPPET: code +package org.superbiz.injection.jms; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; + +public class MessagingBeanTest extends TestCase { + + public void test() throws Exception { + + final Context context = EJBContainer.createEJBContainer().getContext(); + + Messages messages = (Messages) context.lookup("java:global/injection-of-connectionfactory/Messages"); + + messages.sendMessage("Hello World!"); + messages.sendMessage("How are you?"); + messages.sendMessage("Still spinning?"); + + assertEquals(messages.receiveMessage(), "Hello World!"); + assertEquals(messages.receiveMessage(), "How are you?"); + assertEquals(messages.receiveMessage(), "Still spinning?"); + } +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java b/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java index b9961ef..a5924b9 100644 --- a/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java +++ b/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java @@ -1,61 +1,61 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -/** - * @version $Revision$ $Date$ - */ -public class Movie { - - private String director; - private String title; - private int year; - - public Movie() { - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +/** + * @version $Revision$ $Date$ + */ +public class Movie { + + private String director; + private String title; + private int year; + + public Movie() { + } + + public Movie(String director, String title, int year) { + this.director = director; + this.title = title; + this.year = year; + } + + public String getDirector() { + return director; + } + + public void setDirector(String director) { + this.director = director; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java b/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java index 7a9136b..17822f5 100644 --- a/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java +++ b/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java @@ -1,106 +1,106 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -//START SNIPPET: code -package org.superbiz.injection; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.ejb.Stateful; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; - -@Stateful -public class Movies { - - /** - * The field name "movieDatabase" matches the DataSource we - * configure in the TestCase via : - * p.put("movieDatabase", "new://Resource?type=DataSource"); - * <p/> - * This would also match an equivalent delcaration in an openejb.xml: - * <Resource id="movieDatabase" type="DataSource"/> - * <p/> - * If you'd like the freedom to change the field name without - * impact on your configuration you can set the "name" attribute - * of the @Resource annotation to "movieDatabase" instead. - */ - @Resource - private DataSource movieDatabase; - - @PostConstruct - private void construct() throws Exception { - Connection connection = movieDatabase.getConnection(); - try { - PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)"); - stmt.execute(); - } finally { - connection.close(); - } - } - - public void addMovie(Movie movie) throws Exception { - Connection conn = movieDatabase.getConnection(); - try { - PreparedStatement sql = conn.prepareStatement("INSERT into movie (director, title, year) values (?, ?, ?)"); - sql.setString(1, movie.getDirector()); - sql.setString(2, movie.getTitle()); - sql.setInt(3, movie.getYear()); - sql.execute(); - } finally { - conn.close(); - } - } - - public void deleteMovie(Movie movie) throws Exception { - Connection conn = movieDatabase.getConnection(); - try { - PreparedStatement sql = conn.prepareStatement("DELETE from movie where director = ? AND title = ? AND year = ?"); - sql.setString(1, movie.getDirector()); - sql.setString(2, movie.getTitle()); - sql.setInt(3, movie.getYear()); - sql.execute(); - } finally { - conn.close(); - } - } - - public List<Movie> getMovies() throws Exception { - ArrayList<Movie> movies = new ArrayList<Movie>(); - Connection conn = movieDatabase.getConnection(); - try { - PreparedStatement sql = conn.prepareStatement("SELECT director, title, year from movie"); - ResultSet set = sql.executeQuery(); - while (set.next()) { - Movie movie = new Movie(); - movie.setDirector(set.getString("director")); - movie.setTitle(set.getString("title")); - movie.setYear(set.getInt("year")); - movies.add(movie); - } - - } finally { - conn.close(); - } - return movies; - } - -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//START SNIPPET: code +package org.superbiz.injection; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import javax.ejb.Stateful; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +@Stateful +public class Movies { + + /** + * The field name "movieDatabase" matches the DataSource we + * configure in the TestCase via : + * p.put("movieDatabase", "new://Resource?type=DataSource"); + * <p/> + * This would also match an equivalent delcaration in an openejb.xml: + * <Resource id="movieDatabase" type="DataSource"/> + * <p/> + * If you'd like the freedom to change the field name without + * impact on your configuration you can set the "name" attribute + * of the @Resource annotation to "movieDatabase" instead. + */ + @Resource + private DataSource movieDatabase; + + @PostConstruct + private void construct() throws Exception { + Connection connection = movieDatabase.getConnection(); + try { + PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)"); + stmt.execute(); + } finally { + connection.close(); + } + } + + public void addMovie(Movie movie) throws Exception { + Connection conn = movieDatabase.getConnection(); + try { + PreparedStatement sql = conn.prepareStatement("INSERT into movie (director, title, year) values (?, ?, ?)"); + sql.setString(1, movie.getDirector()); + sql.setString(2, movie.getTitle()); + sql.setInt(3, movie.getYear()); + sql.execute(); + } finally { + conn.close(); + } + } + + public void deleteMovie(Movie movie) throws Exception { + Connection conn = movieDatabase.getConnection(); + try { + PreparedStatement sql = conn.prepareStatement("DELETE from movie where director = ? AND title = ? AND year = ?"); + sql.setString(1, movie.getDirector()); + sql.setString(2, movie.getTitle()); + sql.setInt(3, movie.getYear()); + sql.execute(); + } finally { + conn.close(); + } + } + + public List<Movie> getMovies() throws Exception { + ArrayList<Movie> movies = new ArrayList<Movie>(); + Connection conn = movieDatabase.getConnection(); + try { + PreparedStatement sql = conn.prepareStatement("SELECT director, title, year from movie"); + ResultSet set = sql.executeQuery(); + while (set.next()) { + Movie movie = new Movie(); + movie.setDirector(set.getString("director")); + movie.setTitle(set.getString("title")); + movie.setYear(set.getInt("year")); + movies.add(movie); + } + + } finally { + conn.close(); + } + return movies; + } + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java b/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java index 6c41f19..4ab7fcd 100644 --- a/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java +++ b/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java @@ -1,54 +1,54 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; -import java.util.List; -import java.util.Properties; - -//START SNIPPET: code -public class MoviesTest extends TestCase { - - public void test() throws Exception { - - Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - Context context = EJBContainer.createEJBContainer(p).getContext(); - - Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies"); - - movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); - movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); - movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); - - List<Movie> list = movies.getMovies(); - assertEquals("List.size()", 3, list.size()); - - for (Movie movie : list) { - movies.deleteMovie(movie); - } - - assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); - } -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; +import java.util.List; +import java.util.Properties; + +//START SNIPPET: code +public class MoviesTest extends TestCase { + + public void test() throws Exception { + + Properties p = new Properties(); + p.put("movieDatabase", "new://Resource?type=DataSource"); + p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); + p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); + + Context context = EJBContainer.createEJBContainer(p).getContext(); + + Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies"); + + movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); + movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); + movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); + + List<Movie> list = movies.getMovies(); + assertEquals("List.size()", 3, list.size()); + + for (Movie movie : list) { + movies.deleteMovie(movie); + } + + assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); + } +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java index 9b98efc..7a8d9be 100644 --- a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java +++ b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java @@ -1,60 +1,60 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import javax.ejb.EJB; -import javax.ejb.Stateless; - -/** - * This is an EJB 3.1 style pojo stateless session bean - * Every stateless session bean implementation must be annotated - * using the annotation @Stateless - * This EJB has 2 business interfaces: DataReaderRemote, a remote business - * interface, and DataReaderLocal, a local business interface - * <p/> - * The instance variables 'dataStoreRemote' is annotated with the @EJB annotation: - * this means that the application server, at runtime, will inject in this instance - * variable a reference to the EJB DataStoreRemote - * <p/> - * The instance variables 'dataStoreLocal' is annotated with the @EJB annotation: - * this means that the application server, at runtime, will inject in this instance - * variable a reference to the EJB DataStoreLocal - */ -//START SNIPPET: code -@Stateless -public class DataReader { - - @EJB - private DataStoreRemote dataStoreRemote; - @EJB - private DataStoreLocal dataStoreLocal; - @EJB - private DataStore dataStore; - - public String readDataFromLocalStore() { - return "LOCAL:" + dataStoreLocal.getData(); - } - - public String readDataFromLocalBeanStore() { - return "LOCALBEAN:" + dataStore.getData(); - } - - public String readDataFromRemoteStore() { - return "REMOTE:" + dataStoreRemote.getData(); - } -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import javax.ejb.EJB; +import javax.ejb.Stateless; + +/** + * This is an EJB 3.1 style pojo stateless session bean + * Every stateless session bean implementation must be annotated + * using the annotation @Stateless + * This EJB has 2 business interfaces: DataReaderRemote, a remote business + * interface, and DataReaderLocal, a local business interface + * <p/> + * The instance variables 'dataStoreRemote' is annotated with the @EJB annotation: + * this means that the application server, at runtime, will inject in this instance + * variable a reference to the EJB DataStoreRemote + * <p/> + * The instance variables 'dataStoreLocal' is annotated with the @EJB annotation: + * this means that the application server, at runtime, will inject in this instance + * variable a reference to the EJB DataStoreLocal + */ +//START SNIPPET: code +@Stateless +public class DataReader { + + @EJB + private DataStoreRemote dataStoreRemote; + @EJB + private DataStoreLocal dataStoreLocal; + @EJB + private DataStore dataStore; + + public String readDataFromLocalStore() { + return "LOCAL:" + dataStoreLocal.getData(); + } + + public String readDataFromLocalBeanStore() { + return "LOCALBEAN:" + dataStore.getData(); + } + + public String readDataFromRemoteStore() { + return "REMOTE:" + dataStoreRemote.getData(); + } +} //END SNIPPET: code \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java index 0bd8b07..a2edf61 100644 --- a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java +++ b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java @@ -1,39 +1,39 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import javax.ejb.LocalBean; -import javax.ejb.Stateless; - -/** - * This is an EJB 3 style pojo stateless session bean - * Every stateless session bean implementation must be annotated - * using the annotation @Stateless - * This EJB has 2 business interfaces: DataStoreRemote, a remote business - * interface, and DataStoreLocal, a local business interface - */ -//START SNIPPET: code -@Stateless -@LocalBean -public class DataStore implements DataStoreLocal, DataStoreRemote { - - public String getData() { - return "42"; - } - -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import javax.ejb.LocalBean; +import javax.ejb.Stateless; + +/** + * This is an EJB 3 style pojo stateless session bean + * Every stateless session bean implementation must be annotated + * using the annotation @Stateless + * This EJB has 2 business interfaces: DataStoreRemote, a remote business + * interface, and DataStoreLocal, a local business interface + */ +//START SNIPPET: code +@Stateless +@LocalBean +public class DataStore implements DataStoreLocal, DataStoreRemote { + + public String getData() { + return "42"; + } + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java index 477ee6e..ca881bf 100644 --- a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java +++ b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java @@ -1,34 +1,34 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import javax.ejb.Local; - -/** - * This is an EJB 3 local business interface - * A local business interface may be annotated with the @Local - * annotation, but it's optional. A business interface which is - * not annotated with @Local or @Remote is assumed to be Local - */ -//START SNIPPET: code -@Local -public interface DataStoreLocal { - - public String getData(); - -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import javax.ejb.Local; + +/** + * This is an EJB 3 local business interface + * A local business interface may be annotated with the @Local + * annotation, but it's optional. A business interface which is + * not annotated with @Local or @Remote is assumed to be Local + */ +//START SNIPPET: code +@Local +public interface DataStoreLocal { + + public String getData(); + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java index 7d30a2d..eaf8b7a 100644 --- a/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java +++ b/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java @@ -1,33 +1,33 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import javax.ejb.Remote; - -/** - * This is an EJB 3 remote business interface - * A remote business interface must be annotated with the @Remote - * annotation - */ -//START SNIPPET: code -@Remote -public interface DataStoreRemote { - - public String getData(); - -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import javax.ejb.Remote; + +/** + * This is an EJB 3 remote business interface + * A remote business interface must be annotated with the @Remote + * annotation + */ +//START SNIPPET: code +@Remote +public interface DataStoreRemote { + + public String getData(); + +} +//END SNIPPET: code http://git-wip-us.apache.org/repos/asf/tomee/blob/6e2a4f7c/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java ---------------------------------------------------------------------- diff --git a/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java b/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java index 7c199f2..28ef670 100644 --- a/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java +++ b/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java @@ -1,42 +1,42 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.superbiz.injection; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -/** - * A test case for DataReaderImpl ejb, testing both the remote and local interface - */ -//START SNIPPET: code -public class EjbDependencyTest extends TestCase { - - public void test() throws Exception { - final Context context = EJBContainer.createEJBContainer().getContext(); - - DataReader dataReader = (DataReader) context.lookup("java:global/injection-of-ejbs/DataReader"); - - assertNotNull(dataReader); - - assertEquals("LOCAL:42", dataReader.readDataFromLocalStore()); - assertEquals("REMOTE:42", dataReader.readDataFromRemoteStore()); - assertEquals("LOCALBEAN:42", dataReader.readDataFromLocalBeanStore()); - } -} -//END SNIPPET: code +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.superbiz.injection; + +import junit.framework.TestCase; + +import javax.ejb.embeddable.EJBContainer; +import javax.naming.Context; + +/** + * A test case for DataReaderImpl ejb, testing both the remote and local interface + */ +//START SNIPPET: code +public class EjbDependencyTest extends TestCase { + + public void test() throws Exception { + final Context context = EJBContainer.createEJBContainer().getContext(); + + DataReader dataReader = (DataReader) context.lookup("java:global/injection-of-ejbs/DataReader"); + + assertNotNull(dataReader); + + assertEquals("LOCAL:42", dataReader.readDataFromLocalStore()); + assertEquals("REMOTE:42", dataReader.readDataFromRemoteStore()); + assertEquals("LOCALBEAN:42", dataReader.readDataFromLocalBeanStore()); + } +} +//END SNIPPET: code