Repository: tomee Updated Branches: refs/heads/master 22f7ae278 -> 66e0d6610
http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/remote-server.adoc ---------------------------------------------------------------------- diff --git a/docs/remote-server.adoc b/docs/remote-server.adoc index 8fdb19d..f20f724 100644 --- a/docs/remote-server.adoc +++ b/docs/remote-server.adoc @@ -30,25 +30,28 @@ So, here it is in short. Deploy your bean with the Deploy Tool: -.... +[source,java] +---- c:\openejb> openejb.bat deploy beans\myBean.jar -.... +---- See the openejbx30:deploy-tool.html[OPENEJBx30:Deploy Tool] documentation for more details on deploying beans. Start the server: -.... +[source,java] +---- c:\openejb> openejb.bat start -h 25.14.3.92 -p 4201 -.... +---- See the Remote Server command-line guide for more details on starting the Remote Server. Create an initial context in your client as such: -.... +[source,java] +---- Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "ejbd://25.14.3.92:4201"); @@ -56,7 +59,7 @@ p.put("java.naming.security.principal", "myuser"); p.put("java.naming.security.credentials", "mypass"); InitialContext ctx = new InitialContext(p); -.... +---- If you don't have any EJBs or clients to run, try the ubiquitous openejbx30:hello-world.html[Hello World] example. Add the following http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/resource-injection.adoc ---------------------------------------------------------------------- diff --git a/docs/resource-injection.adoc b/docs/resource-injection.adoc index 7b4824b..a70470c 100644 --- a/docs/resource-injection.adoc +++ b/docs/resource-injection.adoc @@ -62,10 +62,11 @@ environment entries at deployment time using deployment descriptor ==== @Resource annotation of a field -.... +[source,java] +---- @Resource int maxLineItems = 10; -.... +---- == Injection through a setter method (method-level injection) @@ -76,9 +77,10 @@ setters can be used as a way to inject environment entry values. You could look up the env-entry using JNDI lookup() method and the following name: -.... +[source,java] +---- java:comp/env/org.apache.openejb.examples.resource.InvoiceBean/maxLineItems -.... +---- The pattern is to combine the fully-qualified class name and the name of a instance field (or a name of the setter method without _set_ prefix @@ -86,27 +88,30 @@ and the first letter lowercased). ==== @Resource annotation of a setter method -.... +[source,java] +---- @Resource public void setMaxLineItems(int maxLineItems) { this.maxLineItems = maxLineItems; } -.... +---- ==== Using env-entry in ejb-jar.xml -.... +[source,java] +---- <env-entry> <description>The maximum number of line items per invoice.</description> <env-entry-name>org.apache.openejb.examples.injection.InvoiceBean/maxLineItems</env-entry-name> <env-entry-type>java.lang.Integer</env-entry-type> <env-entry-value>15</env-entry-value> </env-entry> -.... +---- ==== Using @Resource annotated env-entry -.... +[source,java] +---- public void addLineItem(LineItem item) throws TooManyItemsException { if (item == null) { throw new IllegalArgumentException("Line item must not be null"); @@ -119,7 +124,7 @@ public void addLineItem(LineItem item) throws TooManyItemsException { throw new TooManyItemsException("Number of items exceeded the maximum limit"); } } -.... +---- # JUnit Test @@ -129,18 +134,20 @@ then write our test methods. ==== Test fixture -.... +[source,java] +---- protected void setUp() throws Exception { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); properties.setProperty("openejb.deployments.classpath.include", ".*resource-injection.*"); initialContext = new InitialContext(properties); } -.... +---- ==== Test methods -.... +[source,java] +---- public void testAddLineItem() throws Exception { Invoice order = (Invoice)initialContext.lookup("InvoiceBeanBusinessRemote"); assertNotNull(order); @@ -152,7 +159,7 @@ public void testAddLineItem() throws Exception { fail("Test failed due to: " + tmie.getMessage()); } } -.... +---- # Running @@ -165,7 +172,8 @@ $ cd injection-of-env-entry $ mvn clean test ___________________________ -.... +[source,java] +---- ------------------------------------------------------- T E S T S ------------------------------------------------------- @@ -198,4 +206,4 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/resource-ref-for-datasource.adoc ---------------------------------------------------------------------- diff --git a/docs/resource-ref-for-datasource.adoc b/docs/resource-ref-for-datasource.adoc index c2e1ff9..55d9ab0 100644 --- a/docs/resource-ref-for-datasource.adoc +++ b/docs/resource-ref-for-datasource.adoc @@ -6,7 +6,8 @@ # Via annotation -.... +[source,java] +---- package org.superbiz.refs; import javax.annotation.Resource; @@ -30,14 +31,15 @@ public class MyDataSourceRefBean implements MyBeanInterface { DataSource barDataSource = (DataSource) context.lookup("java:comp/env/org.superbiz.refs.MyDataSourceRefBean/myBarDataSource"); } } -.... +---- == Via xml The above @Resource annotation usage is 100% equivalent to the following xml. -.... +[source,java] +---- <resource-ref> <res-ref-name>myFooDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> @@ -50,4 +52,4 @@ xml. <injection-target-name>myBarDataSource</injection-target-name> </injection-target> </resource-ref> -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/securing-a-web-service.adoc ---------------------------------------------------------------------- diff --git a/docs/securing-a-web-service.adoc b/docs/securing-a-web-service.adoc index 05cfa33..47c8e4a 100644 --- a/docs/securing-a-web-service.adoc +++ b/docs/securing-a-web-service.adoc @@ -86,13 +86,14 @@ content of this element is consistent with the overall structure of _openejb.xml_. The format for properties is the same as if you would use a common java property file. -.... +[source,java] +---- <properties> wss4j.in.action = UsernameToken wss4j.in.passwordType = PasswordDigest wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler </properties> -.... +---- In order to recover WSS4J properties both for input and output, we use naming conventions. Each property is made of .<in|out>.= @@ -102,7 +103,8 @@ For example : _wss4j.in.action = UsernameToken_ # Username Token (Password digest) example #### Excerpt from _openejb-jar.xml_. -.... +[source,java] +---- <openejb-jar xmlns="http://tomee.apache.org/xml/ns/openejb-jar-2.2"> <enterprise-beans> ... @@ -122,13 +124,14 @@ _openejb-jar.xml_. ... </enterprise-beans> </openejb-jar> -.... +---- ==== Request sent by the client. This request contains SOAP headers to manage security. You can see _UsernameToken_ tag from the WS-Security specification. -.... +[source,java] +---- POST /CalculatorImplUsernameTokenHashedPassword HTTP/1.1 Content-Type: text/xml; charset=UTF-8 SOAPAction: "" @@ -162,11 +165,12 @@ xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-s </ns1:sum> </soap:Body> </soap:Envelope> -.... +---- ==== The response returned from the server. -.... +[source,java] +---- HTTP/1.1 200 OK Content-Length: 200 Connection: close @@ -180,7 +184,7 @@ Server: OpenEJB/??? (unknown os) </ns1:sumResponse> </soap:Body> </soap:Envelope> -.... +---- # JAAS with WS-Security @@ -192,7 +196,8 @@ with 1 should be honoured. Here is a snippet from the webservice-ws-security example demonstrating this: -.... +[source,java] +---- public class CustomPasswordHandler implements CallbackHandler { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { @@ -229,7 +234,7 @@ public class CustomPasswordHandler implements CallbackHandler { } } } -.... +---- # Examples A full example (webservice-ws-security) is available with OpenEJB Examples. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/security-annotations.adoc ---------------------------------------------------------------------- diff --git a/docs/security-annotations.adoc b/docs/security-annotations.adoc index 11e27f1..2f86153 100644 --- a/docs/security-annotations.adoc +++ b/docs/security-annotations.adoc @@ -29,7 +29,8 @@ Allow anyone logged in or not to invoke 'svnCheckout'. These three examples are all equivalent. -.... +[source,java] +---- @Stateless public class OpenSourceProjectBean implements Project { @@ -57,7 +58,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow anyone logged in or not to invoke 'svnCheckout'. @@ -66,7 +67,8 @@ public class OpenSourceProjectBean implements Project { Restrict the 'svnCommit' method to only individuals logged in and part of the "committer" role. Note that more than one role can be listed. -.... +[source,java] +---- @Stateless @DeclareRoles({"committer"}) public class OpenSourceProjectBean implements Project { @@ -80,7 +82,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow only logged in users in the "committer" role to invoke 'svnCommit'. @@ -91,7 +93,8 @@ public class OpenSourceProjectBean implements Project { You need to update the @DeclareRoles when referencing roles via isCallerInRole(roleName). -.... +[source,java] +---- @Stateless @DeclareRoles({"committer", "contributor"}) public class OpenSourceProjectBean implements Project { @@ -109,14 +112,15 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- == Restricting all methods in a class Placing the annotation at the class level changes the default of PermitAll -.... +[source,java] +---- @Stateless @DeclareRoles({"committer"}) @RolesAllowed({"committer"}) @@ -134,7 +138,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow only logged in users in the "committer" role to invoke 'svnCommit', 'svnCheckout' or 'submitPatch'. @@ -145,7 +149,8 @@ Security annotations can be used at the class level and method level at the same time. These rules do not stack, so marking 'submitPatch' overrides the default of "committers". -.... +[source,java] +---- @Stateless @DeclareRoles({"committer", "contributor"}) @RolesAllowed({"committer"}) @@ -164,7 +169,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow only logged in users in the "committer" role to invoke 'svnCommit' or 'svnCheckout' @@ -177,7 +182,8 @@ When annotating a bean class with @RolesAllowed, the @PermitAll annotation becomes very useful on individual methods to open them back up again. -.... +[source,java] +---- @Stateless @DeclareRoles({"committer", "contributor"}) @RolesAllowed({"committer"}) @@ -197,7 +203,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow only logged in users in the "committer" role to invoke 'svnCommit'. @@ -211,7 +217,8 @@ The @DenyAll annotation can be used to restrict business interface access from anyone, logged in or not. The method is still invokable from within the bean class itself. -.... +[source,java] +---- @Stateless @DeclareRoles({"committer", "contributor"}) @RolesAllowed({"committer"}) @@ -236,7 +243,7 @@ public class OpenSourceProjectBean implements Project { return s; } } -.... +---- * Allow only logged in users in the "committer" role to invoke 'svnCommit'. @@ -252,7 +259,8 @@ and most callbacks. The following usages of @RolesAllowed have no effect. -.... +[source,java] +---- @Stateful @DecalredRoles({"committer"}) public class MyStatefulBean implements MyBusinessInterface { @@ -272,11 +280,12 @@ public class MyStatefulBean implements MyBusinessInterface { @AroundInvoke @RolesAllowed({"committer"}) public Object invoke(InvocationContext invocationContext) throws -.... +---- Exception \{ return invocationContext.proceed(); } -.... +[source,java] +---- @PostActivate @RolesAllowed({"committer"}) public void activated(){ @@ -289,4 +298,4 @@ Exception \{ return invocationContext.proceed(); } } } -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/security.adoc ---------------------------------------------------------------------- diff --git a/docs/security.adoc b/docs/security.adoc index 785c8d6..3f763b7 100644 --- a/docs/security.adoc +++ b/docs/security.adoc @@ -16,7 +16,8 @@ To make your program authenticate itself to the server, simply construct your InitialContext with the standard javax.naming.Context properties for user/pass info, which is: -.... +[source,java] +---- Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); props.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201"); @@ -26,7 +27,7 @@ props.setProperty("openejb.authentication.realmName", "PropertiesLogin"); // optional InitialContext ctx = new InitialContext(props); ctx.lookup(...); -.... +---- That will get you logged in and all your calls from that context should execute as you. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/securityservice-config.adoc ---------------------------------------------------------------------- diff --git a/docs/securityservice-config.adoc b/docs/securityservice-config.adoc index 3b6f6cd..b0566dc 100644 --- a/docs/securityservice-config.adoc +++ b/docs/securityservice-config.adoc @@ -10,21 +10,23 @@ A SecurityService can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- <SecurityService id="mySecurityService" type="SecurityService"> defaultUser = guest </SecurityService> -.... +---- Alternatively, a SecurityService can be declared via properties in the `<tomee-home>/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] +---- mySecurityService = new://SecurityService?type=SecurityService mySecurityService.defaultUser = guest -.... +---- 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/service-locator.adoc ---------------------------------------------------------------------- diff --git a/docs/service-locator.adoc b/docs/service-locator.adoc index e14857f..7fba3f7 100644 --- a/docs/service-locator.adoc +++ b/docs/service-locator.adoc @@ -20,7 +20,8 @@ examples start with this basic class that has a built-in lookup allowing for a common prefix to be optionally applied to the beginning of all lookup strings. -.... +[source,java] +---- public class MyLocator { private final Context context; @@ -44,12 +45,13 @@ public class MyLocator { } } } -.... +---- == Just the interface Usable with JNDI name formats ending in the full class name of the interface such as: - \{interfaceClass} -.... +[source,java] +---- public <T> T lookup(Class<T> type) { return (T) lookup(type.getName()); } @@ -58,17 +60,18 @@ public <T> T lookup(Class<T> type) { MyLocator locator = new MyLocator(); Widget widget = locator.lookup(Widget.class); -.... +---- Or with a common prefix or with a common prefix supplied in constructor such as: - \{moduleId}/\{interfaceClass} - ejb/\{moduleId}/\{interfaceClass} -.... +[source,java] +---- MyLocator locator = new MyLocator("ejb/superbiz"); Widget widget = locator.lookup(Widget.class); Store store = locator.lookup(Store.class); -.... +---- == Interface class and a prefix @@ -89,11 +92,12 @@ Or with a common prefix or with a common prefix supplied in constructor such as: - \{moduleId}/\{ejbName}/\{interfaceClass} - ejb/\{moduleId}/\{deploymentId}/\{interfaceClass} -.... +[source,java] +---- MyLocator locator = new MyLocator("accountingApp"); Widget widget = locator.lookup("RedWidgetBean", Widget.class); Store store = locator.lookup("StoreBean", Store.class); -.... +---- == Interface class and ejb class @@ -107,7 +111,8 @@ class. Works with: - \{interfaceClass}/\{ejbClass} -.... +[source,java] +---- public <T> T lookup(Class<T> type, Class ejbClass) { return (T) lookup(type.getName() + "/" + ejbClass.getName()); } @@ -116,17 +121,18 @@ public <T> T lookup(Class<T> type, Class ejbClass) { MyLocator locator = new MyLocator(); Widget widget = locator.lookup(Widget.class, BlueWidgetBean.class); -.... +---- Or with a common prefix or with a common prefix supplied in constructor such as: - \{moduleId}/\{interfaceClass}/\{ejbClass} - ejb/\{moduleId}/\{interfaceClass}/\{ejbClass} -.... +[source,java] +---- MyLocator locator = new MyLocator("ejb/purchasingApp"); Widget widget = locator.lookup(Widget.class, RedWidgetBean.class); Store store = locator.lookup(Store.class, StoreBean.class); -.... +---- == Interface class and ejb class with simple names @@ -134,26 +140,29 @@ Similar to the above example but using the simple name of the classes resulting in a JNDI tree that's a bit more human readable. - \{ejbClass.simpleName}/\{interfaceClass.simpleName} -.... +[source,java] +---- public <T> T lookup(Class ejbClass, Class<T> type) { return (T) lookup(ejbClass.getSimpleName() + "" + type.getSimpleName()); } -.... +---- and -.... +[source,java] +---- MyLocator locator = new MyLocator(); Widget widget = locator.lookup(RedWidgetBean.class, Widget.class); -.... +---- Or with a common prefix or with a common prefix supplied in constructor such as: - \{moduleId}/\{ejbClass.simpleName}/\{interfaceClass.simpleName} - ejb/\{moduleId}/\{ejbClass.simpleName}/\{interfaceClass.simpleName} -.... +[source,java] +---- MyLocator locator = new MyLocator("shippingApp"); Widget widget = locator.lookup(GreenWidgetBean.class, Widget.class); Store store = locator.lookup(SuperStoreBean.class, Store.class); -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/singleton-beans.adoc ---------------------------------------------------------------------- diff --git a/docs/singleton-beans.adoc b/docs/singleton-beans.adoc index 906b897..fcee390 100644 --- a/docs/singleton-beans.adoc +++ b/docs/singleton-beans.adoc @@ -68,7 +68,8 @@ The locking modes of Container-Managed Concurrency map directly to the _http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReadWriteLock.html[java.util.concurrent.ReadWriteLock] _ API which looks like this: -.... +[source,java] +---- public interface ReadWriteLock { /** * Returns the lock used for reading. @@ -84,7 +85,7 @@ public interface ReadWriteLock { */ Lock writeLock(); } -.... +---- Literally 100% of the Singleton locking we're talking about is taken from this interface and its javadoc is a great source of information. @@ -113,7 +114,8 @@ the http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/Lock.html[java.util.concurrent.locks.Lock] interface. -.... +[source,java] +---- public interface Lock { /** @@ -138,7 +140,7 @@ public interface Lock { boolean tryLock(long time, TimeUnit unit) throws InterruptedException; } -.... +---- In the event it is not possible to acquire the lock a _javax.ejb.ConcurrentAccessException_ or @@ -178,13 +180,14 @@ the _@DependsOn_ annotation which can be used to list the names of Singleton beans that must be started before the Singleton bean using the annotation. -.... +[source,java] +---- @DependsOn({"SingletonB", "SingletonC"}) @Singleton public class SingletonA { } -.... +---- Circular references are not supported. If BeanA uses @DependsOn to point to BeanB and BeanB also uses @DependsOn to point at BeanA, the result is @@ -210,7 +213,8 @@ needed. Singletons can be declared in the ejb-jar.xml as follows: -.... +[source,java] +---- <ejb-jar> <enterprise-beans> <session> @@ -225,4 +229,4 @@ Singletons can be declared in the ejb-jar.xml as follows: </session> </enterprise-beans> </ejb-jar> -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/singletoncontainer-config.adoc ---------------------------------------------------------------------- diff --git a/docs/singletoncontainer-config.adoc b/docs/singletoncontainer-config.adoc index 353c841..1374736 100644 --- a/docs/singletoncontainer-config.adoc +++ b/docs/singletoncontainer-config.adoc @@ -10,11 +10,12 @@ A SingletonContainer can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- <Container id="mySingletonContainer" type="SINGLETON"> accessTimeout = 30 seconds </Container> -.... +---- Alternatively, a SingletonContainer can be declared via properties in the `<tomee-home>/conf/system.properties` file or via Java @@ -22,10 +23,11 @@ VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- mySingletonContainer = new://Container?type=SINGLETON mySingletonContainer.accessTimeout = 30 seconds -.... +---- 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/spring-and-openejb-3.0.adoc ---------------------------------------------------------------------- diff --git a/docs/spring-and-openejb-3.0.adoc b/docs/spring-and-openejb-3.0.adoc index 563fe25..e73aaef 100644 --- a/docs/spring-and-openejb-3.0.adoc +++ b/docs/spring-and-openejb-3.0.adoc @@ -11,7 +11,8 @@ If you wish to use OpenEJB inside Spring you can do so pretty easily. Include OpenEJB and its dependencies in your classpath as you would in a plain embedded scenario then add a custom factory like the following: -.... +[source,java] +---- public class OpenEjbFactoryBean implements org.springframework.beans.factory.FactoryBean { private Properties properties = new Properties(); @@ -44,11 +45,12 @@ public class OpenEjbFactoryBean implements org.springframework.beans.factory.Fac return true; } } -.... +---- And include that at the top of your spring xml file as follows: -.... +[source,java] +---- <bean id="OpenEjbContext" class="org.acme.OpenEjbFactoryBean"> <property name="jndiEnvironment"> <props> @@ -60,7 +62,7 @@ And include that at the top of your spring xml file as follows: </props> </property> </bean> -.... +---- The value of is meant to be illustrative of the kinds of properties you can pass into OpenEJB. It's possible to create any number of @@ -85,7 +87,8 @@ pull the EntityManager out and return it OrangeUnitBean.java -.... +[source,java] +---- /* * OpenEJB will automatically find this bean. Just put it in the same jar * that your META-INF/persistence.xml file is located in and make sure that @@ -102,22 +105,24 @@ public class OrangeUnitBean implements OrangeUnitLocal { return entityManager; } } -.... +---- OrangeUnitLocal.java -.... +[source,java] +---- /** * The local interface for the OrangeUnitBean */ public interface OrangeUnitLocal { public EntityManager getEntityManager(); } -.... +---- OrangeUnitFactoryBean.java -.... +[source,java] +---- /** * This factory bean will lookup the OrangeUnitBean using the javax.naming.Context * that is created via the OpenEjbFactoryBean above. It will simply grab the EntityManager @@ -152,20 +157,22 @@ public class OrangeUnitFactoryBean implements org.springframework.beans.factory. return true; } } -.... +---- The factory bean would then be declared in your spring xml file as follows: -.... +[source,java] +---- <bean id="OrangeUnit" class="org.acme.OrangeUnitFactoryBean"> <property name="context" ref="OpenEjbContext"> </bean> -.... +---- The EntityManager can then easily be consumed by a spring bean. -.... +[source,java] +---- public class SomePojo { private EntityManager entityManager; @@ -176,22 +183,24 @@ public class SomePojo { ... } -.... +---- In the spring xml -.... +[source,java] +---- <bean id="SomePojo" class="org.acme.SomePojo"> <property name="entityManager" ref="OrangeUnit"> </bean> -.... +---- Here's what all three declarations would look like together in your spring xml: Spring bean definitions combined -.... +[source,java] +---- <bean id="OpenEjbContext" class="org.acme.OpenEjbFactoryBean"> <property name="jndiEnvironment"> <props> @@ -211,7 +220,7 @@ Spring bean definitions combined <bean id="SomePojo" class="org.acme.SomePojo"> <property name="entityManager" ref="OrangeUnit"> </bean> -.... +---- {title= Some more useful info.} Here is a bunch of links suggested by a user. If anybody has time to go through them and write a doc, that http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/spring-ejb-and-jpa.adoc ---------------------------------------------------------------------- diff --git a/docs/spring-ejb-and-jpa.adoc b/docs/spring-ejb-and-jpa.adoc index 7ff90c0..9b20600 100644 --- a/docs/spring-ejb-and-jpa.adoc +++ b/docs/spring-ejb-and-jpa.adoc @@ -140,13 +140,14 @@ $ mvn clean install Which should create output like the following. -.... +[source,java] +---- ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.superbiz.spring.MoviesTest log4j:WARN No appenders could be found for logger -.... +---- (org.springframework.context.support.ClassPathXmlApplicationContext). log4j:WARN Please initialize the log4j system properly. Apache OpenEJB @@ -188,8 +189,9 @@ Exported EJB CineplexImpl with interface org.superbiz.spring.Cineplex to Spring bean CineplexImplLocal Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.141 sec -.... +[source,java] +---- Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/startup.adoc ---------------------------------------------------------------------- diff --git a/docs/startup.adoc b/docs/startup.adoc index efd5835..f33a61a 100644 --- a/docs/startup.adoc +++ b/docs/startup.adoc @@ -94,9 +94,10 @@ That's it. The ejbd will start up and bind to IP 127.0.0.1 and port The following properties would then be used to get an InitialContext from the Remote Server. -.... +[source,java] +---- java.naming.factory.initial = -.... +---- org.apache.openejb.client.RemoteInitialContextFactory java.naming.provider.url = ejbd://127.0.0.1:4201 @@ -142,9 +143,10 @@ will start up and bind to IP 10.45.67.8 and port 4201. The following properties would then be used to get an InitialContext from the EJBd Server Service. -.... +[source,java] +---- java.naming.factory.initial = -.... +---- org.apache.openejb.client.RemoteInitialContextFactory java.naming.provider.url = ejbd://10.45.67.8:4201 @@ -158,9 +160,10 @@ _openejb start -Dejbd.bind=myhost.foo.com_ The following properties would then be used to get an InitialContext from the Remote Server. -.... +[source,java] +---- java.naming.factory.initial = -.... +---- org.apache.openejb.client.RemoteInitialContextFactory java.naming.provider.url = ejbd://myhost.foo.com:4201 @@ -183,9 +186,10 @@ The server will start up and bind to IP 127.0.0.1 and port 8765. The following properties would then be used to get an InitialContext from the Remote Server. -.... +[source,java] +---- java.naming.factory.initial = -.... +---- org.apache.openejb.client.RemoteInitialContextFactory java.naming.provider.url = ejbd://127.0.0.1:8765 @@ -200,9 +204,10 @@ The server will start up and the EJB over HTTP service will bind to IP The following properties would then be used to get an InitialContext from the HTTP/Remote Server. -.... +[source,java] +---- java.naming.factory.initial = -.... +---- org.apache.openejb.client.RemoteInitialContextFactory java.naming.provider.url = http://127.0.0.1:8888/openejb @@ -254,12 +259,13 @@ starts. Once you start OpenEJB using the _openejb start_ command the following output will be seen on the console -.... +[source,java] +---- Apache OpenEJB 3.0 build: 20070825-01:10 http://tomee.apache.org/ OpenEJB ready. [OPENEJB:init] -.... +---- OpenEJB Remote Server ** Starting Services ** NAME IP PORT httpejbd 0.0.0.0 4204 telnet 0.0.0.0 4202 ejbd 0.0.0.0 4201 hsql 0.0.0.0 9001 http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/statefulcontainer-config.adoc ---------------------------------------------------------------------- diff --git a/docs/statefulcontainer-config.adoc b/docs/statefulcontainer-config.adoc index c54da1b..371edfb 100644 --- a/docs/statefulcontainer-config.adoc +++ b/docs/statefulcontainer-config.adoc @@ -10,7 +10,8 @@ A StatefulContainer can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- <Container id="myStatefulContainer" type="STATEFUL"> accessTimeout = 30 seconds bulkPassivate = 100 @@ -20,14 +21,15 @@ body are optional. passivator = org.apache.openejb.core.stateful.SimplePassivater timeOut = 20 </Container> -.... +---- Alternatively, a StatefulContainer can be declared via properties in the `<tomee-home>/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] +---- myStatefulContainer = new://Container?type=STATEFUL myStatefulContainer.accessTimeout = 30 seconds myStatefulContainer.bulkPassivate = 100 @@ -36,7 +38,7 @@ myStatefulContainer.capacity = 1000 myStatefulContainer.frequency = 60 myStatefulContainer.passivator = org.apache.openejb.core.stateful.SimplePassivater myStatefulContainer.timeOut = 20 -.... +---- 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/statelesscontainer-config.adoc ---------------------------------------------------------------------- diff --git a/docs/statelesscontainer-config.adoc b/docs/statelesscontainer-config.adoc index a923fa1..da246b6 100644 --- a/docs/statelesscontainer-config.adoc +++ b/docs/statelesscontainer-config.adoc @@ -10,7 +10,8 @@ A StatelessContainer can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- <Container id="myStatelessContainer" type="STATELESS"> accessTimeout = 30 seconds callbackThreads = 5 @@ -26,7 +27,7 @@ body are optional. strictPooling = true sweepInterval = 5 minutes </Container> -.... +---- Alternatively, a StatelessContainer can be declared via properties in the `<tomee-home>/conf/system.properties` file or via Java @@ -34,7 +35,8 @@ VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myStatelessContainer = new://Container?type=STATELESS myStatelessContainer.accessTimeout = 30 seconds myStatelessContainer.callbackThreads = 5 @@ -49,7 +51,7 @@ myStatelessContainer.replaceAged = true myStatelessContainer.replaceFlushed = false myStatelessContainer.strictPooling = true myStatelessContainer.sweepInterval = 5 minutes -.... +---- Properties and xml can be mixed. Properties will override the xml allowing for easy configuration change without the need for $\{} style @@ -290,12 +292,13 @@ is used in creating the offset and allows the spreading to push the initial ages into the future or into the past. The pool is filled at startup as follows: -.... +[source,java] +---- for (int i = 0; i < poolMin; i++) { long ageOffset = (maxAge / poolMin * i * maxAgeOffset) % maxAge; pool.add(new Bean(), ageOffset)); } -.... +---- The default `MaxAgeOffset` is -1 which causes the initial instances in the pool to live a bit longer before expiring. As a concrete example, @@ -385,7 +388,8 @@ A bean may flush its pool by casting the `SessionContext` to `Flushable` and calling `flush()`. See `SweepInterval` for details on how flush is performed. -.... +[source,java] +---- import javax.annotation.Resource; import javax.ejb.SessionContext; import javax.ejb.Stateless; @@ -401,7 +405,7 @@ public class MyBean { ((Flushable) sessionContext).flush(); } } -.... +---- == strictPooling http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/system-properties.adoc ---------------------------------------------------------------------- diff --git a/docs/system-properties.adoc b/docs/system-properties.adoc index f61ea79..5af90e1 100644 --- a/docs/system-properties.adoc +++ b/docs/system-properties.adoc @@ -17,13 +17,14 @@ of the format: ..where id is the value in the config file for example: -.... +[source,java] +---- <Connector id="mysql"> JdbcDriver com.mysql.jdbc.Driver JdbcUrl jdbc:mysql://localhost/test UserName test </Connector> -.... +---- Could be overridden as follows via system properties on the command line: @@ -40,7 +41,8 @@ fashion as things in the openejb.xml file. For example, when OpenEJB starts it prints out the following: -.... +[source,java] +---- ** Starting Services ** NAME IP PORT httpejbd 0.0.0.0 4204 @@ -50,7 +52,7 @@ For example, when OpenEJB starts it prints out the following: activemq 127.0.0.1 4206 derbynet 0.0.0.0 4205 admin thread 0.0.0.0 4200 -.... +---- Each of those has the same standard xinet.d-like properties which can also be configured as such: @@ -63,6 +65,7 @@ one of the following: bind, port, threads, disabled, only_from. So to set the address and port the ejbd service will bind to, simply specify this on the command line: -.... +[source,java] +---- ./bin/openejb start -Dejbd.bind=192.168.1.12 -Dejbd.port=9988 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/telnet-console.adoc ---------------------------------------------------------------------- diff --git a/docs/telnet-console.adoc b/docs/telnet-console.adoc index 21e6347..4559b77 100644 --- a/docs/telnet-console.adoc +++ b/docs/telnet-console.adoc @@ -14,14 +14,15 @@ _____________________ $ ./bin/openejb start _____________________ -.... +[source,java] +---- OPENEJB_HOME=/Users/dblevins/Desktop/openejb-1.0 OpenEJB 1.0 build: 20060226-1701 http://www.openejb.org resources 1 OpenEJB ready. [init] -.... +---- OpenEJB Remote Server ** Starting Services ** NAME IP PORT + webadmin 0.0.0.0 4203 + @@ -37,18 +38,20 @@ _______________________ $ telnet localhost 4202 _______________________ -.... +[source,java] +---- Trying ::1... Connected to localhost. Escape character is '^] -.... +---- '. OpenEJB Remote Server Console type 'help' for a list of commands [openejb] $ help stop exit system version lookup help [openejb] $ system Containers: Default BMP Container Default CMP Container Default Stateful Container Default Stateless Container -.... +[source,java] +---- Deployments: client/tests/stateful/EncBean client/tests/entity/cmp/RMI-over-IIOP/EJBHome @@ -87,7 +90,7 @@ Deployments: client/tests/entity/cmp/allowed_operations/EntityHome client/tests/stateless/RMI-over-IIOP/EJBHome [openejb] -.... +---- $ exit Connection closed by foreign host. @@ -102,14 +105,15 @@ ____________________________ $ cat conf/telnet.properties ____________________________ -.... +[source,java] +---- server = org.openejb.server.telnet.TelnetServer bind = 127.0.0.1 port = 4202 disabled = false threads = 5 # only_from = 192.168.1.123 -.... +---- You can change the IP, port, and even the number of threads allowed to concurrently access the Telnet service via this file. @@ -118,9 +122,10 @@ concurrently access the Telnet service via this file. Simply edit the config file and set 'disabled' to true -.... +[source,java] +---- disabled = true -.... +---- Then restart OpenEJB. @@ -136,23 +141,25 @@ rest of the file is a direct copy of the xinet.d syntax for HBA. For an example to restrict access to the localhost, you could configure the Telnet Service like this: -.... +[source,java] +---- server = org.openejb.server.telnet.TelnetServer bind = 127.0.0.1 port = 4202 disabled = false threads = 5 only_from = localhost -.... +---- If you wanted to restrict access to localhost _and_ say the hosts 192.168.1.207 and 192.168.1.16, you can simply add them to the list. -.... +[source,java] +---- server = org.openejb.server.telnet.TelnetServer bind = 127.0.0.1 port = 4202 disabled = false threads = 5 only_from = localhost, 192.168.1.207, 192.168.1.16 -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tip-concurrency.adoc ---------------------------------------------------------------------- diff --git a/docs/tip-concurrency.adoc b/docs/tip-concurrency.adoc index 62213f1..5acf195 100644 --- a/docs/tip-concurrency.adoc +++ b/docs/tip-concurrency.adoc @@ -8,7 +8,8 @@ If for whatever reason you want to define the global default concurrency add this to your META-INF/ejb-jar.xml: -.... +[source,java] +---- <?xml version="1.0"?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" @@ -23,10 +24,11 @@ add this to your META-INF/ejb-jar.xml: </session> <enterprise-beans> </ejb-jar> -.... +---- You may need to create the file if it does not exist. -.... +[source,java] +---- src/main/resources/META-INF/ejb-jar.xml -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tip-jersey-client.adoc ---------------------------------------------------------------------- diff --git a/docs/tip-jersey-client.adoc b/docs/tip-jersey-client.adoc index 9fce1d9..fec76e8 100644 --- a/docs/tip-jersey-client.adoc +++ b/docs/tip-jersey-client.adoc @@ -8,13 +8,14 @@ If you have an application that uses jersey-client in any way then it may fail with an error along the lines of: -.... +[source,java] +---- Caused by: java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java) at org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java) ... 34 more -.... +---- This is due to the fact that the jersey-core.jar contains some classes that should not be deployed as part of a javaEE application. For @@ -25,9 +26,10 @@ You could switch to using the http://cxf.apache.org/[Apache CXF Client], which is what we would recommend. If you really want to keep Jersey then you can use set the following property in your _[TomEE].properties_ -.... +[source,java] +---- openejb.api.javax.ws.rs.Path.validation=false -.... +---- This will then allow Jersey classes to be loaded by TomEE (After a restart). http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tip-weblogic.adoc ---------------------------------------------------------------------- diff --git a/docs/tip-weblogic.adoc b/docs/tip-weblogic.adoc index 5a2ba92..b7ed813 100644 --- a/docs/tip-weblogic.adoc +++ b/docs/tip-weblogic.adoc @@ -7,7 +7,8 @@ How to lookup WebLogic Objects from within a TomEE context: -.... +[source,java] +---- Hashtable<String, String> props = new Hashtable<String, String>(); props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(javax.naming.Context.URL_PKG_PREFIXES, "weblogic.jndi.factories"); @@ -15,7 +16,7 @@ props.put("java.naming.provider.url", "t3://your.host.name:7023"); Context ctx = new InitialContext(props); IService s = (IService) ctx.lookup("java:global.com.test.ServiceImpl!com.test.IService"); -.... +---- Obviously you will need to change the actual lookup to your specific object, but you get the idea. http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-and-eclipse.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-and-eclipse.adoc b/docs/tomee-and-eclipse.adoc index a12743d..6468adf 100644 --- a/docs/tomee-and-eclipse.adoc +++ b/docs/tomee-and-eclipse.adoc @@ -110,7 +110,8 @@ hot deployment alter this value to true and restart Tomee. This is the relevant snippet of the web.xml file. -.... +[source,java] +---- <servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> @@ -121,7 +122,7 @@ This is the relevant snippet of the web.xml file. </init-param> .... </servlet> -.... +---- == How to use JULI for TomEE in WTP? @@ -129,10 +130,11 @@ It seems that WTP doesn't manage correctly Tomcat logging configuration (which needs to be done through system properties). A quick workaround is to add these properties manually: -.... +[source,java] +---- -Djava.util.logging.config.file="<tomee>/conf/logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -.... +---- More information on: http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-and-hibernate.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-and-hibernate.adoc b/docs/tomee-and-hibernate.adoc index c2b4cb4..98965b6 100644 --- a/docs/tomee-and-hibernate.adoc +++ b/docs/tomee-and-hibernate.adoc @@ -32,7 +32,8 @@ whichever JPA provider it needs. The following is an example of a fairly common `persistence.xml` for Hibernate -.... +[source,java] +---- <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -49,15 +50,16 @@ Hibernate </properties> </persistence-unit> </persistence> -.... +---- Note, TomEE will automatically add the following property unless it is explicitly configured: -.... +[source,java] +---- <property name="hibernate.transaction.manager_lookup_class" value="org.apache.openejb.hibernate.TransactionManagerLookup"/> -.... +---- == Server Configuration @@ -120,7 +122,8 @@ be sure to put your Database JDBC driver in `<tomee-home>/lib`. The actual Maven dependencies for your project can be added in the usual way: -.... +[source,java] +---- <!-- Hibernate --> <dependency> <groupId>antlr</groupId> @@ -167,4 +170,4 @@ way: <artifactId>javassist</artifactId> <version>3.15.0-GA</version> </dependency> -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-and-security.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-and-security.adoc b/docs/tomee-and-security.adoc index da76d52..1a2072b 100644 --- a/docs/tomee-and-security.adoc +++ b/docs/tomee-and-security.adoc @@ -40,15 +40,17 @@ To put it short, * TomEE uses Tomcat's Security Realm * .... Extra TomEE layer adds support for JAAS JACC WS Security -.... +[source,java] +---- * .... Supports any org.apache.catalina.Realm implementation -.... +---- * .... E.g. add users to $CATALINA_BASE/conf/tomcat-users.xml -.... +[source,java] +---- * .... Alternatively use login.config to provide your own security module -.... +---- ####See Also: link:tomee-jaas.html[TomEE-and-JAAS] http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-jaas.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-jaas.adoc b/docs/tomee-jaas.adoc index 40965f4..49aabfb 100644 --- a/docs/tomee-jaas.adoc +++ b/docs/tomee-jaas.adoc @@ -21,13 +21,15 @@ Note: only the first one will be used. Add to your `CATALINA_OPTS` the `java.security.auth.login.config` system property: -.... +[source,java] +---- -Djava.security.auth.login.config=$CATALINA_BASE/conf/login.config -.... +---- Configure your realm in server.xml file -.... +[source,java] +---- <?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.tomee.loader.OpenEJBListener" /> @@ -50,18 +52,19 @@ Configure your realm in server.xml file </Engine> </Service> </Server> -.... +---- Configure your `login.config` file -.... +[source,java] +---- PropertiesLogin { org.apache.openejb.core.security.jaas.PropertiesLoginModule required Debug=false UsersFile="users.properties" GroupsFile="groups.properties"; }; -.... +---- Configure your login module specifically (`users.properties` for snippets of this page for instance). @@ -70,18 +73,20 @@ Place `users.properties` and `groups.properties` files in `$CATALINA_BASE/conf/` folder. `users.properties` file contains user name and associated password entries, ex.: -.... +[source,java] +---- me=password tomee=tomee -.... +---- `groups.properties` file specifies groups and their users, ex.: -.... +[source,java] +---- my-role=me manager-gui=tomee,me tomee-admin=tomee -.... +---- *NOTE*: `users.properties` and `groups.properties` file names and file location are fixed. If other names are used, the files must be placed in http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-logging-in-eclipse.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-logging-in-eclipse.adoc b/docs/tomee-logging-in-eclipse.adoc index 94e700d..9a4e1ca 100644 --- a/docs/tomee-logging-in-eclipse.adoc +++ b/docs/tomee-logging-in-eclipse.adoc @@ -9,10 +9,11 @@ It seems that WTP doesn't manage correctly Tomcat logging configuration (which needs to be done through system properties). A quick workaround is to add these properties manually: -.... +[source,java] +---- -Djava.util.logging.config.file="<tomee>/conf/logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -.... +---- More information on: http://wiki.eclipse.org/WTP_Tomcat_FAQ#How_do_I_enable_the_JULI_logging_in_a_Tomcat_5.5_Server_instance.3F http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-maven-plugin.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-maven-plugin.adoc b/docs/tomee-maven-plugin.adoc index 6c53fcf..2f514d0 100644 --- a/docs/tomee-maven-plugin.adoc +++ b/docs/tomee-maven-plugin.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] +---- <plugins> <plugin> <groupId>org.apache.openejb.maven</groupId> @@ -27,7 +28,7 @@ Simply add the following to the , and optionally the ), section of your </configuration> </plugin> </plugins> -.... +---- ###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] +---- <plugin> <groupId>org.apache.openejb.maven</groupId> <artifactId>tomee-maven-plugin</artifactId> @@ -141,11 +143,12 @@ deploy apps then run the server. </libs> </configuration> </plugin> -.... +---- ###Auto Reloading Example -.... +[source,java] +---- <plugin> <groupId>org.apache.openejb.maven</groupId> <artifactId>tomee-maven-plugin</artifactId> @@ -159,7 +162,7 @@ deploy apps then run the server. <reloadOnUpdate>true</reloadOnUpdate> </configuration> </plugin> -.... +---- The Synchronization block supports the following configuration options: http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-mp-getting-started.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-mp-getting-started.adoc b/docs/tomee-mp-getting-started.adoc index af24394..7bf3e4b 100644 --- a/docs/tomee-mp-getting-started.adoc +++ b/docs/tomee-mp-getting-started.adoc @@ -12,14 +12,15 @@ described link:maven/index.html[here] You will likely need the full Java EE API added to your pom file: -.... +[source,java] +---- <dependency> <groupId>org.apache.openejb</groupId> <artifactId>javaee-api</artifactId> <version>6.0-6</version> <scope>provided</scope> </dependency> -.... +---- The simplest path is to allow Maven to create an example project for you. Even if you have an existing project you can always use the @@ -35,9 +36,10 @@ application with TomEE. For example, if current version of the archetype is '1.7.1', then the required command to generate an application would be: -.... +[source,java] +---- mvn archetype:generate -DarchetypeGroupId=org.apache.openejb.maven -DarchetypeArtifactId=tomee-webapp-archetype -DarchetypeVersion=1.7.1 -.... +---- The first time you run this command maven downloads the archetype and some parts related to it. Afterwards you see a prompt which allows you @@ -46,7 +48,8 @@ application. If you are using 'tomee' as groupId, 'tomee-demo' as artifactId, '1.0' as version and 'myapp' as package, your console should show something like: -.... +[source,java] +---- Define value for property 'groupId': : tomee Define value for property 'artifactId': : tomee-demo Define value for property 'version': 1.0-SNAPSHOT: : 1.0 @@ -59,25 +62,27 @@ package: myapp ... [INFO] BUILD SUCCESS ... -.... +---- Afterwards you see a new folder with the name you used for the artifactId (in the previous example 'tomee-demo'). For starting the application you have to change the current directory to the directory of the generated application: -.... +[source,java] +---- cd tomee-demo -.... +---- ###Starting a TomEE-Project with Maven With using the archetype everything you need is in place already. So you just have to start TomEE with: -.... +[source,java] +---- mvn package tomee:run -.... +---- The first time you run this command takes a bit longer, because maven has to download e.g. TomEE. Once those parts are downloaded, starting @@ -92,6 +97,7 @@ as a web-archive ('ROOT.war'). The context-paths of the deployed application is ROOT. In our example the generated application contains a servlet mapped to '/index'. So you can access it via: -.... +[source,java] +---- http://localhost:8080/index -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/tomee-webapp.adoc ---------------------------------------------------------------------- diff --git a/docs/tomee-webapp.adoc b/docs/tomee-webapp.adoc index 87aad26..fa37819 100644 --- a/docs/tomee-webapp.adoc +++ b/docs/tomee-webapp.adoc @@ -44,7 +44,8 @@ The only loss of functionality would be the ability to remotely execute EJBs over HTTP. However this can easily be added to a different webapp like so: -.... +[source,java] +---- <servlet> <servlet-name>ServerServlet</servlet-name> <servlet-class>org.apache.openejb.server.httpd.ServerServlet</servlet-class> @@ -54,12 +55,13 @@ like so: <servlet-name>ServerServlet</servlet-name> <url-pattern>/myejbs/*</url-pattern> </servlet-mapping> -.... +---- Then you can create an `InitialContext` that points to that webapp like so: -.... +[source,java] +---- Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "http://127.0.0.1:8080/mywebapp/myejbs"); @@ -70,4 +72,4 @@ p.put("java.naming.security.credentials", "mypass"); InitialContext ctx = new InitialContext(p); MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote"); -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/topic-config.adoc ---------------------------------------------------------------------- diff --git a/docs/topic-config.adoc b/docs/topic-config.adoc index de270aa..fd673fa 100644 --- a/docs/topic-config.adoc +++ b/docs/topic-config.adoc @@ -9,21 +9,23 @@ A Topic can be declared via xml in the `<tomee-home>/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] +---- <Resource id="myTopic" type="javax.jms.Topic"> destination = </Resource> -.... +---- Alternatively, a Topic can be declared via properties in the `<tomee-home>/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] +---- myTopic = new://Resource?type=javax.jms.Topic myTopic.destination = -.... +---- 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/transaction-annotations.adoc ---------------------------------------------------------------------- diff --git a/docs/transaction-annotations.adoc b/docs/transaction-annotations.adoc index ac4704b..0584e91 100644 --- a/docs/transaction-annotations.adoc +++ b/docs/transaction-annotations.adoc @@ -117,7 +117,8 @@ state. == On Methods -.... +[source,java] +---- @Stateless public static class MyBean implements MyBusinessInterface { @@ -130,14 +131,15 @@ public static class MyBean implements MyBusinessInterface { return s; } } -.... +---- * _codeRed_ will be invoked with the attribute of _MANDATORY_ * _codeBlue_ will be invoked with the default attribute of _REQUIRED_ == On Classes -.... +[source,java] +---- @Stateless @TransactionAttribute(TransactionAttributeType.MANDATORY) public static class MyBean implements MyBusinessInterface { @@ -150,14 +152,15 @@ public static class MyBean implements MyBusinessInterface { return s; } } -.... +---- * _codeRed_ and _codeBlue_ will be invoked with the attribute of _MANDATORY_ == Mixed on classes and methods -.... +[source,java] +---- @Stateless @TransactionAttribute(TransactionAttributeType.SUPPORTS) public static class MyBean implements MyBusinessInterface { @@ -176,7 +179,7 @@ public static class MyBean implements MyBusinessInterface { return s; } } -.... +---- * _codeRed_ will be invoked with the attribute of _NEVER_ * _codeBlue_ will be invoked with the attribute of _SUPPORTS_ @@ -189,7 +192,8 @@ methods and most callbacks. The following usages of @TransactionAttribute have no effect. -.... +[source,java] +---- @Stateful public class MyStatefulBean implements MyBusinessInterface { @@ -223,4 +227,4 @@ public class MyStatefulBean implements MyBusinessInterface { } } -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/transactionmanager-config.adoc ---------------------------------------------------------------------- diff --git a/docs/transactionmanager-config.adoc b/docs/transactionmanager-config.adoc index a69194d..2b35afc 100644 --- a/docs/transactionmanager-config.adoc +++ b/docs/transactionmanager-config.adoc @@ -10,7 +10,8 @@ A TransactionManager can be declared via xml in the using a declaration like the following. All properties in the element body are optional. -.... +[source,java] +---- <TransactionManager id="myTransactionManager" type="TransactionManager"> adler32Checksum = true bufferSizeKb = 32 @@ -27,7 +28,7 @@ body are optional. threadsWaitingForceThreshold = -1 txRecovery = false </TransactionManager> -.... +---- Alternatively, a TransactionManager can be declared via properties in the `<tomee-home>/conf/system.properties` file or via Java @@ -35,7 +36,8 @@ VirtualMachine `-D` properties. The properties can also be used when embedding TomEE via the `javax.ejb.embeddable.EJBContainer` API or `InitialContext` -.... +[source,java] +---- myTransactionManager = new://TransactionManager?type=TransactionManager myTransactionManager.adler32Checksum = true myTransactionManager.bufferSizeKb = 32 @@ -51,7 +53,7 @@ myTransactionManager.maxLogFiles = 2 myTransactionManager.minBuffers = 4 myTransactionManager.threadsWaitingForceThreshold = -1 myTransactionManager.txRecovery = false -.... +---- 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/understanding-callbacks.adoc ---------------------------------------------------------------------- diff --git a/docs/understanding-callbacks.adoc b/docs/understanding-callbacks.adoc index b5b9919..89792df 100644 --- a/docs/understanding-callbacks.adoc +++ b/docs/understanding-callbacks.adoc @@ -16,7 +16,8 @@ have an AroundInvoke method and so on. So the following is legal. -.... +[source,java] +---- public class Plant { @AroundInvoke public Object a(InvocationContext ctx) throws Exception { @@ -46,7 +47,7 @@ public class Apple extends Fruit implements AppleLocal { public interface AppleLocal { public String grow(); } -.... +---- The result is that when the "grow" method on AppleLocal (and consequently on Apple) is invoked, the container will first invoke the @@ -57,7 +58,8 @@ are ways to effectively shut off the callbacks, including AroundInvoke, of a parent class by simply overriding the method. We can shut off the "a" around invoke with a slightly different version of Apple as follows: -.... +[source,java] +---- @Stateless public class Apple extends Fruit implements AppleLocal { @@ -75,7 +77,7 @@ public class Apple extends Fruit implements AppleLocal { return "ready to pick"; } } -.... +---- The result of this is that when the "grow" method on AppleLocal is invoked, the container will first invoke the AroundInvoke methods "b" @@ -85,11 +87,12 @@ When they say that an AroundInvoke method cannot be a business method, they mean that they cannot be exposed to clients through a local or remote interface. The following would be illegal. -.... +[source,java] +---- public interface AppleLocal { public String grow(); // This is an AroundInvoke method in the bean class, not a legal business method! public Object c(InvocationContext ctx) throws Exception; } -.... +---- http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/understanding-the-directory-layout.adoc ---------------------------------------------------------------------- diff --git a/docs/understanding-the-directory-layout.adoc b/docs/understanding-the-directory-layout.adoc index cbb69d2..8e640f6 100644 --- a/docs/understanding-the-directory-layout.adoc +++ b/docs/understanding-the-directory-layout.adoc @@ -8,7 +8,8 @@ Unpacking the standalone OpenEJB will result in the following directory layout: -.... +[source,java] +---- apache-openejb-[version]\apps apache-openejb-[version]\bin apache-openejb-[version]\conf @@ -18,7 +19,7 @@ apache-openejb-[version]\logs apache-openejb-[version]\LICENSE apache-openejb-[version]\NOTICE apache-openejb-[version]\README.txt -.... +---- # Directories @@ -49,7 +50,8 @@ This directory contains nothing but a README.txt file at the time OpenEJB is unpacked. The first time OpenEJB is started however, these files will be created: -.... +[source,java] +---- conf/ openejb.xml (main config file) logging.properties (log levels and files) @@ -64,7 +66,7 @@ files will be created: hsql.properties (network socket for hsql client access) httpejbd.properties (network socket for ejb invocations over http) telnet.properties (network socket for telnet "server") -.... +---- These files can be edited as desired. If at any time you are unhappy with your changes or simply wish to start over, you can delete or move http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/unix-daemon.adoc ---------------------------------------------------------------------- diff --git a/docs/unix-daemon.adoc b/docs/unix-daemon.adoc index b5aa326..4e7144b 100644 --- a/docs/unix-daemon.adoc +++ b/docs/unix-daemon.adoc @@ -18,11 +18,12 @@ used. First, we'll need to locate and unpack the `commons-daemon-native.tar.gz` -.... +[source,java] +---- cd $TOMEE_HOME/bin tar xzvf commons-daemon-native.tar.gz cd commons-daemon-1.0.7-native-src/unix/ -.... +---- Note that the `commons-daemon-1.0.7-native-src` directory may have a slightly different version number. @@ -38,40 +39,45 @@ You have to specify the `JAVA_HOME` of the SDK either with the `--with-java=<dir>` parameter or set the `JAVA_HOME` environment to point to your SDK installation. For example: -.... +[source,java] +---- ./configure --with-java=/usr/java -.... +---- or -.... +[source,java] +---- export JAVA_HOME ./configure -.... +---- If your operating system is supported, configure will go through cleanly, otherwise it will report an error (please send us the details of your OS/JDK, or a patch against the sources). To build the binaries and libraries simply do: -.... +[source,java] +---- make -.... +---- This will generate the executable file `jsvc`. Finally, we'll want to set the execution bits and move the `jsvc` binary -.... +[source,java] +---- chmod 755 jsvc mv jsvc $TOMEE_HOME/bin -.... +---- Done! As one script, the above might look like: -.... +[source,java] +---- cd $TOMEE_HOME/bin tar xzvf commons-daemon-native.tar.gz cd commons-daemon-1.0.7-native-src/unix/ @@ -79,33 +85,36 @@ cd commons-daemon-1.0.7-native-src/unix/ make chmod 755 jsvc mv jsvc ../.. -.... +---- == Starting (unix) -.... +[source,java] +---- sudo "$TOMEE_HOME/bin/jsvc" -cp "$TOMEE_HOME/bin/bootstrap.jar:$TOMEE_HOME/bin/tomcat-juli.jar" \ "-javaagent:$TOMEE_HOME/lib/openejb-javaagent.jar" -outfile "$TOMEE_HOME/logs/catalina.out" \ -errfile "$TOMEE_HOME/logs/catalina.err" org.apache.catalina.startup.Bootstrap -.... +---- == Starting (osx) For a 64-bit JVM such as OSX Lion -.... +[source,java] +---- sudo arch -arch x86_64 "$TOMEE_HOME/bin/jsvc" -jvm server -cp "$TOMEE_HOME/bin/bootstrap.jar:$TOMEE_HOME/bin/tomcat-juli.jar" \ "-javaagent:$TOMEE_HOME/lib/openejb-javaagent.jar" -outfile "$TOMEE_HOME/logs/catalina.out" \ -errfile "$TOMEE_HOME/logs/catalina.err" org.apache.catalina.startup.Bootstrap -.... +---- For a 32-bit JVM -.... +[source,java] +---- sudo arch -arch i386 "$TOMEE_HOME/bin/jsvc" -jvm server -cp "$TOMEE_HOME/bin/bootstrap.jar:$TOMEE_HOME/bin/tomcat-juli.jar" \ "-javaagent:$TOMEE_HOME/lib/openejb-javaagent.jar" -outfile "$TOMEE_HOME/logs/catalina.out" \ -errfile "$TOMEE_HOME/logs/catalina.err" org.apache.catalina.startup.Bootstrap -.... +---- === Note on formatting @@ -119,7 +128,8 @@ as long as the resulting command is one long line. Ensure your `$TOME_HOME` and `$JAVA_HOME` variables are set correctly. You should see similar output with the following two commands -.... +[source,java] +---- mingus:~ 01:51:37 $ ls $TOMEE_HOME LICENSE RELEASE-NOTES bin endorsed logs webapps @@ -128,14 +138,15 @@ NOTICE RUNNING.txt conf lib temp work mingus:~ 01:51:46 $ ls $JAVA_HOME bin bundle lib man -.... +---- The `jsvc -debug` option can also show useful information for troubleshooting: -.... +[source,java] +---- $TOMEE_HOME/bin/jsvc -debug -.... +---- Note on OSX, `$JAVA_HOME` should be set to `/System/Library/Frameworks/JavaVM.framework/Home` http://git-wip-us.apache.org/repos/asf/tomee/blob/66e0d661/docs/validation-tool.adoc ---------------------------------------------------------------------- diff --git a/docs/validation-tool.adoc b/docs/validation-tool.adoc index de714e3..0b5e0c5 100644 --- a/docs/validation-tool.adoc +++ b/docs/validation-tool.adoc @@ -113,13 +113,14 @@ classloader, perhaps because it is only in the child classloader. Here is a more concrete example: -.... +[source,java] +---- public interface Person extends EJBObject { } public interface Employee extends Person { } -.... +---- Ok, so when we build our ejb jar, we put both the Person and Employee interfaces in the jar, so everything should be good (so we think). But