From commits-return-44873-archive-asf-public=cust-asf.ponee.io@tomee.apache.org Sat Dec 8 02:33:45 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C2BA018067E for ; Sat, 8 Dec 2018 02:33:43 +0100 (CET) Received: (qmail 45094 invoked by uid 500); 8 Dec 2018 01:33:42 -0000 Mailing-List: contact commits-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tomee.apache.org Delivered-To: mailing list commits@tomee.apache.org Received: (qmail 45073 invoked by uid 99); 8 Dec 2018 01:33:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Dec 2018 01:33:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 263DDE13AB; Sat, 8 Dec 2018 01:33:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dblevins@apache.org To: commits@tomee.apache.org Date: Sat, 08 Dec 2018 01:33:43 -0000 Message-Id: <9cee348fd88f4a37ab5d943dbcca4ac3@git.apache.org> In-Reply-To: <4630d3903bcb44dab73da6ec48b43af2@git.apache.org> References: <4630d3903bcb44dab73da6ec48b43af2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] tomee git commit: Update codeblock style so we have syntax highlighting http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/dynamic-datasource.adoc ---------------------------------------------------------------------- diff --git a/docs/dynamic-datasource.adoc b/docs/dynamic-datasource.adoc index 95bf338..eee4ff7 100644 --- a/docs/dynamic-datasource.adoc +++ b/docs/dynamic-datasource.adoc @@ -19,9 +19,10 @@ functionnal reasons (filtering, aggregation, enriching...). The interface Router (_org.apache.openejb.resource.jdbc.Router_) have only one method to get the datasource to use: -.... +[source,java] +---- Router.getDataSource() -.... +---- The _org.apache.openejb.resource.jdbc.RoutedDataSource_ wraps a classical data source. It has to be used to declare your datasource. @@ -61,7 +62,8 @@ to set to choose the real database to use between three. So in your code you want something like: -.... +[source,java] +---- public class RoutedEJBBean { @PersistenceContext(unitName = "router") private EntityManager em; @@ -76,14 +78,15 @@ public class RoutedEJBBean { em.persist(new Person(id, name)); } } -.... +---- == The router implementation The router will simply manage a map to store proxied datasources and a field to store the datasource used in the current thread (ThreadLocal). -.... +[source,java] +---- public class DeterminedRouter implements Router { private String dataSourceNames; // used to store configuration (openejb.xml) private String defaultDataSourceName; // defautl data source name @@ -161,7 +164,7 @@ public class DeterminedRouter implements Router { this.defaultDataSourceName = name; } } -.... +---- == Creation of the service provider for the router @@ -170,7 +173,8 @@ META-INF/. For example META-INF/org.router. This file will contain something like: -.... +[source,java] +---- @@ -178,14 +182,15 @@ This file will contain something like: ParamWithNoDefaultValue -.... +---- == openejb.xml In the openejb.xml file, you have to declare your dynamic database and in our example it needs the proxied datasources too: -.... +[source,java] +---- Param value @@ -216,4 +221,4 @@ in our example it needs the proxied datasources too: Password JtaManaged true -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejb-local-ref.adoc ---------------------------------------------------------------------- diff --git a/docs/ejb-local-ref.adoc b/docs/ejb-local-ref.adoc index a7787c6..0dabe90 100644 --- a/docs/ejb-local-ref.adoc +++ b/docs/ejb-local-ref.adoc @@ -8,7 +8,8 @@ Usable by EJB, Interceptor, Servlet, Filter, or Listener -.... +[source,java] +---- package org.superbiz.refs; import javax.ejb.EJB; @@ -31,13 +32,14 @@ public class MyEjbLocalRefBean implements MyBeanInterface { BarLocal barLocal = (BarLocal) context.lookup("java:comp/env/org.superbiz.refs.MyEjbLocalRefBean/myBarEjb"); } } -.... +---- # Via xml The above @EJB annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- myFooEjb org.superbiz.refs.FooLocal @@ -51,4 +53,4 @@ The above @EJB annotation usage is 100% equivalent to the following xml. myBarEjb -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejb-over-ssl.adoc ---------------------------------------------------------------------- diff --git a/docs/ejb-over-ssl.adoc b/docs/ejb-over-ssl.adoc index 6b799a6..d888c9b 100644 --- a/docs/ejb-over-ssl.adoc +++ b/docs/ejb-over-ssl.adoc @@ -23,7 +23,8 @@ Once that is done and the `tomee` webapp can be accessed with `https`, an EJB client can invoke over `https` using the following `InitialContext` setup: -.... +[source,java] +---- Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "https://127.0.0.1:8443/tomee/ejb"); @@ -34,7 +35,7 @@ p.put("java.naming.security.credentials", "mypass"); InitialContext ctx = new InitialContext(p); MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote"); -.... +---- If you setup Tomcat (TomEE) to use the APR (Apache Portable Runitme) implementation of SSL on the server side, and you have connection issues @@ -55,7 +56,8 @@ and setup in OpenEJB Standalone by default. Its configuration `conf/ejbds.properties` looks like this: -.... +[source,java] +---- server = org.apache.openejb.server.ejbd.EjbServer bind = 127.0.0.1 port = 4203 @@ -64,12 +66,13 @@ threads = 200 backlog = 200 secure = true discovery = ejb:ejbds://{bind}:{port} -.... +---- To access this service from a remote client, the `InitialContext` would be setup like the following: -.... +[source,java] +---- Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "ejbd://localhost:4201"); @@ -80,7 +83,7 @@ p.put("java.naming.security.credentials", "mypass"); InitialContext ctx = new InitialContext(p); MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote"); -.... +---- === Changing the Cipher Suite @@ -106,7 +109,8 @@ You must now instruct the client and server to use that suite. On the server: -.... +[source,java] +---- server = org.apache.openejb.server.ejbd.EjbServer bind = 127.0.0.1 port = 4203 @@ -116,13 +120,14 @@ backlog = 200 secure = true enabledCipherSuites = TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA discovery = ejb:ejbds://{bind}:{port} -.... +---- On the client, you must supply a property: -.... +[source,java] +---- -Dopenejb.client.enabledCipherSuites=TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA -.... +---- The final piece is to make sure your server has available a private certificate that the the client can trust. This can be certificate from http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejb-ref.adoc ---------------------------------------------------------------------- diff --git a/docs/ejb-ref.adoc b/docs/ejb-ref.adoc index 1c3a6a8..d523822 100644 --- a/docs/ejb-ref.adoc +++ b/docs/ejb-ref.adoc @@ -7,7 +7,8 @@ # Via annotation -.... +[source,java] +---- package org.superbiz.refs; import javax.ejb.EJB; @@ -30,13 +31,14 @@ public class MyEjbRemoteRefBean implements MyBeanInterface { BarRemote barRemote = (BarRemote) context.lookup("java:comp/env/org.superbiz.refs.MyEjbRemoteRefBean/myBarEjb"); } } -.... +---- # Via xml The above @EJB annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- myFooEjb org.superbiz.refs.FooRemote @@ -50,4 +52,4 @@ The above @EJB annotation usage is 100% equivalent to the following xml. myBarEjb -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejb-refs.adoc ---------------------------------------------------------------------- diff --git a/docs/ejb-refs.adoc b/docs/ejb-refs.adoc index f108da5..029347e 100644 --- a/docs/ejb-refs.adoc +++ b/docs/ejb-refs.adoc @@ -15,7 +15,8 @@ the ejb-jar.xml of the referring bean. So in ejb app A colorsApp.jar you have this bean: -.... +[source,java] +---- package com.foo.colors; import javax.ejb.Stateless; @@ -23,12 +24,13 @@ import javax.ejb.Stateless; @Stateless public class OrangeBean implements OrangeRemote { } -.... +---- Then in ejb app B shapesApp.jar you have this bean with a reference to OrangeRemote: -.... +[source,java] +---- package com.foo.shapes; import javax.ejb.Stateless; @@ -38,12 +40,13 @@ import com.foo.colors.OrangeRemote; public class SquareBean implements SquareRemote { @EJB OrangeRemote orangeRemote; } -.... +---- To hook this reference up you need to override this ref and add more info in the ejb-jar.xml of shapesApp.jar as follows: -.... +[source,java] +---- @@ -57,7 +60,7 @@ info in the ejb-jar.xml of shapesApp.jar as follows: -.... +---- == Referencing a bean in another jar (xml only, no annotations) @@ -66,7 +69,8 @@ possible, however more information must be described in the xml. In ejb app A colorsApp.jar you have this bean: -.... +[source,java] +---- package com.foo.colors; import javax.ejb.Stateless; @@ -74,11 +78,12 @@ import javax.ejb.Stateless; @Stateless public class OrangeBean implements OrangeRemote { } -.... +---- Then in ejb app B shapesApp.jar -- note there is no @EJB annotation: -.... +[source,java] +---- package com.foo.shapes; import javax.ejb.Stateless; @@ -88,13 +93,14 @@ import com.foo.colors.OrangeRemote; public class SquareBean implements SquareRemote { OrangeRemote orangeRemote; } -.... +---- Here's how you would hook this reference up, injection and all, with just xml. The following would be added to the ejb-jar.xml of shapesApp.jar: -.... +[source,java] +---- @@ -114,7 +120,7 @@ shapesApp.jar: -.... +---- Note that the value of could actually be anything and the above example would still work as there is no annotation that needs to match the and @@ -129,7 +135,8 @@ to satisfy the lookup to the other server. In this example we are calling our InitialContext `shoe` for fun. -.... +[source,java] +---- @@ -139,12 +146,13 @@ In this example we are calling our InitialContext `shoe` for fun. -.... +---- Declaring the `@EJB` reference is then done using a `mappedName` that references the named `InitialContext` -.... +[source,java] +---- public class BlueBean implements BlueRemote { @EJB(mappedName = "jndi:ext://shoe/OrangeBeanRemote") @@ -155,7 +163,7 @@ public class BlueBean implements BlueRemote { assertEquals("olleh", orangeRemote.echo("hello")); } } -.... +---- Specifically, the `mappedName` syntax is as follows: @@ -169,12 +177,13 @@ supports. If say, there are two servers that have the `OrangeBeanRemote` bean, you could expand the `` delcaration like so: -.... +[source,java] +---- java.naming.provider.url = failover:ejbd://192.168.1.20:4201,ejbd://192.168.1.30:4201 java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory -.... +---- In the event that the `ejbd://192.168.1.20:4201` server cannot be contacted, the second server will be tried. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejb-request-logging.adoc ---------------------------------------------------------------------- diff --git a/docs/ejb-request-logging.adoc b/docs/ejb-request-logging.adoc index 48a48bf..c03474b 100644 --- a/docs/ejb-request-logging.adoc +++ b/docs/ejb-request-logging.adoc @@ -27,11 +27,12 @@ On the client requests/responses are logged on java.util.logging `FINEST` level in category `OpenEJB.client`. The code is similar to the following: -.... +[source,java] +---- final long time = System.nanoTime() - start; final String message = String.format("Invocation %sns - %s - Request(%s) - Response(%s)", time, conn.getURI(), req, res); logger.log(Level.FINEST, message); -.... +---- Note that the check to see if FINEST is enabled is cached for performance reasons, so it must be set at VM startup. @@ -42,9 +43,10 @@ On the server requests/responses are logged in java.util.logging `FINE` in category`"OpenEJB.server.remote.ejb`. The code for that is similar to this: -.... +[source,java] +---- logger.fine("EJB REQUEST: " + req + " -- RESPONSE: " + res); -.... +---- == Request times @@ -83,9 +85,10 @@ security. This information is available in JMX. A sample JMX ObjectName for a `CounterBean` will look like this: -.... +[source,java] +---- openejb.management:J2EEServer=openejb,J2EEApplication=null,EJBModule=StatsModule,StatelessSessionBean=CounterBean,j2eeType=Invocations,name=CounterBean -.... +---- All beans have the following MBean attributes, listed here in shorthand: http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/ejbd-transport.adoc ---------------------------------------------------------------------- diff --git a/docs/ejbd-transport.adoc b/docs/ejbd-transport.adoc index 5d07978..ec183a8 100644 --- a/docs/ejbd-transport.adoc +++ b/docs/ejbd-transport.adoc @@ -18,7 +18,8 @@ you don't want them to be started. In TomEE the transport is the Tomcat one. It uses a servlet brought by TomEE webapp. Here is the servlet as defined in TomEE webapp: -.... +[source,java] +---- ServerServlet org.apache.openejb.server.httpd.ServerServlet @@ -28,7 +29,7 @@ TomEE webapp. Here is the servlet as defined in TomEE webapp: ServerServlet /ejb/* -.... +---- You can easily remove it if you don't use remote EJBs. Another way is to deactivate the servlet using the "activated" init parameter of the @@ -103,9 +104,10 @@ default for `tomee.serialization.class.blacklist` is `*` since TomEE If an EJB request fails because a class is not whitelisted you will find this log entry: -.... +[source,java] +---- WARN - "null OEJP/4.7" FAIL "Security error - foo.Bar is not whitelisted as deserializable, prevented before loading it." - Debug for StackTrace -.... +---- If you trust this class and want to support serialization in remote communication you have to configure these properties appropriately both @@ -114,18 +116,20 @@ on server side as well as on client side. If you only want to support serialization of the classes `foo.Bar` and `foo.Baz` you can configure the properties like this: -.... +[source,java] +---- tomee.serialization.class.whitelist = foo.Bar,foo.Baz tomee.serialization.class.blacklist = - -.... +---- If you trust all classes in the package `foo` define the properties like this: -.... +[source,java] +---- tomee.serialization.class.whitelist = foo. tomee.serialization.class.blacklist = - -.... +---- (Don't forget the trailing `.` after foo, as it will also whitelist all classes in the package `foo2` otherwise.) @@ -133,10 +137,11 @@ classes in the package `foo2` otherwise.) If you trust all classes in the package `foo` except the class `foo.Bar` you have to configure the properties like this: -.... +[source,java] +---- tomee.serialization.class.whitelist = foo. tomee.serialization.class.blacklist = foo.Bar -.... +---- === Revert to behavior of TomEE 1.7.3 @@ -148,10 +153,11 @@ applications runs on TomEE 1.7.3 but does not on TomEE 1.7.4 showing the aforementioned log message, you can define the configuration so that the serialization will work in the same way as it did with TomEE 1.7.3: -.... +[source,java] +---- tomee.serialization.class.whitelist = tomee.serialization.class.blacklist = org.codehaus.groovy.runtime.,org.apache.commons.collections.functors.,org.apache.xalan,java.lang.Process -.... +---- Please note that with this configuration your server may be vulnerable to Java serialization attacks not yet identified by the Zero Day @@ -178,10 +184,11 @@ TomEE 1.7.2 did not have any kind of blacklist when deserializing objects over Ejbd. If you want to revert to this behavior you can simply deactivate the blacklist with this configuration: -.... +[source,java] +---- tomee.serialization.class.whitelist = tomee.serialization.class.blacklist = - -.... +---- Note that this configuration makes your system highly vulnerable to serialization attacks! Consider your system as unsafe! http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/embedded-and-remotable.adoc ---------------------------------------------------------------------- diff --git a/docs/embedded-and-remotable.adoc b/docs/embedded-and-remotable.adoc index aa22bf5..4c81d77 100644 --- a/docs/embedded-and-remotable.adoc +++ b/docs/embedded-and-remotable.adoc @@ -126,7 +126,8 @@ $ mvn clean install Which should create output like the following. -.... +[source,java] +---- ------------------------------------------------------- T E S T S ------------------------------------------------------- @@ -134,7 +135,7 @@ Running org.superbiz.telephone.TelephoneTest Apache OpenEJB 3.0 build: 20080408-04:13 http://tomee.apache.org/ INFO - openejb.home = -.... +---- /Users/dblevins/work/openejb-3.0/examples/telephone-stateful INFO - openejb.base = @@ -168,8 +169,9 @@ admin thread 127.0.0.1 4200 + ------- Ready! Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.89 sec -.... +[source,java] +---- Results : Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/failover-logging.adoc ---------------------------------------------------------------------- diff --git a/docs/failover-logging.adoc b/docs/failover-logging.adoc index 84c4045..1d00be8 100644 --- a/docs/failover-logging.adoc +++ b/docs/failover-logging.adoc @@ -6,21 +6,24 @@ Setting the following logging category to "debug" will open up some new logging information. -.... +[source,java] +---- log4j.category.OpenEJB.server.discovery = debug -.... +---- Or more specifically as: -.... +[source,java] +---- log4j.category.OpenEJB.server.discovery.multipoint = debug log4j.category.OpenEJB.server.discovery.multicast = debug -.... +---- The nature of the debug output is to display all configuration information at startup: -.... +[source,java] +---- DEBUG - Using default 'heart_rate=500' DEBUG - Using default 'max_missed_heartbeats=10' DEBUG - Using default 'max_reconnect_delay=30000' @@ -28,11 +31,12 @@ DEBUG - Using default 'reconnect_delay=5000' DEBUG - Using default 'exponential_backoff=0' DEBUG - Using default 'max_reconnect_attempts=10' INFO - Created Tracker{group='default', groupPrefix='default:', heartRate=500, maxMissedHeartbeats=10, reconnectDelay=5000, maxReconnectDelay=30000, maxReconnectAttempts=10, exponentialBackoff=0, useExponentialBackOff=false, registeredServices=0, discoveredServices=0} -.... +---- Changing the configuration should reflect in the logging as follows: -.... +[source,java] +---- INFO - Using 'heart_rate=200' INFO - Using 'max_missed_heartbeats=2' DEBUG - Using default 'max_reconnect_delay=30000' @@ -40,14 +44,15 @@ DEBUG - Using default 'reconnect_delay=5000' DEBUG - Using default 'exponential_backoff=0' DEBUG - Using default 'max_reconnect_attempts=10' INFO - Created Tracker{group='default', groupPrefix='default:', heartRate=200, maxMissedHeartbeats=2, reconnectDelay=5000, maxReconnectDelay=30000, maxReconnectAttempts=10, exponentialBackoff=0, useExponentialBackOff=false, registeredServices=0, discoveredServices=0} -.... +---- As well as any events at runtime: -.... +[source,java] +---- DEBUG - Expired Service{uri=green://localhost:0, broadcastString='default:green://localhost:0'} Timeout{lastSeen=-5005, threshold=5000} DEBUG - Added Service{uri=green://localhost:0} DEBUG - Removed Service{uri=green://localhost:0} -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/faq.adoc ---------------------------------------------------------------------- diff --git a/docs/faq.adoc b/docs/faq.adoc index d02d971..a901b14 100644 --- a/docs/faq.adoc +++ b/docs/faq.adoc @@ -67,26 +67,29 @@ classpath. For maven, something that winds up directly under "target/classes/" or "target/test-classes/" will work just fine. Then in your test case do this: -.... +[source,java] +---- protected void setUp() throws Exception { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, -.... +---- "org.apache.openejb.client.LocalInitialContextFactory"); -.... +[source,java] +---- URL config = -.... +---- this.getClass().getClassLoader().getResource("openejb.xml"); properties.setProperty("openejb.configuration", config.toExternalForm()); -.... +[source,java] +---- initialContext = new InitialContext(properties); } -.... +---- The file itself doesn't have to be called "openejb.xml", you could have a few different files like that for different testing scenarios each http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/features.adoc ---------------------------------------------------------------------- diff --git a/docs/features.adoc b/docs/features.adoc index a07b216..0127038 100644 --- a/docs/features.adoc +++ b/docs/features.adoc @@ -3,4 +3,3 @@ :jbake-date: 2018-12-05 :jbake-type: page :jbake-status: published - http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/functional-testing-with-openejb,-jetty-and-selenium.adoc ---------------------------------------------------------------------- diff --git a/docs/functional-testing-with-openejb,-jetty-and-selenium.adoc b/docs/functional-testing-with-openejb,-jetty-and-selenium.adoc index 2e64527..740c932 100644 --- a/docs/functional-testing-with-openejb,-jetty-and-selenium.adoc +++ b/docs/functional-testing-with-openejb,-jetty-and-selenium.adoc @@ -22,7 +22,8 @@ http://people.apache.org/~jgallimore/PersonApp.zip[here] . I created a class to start my embedded OpenEJB and Jetty instances and configure them to see the EJB and WAR modules of my application: -.... +[source,java] +---- public class EmbeddedServer { private static EmbeddedServer instance = new EmbeddedServer(); private Server server; @@ -122,7 +123,7 @@ public class EmbeddedServer { return webApp; } } -.... +---- This class sets up an embedded instance of Jetty, running on port 9091. You'll notice the setupJndi() method. This looks through the ejb-ref @@ -138,7 +139,8 @@ In the last code sample, we also set up a custom ServletHandler in Jetty - this is to perform dependency injection. The custom ServletHandler looks like this: -.... +[source,java] +---- public class EmbeddedServerServletHandler extends ServletHandler { private InitialContext initialContext; @@ -149,18 +151,20 @@ public class EmbeddedServerServletHandler extends ServletHandler { public Servlet customizeServlet(Servlet servlet) throws Exception { Class servletClass = servlet.getClass(); Field[] -.... +---- declaredFields = servletClass.getDeclaredFields(); -.... +[source,java] +---- for (Field declaredField : declaredFields) { Annotation[] -.... +---- annotations = declaredField.getAnnotations(); -.... +[source,java] +---- for (Annotation annotation : annotations) { if (EJB.class.equals(annotation.annotationType())) { // inject into this field @@ -186,7 +190,7 @@ annotations = declaredField.getAnnotations(); return new EJBHelper().getBeanInfo(fieldType); } } -.... +---- This looks up deployed beans that match the field type, and uses reflection to set the field. @@ -196,7 +200,8 @@ reflection to set the field. We can now write a functional test. I use a base abstract class to make sure the Embedded server is running, and start Selenium: -.... +[source,java] +---- public abstract class FunctionalTestCase extends TestCase { protected DefaultSelenium selenium; @@ -211,11 +216,12 @@ public abstract class FunctionalTestCase extends TestCase { selenium.stop(); } } -.... +---- and I can then I write a test like this: -.... +[source,java] +---- public class AddPersonTest extends FunctionalTestCase { public void testShouldAddAPerson() throws Exception { selenium.open("/People"); @@ -231,7 +237,7 @@ public class AddPersonTest extends FunctionalTestCase { } } -.... +---- === Sample code http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/generating-ejb-3-annotations.adoc ---------------------------------------------------------------------- diff --git a/docs/generating-ejb-3-annotations.adoc b/docs/generating-ejb-3-annotations.adoc index b678931..64b5a0c 100644 --- a/docs/generating-ejb-3-annotations.adoc +++ b/docs/generating-ejb-3-annotations.adoc @@ -16,7 +16,8 @@ of your project. If you are using Maven, you can add the following to your POM (you will need to update your Eclipse project using mvn eclipse:eclipse afterwards) -.... +[source,java] +---- ... @@ -26,7 +27,7 @@ eclipse:eclipse afterwards) provided -.... +---- Alternatively, import the API jars into your project, and add them to your build path. @@ -46,9 +47,10 @@ Select or deselect the other options as appropriate, and select 'Next'. Options: -.... +[source,java] +---- * Alter SessionBean interfaces - This option makes your session beans -.... +---- implement your remote / local interfaces as opposed to javax.ejb.SessionBean, and stops your remote / local interfaces http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/getting-started.adoc ---------------------------------------------------------------------- diff --git a/docs/getting-started.adoc b/docs/getting-started.adoc index f832bce..0e17673 100644 --- a/docs/getting-started.adoc +++ b/docs/getting-started.adoc @@ -34,13 +34,15 @@ OPENEJB_HOME/lib/openejb-client-3.0.0-SNAPSHOT.jar Open the command prompt and run the following command: -.... +[source,java] +---- d:\openejb-3.0.0-SNAPSHOT\bin\openejb start -.... +---- You will get the following message on the console: -.... +[source,java] +---- D:\openejb-3.0.0-SNAPSHOT>bin\openejb start Apache OpenEJB 3.0.0-SNAPSHOT build: 20070830-07:53 http://tomee.apache.org/ @@ -56,13 +58,14 @@ OpenEJB ready. telnet 0.0.0.0 4202 ------- Ready! -.... +---- ##4. Write an EJB In the EJB project create a new interface named Greeting -.... +[source,java] +---- package com.myejbs; import javax.ejb.Remote; @@ -71,12 +74,13 @@ import javax.ejb.Remote; public interface Greeting { public String greet(); } -.... +---- Now create a new class named GreetingBean which implements the above interface (shown below) -.... +[source,java] +---- package com.myejbs; import javax.ejb.Stateless; @@ -89,7 +93,7 @@ public class GreetingBean implements Greeting { } } -.... +---- == 5. Deploy the EJB @@ -102,7 +106,8 @@ d:-3.0.0-SNAPSHOT > bindeploy apps.jar This should give you the following output: -.... +[source,java] +---- D:\openejb-3.0.0-SNAPSHOT>bin\openejb deploy apps\greeting.jar Application deployed successfully at \{0\} @@ -114,7 +119,7 @@ App(id=D:\openejb-3.0.0-SNAPSHOT\apps\greeting.jar) Ejb(ejb-name=GreetingBean, id=GreetingBean) Jndi(name=GreetingBeanRemote) -.... +---- \{color:#330000}\{_}Notice the Jndi(name=GreetingBeanRemote) information. Keep this handy as this is the JNDI name of the bean which @@ -124,7 +129,8 @@ the client will use for lookup\{_}\{color} In the EJBClient project, create a class named Client (shown below) -.... +[source,java] +---- package com.myclient; import com.myejbs.Greeting; @@ -148,16 +154,17 @@ public class Client { } } } -.... +---- ##7. Run the Client Open Client.java in eclipse and run it as a java application. You should see the following message in the console view: -.... +[source,java] +---- My First Remote Stateless Session Bean -.... +---- ##8. Stop the server @@ -165,6 +172,7 @@ There are two ways to stop the server: 1. You can press Ctrl+c on the command prompt to stop the server 1. On the command prompt type in the following command: -.... +[source,java] +---- D:\openejb-3.0.0-SNAPSHOT>bin\openejb stop -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/hello-world.adoc ---------------------------------------------------------------------- diff --git a/docs/hello-world.adoc b/docs/hello-world.adoc index 6d4871f..d386a87 100644 --- a/docs/hello-world.adoc +++ b/docs/hello-world.adoc @@ -58,24 +58,27 @@ file under this directory - _logs_: Contains log files. === Create a working directory Assuming you are in your home directory, create a directory named projects -.... +[source,java] +---- karan@poweredge:~$ mkdir projects -.... +---- Go to the projects directory -.... +[source,java] +---- karan@poweredge:~$ cd projects -.... +---- We will do all our work in this directory. ### Install Java Download and install Java (version 5 or higher). Also set it up so that you can run the java and javac commands from any directory ### Set OPENEJB_HOME We will setup this variable to refer to the openejb install location. -.... +[source,java] +---- karan@poweredge:~/projects$ export -.... +---- OPENEJB_HOME=/home/karan/install/openejb-3.0 @@ -83,19 +86,21 @@ OPENEJB_HOME=/home/karan/install/openejb-3.0 projects directory ### Create the Remote Interface Using your favorite editor, create a file named Hello.java (shown below) -.... +[source,java] +---- package org.acme; import javax.ejb.Remote; @Remote public interface Hello{ public String sayHello(); } -.... +---- === Create the Bean Class Now create a file named HelloBean.java (shown below) -.... +[source,java] +---- package org.acme; import javax.ejb.Stateless; @Stateless @@ -104,7 +109,7 @@ public class HelloBean implements Hello{ return "Hello World!!!!"; } } -.... +---- === Compile the source code Since we have imported the javax.ejb.Stateless and javax.ejb.Remote annotations, we need these in @@ -112,9 +117,10 @@ our classpath to compile our source code. These annotations can be found in the $OPENEJB_HOME/lib/javaee-5.0-1.jar. Lets compile our source (make sure you are in the projects directory) -.... +[source,java] +---- karan@poweredge:~/projects$ javac -cp $OPENEJB_HOME/lib/javaee-5.0-1.jar -d -.... +---- . *.java @@ -124,22 +130,24 @@ directory. All class files should be under org/acme directory. ### Package the EJB To package the EJB into a JAR, run the following command while you are in the projects directory -.... +[source,java] +---- karan@poweredge:~/projects$ jar cvf hello.jar org -.... +---- The above command will package everything under the org directory (including the org directory itself) into a jar file named hello.jar. Below is the output from running the above command: -.... +[source,java] +---- karan@poweredge:~/projects$ jar cvf hello.jar org added manifest adding: org/(in = 0) (out= 0)(stored 0%) adding: org/acme/(in = 0) (out= 0)(stored 0%) adding: org/acme/Hello.class(in = 203) (out= 168)(deflated 17%) adding: org/acme/HelloBean.class(in = 383) (out= 275)(deflated 28%) -.... +---- == Write an EJB Client Now we will write a Client class which will lookup the EJB , invoke the sayHello() business method and print the @@ -147,7 +155,8 @@ value returned from the method. While you are in the projects directory, create a new file named HelloClient.java . Add the following to this file: -.... +[source,java] +---- package org.acme; import java.util.Properties; import javax.naming.InitialContext; @@ -155,7 +164,7 @@ import javax.naming.Context; import javax.rmi.PortableRemoteObject; public class HelloClient{ public static void main(String[] -.... +---- args) throws Exception\{ Properties props = new Properties(); @@ -167,27 +176,30 @@ result = h.sayHello(); System.out.println(result); } } === Compile HelloClient.java Run the following command: -.... +[source,java] +---- karan@poweredge:~/projects$ javac -d . HelloClient.java -.... +---- == Start the Server Go to the OpenEJB install directory (i.e. OPENEJB_HOME) and run the following command: -.... +[source,java] +---- karan@poweredge:~/install/openejb-3.0$ bin/openejb start -.... +---- Once the Server starts, you will see an output similar to the below in your console: -.... +[source,java] +---- karan@poweredge:~/install/openejb-3.0$ bin/openejb start Apache OpenEJB 3.0 build: 20070926-12:34 http://tomee.apache.org/ OpenEJB ready. [OPENEJB:init] -.... +---- OpenEJB Remote Server ** Starting Services ** NAME IP PORT + httpejbd 0.0.0.0 4204 + @@ -203,20 +215,22 @@ directories. ## Deploy the EJB We will now use the deploy command to deploy the EJB in hello.jar. While you are in the projects directory, run the following command: -.... +[source,java] +---- karan@poweredge:~/projects$ $OPENEJB_HOME/bin/openejb deploy hello.jar -.... +---- The above command should give you the following output: -.... +[source,java] +---- karan@poweredge:~/projects$ $OPENEJB_HOME/bin/openejb deploy hello.jar Application deployed successfully at "hello.jar" App(id=/home/karan/projects/hello.jar) EjbJar(id=hello.jar, path=/home/karan/projects/hello.jar) Ejb(ejb-name=HelloBean, id=HelloBean) Jndi(name=HelloBeanRemote) -.... +---- Notice how the output neatly lays out various deployment details. One thing you might want to note from the output is the JNDI name. This is @@ -224,18 +238,20 @@ the JNDI name we used in the client to lookup the EJB ## Run the Client While you are in the projects directory, run the following command to run the client: -.... +[source,java] +---- karan@poweredge:~/projects$ java -cp -.... +---- latexmath:[$OPENEJB_HOME/lib/openejb-client-3.0.jar:$]OPENEJB_HOME/lib/javaee-5.0-1.jar:. org.acme.HelloClient The above should give you the following output: -.... +[source,java] +---- Hello World!!!! -.... +---- == Help! , it didn't work for me!!. No problem, we are here to help. Just send us an email at users@tomee.apache.org. If possible, send us http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/hibernate.adoc ---------------------------------------------------------------------- diff --git a/docs/hibernate.adoc b/docs/hibernate.adoc index 3c60aa3..e2d653b 100644 --- a/docs/hibernate.adoc +++ b/docs/hibernate.adoc @@ -10,7 +10,8 @@ For a unit called "movie-unit" using two datasources called "movieDatabase" and "movieDatabaseUnmanaged" the following persistence.xml would work. -.... +[source,java] +---- -.... +---- Note that as of OpenEJB 3.1 you do not need to set the `hibernate.transaction.manager_lookup_class` as it will be set for you @@ -58,7 +59,8 @@ strategy like the following will do the trick. This "DynamicTransactionManagerLookup" class can be packed in your jar and deployed with your app. -.... +[source,java] +---- import org.hibernate.HibernateException; import org.hibernate.transaction.TransactionManagerLookup; import javax.transaction.TransactionManager; @@ -94,7 +96,7 @@ public class DynamicTransactionManagerLookup implements TransactionManagerLookup return impl.getUserTransactionName(); } } -.... +---- Then set the Hibernate specific configuration property _hibernate.transaction.manager_lookup_class_ to the name of the factory http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/initialcontext-config.adoc ---------------------------------------------------------------------- diff --git a/docs/initialcontext-config.adoc b/docs/initialcontext-config.adoc index 0dbd7c4..24ffed3 100644 --- a/docs/initialcontext-config.adoc +++ b/docs/initialcontext-config.adoc @@ -10,19 +10,21 @@ A InitialContext can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- -.... +---- Alternatively, a InitialContext can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myInitialContext = new://JndiProvider?type=javax.naming.InitialContext -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/installation-drop-in-war.adoc ---------------------------------------------------------------------- diff --git a/docs/installation-drop-in-war.adoc b/docs/installation-drop-in-war.adoc index d6adcb3..844b16a 100644 --- a/docs/installation-drop-in-war.adoc +++ b/docs/installation-drop-in-war.adoc @@ -32,11 +32,12 @@ http://tomcat.apache.org/download-70.cgi * Update $CATALINA_HOME/conf/tomcat-users.xml to add a tomee user to allow access to the installer page. + -.... +[source,java] +---- -.... +---- * Download the .war file you wish to use - either the tomee-webapp-1.7.1.war (for the webprofile installation) or tomee-webapp-plus-1.7.1.war (for the plus version). http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/installing-tomee.adoc ---------------------------------------------------------------------- diff --git a/docs/installing-tomee.adoc b/docs/installing-tomee.adoc index 774cfae..27e3050 100644 --- a/docs/installing-tomee.adoc +++ b/docs/installing-tomee.adoc @@ -49,15 +49,17 @@ this directory as $CATALINA_HOME in the following. To start TomEE as a background process, invoke -.... +[source,java] +---- $CATALINA_HOME/bin/startup.sh -.... +---- To start TomEE in foreground, invoke -.... +[source,java] +---- $CATALINA_HOME/bin/catalina.sh run -.... +---- == Log Messages @@ -67,17 +69,19 @@ console. When running TomEE in background, it will only print a couple of environment variables. The log messages go to a file -.... +[source,java] +---- $CATALINA_HOME/logs/catalina.out -.... +---- == Stopping TomEE To stop TomEE, invoke -.... +[source,java] +---- $CATALINA_HOME/bin/shutdown.sh -.... +---- If you started TomEE in foreground via `catalina.sh run`, it is safe to simply type `Ctrl-C`. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/javaagent-with-maven-surefire.adoc ---------------------------------------------------------------------- diff --git a/docs/javaagent-with-maven-surefire.adoc b/docs/javaagent-with-maven-surefire.adoc index eaa3f42..1816f2b 100644 --- a/docs/javaagent-with-maven-surefire.adoc +++ b/docs/javaagent-with-maven-surefire.adoc @@ -9,27 +9,30 @@ In maven2 you can enable the javaagent for your tests by adding this to your pom.xml file: -.... +[source,java] +---- org.apache.maven.plugins maven-surefire-plugin pertest -javaagent:latexmath:[${basedir}/target/openejb-javaagent-3.0.jar $]\{basedir}/target -.... +[source,java] +---- org.apache.maven.plugins maven-dependency-plugin copy process-resources copy org.apache.openejb openejb-javaagent 3.0 $\{project.build.directory} -.... +[source,java] +---- -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/javaagent.adoc ---------------------------------------------------------------------- diff --git a/docs/javaagent.adoc b/docs/javaagent.adoc index e4cc685..b784297 100644 --- a/docs/javaagent.adoc +++ b/docs/javaagent.adoc @@ -12,16 +12,18 @@ persistence provider or if using CMP. Adding a java agent is done via a vm parameter as follows: -.... +[source,java] +---- java -javaagent:openejb-javaagent-4.6.0.jar _\[other params...](other-params....html) -.... +---- == Maven2 In maven2 you can enable the javaagent for your tests by adding this to your pom.xml file: -.... +[source,java] +---- @@ -61,4 +63,4 @@ your pom.xml file: -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/javamailsession-config.adoc ---------------------------------------------------------------------- diff --git a/docs/javamailsession-config.adoc b/docs/javamailsession-config.adoc index 70e1500..78cccb1 100644 --- a/docs/javamailsession-config.adoc +++ b/docs/javamailsession-config.adoc @@ -10,19 +10,21 @@ A JavaMailSession can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- -.... +---- Alternatively, a JavaMailSession can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myJavaMailSession = new://Resource?type=javax.mail.Session -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/jms-resources-and-mdb-container.adoc ---------------------------------------------------------------------- diff --git a/docs/jms-resources-and-mdb-container.adoc b/docs/jms-resources-and-mdb-container.adoc index 9cf0e89..3a4f7c8 100644 --- a/docs/jms-resources-and-mdb-container.adoc +++ b/docs/jms-resources-and-mdb-container.adoc @@ -7,7 +7,8 @@ == External ActiveMQ Broker -.... +[source,java] +---- # Do not start the embedded ActiveMQ broker @@ -26,7 +27,7 @@ -.... +---- The `ServerUrl` would be changed to point to the host and port of the ActiveMQ process. The various URL formats that ActiveMQ supports also @@ -34,7 +35,8 @@ work, such as 'failover:'. == Internal ActiveMQ Broker -.... +[source,java] +---- BrokerXmlConfig = broker:(tcp://someHostName:61616) @@ -52,7 +54,7 @@ work, such as 'failover:'. -.... +---- The `BrokerXmlConfig` tells ActiveMQ to start on the tcp host/port `someHostName` and `61616` @@ -63,7 +65,8 @@ Adding the `DataSource` property to your `ActiveMQResourceAdapter` config will automatically setup JDBC Persistence using the `org.apache.activemq.store.jdbc.JDBCPersistenceAdapter` -.... +[source,java] +---- BrokerXmlConfig = broker:(tcp://someHostName:61616) @@ -78,7 +81,7 @@ config will automatically setup JDBC Persistence using the Password = foo -.... +---- === Internal ActiveMQ Broker with activemq.xml @@ -109,7 +112,8 @@ Create an link:activemq.xml[activemq.xml file] a in Then use the `xbean:file:` url prefix in the `BrokerXmlConfig` as shown belog. -.... +[source,java] +---- BrokerXmlConfig = xbean:file:conf/activemq.xml @@ -127,7 +131,7 @@ belog. -.... +---- Finally, restart the server. @@ -136,7 +140,8 @@ Finally, restart the server. The same can be done via properties in an embedded configuration, via the `conf/system.properties` file or on the command line via `-D` flags. -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName()); @@ -154,20 +159,21 @@ p.put("FooQueue", "new://Resource?type=javax.jms.Queue"); p.put("BarTopic", "new://Resource?type=javax.jms.Topic"); InitialContext context = new InitialContext(p); -.... +---- == Global lookup of JMS Resources From anywhere in the same VM as the EJB Container you could lookup the above resources like so: -.... +[source,java] +---- javax.jms.ConnectionFactory cf = (ConnectionFactory) context.lookup("openejb:Resource/MyJmsConnectionFactory"); javax.jms.Queue queue = (Queue) context.lookup("openejb:Resource/FooQueue"); javax.jms.Topic topic = (Topic) context.lookup("openejb:Resource/BarTopic"); -.... +---- == MDB ActivationConfig http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/jmsconnectionfactory-config.adoc ---------------------------------------------------------------------- diff --git a/docs/jmsconnectionfactory-config.adoc b/docs/jmsconnectionfactory-config.adoc index c0327e5..af99dc0 100644 --- a/docs/jmsconnectionfactory-config.adoc +++ b/docs/jmsconnectionfactory-config.adoc @@ -10,7 +10,8 @@ A JmsConnectionFactory can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- connectionMaxIdleTime = 15 Minutes connectionMaxWaitTime = 5 seconds @@ -19,7 +20,7 @@ body are optional. resourceAdapter = Default JMS Resource Adapter transactionSupport = xa -.... +---- Alternatively, a JmsConnectionFactory can be declared via properties in the `/conf/system.properties` file or via Java @@ -27,7 +28,8 @@ VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myJmsConnectionFactory = new://Resource?type=javax.jms.ConnectionFactory myJmsConnectionFactory.connectionMaxIdleTime = 15 Minutes myJmsConnectionFactory.connectionMaxWaitTime = 5 seconds @@ -35,7 +37,7 @@ myJmsConnectionFactory.poolMaxSize = 10 myJmsConnectionFactory.poolMinSize = 0 myJmsConnectionFactory.resourceAdapter = Default JMS Resource Adapter myJmsConnectionFactory.transactionSupport = xa -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/jndi-names.adoc ---------------------------------------------------------------------- diff --git a/docs/jndi-names.adoc b/docs/jndi-names.adoc index 916c3de..0155cff 100644 --- a/docs/jndi-names.adoc +++ b/docs/jndi-names.adoc @@ -13,9 +13,10 @@ before you start reading: == Default JNDI name The default JNDI name is in the following format: -.... +[source,java] +---- {deploymentId}{interfaceType.annotationName} -.... +---- Lets try and understand the above format. Both _deploymentId_ and _interfaceType.annotationName_ are pre-defined variables. There are @@ -136,10 +137,11 @@ and override that further for a specific interface of that ejb. The jndi name format can be set on a server level via a _system property_, for example: -.... +[source,java] +---- $ ./bin/openejb start -Dopenejb.jndiname.format=\{ejbName}/\{interfaceClass}" -.... +---- As usual, other ways of specifying system properties are via the conf/system.properties file in a standalone server, or via the @@ -150,57 +152,62 @@ InitialContext properties when embedded. It's possible to set the openejb.jndiname.format for an ejb-jar jar in a META-INF/openejb-jar.xml file as follows: -.... +[source,java] +---- openejb.deploymentId.format = {ejbName} openejb.jndiname.format = {deploymentId}{interfaceType.annotationName} -.... +---- == Via the tag for a specific ejb The following sets the name specifically for the interface org.superbiz.Foo. -.... +[source,java] +---- -.... +---- Or more generally... -.... +[source,java] +---- -.... +---- Or more generally still... -.... +[source,java] +---- -.... +---- The 'name' attribute can still use templates if it likes, such as: -.... +[source,java] +---- -.... +---- === Multiple tags @@ -219,7 +226,8 @@ intention with these examples is to show the various ways you can isolate specific interfaces or types of interfaces to gain more specific control on how they are named. -.... +[source,java] +---- @@ -230,11 +238,12 @@ control on how they are named. -.... +---- Or -.... +[source,java] +---- @@ -250,11 +259,12 @@ Or -.... +---- Or -.... +[source,java] +---- @@ -265,18 +275,19 @@ Or -.... +---- or -.... +[source,java] +---- -.... +---- # Changing the Default Setting http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/jpa-concepts.adoc ---------------------------------------------------------------------- diff --git a/docs/jpa-concepts.adoc b/docs/jpa-concepts.adoc index 0c74735..1d45025 100644 --- a/docs/jpa-concepts.adoc +++ b/docs/jpa-concepts.adoc @@ -132,7 +132,8 @@ Calling EntityManager.merge() will re-attach a Detached object. Servlets and EJBs can use RESOURCE_LOCAL persistence units through the EntityManagerFactory as follows: -.... +[source,java] +---- @@ -143,11 +144,12 @@ EntityManagerFactory as follows: -.... +---- And referenced as follows -.... +[source,java] +---- import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; @@ -175,13 +177,14 @@ public class MyEjbOrServlet ... { ... } -.... +---- == Valid JTA Unit usage EJBs can use JTA persistence units through the EntityManager as follows: -.... +[source,java] +---- @@ -193,11 +196,12 @@ EJBs can use JTA persistence units through the EntityManager as follows: -.... +---- And referenced as follows -.... +[source,java] +---- import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; @@ -220,4 +224,4 @@ public class MyEjb implements MyEjbInterface { } } -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/local-client-injection.adoc ---------------------------------------------------------------------- diff --git a/docs/local-client-injection.adoc b/docs/local-client-injection.adoc index fd14373..d544a31 100644 --- a/docs/local-client-injection.adoc +++ b/docs/local-client-injection.adoc @@ -37,7 +37,8 @@ The injection occurs via acquiring a LocalInitialContext via the LocalInitialContextFactory and calling _bind("inject", instance)_ passing in the instantiated local client object: -.... +[source,java] +---- @LocalClient public class MoviesTest extends TestCase { @@ -59,7 +60,7 @@ public class MoviesTest extends TestCase { //... other test methods } -.... +---- # Discovery http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/lookup-of-other-ejbs-example.adoc ---------------------------------------------------------------------- diff --git a/docs/lookup-of-other-ejbs-example.adoc b/docs/lookup-of-other-ejbs-example.adoc index de5fb1f..35b6008 100644 --- a/docs/lookup-of-other-ejbs-example.adoc +++ b/docs/lookup-of-other-ejbs-example.adoc @@ -104,7 +104,8 @@ ___________________ Which should create output like the following. -.... +[source,java] +---- ------------------------------------------------------- T E S T S ------------------------------------------------------- @@ -112,7 +113,7 @@ Running org.superbiz.ejblookup.EjbDependencyTest Apache OpenEJB 3.1.5-SNAPSHOT build: 20101129-09:51 http://tomee.apache.org/ INFO - openejb.home = -.... +---- /Users/dblevins/work/openejb-3.1.x/examples/lookup-of-ejbs INFO - openejb.base = @@ -139,8 +140,9 @@ container=Default Stateless Container) INFO - Deployed Application(path=classpath.ear) Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.244 sec -.... +[source,java] +---- Results : Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/managedcontainer-config.adoc ---------------------------------------------------------------------- diff --git a/docs/managedcontainer-config.adoc b/docs/managedcontainer-config.adoc index b0ca1a6..b52b00b 100644 --- a/docs/managedcontainer-config.adoc +++ b/docs/managedcontainer-config.adoc @@ -10,19 +10,21 @@ A ManagedContainer can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- -.... +---- Alternatively, a ManagedContainer can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myManagedContainer = new://Container?type=MANAGED -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/manual-installation.adoc ---------------------------------------------------------------------- diff --git a/docs/manual-installation.adoc b/docs/manual-installation.adoc index ab9c7d7..89bee40 100644 --- a/docs/manual-installation.adoc +++ b/docs/manual-installation.adoc @@ -51,12 +51,13 @@ All Tomcat listener classes must be available in the Tomcat common class loader, so the openejb-loader jar must be copied into the Tomcat lib directory. -.... +[source,java] +---- C:\apache-tomcat-6.0.14>copy webapps\openejb\lib\openejb-loader-3.0.0-SNAPSHOT.jar lib\openejb-loader.jar 1 file(s) copied. apache-tomcat-6.0.14$ cp webapps/openejb/lib/openejb-loader-*.jar lib/openejb-loader.jar -.... +---- Add the following `` to @@ -64,7 +65,8 @@ your conf/server.xml file to load the OpenEJB listener: The snippet is shown below -.... +[source,java] +---- -.... +---- == Update the Tomcat annotations-api.jar file @@ -100,7 +102,8 @@ First, copy the OpenEJB JavaAgent jar into the lib directory. Simply, add the snippet marked below in bin/catalina.bat (Windows) or bin/catalina.sh (Unix) file to enable the OpenEJB javaagent: -.... +[source,java] +---- if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuli set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager @@ -138,7 +141,7 @@ JAVA_OPTS=""-javaagent:$CATALINA_BASE/lib/openejb-javaagent.jar" $JAVA_OPTS" fi #End of Snippet to add -.... +---- ##Note: The example above is an excerpt from the middle of the bin/catalina.sh file. Search for the this section and add the snippet http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/maven.adoc ---------------------------------------------------------------------- diff --git a/docs/maven.adoc b/docs/maven.adoc index 2923618..3f4787c 100644 --- a/docs/maven.adoc +++ b/docs/maven.adoc @@ -34,17 +34,19 @@ http://svn.apache.org/repos/asf/tomee/tomee/trunk Use http://subversion.apache.org/[Subversion] to checkout the example sources from a console like so: -.... +[source,java] +---- svn co http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/[example] -.... +---- Or that you may of course also be using your own project pom.xml If you want to use the latest snapshot locate the __ section in your pom.xml and ensure the following repository exists: -.... +[source,java] +---- apache-m2-snapshot @@ -58,4 +60,4 @@ pom.xml and ensure the following repository exists: -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/maven/index.adoc ---------------------------------------------------------------------- diff --git a/docs/maven/index.adoc b/docs/maven/index.adoc index b526355..b199b63 100644 --- a/docs/maven/index.adoc +++ b/docs/maven/index.adoc @@ -15,7 +15,8 @@ feature-rich plugin that allows for: Simply add the following to the , and optionally the ), section of your `pom.xml` -.... +[source,java] +---- org.apache.openejb.maven @@ -27,7 +28,7 @@ Simply add the following to the , and optionally the ), section of your -.... +---- ###Plugin Goals @@ -112,7 +113,8 @@ This plugin is also usable in projects which are not war. For instance you can use it in a pom project to setup a TomEE install, add libraries, deploy apps then run the server. -.... +[source,java] +---- org.apache.openejb.maven tomee-maven-plugin @@ -141,11 +143,12 @@ deploy apps then run the server. -.... +---- ###Auto Reloading Example -.... +[source,java] +---- org.apache.openejb.maven tomee-maven-plugin @@ -159,7 +162,7 @@ deploy apps then run the server. true -.... +---- The Synchronization block supports the following configuration options: http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/messagedrivencontainer-config.adoc ---------------------------------------------------------------------- diff --git a/docs/messagedrivencontainer-config.adoc b/docs/messagedrivencontainer-config.adoc index 10a9109..9a37df8 100644 --- a/docs/messagedrivencontainer-config.adoc +++ b/docs/messagedrivencontainer-config.adoc @@ -10,14 +10,15 @@ A MessageDrivenContainer can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- activationSpecClass = org.apache.activemq.ra.ActiveMQActivationSpec instanceLimit = 10 messageListenerInterface = javax.jms.MessageListener resourceAdapter = Default JMS Resource Adapter -.... +---- Alternatively, a MessageDrivenContainer can be declared via properties in the `/conf/system.properties` file or via Java @@ -25,13 +26,14 @@ VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myMessageDrivenContainer = new://Container?type=MESSAGE myMessageDrivenContainer.activationSpecClass = org.apache.activemq.ra.ActiveMQActivationSpec myMessageDrivenContainer.instanceLimit = 10 myMessageDrivenContainer.messageListenerInterface = javax.jms.MessageListener myMessageDrivenContainer.resourceAdapter = Default JMS Resource Adapter -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/multicast-discovery.adoc ---------------------------------------------------------------------- diff --git a/docs/multicast-discovery.adoc b/docs/multicast-discovery.adoc index fd6d530..d4b764d 100644 --- a/docs/multicast-discovery.adoc +++ b/docs/multicast-discovery.adoc @@ -26,13 +26,14 @@ going to do a better job at ensuring reliability and ordering. When you boot the server there should be a `conf/multicast.properties` file containing: -.... +[source,java] +---- server = org.apache.openejb.server.discovery.MulticastDiscoveryAgent bind = 239.255.2.3 port = 6142 disabled = true group = default -.... +---- Just need to enable that by setting `disabled=false`. All of the above settings except `server` can be changed. The `port` and `bind` must be @@ -51,13 +52,14 @@ A special `multicast://` URL can be used in the `InitialContext` properties to signify that multicast should be used to seed the connection process. Such as: -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "multicast://239.255.2.3:6142?group=default"); InitialContext remoteContext = new InitialContext(p); -.... +---- The URL has optional query parameters such as `schemes` and `group` and `timeout` which allow you to zero in on a particular type of service of @@ -79,12 +81,13 @@ servers. Servers can use multicast to discover each other, but clients are still free to connect to servers in the network using the server's TCP address. -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "ejbd://192.168.1.30:4201"); InitialContext remoteContext = new InitialContext(p); -.... +---- When the client connects, the server will send the URLs of all the servers in the group and failover will take place normally. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/multiple-business-interface-hazzards.adoc ---------------------------------------------------------------------- diff --git a/docs/multiple-business-interface-hazzards.adoc b/docs/multiple-business-interface-hazzards.adoc index caeae43..d90a4c5 100644 --- a/docs/multiple-business-interface-hazzards.adoc +++ b/docs/multiple-business-interface-hazzards.adoc @@ -12,7 +12,8 @@ some very nasty side effects happen, namely you loose the ability to throw any checked exceptions that are not in the throws clause of both methods. -.... +[source,java] +---- import junit.framework.TestCase; import java.lang.reflect.InvocationHandler; @@ -27,19 +28,21 @@ public class ExceptionTest extends TestCase { public void test() throws Exception { ClassLoader classLoader = this.getClass().getClassLoader(); Class[] -.... +---- interfaces = new Class[]\{One.class, Two.class}; -.... +[source,java] +---- InvocationHandler h = new TestInvocationHandler(); Object proxy = -.... +---- java.lang.reflect.Proxy.newProxyInstance(classLoader, interfaces, h); -.... +[source,java] +---- One one = (One) proxy; try { @@ -59,11 +62,12 @@ java.lang.reflect.Proxy.newProxyInstance(classLoader, interfaces, h); } catch(UndeclaredThrowableException u) { Throwable t = u.getCause(); fail("Undeclared: "+t); // This will always be the code that -.... +---- executes } catch(Throwable t)\{ fail("Caught: "+t); } -.... +[source,java] +---- Two two = (Two) proxy; try { two.run(new CommonException()); @@ -71,11 +75,12 @@ executes } catch(Throwable t)\{ fail("Caught: "+t); } } catch(UndeclaredThrowableException u) { Throwable t = u.getCause(); fail("Undeclared: "+t); // This will always be the code that -.... +---- executes } catch(Throwable t)\{ fail("Caught: "+t); } -.... +[source,java] +---- } public static class CommonException extends Exception { @@ -102,7 +107,7 @@ executes } catch(Throwable t)\{ fail("Caught: "+t); } } private static class TestInvocationHandler implements InvocationHandler -.... +---- \{ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable \{ throw (Throwable)args[0] ; } } } @@ -115,7 +120,8 @@ those two interfaces declare the _same method_ but with _different return types_ the VM proxy code will refuse to create a proxy at all. Take this code example: -.... +[source,java] +---- import junit.framework.TestCase; import java.lang.reflect.InvocationHandler; @@ -129,19 +135,21 @@ public class ReturnTest extends TestCase { public void test() throws Exception { ClassLoader classLoader = this.getClass().getClassLoader(); Class[] -.... +---- interfaces = new Class[]\{ReturnTest.One.class, ReturnTest.Two.class}; -.... +[source,java] +---- InvocationHandler h = new ReturnTest.TestInvocationHandler(); Object proxy = -.... +---- java.lang.reflect.Proxy.newProxyInstance(classLoader, interfaces, h); -.... +[source,java] +---- One one = (One) proxy; try { Object object = one.run(new ThingOne()); @@ -173,16 +181,17 @@ java.lang.reflect.Proxy.newProxyInstance(classLoader, interfaces, h); } private static class TestInvocationHandler implements InvocationHandler -.... +---- \{ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable \{ return args[0] ; } } } Running this code will result in the following exception: -.... +[source,java] +---- java.lang.IllegalArgumentException: methods with same signature -.... +---- run(java.lang.Object) but incompatible return types: [class ReturnTestlatexmath:[$ThingOne, class ReturnTest$]ThingTwo] at http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/multipoint-discovery.adoc ---------------------------------------------------------------------- diff --git a/docs/multipoint-discovery.adoc b/docs/multipoint-discovery.adoc index 171ee46..4106b58 100644 --- a/docs/multipoint-discovery.adoc +++ b/docs/multipoint-discovery.adoc @@ -35,13 +35,14 @@ maintained list. In the server this list can be specified via the `conf/multipoint.properties` file like so: -.... +[source,java] +---- server = org.apache.openejb.server.discovery.MultipointDiscoveryAgent bind = 127.0.0.1 port = 4212 disabled = false initialServers = 192.168.1.20:4212, 192.168.1.30:4212, 192.168.1.40:4212 -.... +---- The above configuration shows the server has an `port` `4212` open for connections by other servers for multipoint communication. The @@ -57,23 +58,25 @@ participate directly in multipoint communication and do *not* connect to the multipoint port. The server list is simply a list of the regular `ejbd://` urls that a client normally uses to connect to a server. -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "failover:ejbd://192.168.1.20:4201,ejbd://192.168.1.30:4201"); InitialContext remoteContext = new InitialContext(p); -.... +---- Failover can work entirely driven by the server, the client does not need to be configured to participate. A client can connect as usual to the server. -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "ejbd://192.168.1.20:4201"); InitialContext remoteContext = new InitialContext(p); -.... +---- If the server at `192.168.1.20:4201` supports failover, so will the client. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/multipoint-recommendations.adoc ---------------------------------------------------------------------- diff --git a/docs/multipoint-recommendations.adoc b/docs/multipoint-recommendations.adoc index 5b93ee9..45048ee 100644 --- a/docs/multipoint-recommendations.adoc +++ b/docs/multipoint-recommendations.adoc @@ -142,11 +142,12 @@ line or via system properties. So it is possible easily set the A bash example might look something like: -.... +[source,java] +---- !/bin/bash OPENEJB_HOME=/opt/openejb-3.1.3 INITIAL_LIST=$(cat /some/shared/directory/our_initial_servers.txt) $OPENEJB_HOME/bin/openejb start -Dmultipoint.initialServers=$INITIAL_LIST -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/multipulse-discovery.adoc ---------------------------------------------------------------------- diff --git a/docs/multipulse-discovery.adoc b/docs/multipulse-discovery.adoc index ec2fd38..83be653 100644 --- a/docs/multipulse-discovery.adoc +++ b/docs/multipulse-discovery.adoc @@ -18,13 +18,14 @@ server can be configured to send multicast UDP packets. After you boot the server for the first time the default configuration will create the file `conf/conf.d/multipulse.properties` containing: -.... +[source,java] +---- server = org.apache.openejb.server.discovery.MulticastPulseAgent bind = 239.255.2.3 port = 6142 disabled = true group = default -.... +---- You just need to enable the agent by setting `disabled = false`. It is advisable to disable multicast in the `multicast.properties file`, or at @@ -45,14 +46,15 @@ for discovery. Edit the `ejbd.properties` file (and any other enabled services such as http, etc.) and ensure that the `discovery` option is set to a value that remote clients will be able to resolve. -.... +[source,java] +---- server = org.apache.openejb.server.ejbd.EjbServer bind = 0.0.0.0 port = 4201 disabled = false threads = 20 discovery = ejb:ejbd://{bind}:{port} -.... +---- NOTE: If either `0.0.0.0` (IPv4) or `[::]` (IPv6) wildcard bind addresses are used then the server will actually broadcast all of it's @@ -70,12 +72,13 @@ A special `multipulse://` URL can be used in the `InitialContext` properties to signify that multipulse should be used to seed the connection process. Such as: -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "multipulse://239.255.2.3:6142?group=default&timeout=250"); InitialContext remoteContext = new InitialContext(p); -.... +---- The URL has optional query parameters such as `schemes` and `group` and `timeout` which allow you to zero in on a particular type of service of @@ -97,12 +100,13 @@ servers. Servers can use multicast to discover each other, but clients are still free to connect to servers in the network using the server's TCP address. -.... +[source,java] +---- Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); p.put(Context.PROVIDER_URL, "ejbd://192.168.1.30:4201"); InitialContext remoteContext = new InitialContext(p); -.... +---- When the client connects, the server will send the URLs of all the servers in the group and failover will take place normally. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/new-in-openejb-3.0.adoc ---------------------------------------------------------------------- diff --git a/docs/new-in-openejb-3.0.adoc b/docs/new-in-openejb-3.0.adoc index 2040649..037fc11 100644 --- a/docs/new-in-openejb-3.0.adoc +++ b/docs/new-in-openejb-3.0.adoc @@ -54,7 +54,8 @@ a JavaBeans PropertyEditor. We include several built-in PropertyEditors already such as Date, InetAddress, Class, File, URL, URI, Map, List and more. -.... +[source,java] +---- import java.net.URI; import java.io.File; import java.util.Date; @@ -65,7 +66,7 @@ public class MyBean { @Resource Date birthday; @Resource File homeDirectory; } -.... +---- == The META-INF/env-entries.properties @@ -87,11 +88,12 @@ things that need injection that are not container controlled resources via a properties file and skip the need for an ejb-jar.xml and it's 5 lines per property madness. -.... +[source,java] +---- blog = http://acme.org/myblog birthday = locale=en_US style=MEDIUM Mar 1, 1954 homeDirectory = /home/esmith/ -.... +---- == Support for GlassFish descriptors @@ -143,9 +145,10 @@ Embedding ## Tomcat 6 Support ## Business locals remotable If you want to make business local interfaces remotable, you can set this property: -.... +[source,java] +---- openejb.remotable.businessLocals=true -.... +---- Then you can lookup your business local interfaces from remote clients. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/openejb-binaries.adoc ---------------------------------------------------------------------- diff --git a/docs/openejb-binaries.adoc b/docs/openejb-binaries.adoc index ca1e5dd..84a3951 100644 --- a/docs/openejb-binaries.adoc +++ b/docs/openejb-binaries.adoc @@ -8,7 +8,8 @@ Add this to your _$HOME/.m2/settings.xml_ to enable publishing to the Apache Nexus repo. This works for snapshots or staging final binaries. -.... +[source,java] +---- @@ -23,10 +24,11 @@ binaries. -.... +---- Then publish via: -.... +[source,java] +---- $ mvn clean deploy -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/openejb.xml.adoc ---------------------------------------------------------------------- diff --git a/docs/openejb.xml.adoc b/docs/openejb.xml.adoc index 258c49d..064308d 100644 --- a/docs/openejb.xml.adoc +++ b/docs/openejb.xml.adoc @@ -12,31 +12,34 @@ and its services such as transaction, security, and data sources. The format is a mix of xml and properties inspired by the format of the httpd configuration file. Basically: -.... +[source,java] +---- ...properties... -.... +---- Such as: -.... +[source,java] +---- username foo password bar -.... +---- _Note the space_. White space is a valid name/value pair separator in any java properties file (along with semi-colon). So the above is equivalent to: -.... +[source,java] +---- username = foo password = bar -.... +---- You are free to use white space, ":", or "=" for your name/value pair separator with no effect on OpenEJB. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/openjpa.adoc ---------------------------------------------------------------------- diff --git a/docs/openjpa.adoc b/docs/openjpa.adoc index 92d4ff7..278fc45 100644 --- a/docs/openjpa.adoc +++ b/docs/openjpa.adoc @@ -8,7 +8,8 @@ OpenJPA is bundled with OpenEJB as the default persistence provider. An example of working `persistence.xml` for OpenJPA: -.... +[source,java] +---- @@ -21,12 +22,13 @@ An example of working `persistence.xml` for OpenJPA: -.... +---- Where the datasources above are configured in your openejb.xml as follows: -.... +[source,java] +---- JdbcDriver = org.hsqldb.jdbcDriver JdbcUrl = jdbc:hsqldb:mem:moviedb @@ -37,11 +39,12 @@ follows: JdbcUrl = jdbc:hsqldb:mem:moviedb JtaManaged = false -.... +---- Or in properties as follows: -.... +[source,java] +---- p.put("movieDatabase", "new://Resource?type=DataSource"); p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); @@ -50,7 +53,7 @@ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource"); p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver"); p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); p.put("movieDatabaseUnmanaged.JtaManaged", "false"); -.... +---- == Common exceptions @@ -63,7 +66,8 @@ objects. If you add the _openjpa.jdbc.SynchronizeMappings_ property as shown below OpenJPA will auto-create all your tables, all your primary keys and all foreign keys exactly to match your objects. -.... +[source,java] +---- @@ -74,7 +78,7 @@ keys and all foreign keys exactly to match your objects. -.... +---- == Auto-commit can not be set while enrolled in a transaction @@ -86,27 +90,30 @@ Pending Using a EXTENDED persistence context ... -.... +[source,java] +---- @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED) EntityManager entityManager; -.... +---- on a persistence unit setup as RESOURCE_LOCAL ... -.... +[source,java] +---- ... -.... +---- inside of a transaction. -.... +[source,java] +---- @TransactionAttribute(TransactionAttributeType.REQUIRED) public void addMovie(Movie movie) throws Exception { entityManager.persist(movie); } -.... +---- Note the default transaction attribute for any ejb method is REQUIRED unless explicitly set otherwise in the bean class or method in question. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/orb-config.adoc ---------------------------------------------------------------------- diff --git a/docs/orb-config.adoc b/docs/orb-config.adoc index 008c005..579523f 100644 --- a/docs/orb-config.adoc +++ b/docs/orb-config.adoc @@ -9,19 +9,21 @@ A ORB can be declared via xml in the `/conf/tomee.xml` file or in a `WEB-INF/resources.xml` file using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- -.... +---- Alternatively, a ORB can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myORB = new://Resource?type=org.omg.CORBA.ORB -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/persistence-context.adoc ---------------------------------------------------------------------- diff --git a/docs/persistence-context.adoc b/docs/persistence-context.adoc index c033d93..64a1eae 100644 --- a/docs/persistence-context.adoc +++ b/docs/persistence-context.adoc @@ -9,7 +9,8 @@ Both lookup and injection of an EntityManager can be configured via the `@PersistenceContext` annotation. -.... +[source,java] +---- package org.superbiz; import javax.persistence.PersistenceContext; @@ -33,14 +34,15 @@ public class MyBean implements MyInterface { EntityManager barEntityManager = (EntityManager) context.lookup("java:comp/env/org.superbiz.MyBean/myBarEntityManager"); } } -.... +---- # Via xml The above @PersistenceContext annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- myFooEntityManager foo-unit @@ -56,4 +58,4 @@ following xml. myBarEntityManager -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/persistence-unit-ref.adoc ---------------------------------------------------------------------- diff --git a/docs/persistence-unit-ref.adoc b/docs/persistence-unit-ref.adoc index 447829d..9ad6e98 100644 --- a/docs/persistence-unit-ref.adoc +++ b/docs/persistence-unit-ref.adoc @@ -13,7 +13,8 @@ lookup and injection. == Via annotation -.... +[source,java] +---- package org.superbiz; import javax.persistence.PersistenceUnit; @@ -35,14 +36,15 @@ public class MyBean implements MyInterface { EntityManagerFactory barEntityManagerFactory = (EntityManagerFactory) context.lookup("java:comp/env/org.superbiz.MyBean/myBarEntityManagerFactory"); } } -.... +---- == Via xml The above @PersistenceUnit annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- org.superbiz.calculator.MyBean/myBarEntityManagerFactory bar-unit @@ -52,13 +54,14 @@ following xml. myBarEntityManagerFactory -.... +---- == Lookup only === Via annotation -.... +[source,java] +---- package org.superbiz; import javax.persistence.PersistenceUnit; @@ -75,17 +78,18 @@ public class MyBean implements MyInterface { EntityManagerFactory fooEntityManagerFactory = (EntityManagerFactory) context.lookup("java:comp/env/myFooEntityManagerFactory"); } } -.... +---- # Via xml The above @PersistenceUnit annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- myFooEntityManagerFactory foo-unit Transaction -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/properties-tool.adoc ---------------------------------------------------------------------- diff --git a/docs/properties-tool.adoc b/docs/properties-tool.adoc index 90fa8ec..be11654 100644 --- a/docs/properties-tool.adoc +++ b/docs/properties-tool.adoc @@ -54,7 +54,8 @@ the new property value before constructing the individual component. # Example output -.... +[source,java] +---- # Container(id=Default CMP Container) # className: org.apache.openejb.core.cmp.CmpContainer # @@ -215,4 +216,4 @@ admin.port=4200 admin.threads=1 admin.name=admin admin.server=org.apache.openejb.server.admin.AdminDaemon -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/provisioning.adoc ---------------------------------------------------------------------- diff --git a/docs/provisioning.adoc b/docs/provisioning.adoc index 306ff73..7390a6e 100644 --- a/docs/provisioning.adoc +++ b/docs/provisioning.adoc @@ -33,9 +33,10 @@ the container is able to access through its filesystem. Example: -.... +[source,java] +---- /MIDDLE/foo/bar/my-local-file.jar -.... +---- === Http/https @@ -44,9 +45,10 @@ JVM ones. Example: -.... +[source,java] +---- http://atos.net/foo/bar/my-http-file.jar -.... +---- === Maven @@ -57,23 +59,26 @@ maven informations to deploy your application. The location should follow: -.... +[source,java] +---- mvn:groupId/artifactId[/[version]/[type]] -.... +---- or -.... +[source,java] +---- mvn:groupId:artifactId[:[version]:[type]] -.... +---- Note: classifier are supported (through version field) For instance you can use: -.... +[source,java] +---- mvn:net.atos.xa/my-application/1.0.0/war -.... +---- ==== Installation @@ -91,6 +96,7 @@ a look to other tip pages). Another way to install it with tomee is to edit or create the file /conf/provisioning.properties and add the line: -.... +[source,java] +---- zip=http://repo1.maven.org/maven2/org/apache/openejb/openejb-provisionning//openejb-provisionning-.zip -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/proxyfactory-config.adoc ---------------------------------------------------------------------- diff --git a/docs/proxyfactory-config.adoc b/docs/proxyfactory-config.adoc index d970fa6..2734904 100644 --- a/docs/proxyfactory-config.adoc +++ b/docs/proxyfactory-config.adoc @@ -10,19 +10,21 @@ A ProxyFactory can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- -.... +---- Alternatively, a ProxyFactory can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myProxyFactory = new://ProxyFactory?type=ProxyFactory -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/queue-config.adoc ---------------------------------------------------------------------- diff --git a/docs/queue-config.adoc b/docs/queue-config.adoc index ac7dd91..22e4f13 100644 --- a/docs/queue-config.adoc +++ b/docs/queue-config.adoc @@ -9,21 +9,23 @@ A Queue can be declared via xml in the `/conf/tomee.xml` file or in a `WEB-INF/resources.xml` file using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- destination = -.... +---- Alternatively, a Queue can be declared via properties in the `/conf/system.properties` file or via Java VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myQueue = new://Resource?type=javax.jms.Queue myQueue.destination = -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style