http://git-wip-us.apache.org/repos/asf/tomee/blob/6972efbb/docs/containers-and-resources.md ---------------------------------------------------------------------- diff --git a/docs/containers-and-resources.md b/docs/containers-and-resources.md deleted file mode 100644 index 941fa0b..0000000 --- a/docs/containers-and-resources.md +++ /dev/null @@ -1,483 +0,0 @@ -index-group=Configuration -type=page -status=published -title=Containers and Resources -~~~~~~ - -<div id="PageContent"> - <p><a name="ContainersandResources-containers"></a></p> -<p><a name="ContainersandResources-DefaultCMPContainercontainer"></a></p> -<h2><a name="ContainersandResources-CMPENTITY"></a>CMP_ENTITY</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Container id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"CMP_ENTITY"</span>></span> -<span class="code-tag"></Container></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Container?type=CMP_ENTITY</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > CmpEngineFactory </td> -<td > Default value is <em>org.apache.openejb.core.cmp.jpa.JpaCmpEngineFactory</em>.</td> -</tr> -</tbody></table> -</div> - -<p><a name="ContainersandResources-TransactionManager"></a></p> -<h2><a name="ContainersandResources-TxMgr"></a>TransactionManager</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><TransactionManager type=<span class="code-quote">"javax.transaction.TransactionManager"</span>></span> -<span class="code-tag"></TransactionManager></span> -</pre> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > defaultTransactionTimeoutSeconds </td> -<td > Default value is <em>10 minutes</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultBMPContainercontainer"></a></p> -<h2><a name="ContainersandResources-BMPENTITY"></a>BMP_ENTITY</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Container id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"BMP_ENTITY"</span>></span> -<span class="code-tag"></Container></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Container?type=BMP_ENTITY</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > PoolSize </td> -<td > Specifies the size of the bean pools for this<br class="atl-forced-newline"> bmp entity container.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>10</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultStatelessContainercontainer"></a></p> -<h2><a name="ContainersandResources-STATELESS"></a>STATELESS</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Container id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"STATELESS"</span>></span> -<span class="code-tag"></Container></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Container?type=STATELESS</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > TimeOut </td> -<td > Specifies the time to wait between invocations. This<br class="atl-forced-newline"> value is measured in milliseconds. A value of 5 would<br class="atl-forced-newline"> result in a time-out of 5 milliseconds between invocations.<br class="atl-forced-newline"> A value of zero would mean no timeout.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>0</em>.</td> -</tr> -<tr> -<td > PoolSize </td> -<td > Specifies the size of the bean pools for this<br class="atl-forced-newline"> stateless SessionBean container.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>10</em>.</td> -</tr> -<tr> -<td > StrictPooling </td> -<td > StrictPooling tells the container what to do when the pool<br class="atl-forced-newline"> reaches it's maximum size and there are incoming requests<br class="atl-forced-newline"> that need instances.<br class="atl-forced-newline"> <br class="atl-forced-newline"> With strict pooling, requests will have to wait for instances<br class="atl-forced-newline"> to become available. The pool size will never grow beyond the<br class="atl-forced-newline"> the set PoolSize value.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Without strict pooling, the container will create temporary<br class="atl-forced-newline"> instances to meet demand. The instances will last for just one<br class="atl-forced-newline"> method invocation and then are removed.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>true</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultStatefulContainercontainer"></a></p> -<h2><a name="ContainersandResources-STATEFUL"></a>STATEFUL</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Container id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"STATEFUL"</span>></span> -<span class="code-tag"></Container></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Container?type=STATEFUL</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > Passivator </td> -<td > The passivator is responsible for writing beans to disk<br class="atl-forced-newline"> at passivation time. Different passivators can be used<br class="atl-forced-newline"> by setting this property to the fully qualified class name<br class="atl-forced-newline"> of the PassivationStrategy implementation. The passivator<br class="atl-forced-newline"> is not responsible for invoking any callbacks or other<br class="atl-forced-newline"> processing, its only responsibly is to write the bean state<br class="atl-forced-newline"> to disk.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Known implementations:<br class="atl-forced-newline"> org.apache.openejb.core.stateful.RAFPassivater<br class="atl-forced-newline"> org.apache.openejb.core.stateful.SimplePassivater<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>org.apache.openejb.core.stateful.SimplePassivater</em>.</td> -</tr> -<tr> -<td > TimeOut </td> -<td > Specifies the time to wait between invocations. This<br class="atl-forced-newline"> value is measured in minutes. A value of 5 would<br class="atl-forced-newline"> result in a time-out of 5 minutes between invocations.<br class="atl-forced-newline"> A value of zero would mean no timeout.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>20</em>.</td> -</tr> -<tr> -<td > PoolSize </td> -<td > Specifies the size of the bean pools for this<br class="atl-forced-newline"> stateful SessionBean container.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>1000</em>.</td> -</tr> -<tr> -<td > BulkPassivate </td> -<td > Property name that specifies the number of instances<br class="atl-forced-newline"> to passivate at one time when doing bulk passivation.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>100</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultMDBContainercontainer"></a></p> -<h2><a name="ContainersandResources-MESSAGE"></a>MESSAGE</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Container id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"MESSAGE"</span>></span> -<span class="code-tag"></Container></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Container?type=MESSAGE</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > ResourceAdapter </td> -<td > The resource adapter delivers messages to the container<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>Default JMS Resource Adapter</em>.</td> -</tr> -<tr> -<td > MessageListenerInterface </td> -<td > Specifies the message listener interface handled by this container<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>javax.jms.MessageListener</em>.</td> -</tr> -<tr> -<td > ActivationSpecClass </td> -<td > Specifies the activation spec class<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>org.apache.activemq.ra.ActiveMQActivationSpec</em>.</td> -</tr> -<tr> -<td > InstanceLimit </td> -<td > Specifies the maximum number of bean instances that are<br class="atl-forced-newline"> allowed to exist for each MDB deployment.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>10</em>.</td> -</tr> -</tbody></table> -</div> - - - -<p><a name="ContainersandResources-resources"></a></p> -<h1><a name="ContainersandResources-Resources"></a>Resources</h1> -<p><a name="ContainersandResources-DefaultJDBCDatabaseresource"></a></p> -<h2><a name="ContainersandResources-javax.sql.DataSource"></a>javax.sql.DataSource</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"javax.sql.DataSource"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=javax.sql.DataSource</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > JtaManaged </td> -<td > Determines wether or not this data source should be JTA managed<br class="atl-forced-newline"> or user managed. If set to 'true' it will automatically be enrolled<br class="atl-forced-newline"> in any ongoing transactions. Calling begin/commit/rollback or setAutoCommit<br class="atl-forced-newline"> on the datasource or connection will not be allowed. If you need to perform<br class="atl-forced-newline"> these functions yourself, set JtaManaged to 'false'<br class="atl-forced-newline"> <br class="atl-forced-newline"> In terms of JPA persistence.xml:<br class="atl-forced-newline"> "JtaManaged=true" can be used as a 'jta-data-source'<br class="atl-forced-newline"> "JtaManaged=false" can be used as a 'non-jta-data-source'<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>true</em>.</td> -</tr> -<tr> -<td > JdbcDriver </td> -<td > Driver class name<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>org.hsqldb.jdbcDriver</em>.</td> -</tr> -<tr> -<td > JdbcUrl </td> -<td > Url for creating connections<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>jdbc:hsqldb:file:data/hsqldb/hsqldb</em>.</td> -</tr> -<tr> -<td > UserName </td> -<td > Default user name<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>sa</em>.</td> -</tr> -<tr> -<td > Password </td> -<td > Default password</td> -</tr> -<tr> -<td > ConnectionProperties </td> -<td > The connection properties that will be sent to the JDBC<br class="atl-forced-newline"> driver when establishing new connections<br class="atl-forced-newline"> <br class="atl-forced-newline"> Format of the string must be [propertyName=property;]*<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE - The "user" and "password" properties will be passed<br class="atl-forced-newline"> explicitly, so they do not need to be included here.</td> -</tr> -<tr> -<td > DefaultAutoCommit </td> -<td > The default auto-commit state of new connections<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>true</em>.</td> -</tr> -<tr> -<td > DefaultReadOnly </td> -<td > The default read-only state of new connections<br class="atl-forced-newline"> If not set then the setReadOnly method will not be called.<br class="atl-forced-newline"> (Some drivers don't support read only mode, ex: Informix)</td> -</tr> -<tr> -<td > DefaultTransactionIsolation </td> -<td > The default TransactionIsolation state of new connections<br class="atl-forced-newline"> If not set then the setTransactionIsolation method will not<br class="atl-forced-newline"> be called. The allowed values for this property are:<br class="atl-forced-newline"> NONE<br class="atl-forced-newline"> READ_COMMITTED<br class="atl-forced-newline"> READ_UNCOMMITTED<br class="atl-forced-newline"> REPEATABLE_READ<br class="atl-forced-newline"> SERIALIZABLE<br class="atl-forced-newline"> <br class="atl-forced-newline"> Note: Most JDBC drivers do not support all isolation levels</td> -</tr> -<tr> -<td > InitialSize </td> -<td > The initial number of connections that are created when the<br class="atl-forced-newline"> pool is started<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>0</em>.</td> -</tr> -<tr> -<td > MaxActive </td> -<td > The maximum number of active connections that can be<br class="atl-forced-newline"> allocated from this pool at the same time, or a negative<br class="atl-forced-newline"> number for no limit.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>20</em>.</td> -</tr> -<tr> -<td > MaxIdle </td> -<td > The maximum number of connections that can remain idle in<br class="atl-forced-newline"> the pool, without extra ones being released, or a negative<br class="atl-forced-newline"> number for no limit.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>20</em>.</td> -</tr> -<tr> -<td > MinIdle </td> -<td > The minimum number of connections that can remain idle in<br class="atl-forced-newline"> the pool, without extra ones being created, or zero to<br class="atl-forced-newline"> create none.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>0</em>.</td> -</tr> -<tr> -<td > MaxWait </td> -<td > The maximum number of milliseconds that the pool will wait<br class="atl-forced-newline"> (when there are no available connections) for a connection<br class="atl-forced-newline"> to be returned before throwing an exception, or -1 to wait<br class="atl-forced-newline"> indefinitely.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>-1</em>.</td> -</tr> -<tr> -<td > ValidationQuery </td> -<td > The SQL query that will be used to validate connections from<br class="atl-forced-newline"> this pool before returning them to the caller. If specified,<br class="atl-forced-newline"> this query MUST be an SQL SELECT statement that returns at<br class="atl-forced-newline"> least one row.</td> -</tr> -<tr> -<td > TestOnBorrow </td> -<td > If true connections will be validated before being borrowed<br class="atl-forced-newline"> from the pool. If the validation fails, the connection is<br class="atl-forced-newline"> destroyed, and a new conection will be retrieved from the<br class="atl-forced-newline"> pool (and validated).<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE - for a true value to have any effect, the<br class="atl-forced-newline"> ValidationQuery parameter must be set.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>true</em>.</td> -</tr> -<tr> -<td > TestOnReturn </td> -<td > If true connections will be validated before being returned<br class="atl-forced-newline"> to the pool. If the validation fails, the connection is<br class="atl-forced-newline"> destroyed instead of being returned to the pool.<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE - for a true value to have any effect, the<br class="atl-forced-newline"> ValidationQuery parameter must be set.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>false</em>.</td> -</tr> -<tr> -<td > TestWhileIdle </td> -<td > If true connections will be validated by the idle connection<br class="atl-forced-newline"> evictor (if any). If the validation fails, the connection is<br class="atl-forced-newline"> destroyed and removed from the pool<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE - for a true value to have any effect, the<br class="atl-forced-newline"> timeBetweenEvictionRunsMillis property must be a positive<br class="atl-forced-newline"> number and the ValidationQuery parameter must be set.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>false</em>.</td> -</tr> -<tr> -<td > TimeBetweenEvictionRunsMillis </td> -<td > The number of milliseconds to sleep between runs of the idle<br class="atl-forced-newline"> connection evictor thread. When set to a negative number, no<br class="atl-forced-newline"> idle connection evictor thread will be run.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>-1</em>.</td> -</tr> -<tr> -<td > NumTestsPerEvictionRun </td> -<td > The number of connectionss to examine during each run of the<br class="atl-forced-newline"> idle connection evictor thread (if any).<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>3</em>.</td> -</tr> -<tr> -<td > MinEvictableIdleTimeMillis </td> -<td > The minimum amount of time a connection may sit idle in the<br class="atl-forced-newline"> pool before it is eligable for eviction by the idle<br class="atl-forced-newline"> connection evictor (if any).<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>1800000</em>.</td> -</tr> -<tr> -<td > PoolPreparedStatements </td> -<td > If true, a statement pool is created for each Connection and<br class="atl-forced-newline"> PreparedStatements created by one of the following methods are<br class="atl-forced-newline"> pooled:<br class="atl-forced-newline"> public PreparedStatement prepareStatement(String sql);<br class="atl-forced-newline"> public PreparedStatement prepareStatement(String sql,<br class="atl-forced-newline"> int resultSetType,<br class="atl-forced-newline"> int resultSetConcurrency)<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>false</em>.</td> -</tr> -<tr> -<td > MaxOpenPreparedStatements </td> -<td > The maximum number of open statements that can be allocated<br class="atl-forced-newline"> from the statement pool at the same time, or zero for no<br class="atl-forced-newline"> limit.<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE - Some drivers have limits on the number of open<br class="atl-forced-newline"> statements, so make sure there are some resources left<br class="atl-forced-newline"> for the other (non-prepared) statements.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>0</em>.</td> -</tr> -<tr> -<td > AccessToUnderlyingConnectionAllowed </td> -<td > If true the raw physical connection to the database can be<br class="atl-forced-newline"> accessed using the following construct:<br class="atl-forced-newline"> Connection conn = ds.getConnection();<br class="atl-forced-newline"> Connection rawConn = ((DelegatingConnection) conn).getInnermostDelegate();<br class="atl-forced-newline"> ...<br class="atl-forced-newline"> conn.close()<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default is false, because misbehaving programs can do harmfull<br class="atl-forced-newline"> things to the raw connection shuch as closing the raw<br class="atl-forced-newline"> connection or continuing to use the raw connection after it<br class="atl-forced-newline"> has been assigned to another logical connection. Be carefull<br class="atl-forced-newline"> and only use when you need direct access to driver specific<br class="atl-f orced-newline"> extentions.<br class="atl-forced-newline"> <br class="atl-forced-newline"> NOTE: Do NOT close the underlying connection, only the<br class="atl-forced-newline"> original logical connection wrapper.<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>false</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultJMSResourceAdapterresource"></a></p> -<h2><a name="ContainersandResources-ActiveMQResourceAdapter"></a>ActiveMQResourceAdapter</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"ActiveMQResourceAdapter"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=ActiveMQResourceAdapter</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > BrokerXmlConfig </td> -<td > Broker configuration<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>broker:(tcp://localhost:61616)?useJmx=false</em>.</td> -</tr> -<tr> -<td > ServerUrl </td> -<td > Broker address<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>vm://localhost?async=true</em>.</td> -</tr> -<tr> -<td > DataSource </td> -<td > DataSource for persistence messages<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>Default Unmanaged JDBC Database</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultJMSConnectionFactoryresource"></a></p> -<h2><a name="ContainersandResources-javax.jms.ConnectionFactory"></a>javax.jms.ConnectionFactory</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"javax.jms.ConnectionFactory"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=javax.jms.ConnectionFactory</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > ResourceAdapter </td> -<td > Default value is <em>Default JMS Resource Adapter</em>.</td> -</tr> -<tr> -<td > TransactionSupport </td> -<td > Specifies if the connection is enrolled in global transaction<br class="atl-forced-newline"> allowed values: xa, local or none<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>xa</em>.</td> -</tr> -<tr> -<td > PoolMaxSize </td> -<td > Maximum number of physical connection to the ActiveMQ broker<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>10</em>.</td> -</tr> -<tr> -<td > PoolMinSize </td> -<td > Minimum number of physical connection to the ActiveMQ broker<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>0</em>.</td> -</tr> -<tr> -<td > ConnectionMaxWaitMilliseconds </td> -<td > Maximum amount of time to wait for a connection<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>5000</em>.</td> -</tr> -<tr> -<td > ConnectionMaxIdleMinutes </td> -<td > Maximum amount of time a connection can be idle before being reclaimed<br class="atl-forced-newline"> <br class="atl-forced-newline"> Default value is <em>15</em>.</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultQueueresource"></a></p> -<h2><a name="ContainersandResources-javax.jms.Queue"></a>javax.jms.Queue</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"javax.jms.Queue"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=javax.jms.Queue</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > destination </td> -<td > Specifies the name of the queue</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultTopicresource"></a></p> -<h2><a name="ContainersandResources-javax.jms.Topic"></a>javax.jms.Topic</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"javax.jms.Topic"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=javax.jms.Topic</p> -</div></div> -<p>Supports the following properties</p> -<div class="table-wrap"> -<table class="mdtable"> <tbody> -<tr> -<th > Property Name </th> -<th > Description </th> -</tr> -<tr> -<td > destination </td> -<td > Specifies the name of the topic</td> -</tr> -</tbody></table> -</div> - - -<p><a name="ContainersandResources-DefaultORBresource"></a></p> -<h2><a name="ContainersandResources-org.omg.CORBA.ORB"></a>org.omg.CORBA.ORB</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"org.omg.CORBA.ORB"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=org.omg.CORBA.ORB</p> -</div></div> -<p>No properties.</p> - -<p><a name="ContainersandResources-DefaultMailSessionresource"></a></p> -<h2><a name="ContainersandResources-javax.mail.Session"></a>javax.mail.Session</h2> -<p>Declarable in tomee.xml via</p> -<div style="border-width: 1px;" class="code panel"><div class="codeContent panelContent"> -<pre class="code-xml"><span class="code-tag"><Resource id=<span class="code-quote">"Foo"</span> type=<span class="code-quote">"javax.mail.Session"</span>></span> -<span class="code-tag"></Resource></span> -</pre> -</div></div> -<p>Declarable in properties via</p> -<div style="border-width: 1px;" class="panel"><div class="panelContent"> -<p>Foo = new://Resource?type=javax.mail.Session</p> -</div></div> -<p>No properties.</p> -
http://git-wip-us.apache.org/repos/asf/tomee/blob/6972efbb/docs/contrib/debug/debug-intellij.adoc ---------------------------------------------------------------------- diff --git a/docs/contrib/debug/debug-intellij.adoc b/docs/contrib/debug/debug-intellij.adoc new file mode 100644 index 0000000..27da57e --- /dev/null +++ b/docs/contrib/debug/debug-intellij.adoc @@ -0,0 +1,182 @@ +:index-group: IDE +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + + +#Debugging an Apache +TomEE App in Intellij IDEA + +Stepping through the http://tomee.apache.org/apache-tomee.html[TomEE] +source code is a must-to-follow step if you want to understand how TomEE +works and later contribute. This is a guide to quickly start your +debugging session with TomEE as a TomEE developer. + +This guide assumes that: + +* Linux is the OS +* IntelliJ IDEA 13.1.3 is the IDE +* Maven 3.0.5 or better is installed + +###Download the Source Code + +For beginners it is recommended not to start with the trunk, because it +is common to have some blockers or non-stable functionality which could +bring your learning to a halt. So first start with the latest stable +released source code. Move to trunk once you are ready to do some code +modification on TomEE. + +http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.7.1/openejb-4.7.1-source-release.zip[Click +here to download TomEE 1.7.1 Source code] + +###Build the Source Code + +First extract the zip file named *openejb-4.7.1-source-release.zip* to +any location. Lets assume it is your home folder. + +_______________________________________ +unzip openejb-4.7.1-source-release -d ~ +_______________________________________ + +The above command will create the *openejb-4.7.1* directory in your home +directory. + +Even though you can do a full build, We will run the following command +to do a quick build so that you can have your meal before your hunger +kills you. + +_________________________________________________________________________________________________________________________________________________ +mvn -Pquick -Dsurefire.useFile=false -DdisableXmlReport=true +-DuniqueVersion=false -ff -Dassemble -DskipTests -DfailIfNoTests=false +clean install +_________________________________________________________________________________________________________________________________________________ + +More details about building the product from the source can be found +http://tomee.apache.org/dev/source-code.html[here]. + +###Deploy TomEE + +The TomEE build builds several distributions (zip & war files) to cater +the different needs of different users. Here we discuss about the tomee +plus distribution & TomEE war distribution only. TomEE+ is the full +feature packed distribution from TomEE. + +TomEE+ zip location: + +_____________________________________________________________________ +~/openejb-4.7.1/tomee/apache-tomee/target/apache-tomee-plus-1.7.1.zip +_____________________________________________________________________ + +Unzip the zip into your home directory (or any other location) + +________________________________________________________________________________ +unzip +~/openejb-4.7.1/tomee/apache-tomee/target/apache-tomee-plus-1.7.1.zip -d +~ +________________________________________________________________________________ + +You will find the directory *apache-tomee-plus-1.7.1* in your home +folder. Lets run the TomEE. + +__________________________________________________ +cd ~/apache-tomee-plus-1.7.1/bin ./catalina.sh run +__________________________________________________ + +"INFO: Server startup in xxxx ms" is the Green light! + +###Prepare your IDE + +Lets prepare our IntelliJ IDEA for the debugging session. + +Start IntelliJ IDEA and Click the Import Project link + +image:idea1.png[image] + +Select the ~/openejb-4.7.1 directory and press OK + +Select import project from external model & Maven as the external model. + +image:idea3.png[image] + +Press Next on this screen. + +image:idea4.png[image] + +Select the main profile. + +image:idea6.png[image] + +Select the org.apache.openejb:openejb:4.7.1 + +image:idea7.png[image] + +Select the JDK you want to use with. + +image:idea8.png[image] + +Give the project a name and press Finish. + +image:idea9.png[image] + +Now your IDE will load the project. + +###First Breakpoint + +Next step is to put a breakpoint at the place where the code is +triggered. Lets understand how the code is triggered. + +TomEE+ is created on top of Tomcat. TomEE registers a Tomcat Lifecycle +Listener *"org.apache.tomee.catalina.ServerListener"* on *server.xml* +file. + +All the Tomcat lifecycle events i.e. before_init, after_init, start, +before_stop etc... are received by the *lifecycleEvent* method of the +ServerListener. + +The execution of TomEE code starts in this lifecycleEvent method. So the +first breakpoint should be on the lifecycleEvent method. + +###Run TomEE+ in debug mode + +If you simply run *catalina.sh jpda run* in the bin folder of tomee +deployment, the server starts in the debug mode but it will quckly pass +your breakpoint before you attach your IDE to the server process. + +So we set** JPDA_SUSPEND="y"** before we start our debugging. This will +tell the server "Do not proceed until the Debugger tool is attached to +the process" + +The convenient way of doing this is adding this line to catalina.sh file +right after the #!/bin/sh line. + +________________________________________ +#!/bin/sh JPDA_SUSPEND="y" + +Now to time to run TomEE+ on debug mode. +________________________________________ + +__________________________________________________ +~/apache-tomee-plus-1.7.1/bin/catalina.sh jpda run +__________________________________________________ + +The terminal should hang with the message *"Listening for transport +dt_socket at address: 8000"* + +###Attach IntelliJ IDEA debugger + +* Menu Bar > Run > Edit Configurations +* Press the "*+*" button on the top left corner to get the Add new +configuration menu +* Select "Remote" from the Add new configuration menu +* Give a name (I gave "TomEE DEBUG") to this new configuration and set +the Port to 8000 +* Click OK. + +image:idea10.png[image] + +To start debugging your TomEE+ + +Main Menu > Run > Debug TomEE DEBUG + +Congratulations! You hit the break point you put at the startup of the +TomEE code. Carry on with your debugging session to learn more. http://git-wip-us.apache.org/repos/asf/tomee/blob/6972efbb/docs/contrib/debug/debug-intellij.md ---------------------------------------------------------------------- diff --git a/docs/contrib/debug/debug-intellij.md b/docs/contrib/debug/debug-intellij.md deleted file mode 100644 index d467cb0..0000000 --- a/docs/contrib/debug/debug-intellij.md +++ /dev/null @@ -1,133 +0,0 @@ -index-group=IDE -type=page -status=published -~~~~~~ -<a name='DEBUGIDE'></a> -#Debugging an Apache TomEE App in Intellij IDEA - -Stepping through the [TomEE](http://tomee.apache.org/apache-tomee.html) source code is a must-to-follow step if you want to understand how TomEE works and later contribute. This is a guide to quickly start your debugging session with TomEE as a TomEE developer. - -This guide assumes that: - - - Linux is the OS - - IntelliJ IDEA 13.1.3 is the IDE - - Maven 3.0.5 or better is installed - - -###Download the Source Code - -For beginners it is recommended not to start with the trunk, because it is common to have some blockers or non-stable functionality which could bring your learning to a halt. So first start with the latest stable released source code. Move to trunk once you are ready to do some code modification on TomEE. - -[Click here to download TomEE 1.7.1 Source code](http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.7.1/openejb-4.7.1-source-release.zip) - -###Build the Source Code - -First extract the zip file named **openejb-4.7.1-source-release.zip** to any location. Lets assume it is your home folder. - -> unzip openejb-4.7.1-source-release -d ~ - -The above command will create the **openejb-4.7.1** directory in your home directory. - -Even though you can do a full build, We will run the following command to do a quick build so that you can have your meal before your hunger kills you. - -> mvn -Pquick -Dsurefire.useFile=false -DdisableXmlReport=true -DuniqueVersion=false -ff -Dassemble -DskipTests -DfailIfNoTests=false clean install - -More details about building the product from the source can be found [here](http://tomee.apache.org/dev/source-code.html). - -###Deploy TomEE - -The TomEE build builds several distributions (zip & war files) to cater the different needs of different users. Here we discuss about the tomee plus distribution & TomEE war distribution only. TomEE+ is the full feature packed distribution from TomEE. - -TomEE+ zip location: - -> ~/openejb-4.7.1/tomee/apache-tomee/target/apache-tomee-plus-1.7.1.zip - -Unzip the zip into your home directory (or any other location) - -> unzip ~/openejb-4.7.1/tomee/apache-tomee/target/apache-tomee-plus-1.7.1.zip -d ~ - -You will find the directory **apache-tomee-plus-1.7.1** in your home folder. Lets run the TomEE. - -> cd ~/apache-tomee-plus-1.7.1/bin <br /> -> ./catalina.sh run <br /> - -"INFO: Server startup in xxxx ms" is the Green light! - -###Prepare your IDE - -Lets prepare our IntelliJ IDEA for the debugging session. - -Start IntelliJ IDEA and Click the Import Project link - - - -Select the ~/openejb-4.7.1 directory and press OK - -Select import project from external model & Maven as the external model. - - - -Press Next on this screen. - - - -Select the main profile. - - - -Select the org.apache.openejb:openejb:4.7.1 - - - -Select the JDK you want to use with. - - - -Give the project a name and press Finish. - - - -Now your IDE will load the project. - -###First Breakpoint - -Next step is to put a breakpoint at the place where the code is triggered. Lets understand how the code is triggered. - -TomEE+ is created on top of Tomcat. TomEE registers a Tomcat Lifecycle Listener **"org.apache.tomee.catalina.ServerListener"** on **server.xml** file. - -All the Tomcat lifecycle events i.e. before_init, after_init, start, before_stop etc... are received by the **lifecycleEvent** method of the ServerListener. - -The execution of TomEE code starts in this lifecycleEvent method. So the first breakpoint should be on the lifecycleEvent method. - -###Run TomEE+ in debug mode - -If you simply run **catalina.sh jpda run** in the bin folder of tomee deployment, the server starts in the debug mode but it will quckly pass your breakpoint before you attach your IDE to the server process. - -So we set** JPDA_SUSPEND="y"** before we start our debugging. This will tell the server "Do not proceed until the Debugger tool is attached to the process" - -The convenient way of doing this is adding this line to catalina.sh file right after the #!/bin/sh line. - -> \#!/bin/sh -> JPDA_SUSPEND="y" -> -Now to time to run TomEE+ on debug mode. - -> ~/apache-tomee-plus-1.7.1/bin/catalina.sh jpda run - -The terminal should hang with the message **"Listening for transport dt_socket at address: 8000"** - -###Attach IntelliJ IDEA debugger - -* Menu Bar > Run > Edit Configurations -* Press the "**+**" button on the top left corner to get the Add new configuration menu -* Select "Remote" from the Add new configuration menu -* Give a name (I gave "TomEE DEBUG") to this new configuration and set the Port to 8000 -* Click OK. - -</div> - -To start debugging your TomEE+ - -Main Menu > Run > Debug TomEE DEBUG - -Congratulations! You hit the break point you put at the startup of the TomEE code. Carry on with your debugging session to learn more. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/6972efbb/docs/custom-injection.adoc ---------------------------------------------------------------------- diff --git a/docs/custom-injection.adoc b/docs/custom-injection.adoc new file mode 100644 index 0000000..33314f4 --- /dev/null +++ b/docs/custom-injection.adoc @@ -0,0 +1,203 @@ +# Custom Injection +:index-group: Unrevised +:jbake-date: 2018-12-05 +:jbake-type: page +:jbake-status: published + +# Overview + +As noted in the link:injection-of-env-entry-example.html[Injection of +env-entry Example] , the EJB 3.0 supported env-entry types are fairly +limited. Also the use of several tags in an ejb-jar.xml can get a bit +verbose. + +OpenEJB does not restrict you to just these data types or require you to +use an ejb-jar.xml to declare them. + +* `@Resource` can be used on any type for which there is +`java.beans.PropertyEditor` +* You may `install your own` PropertyEditors and package them with your +app. +* Java Generics are supported (e.g. List myURIs) +* You may use a `META-INF/env-entries.properties` file as an alternative +to an ejb-jar.xml + +See link:built-in-type-converters.html[Built-in Type Converters] for a +full list of supported env-entry types. + +The source for this example is the "custom-injection" directory located +in the link:downloads.html[openejb-examples.zip] available on the +http://tomee.apache.org/downloads.html[download page]. + +# The Code + +== Bean Class + +.... +@Stateless +public class Stratocaster { + + @Resource(name = "pickups") + private List<Pickup> pickups; + + @Resource(name = "style") + private Style style; + + @Resource(name = "dateCreated") + private Date dateCreated; + + @Resource(name = "guitarStringGuages") + private Map<String, Float> guitarStringGuages; + + @Resource(name = "certificateOfAuthenticity") + private File certificateOfAuthenticity; + + public Date getDateCreated() { + return dateCreated; + } + + /** + * Gets the guage of the electric guitar strings + * used in this guitar. + * + * @param string + * @return + */ + public float getStringGuage(String string) { + return guitarStringGuages.get(string); + } + + public List<Pickup> getPickups() { + return pickups; + } + + public Style getStyle() { + return style; + } + + public File getCertificateOfAuthenticity() { + return certificateOfAuthenticity; + } +} +.... + +== The META-INF/env-entries.properties file + +.... +guitarStringGuages=E1=0.052\nA=0.042\nD=0.030\nG=0.017\nB=0.013\nE=0.010 +certificateOfAuthenticity=/tmp/strat-certificate.txt +dateCreated=1962-03-01 +pickups=S,S,S +style=VINTAGE +.... + +== The Custom Type and Editor + +Support for java.lang.Enum types is already built-in, but we've decided +we'd like to allow abbreviated versions of the enum constants to be +usable. We do this by creating a custom PropertyEditor for our Pickup +enum like so: + +.... +public class PickupEditor extends java.beans.PropertyEditorSupport { + public void setAsText(String text) throws IllegalArgumentException { + text = text.trim(); + + if (text.equalsIgnoreCase("H")) setValue(Pickup.HUMBUCKER); + else if (text.equalsIgnoreCase("S")) setValue(Pickup.SINGLE_COIL); + else throw new IllegalStateException("H and S are the only supported Pickup aliases"); + } +} +.... + +We cleverly install this PropertyEditor in a static block in the Pickup +class that will be executed should someone actually reference the Pickup +type. + +.... +public enum Pickup { + + HUMBUCKER, + SINGLE_COIL; + + // Here's the little magic where we register the PickupEditor + // which knows how to create this object from a string. + // You can add any of your own Property Editors in the same way. + static { + PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class); + } +} +.... + +# Test Case + +.... +public class StratocasterTest extends TestCase { + + @EJB + private Stratocaster strat; + + public void test() throws Exception { + EJBContainer.createEJBContainer().getContext().bind("inject", this); + + Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962"); + assertEquals("Strat.getDateCreated()", date, strat.getDateCreated()); + + List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL); + assertEquals("Strat.getPickups()", pickups, strat.getPickups()); + + assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle()); + + assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1")); + assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A")); + assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D")); + assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G")); + assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B")); + assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E")); + + File file = new File("/tmp/strat-certificate.txt"); + assertEquals("Strat.getCertificateOfAuthenticity()", file,strat.getCertificateOfAuthenticity()); + + + } +} +.... + +# Running it + +Running the example is fairly simple. In the "custom-injection" +directory of the openejb:download.html[examples zip], just run: + +___________________ +$ mvn clean install +___________________ + +Which should create output like the following. + +.... +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running org.superbiz.enventries.StratocasterTest +Apache OpenEJB 3.1-SNAPSHOT build: 20080409-12:05 +http://tomee.apache.org/ +INFO - openejb.home = /Users/dblevins/work/openejb3/examples/custom-injection +INFO - openejb.base = /Users/dblevins/work/openejb3/examples/custom-injection +INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) +INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) +INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory, type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory) +INFO - Found EjbModule in classpath: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes +INFO - Configuring app: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes +INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) +INFO - Auto-creating a container for bean StratocasterImpl: Container(type=STATELESS, id=Default Stateless Container) +INFO - Loaded Module: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes +INFO - Assembling app: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes +INFO - Jndi(name=StratocasterImplLocal) --> Ejb(deployment-id=StratocasterImpl) +INFO - Created Ejb(deployment-id=StratocasterImpl, ejb-name=StratocasterImpl, container=Default Stateless Container) +INFO - Deployed Application(path=/Users/dblevins/work/openejb3/examples/custom-injection/target/classes) +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.705 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 +.... http://git-wip-us.apache.org/repos/asf/tomee/blob/6972efbb/docs/custom-injection.md ---------------------------------------------------------------------- diff --git a/docs/custom-injection.md b/docs/custom-injection.md deleted file mode 100644 index 2a46922..0000000 --- a/docs/custom-injection.md +++ /dev/null @@ -1,193 +0,0 @@ -index-group=Unrevised -type=page -status=published -title=Custom Injection -~~~~~~ -# Overview - -As noted in the [Injection of env-entry Example](injection-of-env-entry-example.html) -, the EJB 3.0 supported env-entry types are fairly limited. Also the use -of several <env-entry> tags in an ejb-jar.xml can get a bit verbose. - -OpenEJB does not restrict you to just these data types or require you to -use an ejb-jar.xml to declare them. - - - `@Resource` can be used on any type for which there is -`java.beans.PropertyEditor` - - You may `install your own` PropertyEditors and package them with your -app. - - Java Generics are supported (e.g. List<URI> myURIs) - - You may use a `META-INF/env-entries.properties` file as an alternative -to an ejb-jar.xml - -See [Built-in Type Converters](built-in-type-converters.html) -for a full list of supported env-entry types. - -The source for this example is the "custom-injection" directory located in -the [openejb-examples.zip](downloads.html) -available on the [download page](http://tomee.apache.org/downloads.html). - -<a name="CustomInjection-TheCode"></a> -# The Code - -<a name="CustomInjection-BeanClass"></a> -## Bean Class - - @Stateless - public class Stratocaster { - - @Resource(name = "pickups") - private List<Pickup> pickups; - - @Resource(name = "style") - private Style style; - - @Resource(name = "dateCreated") - private Date dateCreated; - - @Resource(name = "guitarStringGuages") - private Map<String, Float> guitarStringGuages; - - @Resource(name = "certificateOfAuthenticity") - private File certificateOfAuthenticity; - - public Date getDateCreated() { - return dateCreated; - } - - /** - * Gets the guage of the electric guitar strings - * used in this guitar. - * - * @param string - * @return - */ - public float getStringGuage(String string) { - return guitarStringGuages.get(string); - } - - public List<Pickup> getPickups() { - return pickups; - } - - public Style getStyle() { - return style; - } - - public File getCertificateOfAuthenticity() { - return certificateOfAuthenticity; - } - } - -<a name="CustomInjection-TheMETA-INF/env-entries.propertiesfile"></a> -## The META-INF/env-entries.properties file - - guitarStringGuages=E1=0.052\nA=0.042\nD=0.030\nG=0.017\nB=0.013\nE=0.010 - certificateOfAuthenticity=/tmp/strat-certificate.txt - dateCreated=1962-03-01 - pickups=S,S,S - style=VINTAGE - -<a name="CustomInjection-TheCustomTypeandEditor"></a> -## The Custom Type and Editor - -Support for java.lang.Enum types is already built-in, but we've decided -we'd like to allow abbreviated versions of the enum constants to be usable. - We do this by creating a custom PropertyEditor for our Pickup enum like -so: - - public class PickupEditor extends java.beans.PropertyEditorSupport { - public void setAsText(String text) throws IllegalArgumentException { - text = text.trim(); - - if (text.equalsIgnoreCase("H")) setValue(Pickup.HUMBUCKER); - else if (text.equalsIgnoreCase("S")) setValue(Pickup.SINGLE_COIL); - else throw new IllegalStateException("H and S are the only supported Pickup aliases"); - } - } - -We cleverly install this PropertyEditor in a static block in the Pickup -class that will be executed should someone actually reference the Pickup -type. - - public enum Pickup { - - HUMBUCKER, - SINGLE_COIL; - - // Here's the little magic where we register the PickupEditor - // which knows how to create this object from a string. - // You can add any of your own Property Editors in the same way. - static { - PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class); - } - } - -<a name="CustomInjection-TestCase"></a> -# Test Case - - public class StratocasterTest extends TestCase { - - @EJB - private Stratocaster strat; - - public void test() throws Exception { - EJBContainer.createEJBContainer().getContext().bind("inject", this); - - Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962"); - assertEquals("Strat.getDateCreated()", date, strat.getDateCreated()); - - List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL); - assertEquals("Strat.getPickups()", pickups, strat.getPickups()); - - assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle()); - - assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1")); - assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A")); - assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D")); - assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G")); - assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B")); - assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E")); - - File file = new File("/tmp/strat-certificate.txt"); - assertEquals("Strat.getCertificateOfAuthenticity()", file,strat.getCertificateOfAuthenticity()); - - - } - } - -<a name="CustomInjection-Runningit"></a> -# Running it - -Running the example is fairly simple. In the "custom-injection" directory of the [examples zip](openejb:download.html), just run: - -> $ mvn clean install - -Which should create output like the following. - - - ------------------------------------------------------- - T E S T S - ------------------------------------------------------- - Running org.superbiz.enventries.StratocasterTest - Apache OpenEJB 3.1-SNAPSHOT build: 20080409-12:05 - http://tomee.apache.org/ - INFO - openejb.home = /Users/dblevins/work/openejb3/examples/custom-injection - INFO - openejb.base = /Users/dblevins/work/openejb3/examples/custom-injection - INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) - INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) - INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory, type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory) - INFO - Found EjbModule in classpath: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes - INFO - Configuring app: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes - INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) - INFO - Auto-creating a container for bean StratocasterImpl: Container(type=STATELESS, id=Default Stateless Container) - INFO - Loaded Module: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes - INFO - Assembling app: /Users/dblevins/work/openejb3/examples/custom-injection/target/classes - INFO - Jndi(name=StratocasterImplLocal) --> Ejb(deployment-id=StratocasterImpl) - INFO - Created Ejb(deployment-id=StratocasterImpl, ejb-name=StratocasterImpl, container=Default Stateless Container) - INFO - Deployed Application(path=/Users/dblevins/work/openejb3/examples/custom-injection/target/classes) - Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.705 sec - - Results : - - Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
