You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/07/11 04:30:13 UTC
svn commit: r1145009 [1/3] - /openejb/site/trunk/content/
Author: dblevins
Date: Mon Jul 11 02:30:12 2011
New Revision: 1145009
URL: http://svn.apache.org/viewvc?rev=1145009&view=rev
Log:
formatting
Modified:
openejb/site/trunk/content/application-discovery-via-the-classpath.mdtext
openejb/site/trunk/content/built-in-type-converters.mdtext
openejb/site/trunk/content/configuration-and-assembly.mdtext
openejb/site/trunk/content/configuration.mdtext
openejb/site/trunk/content/configuring-datasources.mdtext
openejb/site/trunk/content/configuring-javamail.mdtext
openejb/site/trunk/content/constructor-injection.mdtext
openejb/site/trunk/content/containers.mdtext
openejb/site/trunk/content/contribution-tips.mdtext
openejb/site/trunk/content/datasource-password-encryption.mdtext
openejb/site/trunk/content/deployment-id.mdtext
openejb/site/trunk/content/deployments.mdtext
openejb/site/trunk/content/details-on-openejb-jar.mdtext
openejb/site/trunk/content/dynamic-datasource.mdtext
openejb/site/trunk/content/ejb-local-ref.mdtext
openejb/site/trunk/content/ejb-ref.mdtext
openejb/site/trunk/content/embedded-configuration.mdtext
openejb/site/trunk/content/embedding-openejb.mdtext
openejb/site/trunk/content/failover.mdtext
openejb/site/trunk/content/hibernate.mdtext
openejb/site/trunk/content/jms-resources-and-mdb-container.mdtext
openejb/site/trunk/content/jndi-names.mdtext
openejb/site/trunk/content/jpa-concepts.mdtext
openejb/site/trunk/content/new-in-openejb-3.0.mdtext
openejb/site/trunk/content/openejb-1.0-beta-1.mdtext
openejb/site/trunk/content/openejb-1.0.mdtext
openejb/site/trunk/content/openejb-3.0-beta-2.mdtext
openejb/site/trunk/content/openejb-3.0.mdtext
openejb/site/trunk/content/openejb-3.1.1.mdtext
openejb/site/trunk/content/openejb-3.1.mdtext
openejb/site/trunk/content/openejb-binaries.mdtext
openejb/site/trunk/content/openjpa.mdtext
openejb/site/trunk/content/persistence-context.mdtext
openejb/site/trunk/content/persistence-unit-ref.mdtext
openejb/site/trunk/content/properties-tool.mdtext
openejb/site/trunk/content/resource-ref-for-datasource.mdtext
openejb/site/trunk/content/securing-a-web-service.mdtext
openejb/site/trunk/content/service-locator.mdtext
openejb/site/trunk/content/singleton-beans.mdtext
openejb/site/trunk/content/spring-and-openejb-3.0.mdtext
openejb/site/trunk/content/webadmin.mdtext
Modified: openejb/site/trunk/content/application-discovery-via-the-classpath.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/application-discovery-via-the-classpath.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/application-discovery-via-the-classpath.mdtext (original)
+++ openejb/site/trunk/content/application-discovery-via-the-classpath.mdtext Mon Jul 11 02:30:12 2011
@@ -8,37 +8,36 @@ applications you'd like deployed while i
Simplify the issue of searching for annotated applications by adding an
ejb-jar.xml like this to your app:
-{code:xml|title="META-INF/ejb-jar.xml}
-<ejb-jar/>
+ <ejb-jar/>
-
- OpenEJB will find the app in the classpath and deploy it along with any
+
+OpenEJB will find the app in the classpath and deploy it along with any
annotated beans it may contain.
-
- The ejb-jar.xml can contain more than just "<ejb-jar/>" as usual.
-
- This is the recommended approach for people using OpenEJB for unit testing
+
+The ejb-jar.xml can contain more than just "<ejb-jar/>" as usual.
+
+This is the recommended approach for people using OpenEJB for unit testing
as it allows OpenEJB to find your application in the classpath without the
need for you to specify any path information which tends to complicate
builds.
# Including/Excluding paths (advanced)
- If you do not like the idea of having the ejb-jar.xml in your app or an
+If you do not like the idea of having the ejb-jar.xml in your app or an
openejb.xml, we can search the classpath for annotated beans (@Stateless,
@Stateful, @MessageDriven) and load them automatically just as if they
contained an ejb-jar.xml.
-
- This form of searching, however, is very expensive as it involves iterating
+
+This form of searching, however, is very expensive as it involves iterating
over every path in the classpath and reading in each class definition
contained thereunder and checking it for annotations.
-
- This approach can only be made faster by helping us trim down or pinpoint
+
+This approach can only be made faster by helping us trim down or pinpoint
the paths we should search via the *openejb.deployments.classpath.include*
property which can be specified as a _system property_ or a property passed
into the _InitialContext_.
-
- The value of this property is a regular expression and therefore can be
+
+The value of this property is a regular expression and therefore can be
absolute or relative. For example the path
"/Users/dblevins/work/swizzle/swizzle-stream/target/classes" which contains
the class files of an application you wish to test could be included in any
@@ -54,17 +53,17 @@ _(very relative)_
- ".\*(swizzle-stream|swizzle-jira|acme-rocket-app).\*"
_(including several paths)_
- Note the filtering is done on URLs in the classpath, so forward slashes
+Note the filtering is done on URLs in the classpath, so forward slashes
should always be used even on OSs using backslash ("\").
- There is an *openejb.deployments.classpath.exclude* property if you wish to
+There is an *openejb.deployments.classpath.exclude* property if you wish to
work in the opposite direction. The default values for both properties are
as follows:
openejb.deployments.classpath.include="" _//include nothing_
openejb.deployments.classpath.exclude=".*" _//exclude everything_
- The exclude and the include is applied separately and the results of each
+The exclude and the include is applied separately and the results of each
are combined together to create the list of paths OpenEJB will scrape for
annotations.
@@ -76,15 +75,15 @@ property to _true_. The default is _fal
# Troubleshooting
- If you're having trouble determining if the META-INF/ejb-jar.xml file for
+If you're having trouble determining if the META-INF/ejb-jar.xml file for
your ejb module is in the classpath, a little debug code like this in your
test setup will help you see what OpenEJB sees (which may be nothing):
-Enumeration<URL> ejbJars =
-this.getClass().getClassLoader().getResources("META-INF/ejb-jar.xml");
-while (ejbJars.hasMoreElements()) {
- URL url = ejbJars.nextElement();
- System.out.println("app = " + url);
-}
+ Enumeration<URL> ejbJars =
+ this.getClass().getClassLoader().getResources("META-INF/ejb-jar.xml");
+ while (ejbJars.hasMoreElements()) {
+ URL url = ejbJars.nextElement();
+ System.out.println("app = " + url);
+ }
Modified: openejb/site/trunk/content/built-in-type-converters.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/built-in-type-converters.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/built-in-type-converters.mdtext (original)
+++ openejb/site/trunk/content/built-in-type-converters.mdtext Mon Jul 11 02:30:12 2011
@@ -70,23 +70,21 @@ on the fly to the field/setter type used
Works with an ejb-jar.xml as follows:
-{code:xml|title=META-INF/ejb-jar.xml}
-<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
-metadata-complete="false">
- <enterprise-beans>
- <session>
- <ejb-name>MyBean</ejb-name>
- <env-entry>
- <env-entry-name>org.superbiz.foo.MyBean/myDate</env-entry-name>
- <env-entry-value>2008-04-19</env-entry-value>
- <env-entry-type>java.lang.String</env-entry-type>
- </env-entry>
- </session>
- </enterprise-beans>
-</ejb-jar>
+ <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
+ metadata-complete="false">
+ <enterprise-beans>
+ <session>
+ <ejb-name>MyBean</ejb-name>
+ <env-entry>
+ <env-entry-name>org.superbiz.foo.MyBean/myDate</env-entry-name>
+ <env-entry-value>2008-04-19</env-entry-value>
+ <env-entry-type>java.lang.String</env-entry-type>
+ </env-entry>
+ </session>
+ </enterprise-beans>
+ </ejb-jar>
- Or with an env-entries.properties file as follows:
- {code:none|title=META-INF/env-entries.properties}
+Or with an env-entries.properties file as follows:
org.superbiz.foo.MyBean/myDate = 2008-04-19
Modified: openejb/site/trunk/content/configuration-and-assembly.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/configuration-and-assembly.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/configuration-and-assembly.mdtext (original)
+++ openejb/site/trunk/content/configuration-and-assembly.mdtext Mon Jul 11 02:30:12 2011
@@ -18,32 +18,25 @@ This usage involves no xml parsing or cl
give it to OpenEJB, OpenEJB doesn't know about it. This is OpenEJB with
all the magic stripped away. At a high level:
-1. You build your app in code using the JAXB tree in code and hand it to
-the *ConfigurationFactory*.
-1. # The *org.apache.openejb.jee* package contains JAXB trees for
-ejb-jar.xml, beans.xml and all the Java EE deployment descriptors.
-1. The *ConfigurationFactory* will produce a fully canonical version of
-the app called the *Info* tree by:
-1. # Merging all sources of meta-data -- xml and annotations
-1. # Resolving all ejb, persistence unit, datasource and other references
-1. # Validating the app and looking for mistakes
-1. The *Info* tree is
-1. # The singular source of information about the application from this
-point forward.
-1. # Pure data with no smarts or logic of any kind.
-1. # The instruction set of what would be built by the assembler.
-1. The *Assembler* will build and start the application exactly as
-described in the *Info* tree.
-1. # When this step completes, you have a running application.
-1. # Any failures prior to this point require no cleanup. Only the
-assembler builds "live" objects.
+ # You build your app in code using the JAXB tree in code and hand it to the {{ConfigurationFactory}}.
+ ## The {{org.apache.openejb.jee}} package contains JAXB trees for ejb-jar.xml, beans.xml and all the Java EE deployment descriptors.
+ # The {{ConfigurationFactory}} will produce a fully canonical version of the app called the {{Info}} tree by:
+ ## Merging all sources of meta-data -- xml and annotations
+ ## Resolving all ejb, persistence unit, datasource and other references
+ ## Validating the app and looking for mistakes
+ # The {{Info}} tree is
+ ## The singular source of information about the application from this point forward.
+ ## Pure data with no smarts or logic of any kind.
+ ## The instruction set of what would be built by the assembler.
+ # The {{Assembler}} will build and start the application exactly as described in the {{Info}} tree.
+ ## When this step completes, you have a running application.
+ ## Any failures prior to this point require no cleanup. Only the assembler builds "live" objects.
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>StatefulTest.java</B></DIV><DIV class="codeContent panelContent">
import javax.ejb.LocalBean;
import javax.ejb.Stateful;
import javax.naming.InitialContext;
-
+
import junit.framework.TestCase;
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.assembler.classic.SecurityServiceInfo;
@@ -52,44 +45,41 @@ assembler builds "live" objects.
import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.StatefulBean;
-
+
public class StatefulTest extends TestCase {
-
+
@Override
protected void setUp() throws Exception {
-
- System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
-LocalInitialContextFactory.class.getName());
-
- ConfigurationFactory config = new ConfigurationFactory();
- Assembler assembler = new Assembler();
-
-
-assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
-
-assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
-
- EjbJar ejbJar = new EjbJar();
- ejbJar.addEnterpriseBean(new StatefulBean(MyBean.class));
-
- assembler.createApplication(config.configureApplication(ejbJar));
+
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ ConfigurationFactory config = new ConfigurationFactory();
+ Assembler assembler = new Assembler();
+
+ assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+ assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatefulBean(MyBean.class));
+
+ assembler.createApplication(config.configureApplication(ejbJar));
}
-
+
public void test() throws Exception {
- InitialContext context = new InitialContext();
- MyBean myBean = (MyBean) context.lookup("MyBeanLocalBean");
-
- assertEquals("pan", myBean.echo("nap"));
+ InitialContext context = new InitialContext();
+ MyBean myBean = (MyBean) context.lookup("MyBeanLocalBean");
+
+ assertEquals("pan", myBean.echo("nap"));
}
-
+
@Stateful
@LocalBean
public static class MyBean {
-
- public String echo(String string) {
- StringBuilder sb = new StringBuilder(string);
- return sb.reverse().toString();
- }
+
+ public String echo(String string) {
+ StringBuilder sb = new StringBuilder(string);
+ return sb.reverse().toString();
+ }
}
}
@@ -100,8 +90,7 @@ assembler.createSecurityService(config.c
Slightly more detailed account of the above. Our startup and deploy world
is broken into two phases:
- 1. configuration (app.jar -> AppInfo) we build up a fully normalized and
-validated tree. Some of the steps are
+ 1. configuration (app.jar -> AppInfo) we build up a fully normalized and validated tree. Some of the steps are
- read in descriptors
- process annotations filling in the descriptor tree
- validating app compliance
@@ -110,23 +99,21 @@ validated tree. Some of the steps are
- turning the descriptor tree into Info objects for final assembly
- final validation check
- 2. assembly (AppInfo -> actual running app) we assemble a running app as
-detailed by the AppInfo
+ 2. assembly (AppInfo -> actual running app) we assemble a running app as detailed by the AppInfo
- creating classloaders for the application
- creating EntityManagers and EntityManagerFactories
- creating live objects associated with resource-env-refs
- creating deployment (CoreDeploymentInfo) objects for each ejb
- creating the jndi enc of each ejb
- - adding method permission objects into the security system (JACC
-Provider)
+ - adding method permission objects into the security system (JACC Provider)
- creating transaction policy objects for each ejb
- - creating interceptor stacks and bindings for each ejb
- - adding ejbs to containers (which may also do things like create
-pools)
+ - creating interceptor stacks and bindings for each ejb
+ - adding ejbs to containers (which may also do things like create pools)
- adding ejbs to the live ContainerSystem registry of ejbs
- adding global jndi entries for each ejb
+
The listings above aren't necesarrily complete or perfectly ordered, but
generally show the nature of the work done in each phase.
@@ -154,8 +141,8 @@ tree and check that everything is compli
All of the aforementioned configuration phase sits behind this info object
tree and an interface that produces it:
- org.apache.openejb.assembler.classic.OpenEjbConfiguration
- org.apache.openejb.assembler.classic.OpenEjbConfigurationFactory
+ - org.apache.openejb.assembler.classic.OpenEjbConfiguration
+ - org.apache.openejb.assembler.classic.OpenEjbConfigurationFactory
The job of the OpenEjbConfigurationFactory is simply to produce an
OpenEjbConfiguration tree. With this simple decoupling when the time comes
Modified: openejb/site/trunk/content/configuration.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/configuration.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/configuration.mdtext (original)
+++ openejb/site/trunk/content/configuration.mdtext Mon Jul 11 02:30:12 2011
@@ -30,24 +30,23 @@ OpenEJB saves deployment descriptors - e
Show a config file with the elements hyperlinked.
-{code:xml|title=openejb.conf}
-<?xml version="1.0"?>
-<openejb>
- <Container id="Default CMP Container" ctype="CMP_ENTITY">
- Global_TX_Database c:/my/app/conf/postgresql.cmp_global_database.xml
- Local_TX_Database c:/my/app/conf/postgresql.cmp_local_database.xml
- </Container>
- <Connector id="Default JDBC Database">
- JdbcDriver org.postgresql.Driver
- JdbcUrl jdbc:postgresql://localhost/mydb
- UserName username
- Password password
- </Connector>
- <SecurityService id="Default Security Service"/>
- <TransactionService id="Default Transaction Manager"/>
- <Deployments jar="c:/my/app/employee.jar"/>
- <Deployments dir="beans/" />
-</openejb>
+ <?xml version="1.0"?>
+ <openejb>
+ <Container id="Default CMP Container" ctype="CMP_ENTITY">
+ Global_TX_Database c:/my/app/conf/postgresql.cmp_global_database.xml
+ Local_TX_Database c:/my/app/conf/postgresql.cmp_local_database.xml
+ </Container>
+ <Connector id="Default JDBC Database">
+ JdbcDriver org.postgresql.Driver
+ JdbcUrl jdbc:postgresql://localhost/mydb
+ UserName username
+ Password password
+ </Connector>
+ <SecurityService id="Default Security Service"/>
+ <TransactionService id="Default Transaction Manager"/>
+ <Deployments jar="c:/my/app/employee.jar"/>
+ <Deployments dir="beans/" />
+ </openejb>
# Basic Layout
Modified: openejb/site/trunk/content/configuring-datasources.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/configuring-datasources.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/configuring-datasources.mdtext (original)
+++ openejb/site/trunk/content/configuring-datasources.mdtext Mon Jul 11 02:30:12 2011
@@ -92,17 +92,14 @@ There are several possible ways to refer
*BY matching variable name to resource name*
-
-{code:java}
-@Stateless
-public class FooBean {
- @Resource DataSource myDerbyDatabase;
-}
+ @Stateless
+ public class FooBean {
+ @Resource DataSource myDerbyDatabase;
+ }
- *OR BY matching name*
+*OR BY matching name*
- {code:java}
@Stateless
public class FooBean {
@Resource(name="myDerbyDatabase")
@@ -111,36 +108,36 @@ public class FooBean {
*OR BY JNDI lookup*
-{code:java}
-@Resource(name="myDerbyDatabase", type=javax.sql.DataSource.class)
-@Stateless
-public class FooBean {
-
- public void setSessionContext(SessionContext sessionContext) {
- DataSource dataSource = (DataSource)
-sessionContext.lookup("myDerbyDatabase");
- }
- public void someOtherMethod() throws Exception {
- InitialContext initialContext = new InitialContext();
- DataSource dataSource = (DataSource)
-initialContext.lookup("java:comp/env/myDerbyDatabase");
+ @Resource(name="myDerbyDatabase", type=javax.sql.DataSource.class)
+ @Stateless
+ public class FooBean {
+
+ public void setSessionContext(SessionContext sessionContext) {
+ DataSource dataSource = (DataSource)
+ sessionContext.lookup("myDerbyDatabase");
+ }
+
+ public void someOtherMethod() throws Exception {
+ InitialContext initialContext = new InitialContext();
+ DataSource dataSource = (DataSource)
+ initialContext.lookup("java:comp/env/myDerbyDatabase");
+ }
}
-}
- *OR*
- {code:xml}
+*OR*
+
<resource-ref>
- <res-ref-name>myDerbyDatabase</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- </resource-ref>
+ <res-ref-name>myDerbyDatabase</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ </resource-ref>
*OR*
<resource-ref>
<res-ref-name>jdbc/myDerbyDatabase</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
- </resource-ref>
+ </resource-ref>
*OR*
@@ -148,5 +145,5 @@ initialContext.lookup("java:comp/env/myD
<res-ref-name>someOtherName</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<mapped-name>myDerbyDatabase</mapped-name>
- </resource-ref>
+ </resource-ref>
Modified: openejb/site/trunk/content/configuring-javamail.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/configuring-javamail.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/configuring-javamail.mdtext (original)
+++ openejb/site/trunk/content/configuring-javamail.mdtext Mon Jul 11 02:30:12 2011
@@ -8,31 +8,30 @@ javax.mail.Session.getDefaultInstance(Pr
Here might be some example properties.
-{code:xml|title=openejb.xml}
-<Resource id="SuperbizMail" type="javax.mail.Session">
- mail.smtp.host=mail.superbiz.org
- mail.smtp.port=25
- mail.transport.protocol=smtp
- mail.smtp.auth=true
- mail.smtp.user=someuser
- password=mypassword
-</Resource>
+ <Resource id="SuperbizMail" type="javax.mail.Session">
+ mail.smtp.host=mail.superbiz.org
+ mail.smtp.port=25
+ mail.transport.protocol=smtp
+ mail.smtp.auth=true
+ mail.smtp.user=someuser
+ password=mypassword
+ </Resource>
- You can create as many <Resource> entries like this as you wish, they just
+You can create as many <Resource> entries like this as you wish, they just
have to have a unique 'id'.
- {note:whitespace}
- Careful not to add whitespace at the end of your property values. A
+{note:whitespace}
+Careful not to add whitespace at the end of your property values. A
java.util.Properties object will leave those in the property values and
they will be passed to the JavaMail provider with the whitespace on the end
which may cause issues if the provider does not actively trim the values
before attempting to use them.
- {note}
+{note}
# Overriding
- If you wanted to do a System property or InitialContext property override
+If you wanted to do a System property or InitialContext property override
of the above example mail session, you could do so like this:
java ... -DSuperbizMail.mail.smtp.host=localhost
Modified: openejb/site/trunk/content/constructor-injection.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/constructor-injection.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/constructor-injection.mdtext (original)
+++ openejb/site/trunk/content/constructor-injection.mdtext Mon Jul 11 02:30:12 2011
@@ -74,24 +74,22 @@ that change as much as we do, definitely
to [jsr-316-comments@jcp.org](mailto:jsr-316-comments@jcp.org.html)
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>Not yet possible</B></DIV><DIV class="codeContent panelContent">
+Not yet possible
+
@Stateless
-
+
public class WidgetBean implements Widget {
-
- public WidgetBean(@Resource(name = "count") Integer count, @EJB Foo
-foo, @Resource DataSource ds) {
+
+ public WidgetBean(@Resource(name = "count") Integer count, @EJB Foo foo, @Resource DataSource ds) {
// do something
}
-
+
public int getCount() {
- return count;
+ return count;
}
-
+
public Foo getFoo() {
- return foo;
+ return foo;
}
}
-
-
Modified: openejb/site/trunk/content/containers.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/containers.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/containers.mdtext (original)
+++ openejb/site/trunk/content/containers.mdtext Mon Jul 11 02:30:12 2011
@@ -9,21 +9,19 @@ defined in the container system. The par
container is the ctype attribute, specifially, a ctype attribute set to
CMP_ENTITY as such...
-{code:xml|title=example_01.conf}
-<?xml version="1.0"?>
-<openejb>
+ <?xml version="1.0"?>
+ <openejb>
-<Container id="Default CMP Container" ctype="CMP_ENTITY"/>
+ <Container id="Default CMP Container" ctype="CMP_ENTITY"/>
-</openejb>
+ </openejb>
-
- The really fun part is that the above configuration file is completely
+The really fun part is that the above configuration file is completely
legal! If you started the server and pointed to this file...
- bq. ./openejb.sh start -conf example_01.conf
+ ./openejb.sh start -conf example_01.conf
- ...you would end up with a running server that contained only one
+...you would end up with a running server that contained only one
container, called "Default CMP Container". You could then deploy beans into
it and everything. There would be no other containers running in the server
at all. If you telnet'd into the server and typed the 'system' command, you
@@ -46,15 +44,14 @@ could see for yourself that there is not
> [openejb]
> $
- You see that. No beans, no JDBC resources, nothing but one CMP container
+You see that. No beans, no JDBC resources, nothing but one CMP container
called "Default CMP Container".
# Naming your Container
- You can call the container anything you want, just change the value of the
+You can call the container anything you want, just change the value of the
id attribute. Here is a container called "My PostgreSQL Contianer"
- {code:xml|title=example_02.conf}
<?xml version="1.0"?>
<openejb>
@@ -88,18 +85,16 @@ be the only container in the list.
After deployment, you would end up with a configuration like this one
-{code:xml|title=example_02.conf}
-<?xml version="1.0"?>
-<openejb>
+ <?xml version="1.0"?>
+ <openejb>
-<Container id="My PostgreSQL Container" ctype="CMP_ENTITY"/>
+ <Container id="My PostgreSQL Container" ctype="CMP_ENTITY"/>
-<Deployments jar="myCMPBean.jar" />
+ <Deployments jar="myCMPBean.jar" />
-</openejb>
+ </openejb>
-
- Most important, that bean will now be mapped directly to the container id
+Most important, that bean will now be mapped directly to the container id
"My PostgreSQL Container". So if you change the name of the container and
do not redeploy the myCMPBean.jar to point to the new container id, you
will have big problems!
@@ -113,9 +108,8 @@ types are:
* STATELESS
* STATEFUL
- The containers can all be of the same type, or a mix of the types.
+The containers can all be of the same type, or a mix of the types.
- {code:xml|title=example_03.conf}
<?xml version="1.0"?>
<openejb>
@@ -140,39 +134,36 @@ container declaration. So it's possible
the same type, but configure each one differently. Let's use our CMP_ENTITY
containers above as an example.
-{code:xml|title=example_03.conf}
-<?xml version="1.0"?>
-<openejb>
+ <?xml version="1.0"?>
+ <openejb>
-<Container id="My PostgreSQL Container" ctype="CMP_ENTITY">
- Global_TX_Database conf/postgresql.cmp.global-database.xml
- Local_TX_Database conf/postgresql.cmp.local-database.xml
-</Container>
+ <Container id="My PostgreSQL Container" ctype="CMP_ENTITY">
+ Global_TX_Database conf/postgresql.cmp.global-database.xml
+ Local_TX_Database conf/postgresql.cmp.local-database.xml
+ </Container>
-<Container id="My MySQL Container" ctype="CMP_ENTITY">
- Global_TX_Database conf/mysql.cmp.global-database.xml
- Local_TX_Database conf/mysql.cmp.local-database.xml
-</Container>
+ <Container id="My MySQL Container" ctype="CMP_ENTITY">
+ Global_TX_Database conf/mysql.cmp.global-database.xml
+ Local_TX_Database conf/mysql.cmp.local-database.xml
+ </Container>
-<Container id="My InstantDB Container" ctype="CMP_ENTITY">
- Global_TX_Database conf/instantdb.cmp.global-database.xml
- Local_TX_Database conf/instantdb.cmp.local-database.xml
-</Container>
+ <Container id="My InstantDB Container" ctype="CMP_ENTITY">
+ Global_TX_Database conf/instantdb.cmp.global-database.xml
+ Local_TX_Database conf/instantdb.cmp.local-database.xml
+ </Container>
-<Container id="My Stateful Session Container" ctype="STATEFUL"/>
-<Container id="My Stateless Session Container" ctype="STATELESS"/>
+ <Container id="My Stateful Session Container" ctype="STATEFUL"/>
+ <Container id="My Stateless Session Container" ctype="STATELESS"/>
-</openejb>
+ </openejb>
-
- The format of the configuration parameters is actually just regular old
+The format of the configuration parameters is actually just regular old
java.util.Properties file format. It keeps things simple and doesn't
require you to type endless amounts of tags that are just name/value pairs
anyway. The java.util.Properties file format allows for spaces, tabs,
colons, or equals signs to separate the name value pairs, so this would
also be acceptable..
- {code:xml|title=example_03.conf}
<?xml version="1.0"?>
<openejb>
Modified: openejb/site/trunk/content/contribution-tips.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/contribution-tips.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/contribution-tips.mdtext (original)
+++ openejb/site/trunk/content/contribution-tips.mdtext Mon Jul 11 02:30:12 2011
@@ -34,53 +34,52 @@ neater ones are (ordered simple to compl
<a name="ContributionTips-Whatistheprocess?"></a>
# What is the process?
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>Contributor.java</B></DIV><DIV class="codeContent panelContent">
public void contributeToOpenSource() {
-
+
boolean stillInterestedAndHavingFun = true;
int taskSize = 1; // start small!
-
+
contributing:
while (stillInterestedAndHavingFun) {
-
- Task task = findSomethingInteresting(taskSize++);
-
- if (!task.hasJira()) {
- createJira(task);
- } else {
- requestToBeAssignedToJira(task.jiraId());
- }
-
- while (task.inProgress()) {
-
- chatOnListALittleGetCleverIdeas(task, new Ideas(task));
- hackALittle(task);
-
- if (task.tooHard() || task.notFun()) {
- // no big deal, try again with something else
- taskSize--;
- continue contributing;
- }
- }
-
- File patchFile = createSvnOrGitPatch(task);
- attachToJira(task.jiraId(), patchFile);
- askForReviewOnList(task.jiraId());
-
- while (!committed(patchFile)) {
-
- try {
- pokeAtSometingElse();
- helpOnUserList();
- dayDream();
- } catch (MoreThanAWeekException e) {
- // Assume it fell off the radar -- happens.
- // Evidence we need more committers.
- bumpThreadOnList(task);
- }
- }
+
+ Task task = findSomethingInteresting(taskSize++);
+
+ if (!task.hasJira()) {
+ createJira(task);
+ } else {
+ requestToBeAssignedToJira(task.jiraId());
+ }
+
+ while (task.inProgress()) {
+
+ chatOnListALittleGetCleverIdeas(task, new Ideas(task));
+ hackALittle(task);
+
+ if (task.tooHard() || task.notFun()) {
+ // no big deal, try again with something else
+ taskSize--;
+ continue contributing;
+ }
+ }
+
+ File patchFile = createSvnOrGitPatch(task);
+ attachToJira(task.jiraId(), patchFile);
+ askForReviewOnList(task.jiraId());
+
+ while (!committed(patchFile)) {
+
+ try {
+ pokeAtSometingElse();
+ helpOnUserList();
+ dayDream();
+ } catch (MoreThanAWeekException e) {
+ // Assume it fell off the radar -- happens.
+ // Evidence we need more committers.
+ bumpThreadOnList(task);
+ }
+ }
}
-
+
}
Modified: openejb/site/trunk/content/datasource-password-encryption.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/datasource-password-encryption.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/datasource-password-encryption.mdtext (original)
+++ openejb/site/trunk/content/datasource-password-encryption.mdtext Mon Jul 11 02:30:12 2011
@@ -33,13 +33,13 @@ encode/decode your password.
#
# This connector will not work until you download the driver at:
# http://www.mysql.com/downloads/api-jdbc-stable.html
-
+
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost/test
UserName test
-
+
# ciphered value for Passw0rd using Static3DES codec is
-xMH5uM1V9vQzVUv5LG7YLA==
+ xMH5uM1V9vQzVUv5LG7YLA==
Password xMH5uM1V9vQzVUv5LG7YLA==
PasswordCipher Static3DES
</Resource>
@@ -106,17 +106,15 @@ shorthand as show below.
### OPTIONS
|-h, --_help_ |Lists these options and exit.|
- |-c, --_cipher_ |Specifies the password cipher implementation to use
-(default is Static3DES).|
+ |-c, --_cipher_ |Specifies the password cipher implementation to use (default is Static3DES).|
|-d, --_decrypt_ |Switches command line tool to decrypt.|
|-e, --_encrypt_ |Switches command line tool to encrypt (default).|
### EXAMPLES
- Encrypt a plain password using the default algorithm.
- {{openejb cipher Passw0rd}}
-
- Output
- {code}
+Encrypt a plain password using the default algorithm.
+{{openejb cipher Passw0rd}}
+
+Output
+
xMH5uM1V9vQzVUv5LG7YLA==
- {code}
Modified: openejb/site/trunk/content/deployment-id.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/deployment-id.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/deployment-id.mdtext (original)
+++ openejb/site/trunk/content/deployment-id.mdtext Mon Jul 11 02:30:12 2011
@@ -101,7 +101,6 @@ Each bean is added to the public, global
as its JNDI lookup. For example, if a bean had a deployment-id of
"/my/bean/foo", a non-bean client could lookup that bean as follows.
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>MyAppClient.java</B></DIV><DIV class="codeContent panelContent">
...
Object bean = initialContext.lookup("/my/bean/Foo");
...
@@ -141,7 +140,6 @@ Just as before, clients can lookup beans
bean's deployment id. For example, if a bean had a deployment-id of
"/my/bean/foo", a client could lookup that bean as follows.
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>MyAppClient.java</B></DIV><DIV class="codeContent panelContent">
...
Object bean = initialContext.lookup("/my/bean/Foo");
...
@@ -161,44 +159,30 @@ just as with the Local Server and Remote
using the bean's deployment id. OpenORB has a JNDI implementation of their
naming service, so lookups can be done just as before.
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>MyAppClient.java</B></DIV><DIV class="codeContent panelContent">
...
- Object bean = initialContext.lookup("/my/bean/Foo");
- ...
- {}
-
- CORBA clients can also access beans in OpenEJB as CORBA objects. These can
-be looked up from OpenORB's naming service (CosNaming) as follows.
-
- {code:title=MyCorbaAppClient.java}
- ...
- String[]
- args = ...
-
+ String[] args = ...
+
// The ORB and Object
org.omg.CORBA.ORB orb = null;
org.omg.CORBA.Object bean = null.
-
+
// The Naming Service and Object Name
org.omg.CosNaming.NamingContext context = null;
- org.omg.CosNaming.NameComponent[]
- name = null;
-
+ org.omg.CosNaming.NameComponent[] name = null;
+
// Get the ORB
- orb = org.omg.CORBA.ORB.init( args, null );
-
- // Get the Naming Service
+ orb = org.omg.CORBA.ORB.init( args, null );
+
+ // Get the Naming Service
org.omg.CORBA.Object ref = null;
ref = orb.resolve_initial_references("NameService");
context = org.omg.CosNaming.NamingContextHelper.narrow( ref );
-
+
// Get the Name as a component
- // Note: the string is the bean's deployment id
- name = new org.omg.CosNaming.NameComponent[ 1 ]
-;
- name[0]
- = new org.omg.CosNaming.NameComponent("/my/bean/foo","");
-
+ // Note: the string is the bean's deployment id
+ name = new org.omg.CosNaming.NameComponent[ 1 ];
+ name[0] = new org.omg.CosNaming.NameComponent("/my/bean/foo","");
+
// Finally, get the bean as a CORBA object
// Equvalent to an InitialContext.lookup("/my/bean/foo");
bean = context.resolve( name );
Modified: openejb/site/trunk/content/deployments.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/deployments.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/deployments.mdtext (original)
+++ openejb/site/trunk/content/deployments.mdtext Mon Jul 11 02:30:12 2011
@@ -8,16 +8,15 @@ Title: Deployments
To include a single jar by name, just declare a 'Deployments' element with
a 'jar' attribute pointing to the jar file on the file system.
-{code:xml|title=openejb.conf}
-<openejb>
-...
-<Deployments jar="c:\my\app\superEjbs.jar" />
-<Deployments jar="c:\someplace\purchasing.jar" />
-<Deployments jar="timeTrack.jar" />
-</openejb>
+ <openejb>
+ ...
+ <Deployments jar="c:\my\app\superEjbs.jar" />
+ <Deployments jar="c:\someplace\purchasing.jar" />
+ <Deployments jar="timeTrack.jar" />
+ </openejb>
- The last element in the example uses a relative path to point to the ejb
+The last element in the example uses a relative path to point to the ejb
jar. This path will be resolved relative to the openejb.base property.
So, for example, of the value of openejb.base was 'c:\timeapp\' then
OpenEJB would look for the jar 'c:\timeapp\timeTrack.jar'. See the [OPENEJB:Configuration]
@@ -25,11 +24,10 @@ OpenEJB would look for the jar 'c:\timea
## A directory of jars
- To point to a directory that contains several jar files that OpenEJB should
+To point to a directory that contains several jar files that OpenEJB should
load, simply declare a 'Deployments' element with a 'dir' attribute
pointing to the directory containing the jar files.
- {code:xml|title=openejb.conf}
<openejb>
...
@@ -73,48 +71,42 @@ For example, if you have a directory str
Then you would delcare a 'Deployments' element with the 'dir' attribute set
to 'C:\myapp\acmeEjbs' as shown below.
-{code:xml|title=openejb.conf}
-<openejb>
-...
+ <openejb>
+ ...
-<Deployments dir="c:\myapp\acmeEjbs" />
-</openejb>
+ <Deployments dir="c:\myapp\acmeEjbs" />
+ </openejb>
- Note that this syntax is the same as the directory syntax above. If
+Note that this syntax is the same as the directory syntax above. If
OpenEJB finds a META-INF directory with an 'ejb-jar.xml' fine inside, then
OpenEJB will treat the directory as an unpacked ejb jar. Otherwise OpenEJB
will look for ejb jar files to load as detailed in the above section.
# Log file
- When trying to figure out if your ejbs were loaded, the openejb.log file is
+When trying to figure out if your ejbs were loaded, the openejb.log file is
an incredible asset.
- If your ejbs were loaded successfully you should see entries like the
+If your ejbs were loaded successfully you should see entries like the
following (1.x and higher only):
- {panel:title=openejb.log}
INFO : Loaded EJBs from
-/usr/local/openejb-1.0-beta1/beans/openejb-itests-beans.jar
+ /usr/local/openejb-1.0-beta1/beans/openejb-itests-beans.jar
INFO : Loaded EJBs from
-/usr/local/openejb-1.0-beta1/beans/openejb-webadmin-clienttools.jar
- {panel}
-
- If your ejbs failed to load, you will see an entry similar to the
+ /usr/local/openejb-1.0-beta1/beans/openejb-webadmin-clienttools.jar
+
+If your ejbs failed to load, you will see an entry similar to the
following.
-
- {panel:title=openejb.log}
- WARN : Jar not loaded. /usr/local/openejb-1.0-beta1/beans/helloworld.jar.
-Jar failed validation. Use the validation tool for more details
- {panel}
-
- Additionally, all the successfully loaded ejbs are individually listed in
+
+ WARN : Jar not loaded. /usr/local/openejb-1.0-beta1/beans/helloworld.jar.
+ Jar failed validation. Use the validation tool for more details
+
+Additionally, all the successfully loaded ejbs are individually listed in
the log file at startup. The Deployment ID listed is the JNDI name used to
lookup the ejb from a client of the Local or Remote Servers. The beans
listed below are from our test suite.
- {noformat}
DEBUG: Deployments : 19
DEBUG: Type Deployment ID
DEBUG: CMP_ENTITY client/tests/entity/cmp/RMI-over-IIOP/EJBHome
@@ -122,22 +114,17 @@ listed below are from our test suite.
DEBUG: STATELESS client/tests/stateless/BeanManagedBasicStatelessHome
DEBUG: STATEFUL client/tests/stateful/BasicStatefulHome
DEBUG: STATELESS client/tests/stateless/EncBean
- DEBUG: STATEFUL
-client/tests/stateful/BeanManagedTransactionTests/EJBHome
+ DEBUG: STATEFUL client/tests/stateful/BeanManagedTransactionTests/EJBHome
DEBUG: BMP_ENTITY client/tests/entity/bmp/RMI-over-IIOP/EJBHome
DEBUG: STATEFUL client/tests/stateful/RMI-over-IIOP/EJBHome
- DEBUG: STATELESS
-client/tests/stateless/BeanManagedTransactionTests/EJBHome
- DEBUG: BMP_ENTITY
-client/tests/entity/bmp/allowed_operations/EntityHome
+ DEBUG: STATELESS client/tests/stateless/BeanManagedTransactionTests/EJBHome
+ DEBUG: BMP_ENTITY client/tests/entity/bmp/allowed_operations/EntityHome
DEBUG: CMP_ENTITY client/tests/entity/cmp/EncBean
DEBUG: STATEFUL client/tests/stateful/BeanManagedBasicStatefulHome
DEBUG: BMP_ENTITY client/tests/entity/bmp/BasicBmpHome
DEBUG: STATELESS client/tests/stateless/BasicStatelessHome
DEBUG: CMP_ENTITY client/tests/entity/cmp/BasicCmpHome
DEBUG: STATELESS client/tools/DatabaseHome
- DEBUG: CMP_ENTITY
-client/tests/entity/cmp/allowed_operations/EntityHome
+ DEBUG: CMP_ENTITY client/tests/entity/cmp/allowed_operations/EntityHome
DEBUG: BMP_ENTITY client/tests/entity/bmp/EncBean
DEBUG: STATELESS client/tests/stateless/RMI-over-IIOP/EJBHome
- {noformat}
Modified: openejb/site/trunk/content/details-on-openejb-jar.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/details-on-openejb-jar.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/details-on-openejb-jar.mdtext (original)
+++ openejb/site/trunk/content/details-on-openejb-jar.mdtext Mon Jul 11 02:30:12 2011
@@ -43,17 +43,16 @@ breeze.
This is the openejb-jar.xml that is created by the Deploy tool in the Hello
World example. As you can see, the file format is extremely simple.
-{code:xml|title=openejb-jar.xml}
-<?xml version="1.0"?>
-<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
- <ejb-deployment ejb-name="Hello"
- deployment-id="Hello"
- container-id="Default Stateless Container"/>
-</openejb-jar>
+ <?xml version="1.0"?>
+ <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+ <ejb-deployment ejb-name="Hello"
+ deployment-id="Hello"
+ container-id="Default Stateless Container"/>
+ </openejb-jar>
- The *ejb-name* attribute is the name you gave the bean in your ejb-jar.xml.
+The *ejb-name* attribute is the name you gave the bean in your ejb-jar.xml.
The *deployment-id* is the name you want to use to lookup the bean in your
client's JNDI namespace. The *container-id* is the name of the container in
your openejb.conf file that you would like the bean to run in. There MUST
@@ -61,10 +60,9 @@ be one *ejb-deployment* element for each
# What if my bean uses a JDBC datasource?
- Then you simply add a <resource-link> element to your <ejb-deployment>
+Then you simply add a <resource-link> element to your <ejb-deployment>
element like this
- {code:xml|title=openejb-jar.xml}
<?xml version="1.0"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
@@ -93,46 +91,43 @@ resource.
You will need one <resource-link> element for every <resource-ref> element
in your ejb-jar.xml. So if you had an ejb-jar.xml like the following
-{code:xml|title=ejb-jar.xml}
-<?xml version="1.0"?>
-<ejb-jar>
- <enterprise-beans>
- <session>
- <ejb-name>MyExampleBean</ejb-name>
- <home>com.widget.ExampleHome</home>
- <remote>com.widget.ExampleObject</remote>
- <ejb-class>com.widget.ExampleBean</ejb-class>
- <session-type>Stateless</session-type>
- <transaction-type>Container</transaction-type>
-
- <resource-ref>
- <description>
- This is a reference to a JDBC database.
- </description>
- <res-ref-name>jdbc/myFirstDatabase</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
-
- <resource-ref>
- <description>
- This is another reference to a JDBC database.
- </description>
- <res-ref-name>jdbc/anotherDatabase</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
-
- </session>
- </enterprise-beans>
-</ejb-jar>
+ <?xml version="1.0"?>
+ <ejb-jar>
+ <enterprise-beans>
+ <session>
+ <ejb-name>MyExampleBean</ejb-name>
+ <home>com.widget.ExampleHome</home>
+ <remote>com.widget.ExampleObject</remote>
+ <ejb-class>com.widget.ExampleBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+
+ <resource-ref>
+ <description>
+ This is a reference to a JDBC database.
+ </description>
+ <res-ref-name>jdbc/myFirstDatabase</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <resource-ref>
+ <description>
+ This is another reference to a JDBC database.
+ </description>
+ <res-ref-name>jdbc/anotherDatabase</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ </session>
+ </enterprise-beans>
+ </ejb-jar>
-
- Then you would need two <resource-link> elements for that bean in your
+Then you would need two <resource-link> elements for that bean in your
openejb-jar.xml file as such.
- {code:xml|title=openejb-jar.xml}
<?xml version="1.0"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
Modified: openejb/site/trunk/content/dynamic-datasource.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/dynamic-datasource.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/dynamic-datasource.mdtext (original)
+++ openejb/site/trunk/content/dynamic-datasource.mdtext Mon Jul 11 02:30:12 2011
@@ -17,7 +17,7 @@ functionnal reasons (filtering, aggregat
The interface Router (*org.apache.openejb.resource.jdbc.Router*) have
only one method to get the datasource to use:
-{code:java}Router.getDataSource(){code}
+ Router.getDataSource()
The *org.apache.openejb.resource.jdbc.RoutedDataSource* wraps a classical
data source. It has to be used to declare your datasource.
@@ -62,20 +62,21 @@ set to choose the real database to use b
So in your code you want something like:
-{code:java}@Stateless
-public class RoutedEJBBean {
- @PersistenceContext(unitName = "router")
- private EntityManager em;
-
- @Resource(name = "My Router", type = DeterminedRouter.class)
- private DeterminedRouter router; // this router is not automatic, we
-need it to select the database to use
-
- public void persist(int id, String name, String clientDatasource) {
- router.setDataSource(clientDatasource);
- em.persist(new Person(id, name));
+ public class RoutedEJBBean {
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ // this router is not automatic, we
+ // need it to select the database to use
+ @Resource(name = "My Router")
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String clientDatasource) {
+ router.setDataSource(clientDatasource);
+ em.persist(new Person(id, name));
+ }
}
-}{code}
+
<a name="DynamicDatasource-Therouterimplementation"></a>
## The router implementation
@@ -83,91 +84,84 @@ need it to select the database to use
The router will simply manage a map to store proxied datasources and a
field to store the datasource used in the current thread (ThreadLocal).
-{code:java}public class DeterminedRouter implements Router {
- private String dataSourceNames; // used to store configuration
-(openejb.xml)
- private String defaultDataSourceName; // defautl data source name
- private Map<String, DataSource> dataSources = null; // proxied data
-sources
- private ThreadLocal<DataSource> currentDataSource = new
-ThreadLocal<DataSource>(); // the datasource to use or null
-
- /**
- * @param datasourceList datasource resource name, separator is a space
- */
- public void setDataSourceNames(String datasourceList) {
- dataSourceNames = datasourceList;
- }
-
- /**
- * lookup datasource in openejb resources
- */
- private void init() { // looking up datasources declared as proxied
- dataSources = new ConcurrentHashMap<String, DataSource>();
- for (String ds : dataSourceNames.split(" ")) {
- ContainerSystem containerSystem =
-SystemInstance.get().getComponent(ContainerSystem.class);
-
- Object o = null;
- Context ctx = containerSystem.getJNDIContext();
- try {
- o = ctx.lookup("openejb:Resource/" + ds);
- if (o instanceof DataSource) {
- dataSources.put(ds, (DataSource) o);
- }
- } catch (NamingException ignore) {
- }
- }
- }
-
- /**
- * @return the user selected data source if it is set
- * or the default one
- * @throws IllegalArgumentException if the data source is not found
- */
- public DataSource getDataSource() {
- // lazy init of routed datasources
- if (dataSources == null) {
- init();
- }
-
- // if no datasource is selected use the default one
- if (currentDataSource.get() == null) {
- if (dataSources.containsKey(defaultDataSourceName)) {
- return dataSources.get(defaultDataSourceName);
-
- } else {
- throw new IllegalArgumentException("you have to specify at
-least one datasource");
- }
- }
-
- // the developper set the datasource to use
- return currentDataSource.get();
- }
-
- /**
- *
- * @param datasourceName data source name
- */
- public void setDataSource(String datasourceName) {
- if (dataSources == null) {
- init();
- }
- if (!dataSources.containsKey(datasourceName)) {
- throw new IllegalArgumentException("data source called " +
-datasourceName + " can't be found.");
- }
- DataSource ds = dataSources.get(datasourceName);
- currentDataSource.set(ds);
+ public class DeterminedRouter implements Router {
+ private String dataSourceNames; // used to store configuration (openejb.xml)
+ private String defaultDataSourceName; // defautl data source name
+ private Map<String, DataSource> dataSources = null; // proxied data sources
+ private ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>(); // the datasource to use or null
+
+ /**
+ * @param datasourceList datasource resource name, separator is a space
+ */
+ public void setDataSourceNames(String datasourceList) {
+ dataSourceNames = datasourceList;
+ }
+
+ /**
+ * lookup datasource in openejb resources
+ */
+ private void init() { // looking up datasources declared as proxied
+ dataSources = new ConcurrentHashMap<String, DataSource>();
+ for (String ds : dataSourceNames.split(" ")) {
+ ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+
+ Object o = null;
+ Context ctx = containerSystem.getJNDIContext();
+ try {
+ o = ctx.lookup("openejb:Resource/" + ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, (DataSource) o);
+ }
+ } catch (NamingException ignore) {
+ }
+ }
+ }
+
+ /**
+ * @return the user selected data source if it is set
+ * or the default one
+ * @throws IllegalArgumentException if the data source is not found
+ */
+ public DataSource getDataSource() {
+ // lazy init of routed datasources
+ if (dataSources == null) {
+ init();
+ }
+
+ // if no datasource is selected use the default one
+ if (currentDataSource.get() == null) {
+ if (dataSources.containsKey(defaultDataSourceName)) {
+ return dataSources.get(defaultDataSourceName);
+
+ } else {
+ throw new IllegalArgumentException("you have to specify at least one datasource");
+ }
+ }
+
+ // the developper set the datasource to use
+ return currentDataSource.get();
+ }
+
+ /**
+ *
+ * @param datasourceName data source name
+ */
+ public void setDataSource(String datasourceName) {
+ if (dataSources == null) {
+ init();
+ }
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ public void setDefaultDataSourceName(String name) {
+ this.defaultDataSourceName = name;
+ }
}
- public void setDefaultDataSourceName(String name) {
- this.defaultDataSourceName = name;
- }
-}{code}
-
-
<a name="DynamicDatasource-Creationoftheserviceproviderfortherouter"></a>
## Creation of the service provider for the router
@@ -177,29 +171,27 @@ META-INF/<package>. For example META-INF
This file will contain something like:
-
<ServiceJar>
<ServiceProvider id="DeterminedRouter" service="Resource"
- type="org.apache.openejb.resource.jdbc.Router"
-class-name="implementation class">
+ type="org.apache.openejb.resource.jdbc.Router" class-name="implementation class">
Param defaultValue
ParamWithNoDefaultValue
</ServiceProvider>
- </ServiceJar>{code}
+ </ServiceJar>
## openejb.xml
- In the openejb.xml file, you have to declare your dynamic database and in
+In the openejb.xml file, you have to declare your dynamic database and in
our example it needs the proxied datasources too:
- {code:xml}<Resource id="router" type="<your implementation>"
-provider="<your provider>">
+ <Resource id="router" type="<your implementation>" provider="<your provider>">
Param value
</Resource>
+
<Resource id="route db" type="DataSource" provider="RoutedDataSource">
Router router
</Resource>
-
+
<!â- real databases â for our example -->
<Resource id="db1" type="DataSource">
JdbcDriver org.hsqldb.jdbcDriver
@@ -221,4 +213,4 @@ provider="<your provider>">
UserName sa
Password
JtaManaged true
- </Resource>{code}
+ </Resource>
Modified: openejb/site/trunk/content/ejb-local-ref.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/ejb-local-ref.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/ejb-local-ref.mdtext (original)
+++ openejb/site/trunk/content/ejb-local-ref.mdtext Mon Jul 11 02:30:12 2011
@@ -2,30 +2,28 @@ Title: ejb-local-ref
<a name="ejb-local-ref-Viaannotation"></a>
# Via annotation
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>Usable by EJB, Interceptor, Servlet, Filter, or Listener</B></DIV><DIV class="codeContent panelContent">
+Usable by EJB, Interceptor, Servlet, Filter, or Listener
+
package org.superbiz.refs;
-
+
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
-
+
@Stateless
@EJB(name = "myFooEjb", beanInterface = FooLocal.class)
public class MyEjbLocalRefBean implements MyBeanInterface {
-
+
@EJB
private BarLocal myBarEjb;
-
+
public void someBusinessMethod() throws Exception {
- if (myBarEjb == null) throw new NullPointerException("myBarEjb not
-injected");
-
- // Both can be looked up from JNDI as well
- InitialContext context = new InitialContext();
- FooLocal fooLocal = (FooLocal)
-context.lookup("java:comp/env/myFooEjb");
- BarLocal barLocal = (BarLocal)
-context.lookup("java:comp/env/org.superbiz.refs.MyEjbLocalRefBean/myBarEjb");
+ if (myBarEjb == null) throw new NullPointerException("myBarEjb not injected");
+
+ // Both can be looked up from JNDI as well
+ InitialContext context = new InitialContext();
+ FooLocal fooLocal = (FooLocal) context.lookup("java:comp/env/myFooEjb");
+ BarLocal barLocal = (BarLocal) context.lookup("java:comp/env/org.superbiz.refs.MyEjbLocalRefBean/myBarEjb");
}
}
@@ -35,19 +33,17 @@ context.lookup("java:comp/env/org.superb
The above @EJB annotation usage is 100% equivalent to the following xml.
-{code:xml|title=ejb-jar.xml or web.xml}
-<ejb-local-ref>
- <ejb-ref-name>myFooEjb</ejb-ref-name>
- <local>org.superbiz.refs.FooLocal</local>
-</ejb-local-ref>
-<ejb-local-ref>
-
-<ejb-ref-name>org.superbiz.refs.MyEjbLocalRefBean/myBarEjb</ejb-ref-name>
- <local>org.superbiz.refs.BarLocal</local>
- <injection-target>
-
-<injection-target-class>org.superbiz.refs.MyEjbLocalRefBean</injection-target-class>
- <injection-target-name>myBarEjb</injection-target-name>
- </injection-target>
-</ejb-local-ref>
+ <ejb-local-ref>
+ <ejb-ref-name>myFooEjb</ejb-ref-name>
+ <local>org.superbiz.refs.FooLocal</local>
+ </ejb-local-ref>
+
+ <ejb-local-ref>
+ <ejb-ref-name>org.superbiz.refs.MyEjbLocalRefBean/myBarEjb</ejb-ref-name>
+ <local>org.superbiz.refs.BarLocal</local>
+ <injection-target>
+ <injection-target-class>org.superbiz.refs.MyEjbLocalRefBean</injection-target-class>
+ <injection-target-name>myBarEjb</injection-target-name>
+ </injection-target>
+ </ejb-local-ref>
Modified: openejb/site/trunk/content/ejb-ref.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/ejb-ref.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/ejb-ref.mdtext (original)
+++ openejb/site/trunk/content/ejb-ref.mdtext Mon Jul 11 02:30:12 2011
@@ -2,30 +2,26 @@ Title: ejb-ref
<a name="ejb-ref-Viaannotation"></a>
# Via annotation
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>Usable by EJB, Interceptor, Servlet, Filter, or Listener</B></DIV><DIV class="codeContent panelContent">
package org.superbiz.refs;
-
+
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
-
+
@Stateless
@EJB(name = "myFooEjb", beanInterface = FooRemote.class)
public class MyEjbRemoteRefBean implements MyBeanInterface {
-
+
@EJB
private BarRemote myBarEjb;
-
+
public void someBusinessMethod() throws Exception {
- if (myBarEjb == null) throw new NullPointerException("myBarEjb not
-injected");
-
- // Both can be looked up from JNDI as well
- InitialContext context = new InitialContext();
- FooRemote fooRemote = (FooRemote)
-context.lookup("java:comp/env/myFooEjb");
- BarRemote barRemote = (BarRemote)
-context.lookup("java:comp/env/org.superbiz.refs.MyEjbRemoteRefBean/myBarEjb");
+ if (myBarEjb == null) throw new NullPointerException("myBarEjb not injected");
+
+ // Both can be looked up from JNDI as well
+ InitialContext context = new InitialContext();
+ FooRemote fooRemote = (FooRemote) context.lookup("java:comp/env/myFooEjb");
+ BarRemote barRemote = (BarRemote) context.lookup("java:comp/env/org.superbiz.refs.MyEjbRemoteRefBean/myBarEjb");
}
}
@@ -35,19 +31,17 @@ context.lookup("java:comp/env/org.superb
The above @EJB annotation usage is 100% equivalent to the following xml.
-{code:xml|title=ejb-jar.xml or web.xml}
-<ejb-ref>
- <ejb-ref-name>myFooEjb</ejb-ref-name>
- <remote>org.superbiz.refs.FooRemote</remote>
-</ejb-ref>
-<ejb-ref>
-
-<ejb-ref-name>org.superbiz.refs.MyEjbRemoteRefBean/myBarEjb</ejb-ref-name>
- <remote>org.superbiz.refs.BarRemote</remote>
- <injection-target>
-
-<injection-target-class>org.superbiz.refs.MyEjbRemoteRefBean</injection-target-class>
- <injection-target-name>myBarEjb</injection-target-name>
- </injection-target>
-</ejb-ref>
+ <ejb-ref>
+ <ejb-ref-name>myFooEjb</ejb-ref-name>
+ <remote>org.superbiz.refs.FooRemote</remote>
+ </ejb-ref>
+ <ejb-ref>
+
+ <ejb-ref-name>org.superbiz.refs.MyEjbRemoteRefBean/myBarEjb</ejb-ref-name>
+ <remote>org.superbiz.refs.BarRemote</remote>
+ <injection-target>
+ <injection-target-class>org.superbiz.refs.MyEjbRemoteRefBean</injection-target-class>
+ <injection-target-name>myBarEjb</injection-target-name>
+ </injection-target>
+ </ejb-ref>
Modified: openejb/site/trunk/content/embedded-configuration.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/embedded-configuration.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/embedded-configuration.mdtext (original)
+++ openejb/site/trunk/content/embedded-configuration.mdtext Mon Jul 11 02:30:12 2011
@@ -83,14 +83,12 @@ org.hibernate.dialect.HSQLDialect");
# Example of using jndi.properties
Here's an example of the same properties being specified via a
-jndi.properties file. This file just needs to be placed in the classpath,
+`jndi.properties file`. This file just needs to be placed in the classpath,
not in a subdirectory of a path in the classpath such as META-INF, but at
the root of any of the paths in the classpath.
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>jndi.properties</B></DIV><DIV class="codeContent panelContent">
# set the initial context factory
- java.naming.factory.initial =
-org.apache.openejb.client.LocalInitialContextFactory
+ java.naming.factory.initial = org.apache.openejb.client.LocalInitialContextFactory
# change some logging
log4j.category.OpenEJB.options = debug
Modified: openejb/site/trunk/content/embedding-openejb.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/embedding-openejb.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/embedding-openejb.mdtext (original)
+++ openejb/site/trunk/content/embedding-openejb.mdtext Mon Jul 11 02:30:12 2011
@@ -49,35 +49,32 @@ debugging, developing, etc.
Try something like this for a simple IntraVM (Local) Client:
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>c:\my\app\MyEjbApplication.java</B></DIV><DIV class="codeContent panelContent">
- import java.util.Properties;
+ import FooHome;
+
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
- import FooHome;
-
+ import java.util.Properties;
+
public class MyEjbApplication {
-
- public static void main( String args[]
-) {
- try{
-
- Properties properties = new Properties();
-
- properties.put(Context.INITIAL_CONTEXT_FACTORY,
- "org.openejb.client.LocalInitialContextFactory");
-
- InitialContext ctx = new InitialContext(properties);
-
- Object obj = ctx.lookup("my/bean/Foo");
-
- FooHome ejbHome = (FooHome)
- PortableRemoteObject.narrow(obj, FooHome.class);
-
- } catch (Exception e){
- e.printStackTRace();
- }
- }
+
+ public static void main(String args[]) {
+ try {
+
+ Properties properties = new Properties();
+
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
+
+ InitialContext ctx = new InitialContext(properties);
+
+ Object obj = ctx.lookup("my/bean/Foo");
+
+ FooHome ejbHome = (FooHome) PortableRemoteObject.narrow(obj, FooHome.class);
+
+ } catch (Exception e) {
+ e.printStackTRace();
+ }
+ }
}
@@ -86,24 +83,21 @@ Try something like this for a simple Int
That would be the simplest spec compliant client you could create. If you
don't care about spec compliance and just want to "cheat", you can do this:
+ import FooHome;
-<DIV class="code panel" style="border-style: solid;border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><B>c:\my\app\MyEjbApplication.java</B></DIV><DIV class="codeContent panelContent">
import javax.naming.InitialContext;
- import FooHome;
-
+
public class MyEjbApplication {
-
- public static void main( String args[]
-) {
- try{
-
- FooHome ejbHome = (FooHome)new InitialContext().lookup(
- "java:openejb/ejb/my/bean/Foo");
-
- } catch (Exception e){
- e.printStackTRace();
- }
- }
+
+ public static void main(String args[]) {
+ try {
+
+ FooHome ejbHome = (FooHome) new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ } catch (Exception e) {
+ e.printStackTRace();
+ }
+ }
}
@@ -277,24 +271,20 @@ in your openejb.conf file will be resolv
base path.
-{code:xml|title=openejb.conf}
-<openejb>
-...
+ <openejb>
+ ...
-<Deployments dir="beans\" />
-</openejb>
+ <Deployments dir="beans\" />
+ </openejb>
-
-
- The above deployment path, "beans\", would automatically be expanded to
+The above deployment path, "beans\", would automatically be expanded to
"c:\dir\openejb\beans".
- If you want tell OpenEJB to look outside the OPENEJB_HOME, then use an
+If you want tell OpenEJB to look outside the OPENEJB_HOME, then use an
absolute file path as shown below.
- {code:xml|title=openejb.conf}
<openejb>
...
@@ -307,21 +297,16 @@ OpenEJB can look in any number of direct
directories to your openejb.conf file as such.
-{code:xml|title=openejb.conf}
-<openejb>
-...
+ <openejb>
+ ...
-<Deployments dir="beans\" />
-<Deployments dir="c:\my\app\my\beans\" /></openejb>
+ <Deployments dir="beans\" />
+ <Deployments dir="c:\my\app\my\beans\" /></openejb>
-
-
-
- Furthermore, you can add jars individually to OpenEJB's deployment path by
+Furthermore, you can add jars individually to OpenEJB's deployment path by
naming the jar directly.
- {code:xml|title=openejb.conf}
<openejb>
...
Modified: openejb/site/trunk/content/failover.mdtext
URL: http://svn.apache.org/viewvc/openejb/site/trunk/content/failover.mdtext?rev=1145009&r1=1145008&r2=1145009&view=diff
==============================================================================
--- openejb/site/trunk/content/failover.mdtext (original)
+++ openejb/site/trunk/content/failover.mdtext Mon Jul 11 02:30:12 2011
@@ -120,15 +120,13 @@ special "multicast://" URL can be used i
signify that multicast should be used to seed the connection process. Such
as:
-{code:java}
-Properties p = new Properties();
-p.put(Context.INITIAL_CONTEXT_FACTORY,
-"org.apache.openejb.client.RemoteInitialContextFactory");
-p.put(Context.PROVIDER_URL, "multicast://239.255.2.3:6142?group=default");
-InitialContext remoteContext = new InitialContext(p);
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.client.RemoteInitialContextFactory");
+ p.put(Context.PROVIDER_URL, "multicast://239.255.2.3:6142?group=default");
+ InitialContext remoteContext = new InitialContext(p);
-
- The URL has optional query parameters such as "schemes" and "group" and
+The URL has optional query parameters such as "schemes" and "group" and
"timeout" which allow you to zero in on a particular type of service of a
particular cluster group as well as set how long you are willing to wait in
the discovery process till finally giving up. The first matching service
@@ -136,34 +134,28 @@ that it sees "flowing" around on the UDP
sticks to for that and subsequent requests, ensuring UDP is only used when
there are no other servers to talk to.
- Note that EJB clients do not need to use multicast to find a server. If
+Note that EJB clients do not need to use multicast to find a server. If
the client knows the URL of a server in the cluster, it may use it and
connect directly to that server, at which point that server will share the
full list of its peers.
## Multicast Servers with TCP Clients
- Note that clients do not need to use multicast to communicate with servers.
- Servers can use multicast to discover each other, but clients are still
+Note that clients do not need to use multicast to communicate with servers.
+Servers can use multicast to discover each other, but clients are still
free to connect to servers in the network using the server's TCP address.
- {code:java}
Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY,
-"org.apache.openejb.client.RemoteInitialContextFactory");
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
p.put(Context.PROVIDER_URL, "ejbd://192.168.1.30:4201");
InitialContext remoteContext = new InitialContext(p);
-
When the client connects, the server will send the URLs of all the servers
in the group and failover will take place normally.
<a name="Failover-Multipoint(TCP)"></a>
# Multipoint (TCP)
-{info:title=Since OpenEJB 3.1.3}
-{span:style=float: right;}
-{gliffy:name=Multipoint|space=OPENEJBx30|page=Failover|align=right|border=false|size=L|version=9}
-{span}
+
As TCP has no real broadcast functionality to speak of, communication of
who is in the network is achieved by each server having a physical
connection to each other server in the network.
@@ -195,8 +187,7 @@ list to bootstrap getting the more valua
In the server this list can be specified via the
-*conf/multipoint.properties* file like so:
-
+`conf/multipoint.properties` file like so:
server = org.apache.openejb.server.discovery.MultipointDiscoveryAgent
bind = 127.0.0.1
@@ -207,7 +198,7 @@ In the server this list can be specified
The above configuration shows the server has an port 4212 open for
connections by other servers for multipoint communication. The
-*initialServers* list should be a comma separated list of other similar
+`initialServers` list should be a comma separated list of other similar
servers on the network. Only one of the servers listed is required to be
running when this server starts up -- it is not required to list all
servers in the network.
@@ -220,20 +211,17 @@ participate directly in multipoint commu
the multipoint port. The server list is simply a list of the regular
"ejbd://" urls that a client normally uses to connect to a server.
-{code:java}
-Properties p = new Properties();
-p.put(Context.INITIAL_CONTEXT_FACTORY,
-"org.apache.openejb.client.RemoteInitialContextFactory");
-p.put(Context.PROVIDER_URL,
-"failover:ejbd://192.168.1.20:4201,ejbd://192.168.1.30:4201");
-InitialContext remoteContext = new InitialContext(p);
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ p.put(Context.PROVIDER_URL, "failover:ejbd://192.168.1.20:4201,ejbd://192.168.1.30:4201");
+ InitialContext remoteContext = new InitialContext(p);
## Considerations
### Network size
- The general disadvantage of this topology is the number of connections
+The general disadvantage of this topology is the number of connections
required. The number of connections for the network of servers is equal to
"(n * n - n) / 2 ", where n is the number of servers. For example, with 5
servers you need 10 connections, with 10 servers you need 45 connections,
@@ -241,14 +229,14 @@ and with 50 servers you need 1225 connec
number of connections across the entire network, each individual server
only needs "n - 1" connections.
- The handling of these sockets is all asynchronous Java NIO code which
+The handling of these sockets is all asynchronous Java NIO code which
allows the server to handle many connections (all of them) with one thread.
From a pure threading perspective, the option is extremely efficient with
just one thread to listen and broadcast to many peers.
### Double connect
- It is possible in this process that two servers learn of each other at the
+It is possible in this process that two servers learn of each other at the
same time and each attempts to connect to the other simultaneously,
resulting in two connections between the same two servers. When this
happens both servers will detect the extra connection and one of the
@@ -258,68 +246,68 @@ server startup by as little as 100 milli
# Multipoint Configuration Recommendations
- As mentioned above the {{initialServers}} is only used for bootstrapping
+As mentioned above the {{initialServers}} is only used for bootstrapping
the multipoint network. Once running, all servers will dynamically
establish direct connections with each other and there is no single point
of failure.
- However to ensure that the bootstrapping process can occur successfully,
+However to ensure that the bootstrapping process can occur successfully,
the {{initialServers}} property of the {{conf/multipoint.properties}} file
must be set carefully and with a specific server start order in mind. Each
server consults its {{initialServers}} list exactly once in the
bootstrapping phase at startup, after that time connections are made
dynamically.
- This means that at least one of the servers listed in {{initialServers}}
+This means that at least one of the servers listed in {{initialServers}}
must already be running when the server starts or the server might never
become introduced and connected to all the other servers in the network.
## Failed scenario (background)
- As an example of a failed scenario, imagine there are three servers;
+As an example of a failed scenario, imagine there are three servers;
server1, server2, server3. They are setup only to point to the server in
front of them making a chain:
- * server1; initialServers = server2
- * server2; initialServers = server3
- * server3; initialServers = <blank>
+ * server1; initialServers = server2
+ * server2; initialServers = server3
+ * server3; initialServers = <blank>
- Which is essentially server1 -> server2 -> server3. This scenario could
+Which is essentially server1 -> server2 -> server3. This scenario could
work, but they servers would have to be started in exactly the opposite
order:
- # server3 starts
- # server2 starts
- #* static: connect to server3
- # server1 starts
- #* static: connect to server2
- #* dynamic: connect to server3
+ # server3 starts
+ # server2 starts
+ #* static: connect to server3
+ # server1 starts
+ #* static: connect to server2
+ #* dynamic: connect to server3
- At this point all servers would be fully connected. But the above setup is
+At this point all servers would be fully connected. But the above setup is
flawed and could easily fail. The first flaw is server3 lists nothing in
its {{initialServers}} list, so if it were restarted it would leave the
multipoint network and not know how to get back in.
-
- The second flaw is if you started them in any other order, you would also
+
+The second flaw is if you started them in any other order, you would also
not get a fully connected multipoint network. Say the servers were started
in "front" order:
- # server1 starts
- #* static: connect to server2 - failed, server2 not started.
- # server2 starts
- #* static: connect to server3 - failed, server3 not started.
- # server3 starts
- #* no connection attempts, initialServers list is empty.
+ # server1 starts
+ #* static: connect to server2 - failed, server2 not started.
+ # server2 starts
+ #* static: connect to server3 - failed, server3 not started.
+ # server3 starts
+ #* no connection attempts, initialServers list is empty.
- After startup completes, all servers will be completely isolated and
+After startup completes, all servers will be completely isolated and
failover will not work. The described setup is weaker than it needs to be.
- Listing just one server means the listed server is a potential point of
+Listing just one server means the listed server is a potential point of
weakness. As a matter of trivia, it is interesting to point out that you
could bring a fourth server online temporarily that lists all three
servers. Once it makes the introductions and all servers learn of each
other, you could shut it down again.
- The above setup is easily fixable via better configuration. If server3
+The above setup is easily fixable via better configuration. If server3
listed both server1 and server2 in its initialServers list, rather than
listing nothing at all, then all servers would fully discover each other
regardless of startup order; assuming all three servers did eventually
@@ -327,54 +315,51 @@ start.
## Bootstrapping Three Servers or Less
- In a three sever scenario, we recommend simply having all three servers
+In a three sever scenario, we recommend simply having all three servers
list all three servers.
-
- * server1/conf/multipoint.properties
- ** initialServers = server1, server2, server3
- * server2/conf/multipoint.properties
- ** initialServers = server1, server2, server3
- * server3/conf/multipoint.properties
- ** initialServers = server1, server2, server3
-
- There's no harm to a server listing itself. It gives you one clean list to
+
+ * server1/conf/multipoint.properties
+ ** initialServers = server1, server2, server3
+ * server2/conf/multipoint.properties
+ ** initialServers = server1, server2, server3
+ * server3/conf/multipoint.properties
+ ** initialServers = server1, server2, server3
+
+There's no harm to a server listing itself. It gives you one clean list to
maintain and it will work even if you decide not to start one of the three
servers.
## Bootstrapping Four Servers or More
- {span:style=float: right;}
- {gliffy:name=MultipointFour|space=OPENEJBx30|page=Failover|align=right|border=false|size=L|version=3}
- {span}
-
- In a scenario of four or more, we recommend picking at least to servers and
+
+In a scenario of four or more, we recommend picking at least to servers and
focus on always keeping at least one of them running. Lets refer to them
as "root" servers for simplicity sake.
- * server1/conf/multipoint.properties
- ** initialServers = server2
- * server2/conf/multipoint.properties
- ** initialServers = server1
+ * server1/conf/multipoint.properties
+ ** initialServers = server2
+ * server2/conf/multipoint.properties
+ ** initialServers = server1
- Root server1 would list root server2 so they would always be linked to each
+Root server1 would list root server2 so they would always be linked to each
other regardless of start order or if one of them went down. Server1 could
be shutdown and reconnect on startup to the full multipoint network through
server2, and vice versa.
-
- All other servers would simply list the root servers (server1, server2) in
+
+All other servers would simply list the root servers (server1, server2) in
their initialServers list.
-
- * server3/conf/multipoint.properties
- ** initialServers = server1, server2
- * server4/conf/multipoint.properties
- ** initialServers = server1, server2
- * serverN/conf/multipoint.properties
- ** initialServers = server1, server2
-
- As long as at least one root server (server1 or server2) was running, you
+
+ * server3/conf/multipoint.properties
+ ** initialServers = server1, server2
+ * server4/conf/multipoint.properties
+ ** initialServers = server1, server2
+ * serverN/conf/multipoint.properties
+ ** initialServers = server1, server2
+
+As long as at least one root server (server1 or server2) was running, you
can bring other servers on and offline at will and always have a fully
connected graph.
-
- Of course all servers once running and connected will have a full list of
+
+Of course all servers once running and connected will have a full list of
all other servers in the network, so if at any time the "root" servers
weren't around to make initial introductions to new servers it would be no
trouble. It's possible to reconfigure new servers to point at any other
@@ -382,21 +367,19 @@ server in the network as all servers wil
"root" servers are no real point of failure in function, but only of
convenience.
- {div:style=clear:both;}{div}
-
## Command line overrides
- Always remember that any property in a conf/<server-service>.properties
+Always remember that any property in a conf/<server-service>.properties
file can be overridden on the command line or via system properties. So it
is possible easily set the initialServers list in startup scripts.
-
- A bash example might look something like:
-1. !/bin/bash
+A bash example might look something like:
+
+ !/bin/bash
-OPENEJB_HOME=/opt/openejb-3.1.3
-INITIAL_LIST=$(cat /some/shared/directory/our_initial_servers.txt)
+ OPENEJB_HOME=/opt/openejb-3.1.3
+ INITIAL_LIST=$(cat /some/shared/directory/our_initial_servers.txt)
-$OPENEJB_HOME/bin/openejb start -Dmultipoint.initialServers=$INITIAL_LIST
+ $OPENEJB_HOME/bin/openejb start -Dmultipoint.initialServers=$INITIAL_LIST