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 2013/11/21 11:22:10 UTC

svn commit: r1544088 [2/2] - in /tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb: ./ async/ config/ core/ core/cmp/ core/entity/ core/ivm/ core/managed/ core/security/ core/singleton/ core/stateless/ util/

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java Thu Nov 21 10:22:09 2013
@@ -72,11 +72,12 @@ public abstract class EjbObjectProxyHand
         Object retValue = null;
         Throwable exc = null;
 
+        final String methodName = m.getName();
         try {
             if (logger.isDebugEnabled()) {
-                logger.debug("invoking method " + m.getName() + " on " + deploymentID + " with identity " + primaryKey);
+                logger.debug("EjbObjectProxyHandler: invoking method " + methodName + " on " + deploymentID + " with identity " + primaryKey);
             }
-            Integer operation = dispatchTable.get(m.getName());
+            Integer operation = dispatchTable.get(methodName);
             if (operation != null) {
                 if (operation == 3) {
                     if (m.getParameterTypes()[0] != EJBObject.class && m.getParameterTypes()[0] != EJBLocalObject.class) {
@@ -159,15 +160,17 @@ public abstract class EjbObjectProxyHand
         } finally {
             if (logger.isDebugEnabled()) {
                 if (exc == null) {
-                    String ret;
-                    try { // if it is a CDI (javassit proxy) it doesn't always work....
-                        ret = retValue.toString();
-                    } catch (Exception e) {
-                        ret = "can't get toString() value (" + e.getMessage() + ")";
+                    String ret = "void";
+                    if (null != retValue) {
+                        try {
+                            ret = retValue.toString();
+                        } catch (Exception e) {
+                            ret = "toString() failed on (" + e.getMessage() + ")";
+                        }
                     }
-                    logger.debug("finished invoking method " + m.getName() + ". Return value:" + ret);
+                    logger.debug("EjbObjectProxyHandler: finished invoking method " + methodName + ". Return value:" + ret);
                 } else {
-                    logger.debug("finished invoking method " + m.getName() + " with exception " + exc);
+                    logger.debug("EjbObjectProxyHandler: finished invoking method " + methodName + " with exception " + exc);
                 }
             }
         }
@@ -235,18 +238,20 @@ public abstract class EjbObjectProxyHand
 
     protected Object businessMethod(final Class<?> interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
         final BeanContext beanContext = getBeanContext();
-        final AsynchronousPool asynchronousPool = beanContext.getModuleContext().getAppContext().getAsynchronousPool();
 
         if (beanContext.isAsynchronous(method)) {
+
             final SecurityService<?> securityService = SystemInstance.get().getComponent(SecurityService.class);
             final Object state = securityService.currentState();
-            final ThreadContext currentCtx = ThreadContext.getThreadContext();
+            final ThreadContext threadContext = ThreadContext.getThreadContext();
+            final AsynchronousPool asynchronousPool = beanContext.getModuleContext().getAppContext().getAsynchronousPool();
+
             return asynchronousPool.invoke(new Callable<Object>() {
                 @Override
                 public Object call() throws Exception {
                     final ThreadContext oldCtx; // ensure context is the same as for the caller
-                    if (currentCtx != null) {
-                        oldCtx = ThreadContext.enter(new ThreadContext(currentCtx));
+                    if (threadContext != null) {
+                        oldCtx = ThreadContext.enter(new ThreadContext(threadContext));
                     } else {
                         oldCtx = null;
                     }
@@ -255,6 +260,11 @@ public abstract class EjbObjectProxyHand
                     securityService.setState(state);
                     try {
                         return synchronizedBusinessMethod(interfce, method, args);
+                    } catch (ApplicationException ae) {
+
+                        logger.warning("EjbObjectProxyHandler: Asynchronous call to '" + interfce.getSimpleName() + "' on '" + method.getName() + "' failed", ae);
+
+                        throw ae;
                     } finally {
                         securityService.setState(threadState);
                         if (oldCtx != null) {

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/managed/ManagedContainer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/managed/ManagedContainer.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/managed/ManagedContainer.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/managed/ManagedContainer.java Thu Nov 21 10:22:09 2013
@@ -449,7 +449,8 @@ public class ManagedContainer implements
         final ThreadContext oldCallContext = ThreadContext.enter(callContext);
         try {
             // Security check
-            boolean internalRemove = BeanContext.Removable.class == callMethod.getDeclaringClass();
+            final boolean internalRemove = BeanContext.Removable.class == callMethod.getDeclaringClass();
+
             if (!internalRemove) {
                 checkAuthorization(callMethod, interfaceType);
             }
@@ -725,7 +726,9 @@ public class ManagedContainer implements
     }
 
     private void checkAuthorization(final Method callMethod, final InterfaceType interfaceType) throws ApplicationException {
+
         final boolean authorized = securityService.isCallerAuthorized(callMethod, interfaceType);
+
         if (!authorized) {
             throw new ApplicationException(new EJBAccessException("Unauthorized Access by Principal Denied"));
         }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java Thu Nov 21 10:22:09 2013
@@ -280,11 +280,10 @@ public abstract class AbstractSecuritySe
         try {
 
             final BeanContext beanContext = threadContext.getBeanContext();
-
             final String ejbName = beanContext.getEjbName();
 
             String name = type == null ? null : type.getSpecName();
-            if ("LocalBean".equals(name) || "LocalBeanHome".equals(name)) {
+            if ("Local".equals(name) || "LocalHome".equals(name) || "LocalBean".equals(name) || "LocalBeanHome".equals(name)) {
                 name = null;
             }
 

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/security/SecurityServiceImpl.java Thu Nov 21 10:22:09 2013
@@ -24,6 +24,7 @@ import org.apache.openejb.util.ConfUtils
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
+import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.util.Map;
@@ -40,8 +41,8 @@ public class SecurityServiceImpl extends
     public SecurityServiceImpl() {
         this(BasicJaccProvider.class.getName());
     }
-    
-    public SecurityServiceImpl(String jaccProviderClass) {
+
+    public SecurityServiceImpl(final String jaccProviderClass) {
         super(jaccProviderClass);
         installJaas();
 
@@ -51,35 +52,42 @@ public class SecurityServiceImpl extends
             // LoginModules that are configured.
             // They should have a chance to perform any special
             // boot-time code that they may need.
-            login("","");
+            login("", "");
         } catch (Throwable e) {
+            //Ignore
         }
     }
 
+    @SuppressWarnings("deprecation")
     protected static void installJaas() {
-        String path = SystemInstance.get().getOptions().get("java.security.auth.login.config", (String) null);
+        final String path = SystemInstance.get().getOptions().get("java.security.auth.login.config", (String) null);
 
         if (path != null) {
             return;
         }
 
-        URL loginConfig = ConfUtils.getConfResource("login.config");
+        final URL loginConfig = ConfUtils.getConfResource("login.config");
 
-        System.setProperty("java.security.auth.login.config", URLDecoder.decode(loginConfig.toExternalForm()));
+        try {
+            System.setProperty("java.security.auth.login.config", URLDecoder.decode(loginConfig.toExternalForm(), "UTF8"));
+        } catch (UnsupportedEncodingException e) {
+            System.setProperty("java.security.auth.login.config", URLDecoder.decode(loginConfig.toExternalForm()));
+        }
     }
 
-    public UUID login(String realmName, String username, String password) throws LoginException {
-        if (realmName == null){
+    @Override
+    public UUID login(String realmName, final String username, final String password) throws LoginException {
+        if (realmName == null) {
             realmName = getRealmName();
         }
-        LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
+        final LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
         context.login();
 
-        Subject subject = context.getSubject();
+        final Subject subject = context.getSubject();
 
-        UUID token =  registerSubject(subject);
+        final UUID token = registerSubject(subject);
         contexts.put(token, context);
-        
+
         return token;
     }
 
@@ -87,8 +95,8 @@ public class SecurityServiceImpl extends
      * @see org.apache.openejb.core.security.AbstractSecurityService#logout(java.util.UUID)
      */
     @Override
-    public void logout(UUID securityIdentity) throws LoginException {
-        LoginContext context = contexts.remove(securityIdentity);
+    public void logout(final UUID securityIdentity) throws LoginException {
+        final LoginContext context = contexts.remove(securityIdentity);
         if (null == context) {
             throw new IllegalStateException("Unable to logout. Can not recover LoginContext.");
         }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java Thu Nov 21 10:22:09 2013
@@ -63,28 +63,28 @@ import static org.apache.openejb.core.tr
  */
 public class SingletonContainer implements RpcContainer {
 
-    private SingletonInstanceManager instanceManager;
+    private final SingletonInstanceManager instanceManager;
 
-    private HashMap<String, BeanContext> deploymentRegistry = new HashMap<String, BeanContext>();
+    private final HashMap<String, BeanContext> deploymentRegistry = new HashMap<String, BeanContext>();
 
     private final ConcurrentMap<Class<?>, List<Method>> interceptorCache = new ConcurrentHashMap<Class<?>, List<Method>>();
 
     private Object containerID = null;
-    private SecurityService securityService;
+    private final SecurityService securityService;
     private Duration accessTimeout;
 
-    public SingletonContainer(Object id, SecurityService securityService) throws OpenEJBException {
+    public SingletonContainer(final Object id, final SecurityService securityService) throws OpenEJBException {
         this.containerID = id;
         this.securityService = securityService;
 
         instanceManager = new SingletonInstanceManager(securityService);
 
-        for (BeanContext beanContext : deploymentRegistry.values()) {
+        for (final BeanContext beanContext : deploymentRegistry.values()) {
             beanContext.setContainer(this);
         }
     }
 
-    public void setAccessTimeout(Duration duration) {
+    public void setAccessTimeout(final Duration duration) {
         this.accessTimeout = duration;
     }
 
@@ -94,8 +94,8 @@ public class SingletonContainer implemen
     }
 
     @Override
-    public synchronized BeanContext getBeanContext(Object deploymentID) {
-        String id = (String) deploymentID;
+    public synchronized BeanContext getBeanContext(final Object deploymentID) {
+        final String id = (String) deploymentID;
         return deploymentRegistry.get(id);
     }
 
@@ -110,9 +110,9 @@ public class SingletonContainer implemen
     }
 
     @Override
-    public void deploy(BeanContext beanContext) throws OpenEJBException {
+    public void deploy(final BeanContext beanContext) throws OpenEJBException {
         instanceManager.deploy(beanContext);
-        String id = (String) beanContext.getDeploymentID();
+        final String id = (String) beanContext.getDeploymentID();
         synchronized (this) {
             deploymentRegistry.put(id, beanContext);
             beanContext.setContainer(this);
@@ -130,14 +130,14 @@ public class SingletonContainer implemen
     }
 
     @Override
-    public void stop(BeanContext info) throws OpenEJBException {
+    public void stop(final BeanContext info) throws OpenEJBException {
         info.stop();
     }
 
     @Override
-    public void undeploy(BeanContext beanContext) {
-        ThreadContext threadContext = new ThreadContext(beanContext, null);
-        ThreadContext old = ThreadContext.enter(threadContext);
+    public void undeploy(final BeanContext beanContext) {
+        final ThreadContext threadContext = new ThreadContext(beanContext, null);
+        final ThreadContext old = ThreadContext.enter(threadContext);
         try {
             instanceManager.freeInstance(threadContext);
         } finally {
@@ -147,7 +147,7 @@ public class SingletonContainer implemen
         instanceManager.undeploy(beanContext);
 
         synchronized (this) {
-            String id = (String) beanContext.getDeploymentID();
+            final String id = (String) beanContext.getDeploymentID();
             beanContext.setContainer(null);
             beanContext.setContainerData(null);
             deploymentRegistry.remove(id);
@@ -155,35 +155,48 @@ public class SingletonContainer implemen
     }
 
     @Override
-    public Object invoke(Object deployID, InterfaceType type, Class callInterface, Method callMethod, Object[] args, Object primKey) throws OpenEJBException {
-        BeanContext beanContext = this.getBeanContext(deployID);
+    public Object invoke(final Object deployID,
+                         InterfaceType type,
+                         final Class callInterface,
+                         final Method callMethod,
+                         final Object[] args,
+                         final Object primKey) throws OpenEJBException {
+        final BeanContext beanContext = this.getBeanContext(deployID);
 
-        if (beanContext == null) throw new OpenEJBException("Deployment does not exist in this container. Deployment(id='" + deployID + "'), Container(id='" + containerID + "')");
+        if (beanContext == null) {
+            throw new OpenEJBException("Deployment does not exist in this container. Deployment(id='" + deployID + "'), Container(id='" + containerID + "')");
+        }
 
         // Use the backup way to determine call type if null was supplied.
-        if (type == null) type = beanContext.getInterfaceType(callInterface);
+        if (type == null) {
+            type = beanContext.getInterfaceType(callInterface);
+        }
 
-        Method runMethod = beanContext.getMatchingBeanMethod(callMethod);
+        final Method runMethod = beanContext.getMatchingBeanMethod(callMethod);
 
-        ThreadContext callContext = new ThreadContext(beanContext, primKey);
-        ThreadContext oldCallContext = ThreadContext.enter(callContext);
-        CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);
+        final ThreadContext callContext = new ThreadContext(beanContext, primKey);
+        final ThreadContext oldCallContext = ThreadContext.enter(callContext);
+        final CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);
         try {
-            boolean authorized = type == InterfaceType.TIMEOUT || getSecurityService().isCallerAuthorized(callMethod, type);
-            if (!authorized)
+
+            final boolean authorized = type == InterfaceType.TIMEOUT || getSecurityService().isCallerAuthorized(callMethod, type);
+
+            if (!authorized) {
                 throw new org.apache.openejb.ApplicationException(new EJBAccessException("Unauthorized Access by Principal Denied"));
+            }
 
-            Class declaringClass = callMethod.getDeclaringClass();
+            final Class declaringClass = callMethod.getDeclaringClass();
             if (EJBHome.class.isAssignableFrom(declaringClass) || EJBLocalHome.class.isAssignableFrom(declaringClass)) {
                 if (callMethod.getName().startsWith("create")) {
                     return createEJBObject(beanContext, callMethod);
-                } else
+                } else {
                     return null;// EJBHome.remove( ) and other EJBHome methods are not process by the container
+                }
             } else if (EJBObject.class == declaringClass || EJBLocalObject.class == declaringClass) {
                 return null;// EJBObject.remove( ) and other EJBObject methods are not process by the container
             }
 
-            Instance instance = instanceManager.getInstance(callContext);
+            final Instance instance = instanceManager.getInstance(callContext);
 
             callContext.setCurrentOperation(type == InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS);
             callContext.setCurrentAllowedStates(null);
@@ -191,6 +204,7 @@ public class SingletonContainer implemen
             callContext.setInvokedInterface(callInterface);
 
             if (currentCreationalContext != null) {
+                //noinspection unchecked
                 currentCreationalContext.set(instance.creationalContext);
             }
 
@@ -208,18 +222,23 @@ public class SingletonContainer implemen
         return securityService;
     }
 
-    protected Object _invoke(Method callMethod, Method runMethod, Object[] args, Instance instance, ThreadContext callContext, InterfaceType callType) throws OpenEJBException {
-        BeanContext beanContext = callContext.getBeanContext();
+    protected Object _invoke(final Method callMethod,
+                             final Method runMethod,
+                             final Object[] args,
+                             final Instance instance,
+                             final ThreadContext callContext,
+                             final InterfaceType callType) throws OpenEJBException {
+        final BeanContext beanContext = callContext.getBeanContext();
 
-        Duration accessTimeout = getAccessTimeout(beanContext, runMethod);
-        boolean read = javax.ejb.LockType.READ.equals(beanContext.getConcurrencyAttribute(runMethod));
+        final Duration accessTimeout = getAccessTimeout(beanContext, runMethod);
+        final boolean read = javax.ejb.LockType.READ.equals(beanContext.getConcurrencyAttribute(runMethod));
 
         final Lock lock = aquireLock(read, accessTimeout, instance, runMethod);
 
         Object returnValue;
         try {
 
-            TransactionPolicy txPolicy = createTransactionPolicy(beanContext.getTransactionType(callMethod, callType), callContext);
+            final TransactionPolicy txPolicy = createTransactionPolicy(beanContext.getTransactionType(callMethod, callType), callContext);
 
             returnValue = null;
             try {
@@ -227,13 +246,16 @@ public class SingletonContainer implemen
                     callContext.setCurrentOperation(Operation.BUSINESS_WS);
                     returnValue = invokeWebService(args, beanContext, runMethod, instance);
                 } else {
-                    List<InterceptorData> interceptors = beanContext.getMethodInterceptors(runMethod);
-                    InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, callType == InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS, interceptors,
-                            instance.interceptors);
+                    final List<InterceptorData> interceptors = beanContext.getMethodInterceptors(runMethod);
+                    final InterceptorStack interceptorStack = new InterceptorStack(instance.bean,
+                                                                                   runMethod,
+                                                                                   callType == InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS,
+                                                                                   interceptors,
+                                                                                   instance.interceptors);
                     returnValue = interceptorStack.invoke(args);
                 }
             } catch (Throwable e) {// handle reflection exception
-                ExceptionType type = beanContext.getExceptionType(e);
+                final ExceptionType type = beanContext.getExceptionType(e);
                 if (type == ExceptionType.SYSTEM) {
                     /* System Exception ****************************/
 
@@ -257,7 +279,7 @@ public class SingletonContainer implemen
         return returnValue;
     }
 
-    private Duration getAccessTimeout(BeanContext beanContext, Method callMethod) {
+    private Duration getAccessTimeout(final BeanContext beanContext, final Method callMethod) {
         Duration accessTimeout = beanContext.getAccessTimeout(callMethod);
         if (accessTimeout == null) {
             accessTimeout = beanContext.getAccessTimeout();
@@ -268,7 +290,7 @@ public class SingletonContainer implemen
         return accessTimeout;
     }
 
-    private Lock aquireLock(boolean read, final Duration accessTimeout, final Instance instance, final Method runMethod) {
+    private Lock aquireLock(final boolean read, final Duration accessTimeout, final Instance instance, final Method runMethod) {
         final Lock lock;
         if (read) {
             lock = instance.lock.readLock();
@@ -276,9 +298,10 @@ public class SingletonContainer implemen
             lock = instance.lock.writeLock();
         }
 
-        boolean lockAcquired;
+        final boolean lockAcquired;
         if (accessTimeout == null || accessTimeout.getTime() < 0) {
             // wait indefinitely for a lock
+            //noinspection LockAcquiredButNotSafelyReleased
             lock.lock();
             lockAcquired = true;
         } else if (accessTimeout.getTime() == 0) {
@@ -289,26 +312,38 @@ public class SingletonContainer implemen
             try {
                 lockAcquired = lock.tryLock(accessTimeout.getTime(), accessTimeout.getUnit());
             } catch (InterruptedException e) {
-                throw (ConcurrentAccessTimeoutException) new ConcurrentAccessTimeoutException("Unable to get " + (read ? "read" : "write") + " lock within specified time on '" + runMethod.getName() + "' method for: " + instance.bean.getClass().getName()).initCause(e);
+                throw (ConcurrentAccessTimeoutException) new ConcurrentAccessTimeoutException("Unable to get " +
+                                                                                              (read ? "read" : "write") +
+                                                                                              " lock within specified time on '" +
+                                                                                              runMethod.getName() +
+                                                                                              "' method for: " +
+                                                                                              instance.bean.getClass().getName()).initCause(e);
             }
         }
 
         // Did we acquire the lock to the current execution?
         if (!lockAcquired) {
-            throw new ConcurrentAccessTimeoutException("Unable to get " + (read ? "read" : "write") + " lock on '" + runMethod.getName() + "' method for: " + instance.bean.getClass().getName());
+            throw new ConcurrentAccessTimeoutException("Unable to get " +
+                                                       (read ? "read" : "write") +
+                                                       " lock on '" +
+                                                       runMethod.getName() +
+                                                       "' method for: " +
+                                                       instance.bean.getClass().getName());
         }
 
         return lock;
     }
 
-    private Object invokeWebService(Object[] args, BeanContext beanContext, Method runMethod, Instance instance) throws Exception {
+    private Object invokeWebService(final Object[] args, final BeanContext beanContext, final Method runMethod, final Instance instance) throws Exception {
         if (args.length < 2) {
             throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
         }
 
-        Object messageContext = args[0];
+        final Object messageContext = args[0];
 
-        if (messageContext == null) throw new IllegalArgumentException("MessageContext is null.");
+        if (messageContext == null) {
+            throw new IllegalArgumentException("MessageContext is null.");
+        }
 
         // This object will be used as an interceptor in the stack and will be responsible
         // for unmarshalling the soap message parts into an argument list that will be
@@ -316,20 +351,22 @@ public class SingletonContainer implemen
         //
         // We just need to make it an interceptor in the OpenEJB sense and tack it on the end
         // of our stack.
-        Object interceptor = args[1];
+        final Object interceptor = args[1];
 
-        if (interceptor == null) throw new IllegalArgumentException("Interceptor instance is null.");
+        if (interceptor == null) {
+            throw new IllegalArgumentException("Interceptor instance is null.");
+        }
 
         final Class<?> interceptorClass = interceptor.getClass();
 
         //  Add the webservice interceptor to the list of interceptor instances
-        Map<String, Object> interceptors = new HashMap<String, Object>(instance.interceptors);
+        final Map<String, Object> interceptors = new HashMap<String, Object>(instance.interceptors);
         {
             interceptors.put(interceptorClass.getName(), interceptor);
         }
 
         //  Create an InterceptorData for the webservice interceptor to the list of interceptorDatas for this method
-        List<InterceptorData> interceptorDatas = new ArrayList<InterceptorData>();
+        final List<InterceptorData> interceptorDatas = new ArrayList<InterceptorData>();
         {
             final InterceptorData providerData = new InterceptorData(interceptorClass);
 
@@ -350,8 +387,8 @@ public class SingletonContainer implemen
             interceptorDatas.addAll(beanContext.getMethodInterceptors(runMethod));
         }
 
-        InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS_WS, interceptorDatas, interceptors);
-        Object[] params = new Object[runMethod.getParameterTypes().length];
+        final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS_WS, interceptorDatas, interceptors);
+        final Object[] params = new Object[runMethod.getParameterTypes().length];
         if (messageContext instanceof javax.xml.rpc.handler.MessageContext) {
             ThreadContext.getThreadContext().set(javax.xml.rpc.handler.MessageContext.class, (javax.xml.rpc.handler.MessageContext) messageContext);
             return interceptorStack.invoke((javax.xml.rpc.handler.MessageContext) messageContext, params);
@@ -369,7 +406,7 @@ public class SingletonContainer implemen
         throw new IllegalArgumentException("Uknown MessageContext type: " + messageContext.getClass().getName());
     }
 
-    protected ProxyInfo createEJBObject(BeanContext beanContext, Method callMethod) {
+    protected ProxyInfo createEJBObject(final BeanContext beanContext, final Method callMethod) {
         return new ProxyInfo(beanContext, null);
     }
 }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java Thu Nov 21 10:22:09 2013
@@ -27,43 +27,48 @@ import javax.xml.ws.handler.MessageConte
 import java.security.Principal;
 
 public class EjbWsContext implements WebServiceContext {
-    private SessionContext context;
+    private final SessionContext context;
     
-    public EjbWsContext(SessionContext context) {
+    public EjbWsContext(final SessionContext context) {
         this.context = context;
     }
     
+    @Override
     public MessageContext getMessageContext() {
-        ThreadContext threadContext = ThreadContext.getThreadContext();
-        MessageContext messageContext = threadContext.get(MessageContext.class);
+        final ThreadContext threadContext = ThreadContext.getThreadContext();
+        final MessageContext messageContext = threadContext.get(MessageContext.class);
         if (messageContext == null) {
             throw new IllegalStateException("Only calls on the service-endpoint have a MessageContext.");
         }
         return messageContext;
     }
 
+    @Override
     public Principal getUserPrincipal() {
         return this.context.getCallerPrincipal();
     }
 
-    public boolean isUserInRole(String roleName) {
+    @Override
+    public boolean isUserInRole(final String roleName) {
         return this.context.isCallerInRole(roleName);
     }
 
     private AddressingSupport getAddressingSupport() {
-        ThreadContext threadContext = ThreadContext.getThreadContext();
-        AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
+        final ThreadContext threadContext = ThreadContext.getThreadContext();
+        final AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
         if (wsaSupport == null) {
             throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
         }
         return wsaSupport;
     }
     
-    public EndpointReference getEndpointReference(Element... referenceParameters) {
+    @Override
+    public EndpointReference getEndpointReference(final Element... referenceParameters) {
         return getAddressingSupport().getEndpointReference(referenceParameters);      
     }
 
-    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
+    @Override
+    public <T extends EndpointReference> T getEndpointReference(final Class<T> clazz, final Element... referenceParameters) {
         return getAddressingSupport().getEndpointReference(clazz, referenceParameters);
     }
 }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/Instance.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/Instance.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/Instance.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/Instance.java Thu Nov 21 10:22:09 2013
@@ -31,7 +31,7 @@ public class Instance {
 
     private Pool<Instance>.Entry poolEntry;
 
-    public Instance(Object bean, Map<String, Object> interceptors, CreationalContext creationalContext) {
+    public Instance(final Object bean, final Map<String, Object> interceptors, final CreationalContext creationalContext) {
         this.bean = bean;
         this.interceptors = interceptors;
         this.creationalContext = creationalContext;
@@ -41,7 +41,7 @@ public class Instance {
         return poolEntry;
     }
 
-    public void setPoolEntry(Pool<Instance>.Entry poolEntry) {
+    public void setPoolEntry(final Pool<Instance>.Entry poolEntry) {
         this.poolEntry = poolEntry;
     }
 }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java Thu Nov 21 10:22:09 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.openejb.core.stateless;
 
-import org.apache.openejb.ApplicationException;
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.ContainerType;
 import org.apache.openejb.InterfaceType;
@@ -58,13 +57,19 @@ import static org.apache.openejb.core.tr
  * @org.apache.xbean.XBean element="statelessContainer"
  */
 public class StatelessContainer implements org.apache.openejb.RpcContainer {
+
     private final ConcurrentMap<Class<?>, List<Method>> interceptorCache = new ConcurrentHashMap<Class<?>, List<Method>>();
     private final StatelessInstanceManager instanceManager;
     private final Map<String, BeanContext> deploymentRegistry = new HashMap<String, BeanContext>();
     private final Object containerID;
     private final SecurityService securityService;
 
-    public StatelessContainer(Object id, SecurityService securityService, Duration accessTimeout, Duration closeTimeout, Pool.Builder poolBuilder, int callbackThreads) {
+    public StatelessContainer(final Object id,
+                              final SecurityService securityService,
+                              final Duration accessTimeout,
+                              final Duration closeTimeout,
+                              final Pool.Builder poolBuilder,
+                              final int callbackThreads) {
         this.containerID = id;
         this.securityService = securityService;
         this.instanceManager = new StatelessInstanceManager(securityService, accessTimeout, closeTimeout, poolBuilder, callbackThreads);
@@ -76,7 +81,7 @@ public class StatelessContainer implemen
     }
 
     @Override
-    public synchronized BeanContext getBeanContext(Object deploymentID) {
+    public synchronized BeanContext getBeanContext(final Object deploymentID) {
         final String id = (String) deploymentID;
         return deploymentRegistry.get(id);
     }
@@ -92,7 +97,7 @@ public class StatelessContainer implemen
     }
 
     @Override
-    public void deploy(BeanContext beanContext) throws OpenEJBException {
+    public void deploy(final BeanContext beanContext) throws OpenEJBException {
         final String id = (String) beanContext.getDeploymentID();
         synchronized (this) {
             deploymentRegistry.put(id, beanContext);
@@ -122,7 +127,7 @@ public class StatelessContainer implemen
     }
 
     @Override
-    public void undeploy(BeanContext beanContext) {
+    public void undeploy(final BeanContext beanContext) {
         this.instanceManager.undeploy(beanContext);
 
         synchronized (this) {
@@ -133,8 +138,14 @@ public class StatelessContainer implemen
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
-    public Object invoke(Object deployID, InterfaceType type, Class callInterface, Method callMethod, Object[] args, Object primKey) throws OpenEJBException {
+    public Object invoke(final Object deployID,
+                         InterfaceType type,
+                         final Class callInterface,
+                         final Method callMethod,
+                         final Object[] args,
+                         final Object primKey) throws OpenEJBException {
         final BeanContext beanContext = this.getBeanContext(deployID);
 
         if (beanContext == null) {
@@ -149,15 +160,22 @@ public class StatelessContainer implemen
 
         final Method runMethod = beanContext.getMatchingBeanMethod(callMethod);
         final ThreadContext callContext = new ThreadContext(beanContext, primKey);
-        final ThreadContext oldCallContext = ThreadContext.enter(callContext);
+        ThreadContext oldCallContext = null;
+
         Instance bean = null;
-        CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);
+        final CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);
+
         try {
+
+            //Check auth before overriding context
             final boolean authorized = type == InterfaceType.TIMEOUT || this.securityService.isCallerAuthorized(callMethod, type);
+
             if (!authorized) {
                 throw new org.apache.openejb.ApplicationException(new javax.ejb.EJBAccessException("Unauthorized Access by Principal Denied"));
             }
 
+            oldCallContext = ThreadContext.enter(callContext);
+
             final Class declaringClass = callMethod.getDeclaringClass();
             if (javax.ejb.EJBHome.class.isAssignableFrom(declaringClass) || javax.ejb.EJBLocalHome.class.isAssignableFrom(declaringClass)) {
                 if (callMethod.getName().startsWith("create")) {
@@ -181,6 +199,7 @@ public class StatelessContainer implemen
             return _invoke(callMethod, runMethod, args, bean, callContext, type);
 
         } finally {
+
             if (bean != null) {
                 if (callContext.isDiscardInstance()) {
                     this.instanceManager.discardInstance(callContext, bean);
@@ -188,15 +207,20 @@ public class StatelessContainer implemen
                     this.instanceManager.poolInstance(callContext, bean);
                 }
             }
-            ThreadContext.exit(oldCallContext);
+
+            if (null != oldCallContext) {
+                ThreadContext.exit(oldCallContext);
+            }
+
             if (currentCreationalContext != null) {
                 currentCreationalContext.remove();
             }
         }
     }
 
-    private Object _invoke(Method callMethod, Method runMethod, Object[] args, Instance instance, ThreadContext callContext, InterfaceType type)
-            throws OpenEJBException {
+    @SuppressWarnings("ThrowFromFinallyBlock")
+    private Object _invoke(final Method callMethod, final Method runMethod, final Object[] args, final Instance instance, final ThreadContext callContext, final InterfaceType type)
+        throws OpenEJBException {
         final BeanContext beanContext = callContext.getBeanContext();
         final TransactionPolicy txPolicy = createTransactionPolicy(beanContext.getTransactionType(callMethod, type), callContext);
 
@@ -232,8 +256,6 @@ public class StatelessContainer implemen
             } catch (SystemException e) {
                 callContext.setDiscardInstance(true);
                 throw e;
-            } catch (ApplicationException e) {
-                throw e;
             } catch (RuntimeException e) {
                 callContext.setDiscardInstance(true);
                 throw e;
@@ -242,7 +264,7 @@ public class StatelessContainer implemen
         return returnValue;
     }
 
-    private Object invokeWebService(Object[] args, BeanContext beanContext, Method runMethod, Instance instance) throws Exception {
+    private Object invokeWebService(final Object[] args, final BeanContext beanContext, final Method runMethod, final Instance instance) throws Exception {
         if (args.length < 2) {
             throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
         }
@@ -290,7 +312,7 @@ public class StatelessContainer implemen
         return returnValue;
     }
 
-    private List<Method> retrieveAroundInvokes(Class<?> interceptorClass) {
+    private List<Method> retrieveAroundInvokes(final Class<?> interceptorClass) {
         final List<Method> cached = this.interceptorCache.get(interceptorClass);
         if (cached != null) {
             return cached;

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainerFactory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainerFactory.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainerFactory.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainerFactory.java Thu Nov 21 10:22:09 2013
@@ -34,15 +34,15 @@ public class StatelessContainerFactory {
     private int callbackThreads = 5;
     private Duration closeTimeout;
 
-    public void setCallbackThreads(int callbackThreads) {
+    public void setCallbackThreads(final int callbackThreads) {
         this.callbackThreads = callbackThreads;
     }
 
-    public void setId(Object id) {
+    public void setId(final Object id) {
         this.id = id;
     }
 
-    public void setSecurityService(SecurityService securityService) {
+    public void setSecurityService(final SecurityService securityService) {
         this.securityService = securityService;
     }
 
@@ -51,70 +51,72 @@ public class StatelessContainerFactory {
      * backwards compatibility
      *
      * @deprecated use AccessTimeout
-     * @param accessTimeout
+     * @param accessTimeout Duration
      */
-    public void setTimeOut(Duration accessTimeout) {
+    @Deprecated
+    public void setTimeOut(final Duration accessTimeout) {
         this.accessTimeout = accessTimeout;
     }
 
     /**
      *
-     * @param accessTimeout
+     * @param accessTimeout Duration
      */
-    public void setAccessTimeout(Duration accessTimeout) {
+    public void setAccessTimeout(final Duration accessTimeout) {
         if (this.accessTimeout == null) setTimeOut(accessTimeout);
     }
 
-    public void setMaxSize(int max) {
+    public void setMaxSize(final int max) {
         if (this.max == null) setPoolSize(max);
     }
 
     /**
      * @deprecated use MaxSize
-     * @param max
+     * @param max int
      */
-    public void setPoolSize(int max) {
+    @Deprecated
+    public void setPoolSize(final int max) {
         this.max = max;
         pool.setPoolSize(max);
     }
 
-    public void setMinSize(int min) {
+    public void setMinSize(final int min) {
         pool.setMinSize(min);
     }
 
-    public void setStrictPooling(boolean strict) {
+    public void setStrictPooling(final boolean strict) {
         pool.setStrictPooling(strict);
     }
 
-    public void setMaxAge(Duration maxAge) {
+    public void setMaxAge(final Duration maxAge) {
         pool.setMaxAge(maxAge);
     }
 
-    public void setIdleTimeout(Duration idleTimeout) {
+    public void setIdleTimeout(final Duration idleTimeout) {
         pool.setIdleTimeout(idleTimeout);
     }
 
-    public void setSweepInterval(Duration interval) {
+    public void setSweepInterval(final Duration interval) {
         pool.setSweepInterval(interval);
     }
 
-    public void setReplaceAged(boolean replaceAged) {
+    public void setReplaceAged(final boolean replaceAged) {
         pool.setReplaceAged(replaceAged);
     }
 
-    public void setReplaceFlushed(boolean replaceFlushed) {
+    public void setReplaceFlushed(final boolean replaceFlushed) {
         pool.setReplaceFlushed(replaceFlushed);
     }
 
-    public void setGarbageCollection(boolean garbageCollection) {
+    public void setGarbageCollection(final boolean garbageCollection) {
         pool.setGarbageCollection(garbageCollection);
     }
 
-    public void setMaxAgeOffset(double maxAgeOffset) {
+    public void setMaxAgeOffset(final double maxAgeOffset) {
         pool.setMaxAgeOffset(maxAgeOffset);
     }
 
-    public void setCloseTimeout(Duration closeTimeout) {
+    public void setCloseTimeout(final Duration closeTimeout) {
         this.closeTimeout = closeTimeout;
     }
 

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContext.java Thu Nov 21 10:22:09 2013
@@ -31,13 +31,13 @@ public class StatelessContext extends Ba
 
     private final Flushable flushable;
 
-    public StatelessContext(SecurityService securityService, Flushable flushable) {
+    public StatelessContext(final SecurityService securityService, final Flushable flushable) {
         super(securityService);
         this.flushable = flushable;
     }
 
     @Override
-    public void check(Call call) {
+    public void check(final Call call) {
         final Operation operation = ThreadContext.getThreadContext().getCurrentOperation();
 
         switch (call) {
@@ -85,6 +85,7 @@ public class StatelessContext extends Ba
         }
     }
 
+    @Override
     public void flush() throws IOException {
         flushable.flush();
     }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbHomeHandler.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbHomeHandler.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbHomeHandler.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbHomeHandler.java Thu Nov 21 10:22:09 2013
@@ -27,24 +27,28 @@ import java.util.List;
 
 public class StatelessEjbHomeHandler extends EjbHomeProxyHandler {
 
-    public StatelessEjbHomeHandler(BeanContext beanContext, InterfaceType interfaceType, List<Class> interfaces, Class mainInterface) {
+    public StatelessEjbHomeHandler(final BeanContext beanContext, final InterfaceType interfaceType, final List<Class> interfaces, final Class mainInterface) {
         super(beanContext, interfaceType, interfaces, mainInterface);
     }
 
-    protected Object findX(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object findX(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
         throw new UnsupportedOperationException("Stateful beans may not have find methods");
     }
 
-    protected Object removeByPrimaryKey(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object removeByPrimaryKey(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
         throw new RemoveException("Session objects are private resources and do not have primary keys");
     }
 
-    protected Object removeWithHandle(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object removeWithHandle(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
         // stateless can't be removed
         return null;
     }
 
-    protected EjbObjectProxyHandler newEjbObjectHandler(BeanContext beanContext, Object pk, InterfaceType interfaceType, List<Class> interfaces, Class mainInterface) {
+    @Override
+    protected EjbObjectProxyHandler newEjbObjectHandler(final BeanContext beanContext, final Object pk, final InterfaceType interfaceType, final List<Class> interfaces, final Class mainInterface) {
         return new StatelessEjbObjectHandler(getBeanContext(), pk, interfaceType, interfaces, mainInterface);
     }
 

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbObjectHandler.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbObjectHandler.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbObjectHandler.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessEjbObjectHandler.java Thu Nov 21 10:22:09 2013
@@ -27,41 +27,48 @@ import java.rmi.RemoteException;
 import java.util.List;
 
 public class StatelessEjbObjectHandler extends EjbObjectProxyHandler {
+
     public Object registryId;
 
-    public StatelessEjbObjectHandler(BeanContext beanContext, Object pk, InterfaceType interfaceType, List<Class> interfaces, Class mainInterface) {
+    public StatelessEjbObjectHandler(final BeanContext beanContext, final Object pk, final InterfaceType interfaceType, final List<Class> interfaces, final Class mainInterface) {
         super(beanContext, pk, interfaceType, interfaces, mainInterface);
     }
 
-    public static Object createRegistryId(Object primKey, Object deployId, Container contnr) {
+    public static Object createRegistryId(final Object primKey, final Object deployId, final Container contnr) {
         return "" + deployId + contnr.getContainerID();
     }
 
+    @Override
     public Object getRegistryId() {
-        if (registryId == null)
+        if (registryId == null) {
             registryId = createRegistryId(primaryKey, deploymentID, container);
+        }
         return registryId;
     }
 
-    protected Object getPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object getPrimaryKey(final Method method, final Object[] args, final Object proxy) throws Throwable {
         throw new RemoteException("Session objects are private resources and do not have primary keys");
     }
 
-    protected Object isIdentical(Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object isIdentical(final Method method, final Object[] args, final Object proxy) throws Throwable {
         try {
-            EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(args[0]);
-            return new Boolean(deploymentID.equals(handler.deploymentID));
+            final EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(args[0]);
+            return deploymentID.equals(handler.deploymentID);
         } catch (Throwable t) {
             return Boolean.FALSE;
 
         }
     }
 
+    @Override
     public void invalidateReference() {
         // stateless can't be removed
     }
 
-    protected Object remove(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
+    @Override
+    protected Object remove(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
         // stateless can't be removed
         return null;
     }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java Thu Nov 21 10:22:09 2013
@@ -283,6 +283,7 @@ public class StatelessInstanceManager {
         }
     }
 
+    @SuppressWarnings("unchecked")
     private void freeInstance(final ThreadContext callContext, final Instance instance) {
         try {
             callContext.setCurrentOperation(Operation.PRE_DESTROY);

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/ArrayEnumeration.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/ArrayEnumeration.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/ArrayEnumeration.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/ArrayEnumeration.java Thu Nov 21 10:22:09 2013
@@ -26,23 +26,25 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.Vector;
 
+@SuppressWarnings("UseOfObsoleteCollectionType")
 public final class ArrayEnumeration implements Enumeration, Externalizable {
+
     static final long serialVersionUID = -1194966576855523042L;
 
     private Object[] elements;
     private int elementsIndex;
 
-    public ArrayEnumeration(Vector elements) {
+    public ArrayEnumeration(final Vector elements) {
         this.elements = new Object[elements.size()];
         elements.copyInto(this.elements);
     }
 
-    public ArrayEnumeration(List list) {
+    public ArrayEnumeration(final List list) {
         this.elements = new Object[list.size()];
         list.toArray(this.elements);
     }
 
-    public ArrayEnumeration(Set<?> set) {
+    public ArrayEnumeration(final Set<?> set) {
         this.elements = new Object[set.size()];
         set.toArray(this.elements);
     }
@@ -50,11 +52,11 @@ public final class ArrayEnumeration impl
     public ArrayEnumeration() {
     }
 
-    public Object get(int index) {
+    public Object get(final int index) {
         return elements[index];
     }
 
-    public void set(int index, Object o) {
+    public void set(final int index, final Object o) {
         elements[index] = o;
     }
 
@@ -62,24 +64,30 @@ public final class ArrayEnumeration impl
         return elements.length;
     }
 
+    @Override
     public boolean hasMoreElements() {
         return elementsIndex < elements.length;
     }
 
+    @Override
     public Object nextElement() {
-        if (!hasMoreElements()) throw new NoSuchElementException("No more elements exist");
+        if (!hasMoreElements()) {
+            throw new NoSuchElementException("No more elements exist");
+        }
         return elements[elementsIndex++];
     }
 
-    public void writeExternal(ObjectOutput out) throws IOException {
+    @Override
+    public void writeExternal(final ObjectOutput out) throws IOException {
         out.writeInt(elements.length);
         out.writeInt(elementsIndex);
-        for (int i = 0; i < elements.length; i++) {
-            out.writeObject(elements[i]);
+        for (final Object element : elements) {
+            out.writeObject(element);
         }
     }
 
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    @Override
+    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
         elements = new Object[in.readInt()];
         elementsIndex = in.readInt();
         for (int i = 0; i < elements.length; i++) {

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java?rev=1544088&r1=1544087&r2=1544088&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java Thu Nov 21 10:22:09 2013
@@ -15,65 +15,68 @@
  * limitations under the License.
  */
 package org.apache.openejb.util;
+
 /**
  * Contains Logger categories used in OpenEJB. Be careful when adding new Categories. For example, if a new Category
  * named OpenEJB.shutdown needs to be added, then the following is not a recommended way
  * public static final LogCategory OPENEJB_SHUTDOWN = new LogCategory("OpenEJB.shutdown");
  * The above is not recommended because the above logger has a parent logger in OpenEJB. If we change the Parent logger
  * category i.e. lets say to OPENEJB (all uppercase), then to maintain the parent-child relationship, we will need
- * to change other loggers too. For example, we will not need to change OPENEJB_STARTUP and OPENEJB_SERVER because 
+ * to change other loggers too. For example, we will not need to change OPENEJB_STARTUP and OPENEJB_SERVER because
  * of the way they are defined (using OPENEJB.name as a prefix).
  * A better way of adding the Category would be
  * public static final LogCategory OPENEJB_SHUTDOWN = new LogCategory( OPENEJB.name + ".shutdown");
- * 
- *
  */
 public final class LogCategory {
-	private final String name;
-	public static final LogCategory OPENEJB = new LogCategory( "OpenEJB");
-	public static final LogCategory OPENEJB_ADMIN = OPENEJB.createChild("admin");
-	public static final LogCategory OPENEJB_STARTUP = OPENEJB.createChild("startup");
-	public static final LogCategory OPENEJB_STARTUP_CONFIG = OPENEJB_STARTUP.createChild("config");
-	public static final LogCategory OPENEJB_STARTUP_VALIDATION = OPENEJB_STARTUP.createChild("validation");
-	public static final LogCategory OPENEJB_SERVER = OPENEJB.createChild("server");
-	public static final LogCategory OPENEJB_SERVER_REMOTE = OPENEJB_SERVER.createChild("remote");
-	public static final LogCategory OPENEJB_SECURITY = OPENEJB.createChild("security");
-	public static final LogCategory OPENEJB_RESOURCE_JDBC = OPENEJB.createChild("resource.jdbc");
-	public static final LogCategory OPENEJB_CONNECTOR = OPENEJB.createChild("connector");
-	public static final LogCategory OPENEJB_DEPLOY = OPENEJB.createChild("deploy");
-	public static final LogCategory OPENEJB_HSQL = OPENEJB.createChild("hsql");
-	public static final LogCategory OPENEJB_WS = OPENEJB.createChild("ws");
-	public static final LogCategory OPENEJB_RS = OPENEJB.createChild("rs");
-	public static final LogCategory OPENEJB_JPA = OPENEJB.createChild("jpa");
+
+    private final String name;
+    public static final LogCategory OPENEJB = new LogCategory("OpenEJB");
+    public static final LogCategory OPENEJB_ADMIN = OPENEJB.createChild("admin");
+    public static final LogCategory OPENEJB_STARTUP = OPENEJB.createChild("startup");
+    public static final LogCategory OPENEJB_STARTUP_CONFIG = OPENEJB_STARTUP.createChild("config");
+    public static final LogCategory OPENEJB_STARTUP_VALIDATION = OPENEJB_STARTUP.createChild("validation");
+    public static final LogCategory OPENEJB_SERVER = OPENEJB.createChild("server");
+    public static final LogCategory OPENEJB_SERVER_REMOTE = OPENEJB_SERVER.createChild("remote");
+    public static final LogCategory OPENEJB_SECURITY = OPENEJB.createChild("security");
+    public static final LogCategory OPENEJB_RESOURCE_JDBC = OPENEJB.createChild("resource.jdbc");
+    public static final LogCategory OPENEJB_CONNECTOR = OPENEJB.createChild("connector");
+    public static final LogCategory OPENEJB_DEPLOY = OPENEJB.createChild("deploy");
+    public static final LogCategory OPENEJB_HSQL = OPENEJB.createChild("hsql");
+    public static final LogCategory OPENEJB_WS = OPENEJB.createChild("ws");
+    public static final LogCategory OPENEJB_RS = OPENEJB.createChild("rs");
+    public static final LogCategory OPENEJB_JPA = OPENEJB.createChild("jpa");
     public static final LogCategory OPENEJB_CDI = OPENEJB.createChild("cdi");
-	public static final LogCategory TRANSACTION = new LogCategory( "Transaction");
-	public static final LogCategory ACTIVEMQ = new LogCategory( "org.apache.activemq");
-	public static final LogCategory GERONIMO = new LogCategory( "org.apache.geronimo");
-	public static final LogCategory OPENJPA = new LogCategory( "openjpa");
-	public static final LogCategory CORBA_ADAPTER = new LogCategory( "CORBA-Adapter");
-	public static final LogCategory AXIS = new LogCategory( "axis");
-	public static final LogCategory AXIS2 = new LogCategory( "axis");
-	public static final LogCategory CXF = new LogCategory( "cxf");
-	public static final LogCategory TIMER = new LogCategory( "Timer");
-	public static final LogCategory HTTPSERVER = OPENEJB_SERVER.createChild("http");
-	public static final LogCategory SERVICEPOOL = OPENEJB_SERVER.createChild("pool");
+    public static final LogCategory TRANSACTION = new LogCategory("Transaction");
+    public static final LogCategory ACTIVEMQ = new LogCategory("org.apache.activemq");
+    public static final LogCategory GERONIMO = new LogCategory("org.apache.geronimo");
+    public static final LogCategory OPENJPA = new LogCategory("openjpa");
+    public static final LogCategory CORBA_ADAPTER = new LogCategory("CORBA-Adapter");
+    public static final LogCategory AXIS = new LogCategory("axis");
+    public static final LogCategory AXIS2 = new LogCategory("axis");
+    public static final LogCategory CXF = new LogCategory("cxf");
+    public static final LogCategory TIMER = new LogCategory("Timer");
+    public static final LogCategory HTTPSERVER = OPENEJB_SERVER.createChild("http");
+    public static final LogCategory SERVICEPOOL = OPENEJB_SERVER.createChild("pool");
     public static final LogCategory OPENEJB_SQL = OPENEJB.createChild("sql");
 
-    private LogCategory(String name){
-		this.name = name;
-	}
-	public String getName() {
-		return name;
-	}
-	/**
-	 * Creates a child category of this category. <B>Use this method sparingly</B>. This method is to be used in only those circumstances where the name of the 
-	 * category is not known upfront and is a derived name. If you know the name of the category, it is highly recommended to add a static final field 
-	 * of type LogCategory in this class
-	 * @param child
-	 * @return - LogCategory
-	 */
-	public LogCategory createChild(String child){
-		return new LogCategory(this.name+"."+child);
-	}
+    private LogCategory(final String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Creates a child category of this category. <B>Use this method sparingly</B>. This method is to be used in only those circumstances where the name of the
+     * category is not known upfront and is a derived name. If you know the name of the category, it is highly recommended to add a static final field
+     * of type LogCategory in this class
+     *
+     * @param child String
+     * @return - LogCategory
+     */
+    public LogCategory createChild(final String child) {
+        return new LogCategory(this.name + "." + child);
+    }
 
 }