From de7099c54f139c45c373b593638e677594c6dd70 Mon Sep 17 00:00:00 2001 From: Carlos Chacin Date: Wed, 5 Dec 2018 22:07:26 -0800 Subject: [PATCH 1/2] TOMEE-2316 Convert Markdown files to Asciidoc in the docs folder - 10 --- docs/spring-and-openejb-3.0.adoc | 224 ++++++++++++++ docs/spring-and-openejb-3.0.md | 190 ------------ docs/spring-ejb-and-jpa.adoc | 195 ++++++++++++ docs/spring-ejb-and-jpa.md | 173 ----------- docs/spring.adoc | 139 +++++++++ docs/spring.md | 124 -------- docs/ssh.adoc | 63 ++++ docs/ssh.md | 51 --- docs/standalone-server.adoc | 24 ++ docs/standalone-server.md | 27 -- docs/startup.adoc | 267 ++++++++++++++++ docs/startup.md | 296 ------------------ docs/statefulcontainer-config.adoc | 165 ++++++++++ docs/statefulcontainer-config.md | 160 ---------- docs/statelesscontainer-config.adoc | 441 ++++++++++++++++++++++++++ docs/statelesscontainer-config.md | 461 ---------------------------- docs/system-properties-files.adoc | 25 ++ docs/system-properties-files.md | 22 -- docs/system-properties.adoc | 68 ++++ docs/system-properties.md | 68 ---- 20 files changed, 1611 insertions(+), 1572 deletions(-) create mode 100644 docs/spring-and-openejb-3.0.adoc delete mode 100644 docs/spring-and-openejb-3.0.md create mode 100644 docs/spring-ejb-and-jpa.adoc delete mode 100644 docs/spring-ejb-and-jpa.md create mode 100644 docs/spring.adoc delete mode 100644 docs/spring.md create mode 100644 docs/ssh.adoc delete mode 100644 docs/ssh.md create mode 100644 docs/standalone-server.adoc delete mode 100644 docs/standalone-server.md create mode 100644 docs/startup.adoc delete mode 100644 docs/startup.md create mode 100644 docs/statefulcontainer-config.adoc delete mode 100644 docs/statefulcontainer-config.md create mode 100644 docs/statelesscontainer-config.adoc delete mode 100644 docs/statelesscontainer-config.md create mode 100644 docs/system-properties-files.adoc delete mode 100644 docs/system-properties-files.md create mode 100644 docs/system-properties.adoc delete mode 100644 docs/system-properties.md diff --git a/docs/spring-and-openejb-3.0.adoc b/docs/spring-and-openejb-3.0.adoc new file mode 100644 index 00000000000..ea2c24c044d --- /dev/null +++ b/docs/spring-and-openejb-3.0.adoc @@ -0,0 +1,224 @@ +:jbake-title: Spring and OpenEJB 3.0 +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + + +\{note}OpenEJB 3.1 and later users should refer to the [Spring] +page.\{note} # Bootstrapping OpenEJB in Spring + +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: + +.... +public class OpenEjbFactoryBean implements org.springframework.beans.factory.FactoryBean { + + private Properties properties = new Properties(); + + public OpenEjbFactoryBean() { + properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); + } + + public Properties getJndiEnvironment() { + return properties; + } + + public void setJndiEnvironment(Properties properties) { + this.properties.putAll(properties); + } + + public Object getObject() { + try { + return new InitialContext(properties); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public Class getObjectType(){ + return Context.class; + } + + boolean isSingleton() { + return true; + } +} +.... + +And include that at the top of your spring xml file as follows: + +.... + + + + new://Resource?type=DataSource + com.mysql.jdbc.Driver + jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true + root + + + + +.... + +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 +datasources, topics, queues, containers and more this way. + +Just as with Unit Testing, OpenEJB will find and automatically deploy +all the EJB beans it [finds in the classpath|Application discovery via +the classpath]. You can then expose any of these things to other Spring +components with custom factory beans. + +== Injecting OpenEJB-created resources into Spring components + +If you want to have any of the Topics, Queues, DataSources, +EntityManagers or more that OpenEJB creates injected into components +that Spring creates, here's one technique.... + +Let's say you have a persistence unit called "_OrangeUnit_" declared in +a persistence.xml file. One way to get the related _EntityManager_ +created by OpenEJB is to do as follows. Create an @Stateless bean with +an @PersistenceContext ref in it, then use a factory bean to look it up, +pull the EntityManager out and return it + +OrangeUnitBean.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 + * that same jar file also has a META-INF/ejb-jar.xml file. The ejb-jar.xml + * need only contain the text "" at minimum. + */ +@Stateless +public class OrangeUnitBean implements OrangeUnitLocal { + + @PersistenceContext(unitName="OrangeUnit") + private EntityManager entityManager; + + public EntityManager getEntityManager() { + return entityManager; + } +} +.... + +OrangeUnitLocal.java + +.... +/** + * The local interface for the OrangeUnitBean + */ +public interface OrangeUnitLocal { + public EntityManager getEntityManager(); +} +.... + +OrangeUnitFactoryBean.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 + * from that bean and hand it over to Spring. Anyone in Spring-land can then easily get + * a reference to the EntityManager by simply referencing this factory bean. + */ +public class OrangeUnitFactoryBean implements org.springframework.beans.factory.FactoryBean { + private Context context; + + public Context getContext() { + return context; + } + + public void setContext(Context context) { + this.context = context; + } + + public Object getObject() { + try { + ResourceLocal bean = (ResourceLocal) context.lookup("OrangeUnitBeanLocal"); + return bean.getEntityManager(); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + public Class getObjectType(){ + return EntityManager.class; + } + + boolean isSingleton() { + return true; + } +} +.... + +The factory bean would then be declared in your spring xml file as +follows: + +.... + + + +.... + +The EntityManager can then easily be consumed by a spring bean. + +.... +public class SomePojo { + + private EntityManager entityManager; + + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + ... +} +.... + +In the spring xml + +.... + + + +.... + +Here's what all three declarations would look like together in your +spring xml: + +Spring bean definitions combined + +.... + + + + new://Resource?type=DataSource + com.mysql.jdbc.Driver + jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true + root + + + + + + + + + + + + +.... + +:jbake-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 +would be great. These links explain how to make available spring +components to openejb +http://twasink.net/blog/archives/2007/01/using_spring_wi.html +http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.html +http://wiki.netbeans.org/MavenSpringEJBsOnGlassfish + +\{info} diff --git a/docs/spring-and-openejb-3.0.md b/docs/spring-and-openejb-3.0.md deleted file mode 100644 index 7ac4ccee8a9..00000000000 --- a/docs/spring-and-openejb-3.0.md +++ /dev/null @@ -1,190 +0,0 @@ -title=Spring and OpenEJB 3.0 -type=page -status=published -~~~~~~ - -{note}OpenEJB 3.1 and later users should refer to the [Spring] page.{note} -# Bootstrapping OpenEJB in Spring - -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: - - public class OpenEjbFactoryBean implements org.springframework.beans.factory.FactoryBean { - - private Properties properties = new Properties(); - - public OpenEjbFactoryBean() { - properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); - } - - public Properties getJndiEnvironment() { - return properties; - } - - public void setJndiEnvironment(Properties properties) { - this.properties.putAll(properties); - } - - public Object getObject() { - try { - return new InitialContext(properties); - } catch (NamingException e) { - throw new RuntimeException(e); - } - } - - public Class getObjectType(){ - return Context.class; - } - - boolean isSingleton() { - return true; - } - } - -And include that at the top of your spring xml file as follows: - - - - - new://Resource?type=DataSource - com.mysql.jdbc.Driver - jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true - root - - - - - -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 datasources, topics, queues, containers and more this way. - -Just as with Unit Testing, OpenEJB will find and automatically deploy all the EJB beans it [finds in the classpath|Application discovery via the classpath]. You can then expose any of these things to other Spring components with custom factory beans. - -# Injecting OpenEJB-created resources into Spring components - -If you want to have any of the Topics, Queues, DataSources, EntityManagers or more that OpenEJB creates injected into components that Spring creates, here's one technique.... - -Let's say you have a persistence unit called "*OrangeUnit*" declared in a persistence.xml file. One way to get the related *EntityManager* created by OpenEJB is to do as follows. Create an @Stateless bean with an @PersistenceContext ref in it, then use a factory bean to look it up, pull the EntityManager out and return it - -OrangeUnitBean.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 - * that same jar file also has a META-INF/ejb-jar.xml file. The ejb-jar.xml - * need only contain the text "" at minimum. - */ - @Stateless - public class OrangeUnitBean implements OrangeUnitLocal { - - @PersistenceContext(unitName="OrangeUnit") - private EntityManager entityManager; - - public EntityManager getEntityManager() { - return entityManager; - } - } - -OrangeUnitLocal.java - - /** - * The local interface for the OrangeUnitBean - */ - public interface OrangeUnitLocal { - public EntityManager getEntityManager(); - } - -OrangeUnitFactoryBean.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 - * from that bean and hand it over to Spring. Anyone in Spring-land can then easily get - * a reference to the EntityManager by simply referencing this factory bean. - */ - public class OrangeUnitFactoryBean implements org.springframework.beans.factory.FactoryBean { - private Context context; - - public Context getContext() { - return context; - } - - public void setContext(Context context) { - this.context = context; - } - - public Object getObject() { - try { - ResourceLocal bean = (ResourceLocal) context.lookup("OrangeUnitBeanLocal"); - return bean.getEntityManager(); - } catch (NamingException e) { - throw new RuntimeException(e); - } - } - - public Class getObjectType(){ - return EntityManager.class; - } - - boolean isSingleton() { - return true; - } - } - -The factory bean would then be declared in your spring xml file as follows: - - - - - - -The EntityManager can then easily be consumed by a spring bean. - - public class SomePojo { - - private EntityManager entityManager; - - public void setEntityManager(EntityManager entityManager) { - this.entityManager = entityManager; - } - - ... - } - -In the spring xml - - - - - -Here's what all three declarations would look like together in your spring xml: - -Spring bean definitions combined - - - - - new://Resource?type=DataSource - com.mysql.jdbc.Driver - jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true - root - - - - - - - - - - - - - -{info: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 would be great. These links explain how to make available spring components to openejb -http://twasink.net/blog/archives/2007/01/using_spring_wi.html -http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.html -http://wiki.netbeans.org/MavenSpringEJBsOnGlassfish - -{info} - diff --git a/docs/spring-ejb-and-jpa.adoc b/docs/spring-ejb-and-jpa.adoc new file mode 100644 index 00000000000..416fa4ec398 --- /dev/null +++ b/docs/spring-ejb-and-jpa.adoc @@ -0,0 +1,195 @@ +# Spring EJB and JPA +:index-group: Spring +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + +\{note}OpenEJB 3.1 or later required\{note} This example shows +how to combine Spring, OpenEJB and Hibernate using the integration code +provided by OpenEJB. Here, OpenEJB is used as an embeddable EJB +container inside of Spring. See the link:spring.html[Spring] page for +details. + +We use the basic Movie example and expand it to include more objects to +demonstrate both Spring beans, EJB Session beans, and JPA persistent +objects in one application. The premise of the example is a Cineplex +that has a number of Theaters (viewing screens), each playing a number +of Movies. The basic object layout is as follows: + +Object + +Type + +Description + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java[CineplexImpl] + +@Stateless + +Shows the use of @Resource to have Spring beans injected. Specifically, +the _Theaters_ Spring bean + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java[Theaters] + +Spring bean + +Simple wrapper object injected into _CineplexImpl_ + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java[Theater] + +Spring bean + +Shows that EJBs can be injected into Spring beans. Uses both the +_Movies_ EJB and the _Movie_ JPA objects + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java[MoviesImpl] + +@Stateful + +Wraps a JPA EntityManager and provides transactional access to the +persistent _Movie_ objects + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java[Movie] + +@Entity + +Basic JPA bean that is used both by Spring beans and EJBs. The same +_Movie_ object as in all the other persistence related examples. + +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java[AvailableMovies] + +Spring bean + +Simple object used as a clever way to seed the EntityManager (and +really, the database) with persistent _Movie_ objects + +# Required jars + +To setup the integration you'll need: + +[arabic] +. The standard OpenEJB 3.1 libraries +. The +https://repository.apache.org/content/groups/public/org/apache/openejb/openejb-spring/3.1.2/openejb-spring-3.1.2.jar[openejb-spring-3.1.jar] +or later +. Spring 2.5 or other (any version should work) + +In Maven2 this can be done by adding the following dependencies to your +pom.xml +\{snippet:id=required|url=openejb3/examples/spring-integration/pom.xml|lang=xml} +For other environments, you can simply link:downloads.html[download an +openejb-3.1.zip] or later and include all the jars under the lib/ +directory in your classpath. Then download and add the +[openejb-spring-3.1.jar|http://people.apache.org/repo/m2-ibiblio-rsync-repository/org/apache/openejb/openejb-spring/3.1/openejb-spring-3.1.jar] +along with your Spring jars. + +# The Spring xml + +Bootstrapping and Configuring OpenEJB is fairly simple. +\{snippet:id=bootstrapping|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} +As well, you can optionally declare any resources or containers. +Anything declarable as a or in the openejb.xml can instead be declared +in the Spring xml file as shown here. +\{snippet:id=resources|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} +And finally our Spring beans. +\{snippet:id=pojos|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} +:jbake-title: Don't forget} +\{snippet:id=annotations|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} +It allows various annotations to be detected in bean classes: Spring's +@Required and @Autowired, as well as JSR 250's @PostConstruct, +@PreDestroy and @Resource (if available), JAX-WS's @WebServiceRef (if +available), EJB3's @EJB (if available), and JPA's @PersistenceContext +and @PersistenceUnit (if available). Alternatively, you may choose to +activate the individual BeanPostProcessors for those annotations. +\{note} + +# The Code + +In efforts to keep the example page somewhat short, we'll show just +three beans, each demonstrating a particular relationship. + +The first is the CineplexImpl EJB which shows EJB -> Spring. +\{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java|lang=java} + +The second is the Theater Spring bean which shows Spring -> EJB. +\{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java|lang=java} + +The last is the AvailableMovies Spring bean which Shows Spring -> EJB -> +JPA +\{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java|lang=java} + +# The TestCase + +The JUnit TestCase uses a ClassPathXmlApplicationContext to load the +Spring ApplicationContext. Anything that loads your Spring xml file +should work fine. The following code would work a plain java app as +well. + +\{snippet:id=code|url=openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java|lang=java} + +# Running + +The source for this example can be downloaded from svn via: + +$ svn co +http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration + +Then, in the "spring-integration" directory, run: + +$ mvn clean install + +Which should create output like the following. + +.... +------------------------------------------------------- + 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 +3.1 build: 20081009-03:31 http://tomee.apache.org/ INFO - openejb.home = +/Users/dblevins/work/openejb3/examples/spring-integration INFO - +openejb.base = /Users/dblevins/work/openejb3/examples/spring-integration +INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory, +type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory) INFO - +Configuring Service(id=MovieDatabase, type=Resource, provider-id=Default +JDBC Database) INFO - Configuring Service(id=MovieDatabaseUnmanaged, +type=Resource, provider-id=Default JDBC Database) INFO - Found EjbModule +in classpath: +/Users/dblevins/work/openejb3/examples/spring-integration/target/classes +INFO - Beginning load: +/Users/dblevins/work/openejb3/examples/spring-integration/target/classes +INFO - Configuring enterprise application: classpath.ear INFO - +Configuring Service(id=Default Stateless Container, type=Container, +provider-id=Default Stateless Container) INFO - Auto-creating a +container for bean CineplexImpl: Container(type=STATELESS, id=Default +Stateless Container) INFO - Auto-linking resource-ref +'org.superbiz.spring.CineplexImpl/theaters' in bean CineplexImpl to +Resource(id=theaters) INFO - Configuring Service(id=Default Stateful +Container, type=Container, provider-id=Default Stateful Container) INFO +- Auto-creating a container for bean Movies: Container(type=STATEFUL, +id=Default Stateful Container) INFO - Configuring +PersistenceUnit(name=movie-unit, +provider=org.hibernate.ejb.HibernatePersistence) INFO - Enterprise +application "classpath.ear" loaded. INFO - Assembling app: classpath.ear +INFO - PersistenceUnit(name=movie-unit, +provider=org.hibernate.ejb.HibernatePersistence) INFO - +Jndi(name=CineplexImplLocal) --> Ejb(deployment-id=CineplexImpl) INFO - +Jndi(name=MoviesLocal) --> Ejb(deployment-id=Movies) INFO - Created +Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful +Container) INFO - Created Ejb(deployment-id=CineplexImpl, +ejb-name=CineplexImpl, container=Default Stateless Container) INFO - +Deployed Application(path=classpath.ear) INFO - Exported EJB Movies with +interface org.superbiz.spring.Movies to Spring bean MoviesLocal INFO - +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 + +.... +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 +.... diff --git a/docs/spring-ejb-and-jpa.md b/docs/spring-ejb-and-jpa.md deleted file mode 100644 index 8b1512bce1a..00000000000 --- a/docs/spring-ejb-and-jpa.md +++ /dev/null @@ -1,173 +0,0 @@ -index-group=Spring -type=page -status=published -title=Spring EJB and JPA -~~~~~~ -{note}OpenEJB 3.1 or later required{note} -This example shows how to combine Spring, OpenEJB and Hibernate using the -integration code provided by OpenEJB. Here, OpenEJB is used as an -embeddable EJB container inside of Spring. See the [Spring](spring.html) - page for details. - -We use the basic Movie example and expand it to include more objects to -demonstrate both Spring beans, EJB Session beans, and JPA persistent -objects in one application. The premise of the example is a Cineplex that -has a number of Theaters (viewing screens), each playing a number of -Movies. The basic object layout is as follows: - - - - - - - - - -
Object Type Description
[CineplexImpl](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java) - @Stateless Shows the use of @Resource to have Spring beans injected. -Specifically, the _Theaters_ Spring bean
[Theaters](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java) - Spring bean Simple wrapper object injected into _CineplexImpl_
[Theater](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java) - Spring bean Shows that EJBs can be injected into Spring beans. Uses -both the _Movies_ EJB and the _Movie_ JPA objects
[MoviesImpl](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java) - @Stateful Wraps a JPA EntityManager and provides transactional access -to the persistent _Movie_ objects
[Movie](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java) - @Entity Basic JPA bean that is used both by Spring beans and EJBs. -The same _Movie_ object as in all the other persistence related examples.
[AvailableMovies](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java) - Spring bean Simple object used as a clever way to seed the -EntityManager (and really, the database) with persistent _Movie_ objects
- - -# Required jars - -To setup the integration you'll need: - -1. The standard OpenEJB 3.1 libraries -1. The [openejb-spring-3.1.jar](https://repository.apache.org/content/groups/public/org/apache/openejb/openejb-spring/3.1.2/openejb-spring-3.1.2.jar) - or later -1. Spring 2.5 or other (any version should work) - -In Maven2 this can be done by adding the following dependencies to your -pom.xml -{snippet:id=required|url=openejb3/examples/spring-integration/pom.xml|lang=xml} -For other environments, you can simply [download an openejb-3.1.zip](downloads.html) - or later and include all the jars under the lib/ directory in your -classpath. Then download and add the [openejb-spring-3.1.jar|http://people.apache.org/repo/m2-ibiblio-rsync-repository/org/apache/openejb/openejb-spring/3.1/openejb-spring-3.1.jar] - along with your Spring jars. - - -# The Spring xml - -Bootstrapping and Configuring OpenEJB is fairly simple. -{snippet:id=bootstrapping|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} -As well, you can optionally declare any resources or containers. Anything -declarable as a or in the openejb.xml can instead be -declared in the Spring xml file as shown here. -{snippet:id=resources|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} -And finally our Spring beans. -{snippet:id=pojos|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} -{note:title=Don't forget} -{snippet:id=annotations|url=openejb3/examples/spring-integration/src/main/resources/movies.xml|lang=xml} -It allows various annotations to be detected in bean classes: Spring's -@Required and @Autowired, as well as JSR 250's @PostConstruct, @PreDestroy -and @Resource (if available), JAX-WS's @WebServiceRef (if available), -EJB3's @EJB (if available), and JPA's @PersistenceContext and -@PersistenceUnit (if available). Alternatively, you may choose to activate -the individual BeanPostProcessors for those annotations. -{note} - - -# The Code - -In efforts to keep the example page somewhat short, we'll show just three -beans, each demonstrating a particular relationship. - -The first is the CineplexImpl EJB which shows EJB \-> Spring. -{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java|lang=java} - -The second is the Theater Spring bean which shows Spring \-> EJB. -{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java|lang=java} - -The last is the AvailableMovies Spring bean which Shows Spring \-> EJB \-> -JPA -{snippet:id=code|url=openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java|lang=java} - - -# The TestCase - -The JUnit TestCase uses a ClassPathXmlApplicationContext to load the Spring -ApplicationContext. Anything that loads your Spring xml file should work -fine. The following code would work a plain java app as well. - -{snippet:id=code|url=openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java|lang=java} - - -# Running - -The source for this example can be downloaded from svn via: - -$ svn co [http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration](http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/spring-integration) - -Then, in the "spring-integration" directory, run: - -$ mvn clean install - -Which should create output like the following. - - - ------------------------------------------------------- - 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 3.1 build: 20081009-03:31 - http://tomee.apache.org/ - INFO - openejb.home = -/Users/dblevins/work/openejb3/examples/spring-integration - INFO - openejb.base = -/Users/dblevins/work/openejb3/examples/spring-integration - INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory, -type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory) - INFO - Configuring Service(id=MovieDatabase, type=Resource, -provider-id=Default JDBC Database) - INFO - Configuring Service(id=MovieDatabaseUnmanaged, type=Resource, -provider-id=Default JDBC Database) - INFO - Found EjbModule in classpath: -/Users/dblevins/work/openejb3/examples/spring-integration/target/classes - INFO - Beginning load: -/Users/dblevins/work/openejb3/examples/spring-integration/target/classes - INFO - Configuring enterprise application: classpath.ear - INFO - Configuring Service(id=Default Stateless Container, type=Container, -provider-id=Default Stateless Container) - INFO - Auto-creating a container for bean CineplexImpl: -Container(type=STATELESS, id=Default Stateless Container) - INFO - Auto-linking resource-ref -'org.superbiz.spring.CineplexImpl/theaters' in bean CineplexImpl to -Resource(id=theaters) - INFO - Configuring Service(id=Default Stateful Container, type=Container, -provider-id=Default Stateful Container) - INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, -id=Default Stateful Container) - INFO - Configuring PersistenceUnit(name=movie-unit, -provider=org.hibernate.ejb.HibernatePersistence) - INFO - Enterprise application "classpath.ear" loaded. - INFO - Assembling app: classpath.ear - INFO - PersistenceUnit(name=movie-unit, -provider=org.hibernate.ejb.HibernatePersistence) - INFO - Jndi(name=CineplexImplLocal) --> Ejb(deployment-id=CineplexImpl) - INFO - Jndi(name=MoviesLocal) --> Ejb(deployment-id=Movies) - INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default -Stateful Container) - INFO - Created Ejb(deployment-id=CineplexImpl, ejb-name=CineplexImpl, -container=Default Stateless Container) - INFO - Deployed Application(path=classpath.ear) - INFO - Exported EJB Movies with interface org.superbiz.spring.Movies to -Spring bean MoviesLocal - INFO - 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 - - Results : - - Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 diff --git a/docs/spring.adoc b/docs/spring.adoc new file mode 100644 index 00000000000..7f2e5b3c7d1 --- /dev/null +++ b/docs/spring.adoc @@ -0,0 +1,139 @@ +# Spring +:index-group: Spring +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + +\{note} This document and the related feature is considered a prototype +and will change based on user feedback. All comments suggestions +welcome. \{note} + +# Introduction + +The OpenEJB Spring integration makes all Spring defined beans injectable +to Java EE components, and all Java EE components can be injected to +Spring beans. The injection system supports arbitrarily complex nesting +(e.g., Spring bean injected into a Java EE component, which is then +injected into another Spring bean), including: + +* @Resouce injection of any Spring bean into EJB +* Injection of any Java EE resource into a Spring bean, including: ** +EJB 3.0 beans ** EJB 3.1 Singleton Bean ** JDBC Connector ** JMS +Connector ** JMS Queue and Topic ** Generic Java EE Connector (JCA) + +In addition, the OpenEJB Spring integration add support for discovery +and deployment of standard Java EE packages within a Spring context, +including: + +* EAR +* EJB Jar +* Persistence Unit +* RAR + +_Requirements:_ * OpenEJB 3.1+ * Spring X.X * Java 1.5 or 1.6 + +# Spring Beans + +The following beans are usable in any spring xml file. + +Class + +Description + +org.apache.openejb.spring.ClassPathApplication + +Scrapes the classpath for all EJB, RAR, and Persistence applications, +deploys them, and imports them into the current ApplicationContext. All +applications found are treated as one big EAR unless the +_classpathAsEar_ property is set to _false_ + +org.apache.openejb.spring.Application + +Scrapes an individual jar file for EJB, RAR, and Persistence +applications, deploys them, and imports them into the current +ApplicationContext. The 'jarFile' property is required. The application +is treated as it's own self-contained EAR, separate from other uses of +'Application' + +org.apache.openejb.spring.Resource + +Allows an OpenEJB to be declared in the Spring ApplicationContext + +org.apache.openejb.spring.OpenEJBResource + +A FactoryBean that imports a Resource from OpenEJB into the Spring +ApplicationContext. Has the following properties: _type_ such as +javax.sql.DataSource, and _resourceId_. In the future this bean will not +be required and all OpenEJB Resources will automatically be imported +into the Spring ApplicationContext + +org.apache.openejb.spring.BmpContainer + +Allows an OpenEJB BMP to be declared in the Spring ApplicationContext. +Has the following properties: _poolSize_ + +org.apache.openejb.spring.CmpContainer + +Allows an OpenEJB CMP to be declared in the Spring ApplicationContext. + +org.apache.openejb.spring.SingletonContainer + +Allows an OpenEJB Singleton to be declared in the Spring +ApplicationContext. Has the following properties: _accessTimeout_ + +org.apache.openejb.spring.StatefulContainer + +Allows an OpenEJB Stateful to be declared in the Spring +ApplicationContext. Has the following properties: _timeOut_ + +org.apache.openejb.spring.StatelessContainer + +Allows an OpenEJB Stateful to be declared in the Spring +ApplicationContext. Has the following properties: _timeOut_, _poolSize_, +and _strictPooling_ + +org.apache.openejb.spring.MdbContainer + +Allows an OpenEJB Message-Driven to be declared in the Spring +ApplicationContext. Has the following properties: _resourceAdapter_, +_messageListenerInterface_, _activationSpecClass_, and _instanceLimit_ + +org.apache.openejb.spring.EJB + +A FactoryBean that imports an EJB from OpenEJB into the Spring +ApplicationContext. One of these is automatically created for each +interface of each EJB, but explicit use can be nice if you desire to +import an EJB with a specific name. Has the following properties: +_deploymentId_, _interface_ + +# Examples + +See the link:spring-ejb-and-jpa.html[Spring EJB and JPA] page for +example code and a working Spring xml file. + +# \{anchor:problems} Problems? + +If you are having problems with the installation, please send a message +to the OpenEJB users link:mailing-lists.html[mailing list] containing +any error message(s) and the following information: + +* OpenEJB Version +* Spring Version +* Java Version (execute java -version) +* Operating System Type and Version + +# Limitations + +_JavaAgent_ - OpenEJB uses OpenJPA to provide JPA and CMP persistence, +and OpenJPA currently requires a JavaAgent to function properly in a +Java 1.5 environment. OpenJPA does not require a JavaAgent in Java 1.6. +Use Hibernate as your the provider in your persistence.xml files if you +wish to avoid this requirement. + +_EntityManager_ - Having an OpenEJB created EntityManager or +EntityManagerFactory injected into Spring beans is currently not +supported. This will be added to the next release. A small workaround +for this is to use an EJB as a factory by adding a 'getEntityManager' +method an using it as a +http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-class-instance-factory-method[Spring +instance factory method] . diff --git a/docs/spring.md b/docs/spring.md deleted file mode 100644 index a815b740412..00000000000 --- a/docs/spring.md +++ /dev/null @@ -1,124 +0,0 @@ -index-group=Spring -type=page -status=published -title=Spring -~~~~~~ -{note} -This document and the related feature is considered a prototype and will -change based on user feedback. All comments suggestions welcome. -{note} - - -# Introduction - -The OpenEJB Spring integration makes all Spring defined beans injectable to -Java EE components, and all Java EE components can be injected to Spring beans. -The injection system supports arbitrarily complex nesting (e.g., Spring -bean injected into a Java EE component, which is then injected into another -Spring bean), including: - - * @Resouce injection of any Spring bean into EJB - * Injection of any Java EE resource into a Spring bean, including: - ** EJB 3.0 beans - ** EJB 3.1 Singleton Bean - ** JDBC Connector - ** JMS Connector - ** JMS Queue and Topic - ** Generic Java EE Connector (JCA) - -In addition, the OpenEJB Spring integration add support for discovery and -deployment of standard Java EE packages within a Spring context, including: - - * EAR - * EJB Jar - * Persistence Unit - * RAR - -*Requirements:* - * OpenEJB 3.1+ - * Spring X.X - * Java 1.5 or 1.6 - - -# Spring Beans - -The following beans are usable in any spring xml file. - - - - - - - - - - - - - - -
Class Description
org.apache.openejb.spring.ClassPathApplication Scrapes the classpath -for all EJB, RAR, and Persistence applications, deploys them, and imports -them into the current ApplicationContext. All applications found are -treated as one big EAR unless the _classpathAsEar_ property is set to -_false_
org.apache.openejb.spring.Application Scrapes an individual jar file -for EJB, RAR, and Persistence applications, deploys them, and imports them -into the current ApplicationContext. The 'jarFile' property is required. -The application is treated as it's own self-contained EAR, separate from -other uses of 'Application'
org.apache.openejb.spring.Resource Allows an OpenEJB to be -declared in the Spring ApplicationContext
org.apache.openejb.spring.OpenEJBResource A FactoryBean that imports a -Resource from OpenEJB into the Spring ApplicationContext. Has the -following properties: _type_ such as javax.sql.DataSource, and -_resourceId_. In the future this bean will not be required and all OpenEJB -Resources will automatically be imported into the Spring ApplicationContext -
org.apache.openejb.spring.BmpContainer Allows an OpenEJB BMP - to be declared in the Spring ApplicationContext. Has the -following properties: _poolSize_
org.apache.openejb.spring.CmpContainer Allows an OpenEJB CMP - to be declared in the Spring ApplicationContext.
org.apache.openejb.spring.SingletonContainer Allows an OpenEJB -Singleton to be declared in the Spring ApplicationContext. Has -the following properties: _accessTimeout_
org.apache.openejb.spring.StatefulContainer Allows an OpenEJB Stateful - to be declared in the Spring ApplicationContext. Has the -following properties: _timeOut_
org.apache.openejb.spring.StatelessContainer Allows an OpenEJB Stateful - to be declared in the Spring ApplicationContext. Has the -following properties: _timeOut_, _poolSize_, and _strictPooling_
org.apache.openejb.spring.MdbContainer Allows an OpenEJB Message-Driven - to be declared in the Spring ApplicationContext. Has the -following properties: _resourceAdapter_, _messageListenerInterface_, -_activationSpecClass_, and _instanceLimit_
org.apache.openejb.spring.EJB A FactoryBean that imports an EJB from -OpenEJB into the Spring ApplicationContext. One of these is automatically -created for each interface of each EJB, but explicit use can be nice if you -desire to import an EJB with a specific name. Has the following -properties: _deploymentId_, _interface_
- - -# Examples - -See the [Spring EJB and JPA](spring-ejb-and-jpa.html) - page for example code and a working Spring xml file. - - -# {anchor:problems} Problems? - -If you are having problems with the installation, please send a message to -the OpenEJB users [mailing list](mailing-lists.html) - containing any error message(s) and the following information: - -* OpenEJB Version -* Spring Version -* Java Version (execute java -version) -* Operating System Type and Version - - -# Limitations - - *JavaAgent* - OpenEJB uses OpenJPA to provide JPA and CMP persistence, and -OpenJPA currently requires a JavaAgent to function properly in a Java 1.5 -environment. OpenJPA does not require a JavaAgent in Java 1.6. Use -Hibernate as your the provider in your persistence.xml files if you wish to -avoid this requirement. - - *EntityManager* - Having an OpenEJB created EntityManager or -EntityManagerFactory injected into Spring beans is currently not supported. - This will be added to the next release. A small workaround for this is to -use an EJB as a factory by adding a 'getEntityManager' method an using it -as a [Spring instance factory method](http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-class-instance-factory-method) -. diff --git a/docs/ssh.adoc b/docs/ssh.adoc new file mode 100644 index 00000000000..fd09c9508b1 --- /dev/null +++ b/docs/ssh.adoc @@ -0,0 +1,63 @@ +# SSH +:index-group: Unrevised +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + + +== Connecting To OpenEJB or TomEE Through SSH + +=== Description + +It can be very useful to connect to the server to get some informations. + +=== Solution + +For such a case OpenEJB/TomEE proposes to start with the Java EE server +a SSH server. Currently the security is based on JAAS (see how to +configure JAAS for TomEE for more information about it). + +=== Installation + +Simply extract the openejb-ssh jar in the lib of tomee +(webapps/tomee/lib) or openejb libs (lib folder). Then simply connect +using your JAAS credential. + +Note: you can use the provisioning features of openejb to do this job! + +Then simply activate the service manage: it is done setting the system +property openejb.servicemanager.enabled to true. + +Note: it can be done through the conf/system.properties file. Note2: +please take care to not add space after true (not 'true ' for instance). + +=== OpenEJB SSH Shell + +Once you are connected you get some commands: + +* deploy : deploy an application +* undeploy : undeploy an application +* list: list deployed EJBs +* classloader : print the classloader tree of the app specified by the +id +* jmx : interact with JMX ** jmx list: list mbeans ** jmx get ** jmx set +** jmx invoke ([, ...) +* properties: print server configuration as properties +* script ++ ++ +: execute the following script code using the following language with +the JSR 223 +* script file ++ ++ +: execute the following script using the language (from the extension of +the file) with the JSR 223 +* ls []: list the file in path is specified or in the base of the server +if not +* cat : print a file +* part - : print the part of a file + +Note1: JSR 223 can need to add some jar to openejb/tomee lib folder +(groovy-all for instance to use groovy) Note2: ls, part, cat commands +have to use $home and $base properties to specified the path diff --git a/docs/ssh.md b/docs/ssh.md deleted file mode 100644 index 88788f401e3..00000000000 --- a/docs/ssh.md +++ /dev/null @@ -1,51 +0,0 @@ -index-group=Unrevised -type=page -status=published -title=SSH -~~~~~~ - -# Connecting To OpenEJB or TomEE Through SSH -## Description - -It can be very useful to connect to the server to get some informations. - -## Solution - -For such a case OpenEJB/TomEE proposes to start with the Java EE server a SSH server. Currently the security -is based on JAAS (see how to configure JAAS for TomEE for more information about it). - -## Installation - -Simply extract the openejb-ssh jar in the lib of tomee (webapps/tomee/lib) or openejb libs (lib folder). -Then simply connect using your JAAS credential. - -Note: you can use the provisioning features of openejb to do this job! - -Then simply activate the service manage: it is done setting the system property -openejb.servicemanager.enabled to true. - -Note: it can be done through the conf/system.properties file. -Note2: please take care to not add space after true (not 'true ' for instance). - -## OpenEJB SSH Shell - -Once you are connected you get some commands: - -* deploy : deploy an application -* undeploy : undeploy an application -* list: list deployed EJBs -* classloader : print the classloader tree of the app specified by the id -* jmx : interact with JMX -** jmx list: list mbeans -** jmx get -** jmx set -** jmx invoke ([, ...) -* properties: print server configuration as properties -* script