You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/07/15 23:55:19 UTC
svn commit: r1610862 [16/44] - in /tomee/tomee/trunk/itests: ./ failover-ejb/
failover-ejb/src/main/java/org/apache/openejb/itest/failover/ejb/ failover/
failover/src/main/java/org/apache/openejb/itest/failover/
failover/src/main/java/org/apache/openej...
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedBean.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedBean.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedBean.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedBean.java Tue Jul 15 21:55:09 2014
@@ -35,17 +35,17 @@ import org.apache.openejb.test.intercept
/**
* @version $Rev$ $Date$
*/
-@Stateless(name="BasicStatelessIntercepted")
+@Stateless(name = "BasicStatelessIntercepted")
@Interceptors({ClassInterceptor.class})
-public class BasicStatelessInterceptedBean extends SuperInterceptedBean
- implements BasicStatelessInterceptedLocal, BasicStatelessInterceptedRemote {
-
+public class BasicStatelessInterceptedBean extends SuperInterceptedBean
+ implements BasicStatelessInterceptedLocal, BasicStatelessInterceptedRemote {
+
private static Map<String, Object> contextData = new LinkedHashMap<String, Object>();
/**
* A simple dummy business method to concat 2 strings
*/
- public String concat(String str1, String str2) {
+ public String concat(final String str1, final String str2) {
return str1.concat(str2);
}
@@ -53,21 +53,21 @@ public class BasicStatelessInterceptedBe
* A simple dummy busines method to reverse a string
*/
@Interceptors({MethodInterceptor.class})
- public String reverse(String str) {
- StringBuffer b = new StringBuffer(str);
+ public String reverse(final String str) {
+ final StringBuffer b = new StringBuffer(str);
return b.reverse().toString();
}
-
+
/**
* @param ctxData the contextData to set
*/
- private void setContextData(Map<String, Object> ctxData) {
+ private void setContextData(final Map<String, Object> ctxData) {
BasicStatelessInterceptedBean.contextData.putAll(ctxData);
}
/**
* <code>ClassInterceptor</code> should not intercept this.
- *
+ *
* @return the contextData
*/
@ExcludeClassInterceptors
@@ -76,48 +76,46 @@ public class BasicStatelessInterceptedBe
}
/**
- * The interceptor method.
+ * The interceptor method.
* This should intercept all business methods in this bean class.
* It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
- *
+ *
* @param ctx - InvocationContext
- *
- * @return - the result of the next method invoked. If a method returns void, proceed returns null.
- * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
- * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
* If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
- *
* @throws Exception runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
*/
@AroundInvoke
- public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
- Map<String, Object> ctxData = Interceptor.profile(ctx, "inBeanInterceptor");
+ public Object inBeanInterceptor(final InvocationContext ctx) throws Exception {
+ final Map<String, Object> ctxData = Interceptor.profile(ctx, "inBeanInterceptor");
setContextData(ctxData);
return ctx.proceed();
}
/**
- * The interceptor method.
+ * The interceptor method.
* This should intercept postConstruct of the bean
- *
+ *
* @throws Exception runtime exceptions.
- */
+ */
@PostConstruct
public void inBeanInterceptorPostConstruct() throws Exception {
- Map<String, Object> ctxData = Interceptor.profile(this, "inBeanInterceptorPostConstruct");
+ final Map<String, Object> ctxData = Interceptor.profile(this, "inBeanInterceptorPostConstruct");
setContextData(ctxData);
}
-
-
+
+
/**
- * The interceptor method.
+ * The interceptor method.
* This should intercept preDestroy of the bean.
- *
+ *
* @throws Exception runtime exceptions.
- */
+ */
@PreDestroy
public void inBeanInterceptorPreDestroy() throws Exception {
- Map<String, Object> ctxData = Interceptor.profile(this, "inBeanInterceptorPreDestroy");
+ final Map<String, Object> ctxData = Interceptor.profile(this, "inBeanInterceptorPreDestroy");
setContextData(ctxData);
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedLocal.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedLocal.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedLocal.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedLocal.java Tue Jul 15 21:55:09 2014
@@ -20,15 +20,14 @@ import java.util.Map;
import java.util.List;
/**
- *
* @version $Rev$ $Date$
*/
public interface BasicStatelessInterceptedLocal {
-
+
public String reverse(String str);
-
+
public String concat(String str1, String str2);
-
+
public Map<String, Object> getContextData();
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedRemote.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedRemote.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedRemote.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessInterceptedRemote.java Tue Jul 15 21:55:09 2014
@@ -25,11 +25,11 @@ import javax.ejb.Remote;
*/
@Remote
public interface BasicStatelessInterceptedRemote {
-
+
public String reverse(String str);
-
+
public String concat(String str1, String str2);
-
+
public Map<String, Object> getContextData();
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessLocalObject.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessLocalObject.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessLocalObject.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessLocalObject.java Tue Jul 15 21:55:09 2014
@@ -22,52 +22,51 @@ import java.util.Properties;
import org.apache.openejb.test.ApplicationException;
import org.apache.openejb.test.object.OperationsPolicy;
-public interface BasicStatelessLocalObject extends javax.ejb.EJBLocalObject{
-
+public interface BasicStatelessLocalObject extends javax.ejb.EJBLocalObject {
+
/**
* Reverses the string passed in then returns it
- *
+ *
* @return string
*/
public String businessMethod(String text);
-
+
/**
* Throws an ApplicationException when invoked
- *
*/
public void throwApplicationException() throws ApplicationException;
-
+
/**
* Throws a java.lang.NullPointerException when invoked
- * This is a system exception and should result in the
+ * This is a system exception and should result in the
* destruction of the instance and invalidation of the
* remote reference.
- *
*/
public void throwSystemException_NullPointer();
-
+
/**
- * Returns a report of the bean's
+ * Returns a report of the bean's
* runtime permissions
- *
+ *
* @return properties
*/
public Properties getPermissionsReport();
-
+
/**
* Returns a report of the allowed opperations
* for one of the bean's methods.
- *
+ *
* @param methodName The method for which to get the allowed opperations report
- * @return operations policy
+ * @return operations policy
*/
public OperationsPolicy getAllowedOperationsReport(String methodName);
/**
* Schedules a timer with the specified name. This name is used to notify via the TimerSyncBean.
+ *
* @param name the name used to notify via the TimerSyncBean
*/
public void scheduleTimer(String name);
-
+
public String remove(String obj);
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessObject.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessObject.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessObject.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessObject.java Tue Jul 15 21:55:09 2014
@@ -22,52 +22,51 @@ import java.util.Properties;
import org.apache.openejb.test.ApplicationException;
import org.apache.openejb.test.object.OperationsPolicy;
-public interface BasicStatelessObject extends javax.ejb.EJBObject{
-
+public interface BasicStatelessObject extends javax.ejb.EJBObject {
+
/**
* Reverses the string passed in then returns it
- *
+ *
* @return string
*/
public String businessMethod(String text) throws RemoteException;
-
+
/**
* Throws an ApplicationException when invoked
- *
*/
public void throwApplicationException() throws RemoteException, ApplicationException;
-
+
/**
* Throws a java.lang.NullPointerException when invoked
- * This is a system exception and should result in the
+ * This is a system exception and should result in the
* destruction of the instance and invalidation of the
* remote reference.
- *
*/
public void throwSystemException_NullPointer() throws RemoteException;
-
+
/**
- * Returns a report of the bean's
+ * Returns a report of the bean's
* runtime permissions
- *
+ *
* @return properties
*/
public Properties getPermissionsReport() throws RemoteException;
-
+
/**
* Returns a report of the allowed opperations
* for one of the bean's methods.
- *
+ *
* @param methodName The method for which to get the allowed opperations report
- * @return operations policy
+ * @return operations policy
*/
public OperationsPolicy getAllowedOperationsReport(String methodName) throws RemoteException;
/**
* Schedules a timer with the specified name. This name is used to notify via the TimerSyncBean.
+ *
* @param name the name used to notify via the TimerSyncBean
*/
public void scheduleTimer(String name) throws RemoteException;
-
+
public String remove(String obj) throws RemoteException;
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BasicStatelessPojoBean.java Tue Jul 15 21:55:09 2014
@@ -34,30 +34,28 @@ public class BasicStatelessPojoBean impl
* @return
* @see org.apache.openejb.test.stateless.BasicStatelessObject#businessMethod
*/
- public String businessMethod(String text){
- StringBuffer b = new StringBuffer(text);
+ public String businessMethod(final String text) {
+ final StringBuffer b = new StringBuffer(text);
return b.reverse().toString();
}
- public void scheduleTimer(String name) {
+ public void scheduleTimer(final String name) {
// ejbContext.getTimerService().createTimer(1, name);
}
- public Object echo(Object object) {
+ public Object echo(final Object object) {
return object;
}
/**
* Throws an ApplicationException when invoked
- *
*/
public void throwApplicationException() throws ApplicationException {
throw new ApplicationException("Testing ability to throw Application Exceptions");
}
-
+
/**
* Throws an ApplicationException when invoked
- *
*/
public void throwAnnotatedApplicationException() {
throw new AnnotatedApplicationException("Testing ability to throw Application Exceptions (annotated)");
@@ -68,7 +66,6 @@ public class BasicStatelessPojoBean impl
* This is a system exception and should result in the
* destruction of the instance and invalidation of the
* remote reference.
- *
*/
public void throwSystemException_NullPointer() {
throw new NullPointerException("Testing ability to throw System Exceptions");
@@ -76,21 +73,21 @@ public class BasicStatelessPojoBean impl
/**
* Maps to BasicStatelessObject.getPermissionsReport
- *
+ * <p/>
* Returns a report of the bean's
* runtime permissions
*
* @return
* @see org.apache.openejb.test.stateless.BasicStatelessObject#getPermissionsReport
*/
- public Properties getPermissionsReport(){
+ public Properties getPermissionsReport() {
/* TO DO: */
return null;
}
/**
* Maps to BasicStatelessObject.getAllowedOperationsReport
- *
+ * <p/>
* Returns a report of the allowed opperations
* for one of the bean's methods.
*
@@ -98,19 +95,19 @@ public class BasicStatelessPojoBean impl
* @return
* @see org.apache.openejb.test.stateless.BasicStatelessObject#getAllowedOperationsReport
*/
- public OperationsPolicy getAllowedOperationsReport(String methodName){
+ public OperationsPolicy getAllowedOperationsReport(final String methodName) {
return null;
}
@Resource
- public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+ public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException {
}
public Object remove() {
return "Executed remove() Method";
}
-
- public String remove(String arg) {
+
+ public String remove(final String arg) {
return arg;
}
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessBean.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessBean.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessBean.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessBean.java Tue Jul 15 21:55:09 2014
@@ -32,65 +32,64 @@ import javax.transaction.UserTransaction
import org.apache.openejb.test.object.Account;
import org.apache.openejb.test.object.Transaction;
-public class BeanTxStatelessBean implements javax.ejb.SessionBean{
+public class BeanTxStatelessBean implements javax.ejb.SessionBean {
+
-
private String name;
private SessionContext ejbContext;
private InitialContext jndiContext;
public final String jndiDatabaseEntry = "jdbc/stateless/beanManagedTransaction/database";
-
//=============================
// Home interface methods
//
-
+
//
// Home interface methods
//=============================
-
+
//=============================
// Remote interface methods
//
-
- public Transaction getUserTransaction() throws RemoteException{
-
+
+ public Transaction getUserTransaction() throws RemoteException {
+
UserTransaction ut = null;
- try{
+ try {
ut = ejbContext.getUserTransaction();
- } catch (IllegalStateException ise){
+ } catch (final IllegalStateException ise) {
throw new RemoteException(ise.getMessage());
}
if (ut == null) return null;
return new Transaction(ut);
}
-
- public Transaction jndiUserTransaction() throws RemoteException{
+
+ public Transaction jndiUserTransaction() throws RemoteException {
UserTransaction ut = null;
- try{
- ut = (UserTransaction)jndiContext.lookup("java:comp/UserTransaction");
- } catch (Exception e){
+ try {
+ ut = (UserTransaction) jndiContext.lookup("java:comp/UserTransaction");
+ } catch (final Exception e) {
throw new RemoteException(e.getMessage());
}
if (ut == null) return null;
return new Transaction(ut);
}
- public void openAccount(Account acct, Boolean rollback) throws RemoteException, RollbackException{
-
- try{
- DataSource ds = (DataSource)javax.rmi.PortableRemoteObject.narrow( jndiContext.lookup("java:comp/env/database"), DataSource.class);
- Connection con = ds.getConnection();
+ public void openAccount(final Account acct, final Boolean rollback) throws RemoteException, RollbackException {
+
+ try {
+ final DataSource ds = (DataSource) javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/database"), DataSource.class);
+ final Connection con = ds.getConnection();
try {
- UserTransaction ut = ejbContext.getUserTransaction();
+ final UserTransaction ut = ejbContext.getUserTransaction();
/*[1] Begin the transaction */
ut.begin();
/*[2] Update the table */
- PreparedStatement stmt = con.prepareStatement("insert into Account (SSN, First_name, Last_name, Balance) values (?,?,?,?)");
+ final PreparedStatement stmt = con.prepareStatement("insert into Account (SSN, First_name, Last_name, Balance) values (?,?,?,?)");
try {
stmt.setString(1, acct.getSsn());
stmt.setString(2, acct.getFirstName());
@@ -109,40 +108,40 @@ public class BeanTxStatelessBean impleme
} finally {
con.close();
}
- } catch (RollbackException re){
+ } catch (final RollbackException re) {
throw re;
- } catch (Exception e){
+ } catch (final Exception e) {
e.printStackTrace();
- throw new RemoteException("[Bean] "+e.getClass().getName()+" : "+e.getMessage());
+ throw new RemoteException("[Bean] " + e.getClass().getName() + " : " + e.getMessage());
}
}
- public Account retreiveAccount(String ssn) throws RemoteException {
- Account acct = new Account();
- try{
- DataSource ds = (DataSource)javax.rmi.PortableRemoteObject.narrow( jndiContext.lookup("java:comp/env/database"), DataSource.class);
- Connection con = ds.getConnection();
+ public Account retreiveAccount(final String ssn) throws RemoteException {
+ final Account acct = new Account();
+ try {
+ final DataSource ds = (DataSource) javax.rmi.PortableRemoteObject.narrow(jndiContext.lookup("java:comp/env/database"), DataSource.class);
+ final Connection con = ds.getConnection();
try {
- PreparedStatement stmt = con.prepareStatement("select * from Account where SSN = ?");
+ final PreparedStatement stmt = con.prepareStatement("select * from Account where SSN = ?");
try {
stmt.setString(1, ssn);
- ResultSet rs = stmt.executeQuery();
+ final ResultSet rs = stmt.executeQuery();
if (!rs.next()) return null;
- acct.setSsn( rs.getString(1) );
- acct.setFirstName( rs.getString(2) );
- acct.setLastName( rs.getString(3) );
- acct.setBalance( rs.getInt(4) );
+ acct.setSsn(rs.getString(1));
+ acct.setFirstName(rs.getString(2));
+ acct.setLastName(rs.getString(3));
+ acct.setBalance(rs.getInt(4));
} finally {
stmt.close();
}
} finally {
con.close();
}
- } catch (Exception e){
+ } catch (final Exception e) {
e.printStackTrace();
- throw new RemoteException("[Bean] "+e.getClass().getName()+" : "+e.getMessage());
+ throw new RemoteException("[Bean] " + e.getClass().getName() + " : " + e.getMessage());
}
return acct;
}
@@ -156,52 +155,56 @@ public class BeanTxStatelessBean impleme
//=================================
// SessionBean interface methods
//
+
/**
- *
* @param name
- * @exception javax.ejb.CreateException
+ * @throws javax.ejb.CreateException
*/
- public void ejbCreate() throws javax.ejb.CreateException{
+ public void ejbCreate() throws javax.ejb.CreateException {
try {
- jndiContext = new InitialContext();
- } catch (Exception e){
- throw new CreateException("Can not get the initial context: "+e.getMessage());
+ jndiContext = new InitialContext();
+ } catch (final Exception e) {
+ throw new CreateException("Can not get the initial context: " + e.getMessage());
}
}
+
/**
* Set the associated session context. The container calls this method
* after the instance creation.
*/
- public void setSessionContext(SessionContext ctx) throws EJBException,RemoteException {
+ public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException {
ejbContext = ctx;
}
+
/**
* A container invokes this method before it ends the life of the session
* object. This happens as a result of a client's invoking a remove
* operation, or when a container decides to terminate the session object
* after a timeout.
*/
- public void ejbRemove() throws EJBException,RemoteException {
+ public void ejbRemove() throws EJBException, RemoteException {
}
+
/**
* The activate method is called when the instance is activated
* from its "passive" state. The instance should acquire any resource
* that it has released earlier in the ejbPassivate() method.
*/
- public void ejbActivate() throws EJBException,RemoteException {
+ public void ejbActivate() throws EJBException, RemoteException {
}
+
/**
* The passivate method is called before the instance enters
* the "passive" state. The instance should release any resources that
* it can re-acquire later in the ejbActivate() method.
*/
- public void ejbPassivate() throws EJBException,RemoteException {
+ public void ejbPassivate() throws EJBException, RemoteException {
}
//
// SessionBean interface methods
//==================================
-
- public String remove(String arg) {
+
+ public String remove(final String arg) {
return arg;
}
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessHome.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessHome.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessHome.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessHome.java Tue Jul 15 21:55:09 2014
@@ -20,5 +20,5 @@ package org.apache.openejb.test.stateles
public interface BeanTxStatelessHome extends javax.ejb.EJBHome {
public BeanTxStatelessObject create()
- throws javax.ejb.CreateException, java.rmi.RemoteException;
+ throws javax.ejb.CreateException, java.rmi.RemoteException;
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessObject.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessObject.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessObject.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/BeanTxStatelessObject.java Tue Jul 15 21:55:09 2014
@@ -21,10 +21,10 @@ import java.rmi.RemoteException;
import org.apache.openejb.test.object.Account;
import org.apache.openejb.test.object.Transaction;
-public interface BeanTxStatelessObject extends javax.ejb.EJBObject{
-
+public interface BeanTxStatelessObject extends javax.ejb.EJBObject {
+
public Transaction getUserTransaction() throws RemoteException;
-
+
public Transaction jndiUserTransaction() throws RemoteException;
public void openAccount(Account account, Boolean commit) throws RemoteException, javax.transaction.RollbackException;
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessBean.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessBean.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessBean.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessBean.java Tue Jul 15 21:55:09 2014
@@ -30,62 +30,61 @@ import javax.transaction.RollbackExcepti
import org.apache.openejb.test.object.Account;
-public class ContainerTxStatelessBean implements javax.ejb.SessionBean{
+public class ContainerTxStatelessBean implements javax.ejb.SessionBean {
+
-
private String name;
private SessionContext ejbContext;
private InitialContext jndiContext;
public final String jndiDatabaseEntry = "jdbc/stateless/containerManagedTransaction/database";
-
//=============================
// Home interface methods
//
-
+
//
// Home interface methods
//=============================
-
+
//=============================
// Remote interface methods
//
-
- public String txMandatoryMethod(String message) {
+
+ public String txMandatoryMethod(final String message) {
return message;
}
-
- public String txNeverMethod(String message) {
+
+ public String txNeverMethod(final String message) {
return message;
}
-
- public String txNotSupportedMethod(String message) {
+
+ public String txNotSupportedMethod(final String message) {
return message;
}
-
- public String txRequiredMethod(String message) {
+
+ public String txRequiredMethod(final String message) {
return message;
}
-
- public String txRequiresNewMethod(String message) {
+
+ public String txRequiresNewMethod(final String message) {
return message;
}
-
- public String txSupportsMethod(String message) {
+
+ public String txSupportsMethod(final String message) {
return message;
}
- public void openAccount(Account acct, Boolean rollback) throws RollbackException{
-
- try{
- DataSource ds = (DataSource)jndiContext.lookup("java:comp/env/database");
- Connection con = ds.getConnection();
+ public void openAccount(final Account acct, final Boolean rollback) throws RollbackException {
+
+ try {
+ final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/database");
+ final Connection con = ds.getConnection();
try {
/*[2] Update the table */
- PreparedStatement stmt = con.prepareStatement("insert into Account (SSN, First_name, Last_name, Balance) values (?,?,?,?)");
+ final PreparedStatement stmt = con.prepareStatement("insert into Account (SSN, First_name, Last_name, Balance) values (?,?,?,?)");
try {
stmt.setString(1, acct.getSsn());
stmt.setString(2, acct.getFirstName());
@@ -98,35 +97,35 @@ public class ContainerTxStatelessBean im
} finally {
con.close();
}
- } catch (Exception e){
+ } catch (final Exception e) {
//throw new RemoteException("[Bean] "+e.getClass().getName()+" : "+e.getMessage());
}
}
- public Account retreiveAccount(String ssn) {
- Account acct = new Account();
- try{
- DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/database");
- Connection con = ds.getConnection();
+ public Account retreiveAccount(final String ssn) {
+ final Account acct = new Account();
+ try {
+ final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/database");
+ final Connection con = ds.getConnection();
try {
- PreparedStatement stmt = con.prepareStatement("select * from Account where SSN = ?");
+ final PreparedStatement stmt = con.prepareStatement("select * from Account where SSN = ?");
try {
stmt.setString(1, ssn);
- ResultSet rs = stmt.executeQuery();
+ final ResultSet rs = stmt.executeQuery();
if (!rs.next()) return null;
- acct.setSsn( rs.getString(1) );
- acct.setFirstName( rs.getString(2) );
- acct.setLastName( rs.getString(3) );
- acct.setBalance( rs.getInt(4) );
+ acct.setSsn(rs.getString(1));
+ acct.setFirstName(rs.getString(2));
+ acct.setLastName(rs.getString(3));
+ acct.setBalance(rs.getInt(4));
} finally {
stmt.close();
}
} finally {
con.close();
}
- } catch (Exception e){
+ } catch (final Exception e) {
//throw new RemoteException("[Bean] "+e.getClass().getName()+" : "+e.getMessage());
}
return acct;
@@ -141,52 +140,57 @@ public class ContainerTxStatelessBean im
//=================================
// SessionBean interface methods
//
+
/**
- *
- * @exception javax.ejb.CreateException
+ * @throws javax.ejb.CreateException
*/
- public void ejbCreate() throws javax.ejb.CreateException{
+ public void ejbCreate() throws javax.ejb.CreateException {
try {
- jndiContext = new InitialContext();
- } catch (Exception e){
- throw new CreateException("Can not get the initial context: "+e.getMessage());
+ jndiContext = new InitialContext();
+ } catch (final Exception e) {
+ throw new CreateException("Can not get the initial context: " + e.getMessage());
}
}
+
/**
* Set the associated session context. The container calls this method
* after the instance creation.
*/
- public void setSessionContext(SessionContext ctx) throws EJBException,RemoteException {
+ public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException {
ejbContext = ctx;
}
+
/**
* A container invokes this method before it ends the life of the session
* object. This happens as a result of a client's invoking a remove
* operation, or when a container decides to terminate the session object
* after a timeout.
*/
- public void ejbRemove() throws EJBException,RemoteException {
+ public void ejbRemove() throws EJBException, RemoteException {
}
+
/**
* The activate method is called when the instance is activated
* from its "passive" state. The instance should acquire any resource
* that it has released earlier in the ejbPassivate() method.
*/
- public void ejbActivate() throws EJBException,RemoteException {
+ public void ejbActivate() throws EJBException, RemoteException {
}
+
/**
* The passivate method is called before the instance enters
* the "passive" state. The instance should release any resources that
* it can re-acquire later in the ejbActivate() method.
*/
- public void ejbPassivate() throws EJBException,RemoteException {
+ public void ejbPassivate() throws EJBException, RemoteException {
}
- //
+
+ //
// SessionBean interface methods
//==================================
- public String remove(String arg) {
+ public String remove(final String arg) {
return arg;
}
-
-
+
+
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessHome.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessHome.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessHome.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessHome.java Tue Jul 15 21:55:09 2014
@@ -17,9 +17,8 @@
package org.apache.openejb.test.stateless;
-
public interface ContainerTxStatelessHome extends javax.ejb.EJBHome {
public ContainerTxStatelessObject create()
- throws javax.ejb.CreateException, java.rmi.RemoteException;
+ throws javax.ejb.CreateException, java.rmi.RemoteException;
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessObject.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessObject.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessObject.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContainerTxStatelessObject.java Tue Jul 15 21:55:09 2014
@@ -22,21 +22,21 @@ import javax.transaction.RollbackExcepti
import org.apache.openejb.test.object.Account;
-public interface ContainerTxStatelessObject extends javax.ejb.EJBObject{
-
+public interface ContainerTxStatelessObject extends javax.ejb.EJBObject {
+
public String txMandatoryMethod(String message) throws RemoteException;
-
+
public String txNeverMethod(String message) throws RemoteException;
-
+
public String txNotSupportedMethod(String message) throws RemoteException;
-
+
public String txRequiredMethod(String message) throws RemoteException;
-
+
public String txRequiresNewMethod(String message) throws RemoteException;
-
+
public String txSupportsMethod(String message) throws RemoteException;
public Account retreiveAccount(String ssn) throws RemoteException;
-
+
public void openAccount(Account acct, Boolean rollback) throws RemoteException, RollbackException;
}
Modified: tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateless/ContextLookupStatelessBean.java Tue Jul 15 21:55:09 2014
@@ -62,15 +62,15 @@ public class ContextLookupStatelessBean
public void lookupEntityBean() throws TestFailureException {
try {
try {
- BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateless/beanReferences/bmp_entity");
+ final BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateless/beanReferences/bmp_entity");
Assert.assertNotNull("The EJBHome looked up is null", home);
- BasicBmpObject object = home.createObject("Enc Bean");
+ final BasicBmpObject object = home.createObject("Enc Bean");
Assert.assertNotNull("The EJBObject is null", object);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -78,15 +78,15 @@ public class ContextLookupStatelessBean
public void lookupStatefulBean() throws TestFailureException {
try {
try {
- BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateless/beanReferences/stateful");
+ final BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateless/beanReferences/stateful");
Assert.assertNotNull("The EJBHome looked up is null", home);
- BasicStatefulObject object = home.createObject("Enc Bean");
+ final BasicStatefulObject object = home.createObject("Enc Bean");
Assert.assertNotNull("The EJBObject is null", object);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -94,80 +94,80 @@ public class ContextLookupStatelessBean
public void lookupStatelessBean() throws TestFailureException {
try {
try {
- BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateless/beanReferences/stateless");
+ final BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateless/beanReferences/stateless");
Assert.assertNotNull("The EJBHome looked up is null", home);
- BasicStatelessObject object = home.createObject();
+ final BasicStatelessObject object = home.createObject();
Assert.assertNotNull("The EJBObject is null", object);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupStatelessBusinessLocal() throws TestFailureException{
- try{
- try{
- BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) ejbContext.lookup("stateless/beanReferences/stateless-business-local");
- Assert.assertNotNull("The EJB BusinessLocal is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatelessBusinessLocal() throws TestFailureException {
+ try {
+ try {
+ final BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) ejbContext.lookup("stateless/beanReferences/stateless-business-local");
+ Assert.assertNotNull("The EJB BusinessLocal is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupStatelessBusinessRemote() throws TestFailureException{
- try{
- try{
- BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateless/beanReferences/stateless-business-remote");
- Assert.assertNotNull("The EJB BusinessRemote is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatelessBusinessRemote() throws TestFailureException {
+ try {
+ try {
+ final BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateless/beanReferences/stateless-business-remote");
+ Assert.assertNotNull("The EJB BusinessRemote is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupStatefulBusinessLocal() throws TestFailureException{
- try{
- try{
- BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateless/beanReferences/stateful-business-local");
- Assert.assertNotNull("The EJB BusinessLocal is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatefulBusinessLocal() throws TestFailureException {
+ try {
+ try {
+ final BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateless/beanReferences/stateful-business-local");
+ Assert.assertNotNull("The EJB BusinessLocal is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupStatefulBusinessLocalBean() throws TestFailureException{
- try{
- try{
- BasicStatelessPojoBean object = (BasicStatelessPojoBean) ejbContext.lookup("stateless/beanReferences/stateful-business-localbean");
- Assert.assertNotNull("The EJB BusinessLocalBean is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatefulBusinessLocalBean() throws TestFailureException {
+ try {
+ try {
+ final BasicStatelessPojoBean object = (BasicStatelessPojoBean) ejbContext.lookup("stateless/beanReferences/stateful-business-localbean");
+ Assert.assertNotNull("The EJB BusinessLocalBean is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupStatefulBusinessRemote() throws TestFailureException{
- try{
- try{
- BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateless/beanReferences/stateful-business-remote");
- Assert.assertNotNull("The EJB BusinessRemote is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatefulBusinessRemote() throws TestFailureException {
+ try {
+ try {
+ final BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateless/beanReferences/stateful-business-remote");
+ Assert.assertNotNull("The EJB BusinessRemote is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -175,16 +175,16 @@ public class ContextLookupStatelessBean
public void lookupStringEntry() throws TestFailureException {
try {
try {
- String expected = new String("1");
- String actual = (String) ejbContext.lookup("stateless/references/String");
+ final String expected = new String("1");
+ final String actual = (String) ejbContext.lookup("stateless/references/String");
Assert.assertNotNull("The String looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -192,16 +192,16 @@ public class ContextLookupStatelessBean
public void lookupDoubleEntry() throws TestFailureException {
try {
try {
- Double expected = new Double(1.0D);
- Double actual = (Double) ejbContext.lookup("stateless/references/Double");
+ final Double expected = new Double(1.0D);
+ final Double actual = (Double) ejbContext.lookup("stateless/references/Double");
Assert.assertNotNull("The Double looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -209,16 +209,16 @@ public class ContextLookupStatelessBean
public void lookupLongEntry() throws TestFailureException {
try {
try {
- Long expected = new Long(1L);
- Long actual = (Long) ejbContext.lookup("stateless/references/Long");
+ final Long expected = new Long(1L);
+ final Long actual = (Long) ejbContext.lookup("stateless/references/Long");
Assert.assertNotNull("The Long looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -226,16 +226,16 @@ public class ContextLookupStatelessBean
public void lookupFloatEntry() throws TestFailureException {
try {
try {
- Float expected = new Float(1.0F);
- Float actual = (Float) ejbContext.lookup("stateless/references/Float");
+ final Float expected = new Float(1.0F);
+ final Float actual = (Float) ejbContext.lookup("stateless/references/Float");
Assert.assertNotNull("The Float looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -243,16 +243,16 @@ public class ContextLookupStatelessBean
public void lookupIntegerEntry() throws TestFailureException {
try {
try {
- Integer expected = new Integer(1);
- Integer actual = (Integer) ejbContext.lookup("stateless/references/Integer");
+ final Integer expected = new Integer(1);
+ final Integer actual = (Integer) ejbContext.lookup("stateless/references/Integer");
Assert.assertNotNull("The Integer looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -260,16 +260,16 @@ public class ContextLookupStatelessBean
public void lookupShortEntry() throws TestFailureException {
try {
try {
- Short expected = new Short((short) 1);
- Short actual = (Short) ejbContext.lookup("stateless/references/Short");
+ final Short expected = new Short((short) 1);
+ final Short actual = (Short) ejbContext.lookup("stateless/references/Short");
Assert.assertNotNull("The Short looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -277,16 +277,16 @@ public class ContextLookupStatelessBean
public void lookupBooleanEntry() throws TestFailureException {
try {
try {
- Boolean expected = new Boolean(true);
- Boolean actual = (Boolean) ejbContext.lookup("stateless/references/Boolean");
+ final Boolean expected = new Boolean(true);
+ final Boolean actual = (Boolean) ejbContext.lookup("stateless/references/Boolean");
Assert.assertNotNull("The Boolean looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -294,16 +294,16 @@ public class ContextLookupStatelessBean
public void lookupByteEntry() throws TestFailureException {
try {
try {
- Byte expected = new Byte((byte) 1);
- Byte actual = (Byte) ejbContext.lookup("stateless/references/Byte");
+ final Byte expected = new Byte((byte) 1);
+ final Byte actual = (Byte) ejbContext.lookup("stateless/references/Byte");
Assert.assertNotNull("The Byte looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -311,16 +311,16 @@ public class ContextLookupStatelessBean
public void lookupCharacterEntry() throws TestFailureException {
try {
try {
- Character expected = new Character('D');
- Character actual = (Character) ejbContext.lookup("stateless/references/Character");
+ final Character expected = new Character('D');
+ final Character actual = (Character) ejbContext.lookup("stateless/references/Character");
Assert.assertNotNull("The Character looked up is null", actual);
Assert.assertEquals(expected, actual);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
@@ -328,112 +328,112 @@ public class ContextLookupStatelessBean
public void lookupResource() throws TestFailureException {
try {
try {
- Object obj = ejbContext.lookup("datasource");
+ final Object obj = ejbContext.lookup("datasource");
Assert.assertNotNull("The DataSource is null", obj);
Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
- } catch (Exception e) {
+ } catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe) {
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupJMSConnectionFactory() throws TestFailureException{
- try{
- try{
+ public void lookupJMSConnectionFactory() throws TestFailureException {
+ try {
+ try {
Object obj = ejbContext.lookup("jms");
Assert.assertNotNull("The JMS ConnectionFactory is null", obj);
Assert.assertTrue("Not an instance of ConnectionFactory", obj instanceof ConnectionFactory);
- ConnectionFactory connectionFactory = (ConnectionFactory) obj;
+ final ConnectionFactory connectionFactory = (ConnectionFactory) obj;
testJmsConnection(connectionFactory.createConnection());
obj = ejbContext.lookup("TopicCF");
Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
Assert.assertTrue("Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
- TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
+ final TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
testJmsConnection(topicConnectionFactory.createConnection());
obj = ejbContext.lookup("QueueCF");
Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
Assert.assertTrue("Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
- QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
+ final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
testJmsConnection(queueConnectionFactory.createConnection());
- } catch (Exception e){
+ } catch (final Exception e) {
e.printStackTrace();
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- private void testJmsConnection(Connection connection) throws JMSException {
- Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- Topic topic = session.createTopic("test");
- MessageProducer producer = session.createProducer(topic);
+ private void testJmsConnection(final Connection connection) throws JMSException {
+ final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+ final Topic topic = session.createTopic("test");
+ final MessageProducer producer = session.createProducer(topic);
producer.send(session.createMessage());
producer.close();
session.close();
connection.close();
}
- public void lookupPersistenceUnit() throws TestFailureException{
- try{
- try{
- EntityManagerFactory emf = (EntityManagerFactory)ejbContext.lookup("persistence/TestUnit");
- Assert.assertNotNull("The EntityManagerFactory is null", emf );
+ public void lookupPersistenceUnit() throws TestFailureException {
+ try {
+ try {
+ final EntityManagerFactory emf = (EntityManagerFactory) ejbContext.lookup("persistence/TestUnit");
+ Assert.assertNotNull("The EntityManagerFactory is null", emf);
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
-
- public void lookupPersistenceContext() throws TestFailureException{
- try{
- try{
- EntityManager em = (EntityManager)ejbContext.lookup("persistence/TestContext");
+
+ public void lookupPersistenceContext() throws TestFailureException {
+ try {
+ try {
+ final EntityManager em = (EntityManager) ejbContext.lookup("persistence/TestContext");
Assert.assertNotNull("The EntityManager is null", em);
// call a do nothing method to assure entity manager actually exists
em.getFlushMode();
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
- public void lookupSessionContext() throws TestFailureException{
- try{
- try{
- InitialContext ctx = new InitialContext();
- Assert.assertNotNull("The InitialContext is null", ctx);
+ public void lookupSessionContext() throws TestFailureException {
+ try {
+ try {
+ final InitialContext ctx = new InitialContext();
+ Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
- SessionContext sctx = (SessionContext)ctx.lookup("java:comp/env/sessioncontext");
- Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx );
+ final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext");
+ Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx);
// lookup using global name
- EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext");
- Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx );
+ final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
+ Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
// verify context was set via legacy set method
- Assert.assertNotNull("The SessionContext is null from setter method", ejbContext );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ Assert.assertNotNull("The SessionContext is null from setter method", ejbContext);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
-
+
}
-
-
+
+
//
// Remote interface methods
//=============================
@@ -446,7 +446,7 @@ public class ContextLookupStatelessBean
* Set the associated session context. The container calls this method
* after the instance creation.
*/
- public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException {
+ public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException {
ejbContext = ctx;
}
@@ -487,23 +487,23 @@ public class ContextLookupStatelessBean
//
// SessionBean interface methods
//================================
-
- public String remove(String arg) {
+
+ public String remove(final String arg) {
return arg;
}
- public void lookupStatelessBusinessLocalBean() throws TestFailureException{
- try{
- try{
- BasicStatelessPojoBean object = (BasicStatelessPojoBean) ejbContext.lookup("stateless/beanReferences/stateless-business-localbean");
- Assert.assertNotNull("The EJB BusinessLocalBean is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupStatelessBusinessLocalBean() throws TestFailureException {
+ try {
+ try {
+ final BasicStatelessPojoBean object = (BasicStatelessPojoBean) ejbContext.lookup("stateless/beanReferences/stateless-business-localbean");
+ Assert.assertNotNull("The EJB BusinessLocalBean is null", object);
+ } catch (final Exception e) {
+ Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
- } catch (AssertionFailedError afe){
+ } catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
-
+
}