On TomEE website, there is no documentation about TomEE Embedded !
Maven dependencies
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>tomee-embedded</artifactId>
<version>1.5.2</version>
</dependency>
Optionnal : For WebServices (REST and SOAP)
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>tomee-webservices</artifactId>
<version>1.5.2</version>
</dependency>
Optionnal : For SOAP WebServices
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-cxf</artifactId>
<version>4.5.2</version>
</dependency>
Optionnal : For Custom Broker (Configuration by activemq.xml file)
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.13</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
Build Tomee Embedded Configuration
Configuration configuration = new Configuration();
configuration.setHttpPort(8000);
configuration.setStopPort(8005);
configuration.setDir("/tmp/tomee");
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
LocalInitialContextFactory.class.getName());
//Optionnal : Configure Datasource (SQLServer example)
properties.put("MyDatasource", "new://Resource?type=DataSource");
properties.put("MyDatasource.JdbcDriver",
"net.sourceforge.jtds.jdbc.Driver");
properties.put("MyDatasource.JdbcUrl",
"jdbc:jtds:sqlserver://localhost:1433;DatabaseName=mybase");
properties.put("MyDatasource.UserName", "myuser");
properties.put("MyDatasource.Password", "mypass");
//Optionnal : Configure ActiveMQ
properties.put("MyResourceAdapter",
"new://Resource?type=ActiveMQResourceAdapter");
properties.put("MyResourceAdapter.BrokerXmlConfig",
"broker:(tcp://localhost:61616)"); //Default broker
//properties.put("MyResourceAdapter.BrokerXmlConfig",
"xbean:file:/tmp/activemq.xml"); //Custom broker (by xml)
properties.put("MyResourceAdapter.ServerUrl", "tcp://localhost:61616");
//Optionnal : Configure Connection Factory
properties.put("MyConnectionFactory",
"new://Resource?type=javax.jms.ConnectionFactory");
properties.put("MyConnectionFactory.ResourceAdapter", "MyResourceAdapter");
//Optionnal : Configure JMS Container
properties.put("MyJmsMdbContainer", "new://Container?type=MESSAGE");
properties.put("MyJmsMdbContainer.ResourceAdapter", "MyResourceAdapter");
//Optionnal : Create queue
properties.put("MyQueue", "new://Resource?type=javax.jms.Queue");
configuration.setProperties(properties);
Start Tomee
Container container = new Container();
container.setup(configuration)
container.start();
container.deploy("", "/tmp/ROOT.war", true);
container.deploy("ear", "/tmp/myear.ear", false);
container.deploy("war", "/tmp/mywar.war", true);
container.await();
Tips
Use custom tomcat connector (e.g. : To define SSL or additionnals tomcat
connectors)
I propose a patch who permit to configure custom connector(s). If custom
connector option is not set, default connector was create.
Patch available here (from 1.6.0-SNAPSHOT of 28/05/2013) :
https://github.com/xesnet/test/blob/master/proposal/tomee-embedded.patch
Example for configure SSL
final Connector connector = new Connector(Http11Protocol.class.getName());
connector.setPort(8443);
connector.setAttribute("connectionTimeout", 3000);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("keyAlias", "mykeyalias");
connector.setAttribute("keystorePass", "mykeystorepass");
connector.setAttribute("keystoreFile", "/tmp/myfile.keystore");
connector.setAttribute("clientAuth", "false");
connector.setAttribute("sslProtocol", "TLS");
connector.setAttribute("SSLEnabled", true);
List<Connector> connectors = new ArrayList<Connector>();
connectors.add(connector);
configuration.setConnectors(connectors);
You can inject java properties in activemq.xml by adding in xml file
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
</bean>
If you add in xml this ${activeMQ.dataDirectory}. You just need to write
this code for replacement :
System.setProperty("activeMQ.dataDirectory", "/tmp/activemq_data");
--
View this message in context:
http://openejb.979440.n4.nabble.com/Proposal-TomEE-embedded-documentation-tp4663710.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.