From adcde2ec1d834c9e91806a356bc39ff00a42915f Mon Sep 17 00:00:00 2001 From: Sven Diedrichsen Date: Mon, 8 Oct 2018 00:15:30 +0200 Subject: [PATCH] fixing bugs of blocker and major --- .../src/main/java/com/sun/ejb/EJBUtils.java | 183 ++-- .../base/io/EJBObjectOutputStreamHandler.java | 108 +-- .../com/sun/ejb/containers/BaseContainer.java | 840 +++++++++--------- .../CallbackInvocationContext.java | 10 +- .../interceptors/InterceptorUtil.java | 27 +- .../containers/util/pool/BlockingPool.java | 12 +- .../containers/util/pool/NonBlockingPool.java | 171 ++-- .../descriptor/ContainerTransaction.java | 72 +- 8 files changed, 706 insertions(+), 717 deletions(-) diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java index 1fc6f1b8882..4ce7c97eb07 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java @@ -73,7 +73,7 @@ * * Note that much of this code has to execute in the client so * it needs to be careful about which server-only resources it - * uses and in which code paths. + * uses and in which code paths. * */ public class EJBUtils { @@ -85,7 +85,7 @@ public class EJBUtils { // Internal property to force generated ejb container classes to // be created during deployment time instead of dynamically. Note that - // this property does *not* cover RMI-IIOP stub generation. + // this property does *not* cover RMI-IIOP stub generation. // See IASEJBC.java for more details. private static final String EJB_USE_STATIC_CODEGEN_PROP = "com.sun.ejb.UseStaticCodegen"; @@ -108,15 +108,15 @@ public class EJBUtils { private static final String GLASSFISH_JNDI_NAME_SEP = "#"; /** - * Utility methods for serializing EJBs, primary keys and - * container-managed fields, all of which may include Remote EJB + * Utility methods for serializing EJBs, primary keys and + * container-managed fields, all of which may include Remote EJB * references, * Local refs, JNDI Contexts etc which are not Serializable. * This is not used for normal RMI-IIOP serialization. - * It has boolean replaceObject control, whether to call replaceObject + * It has boolean replaceObject control, whether to call replaceObject * or not */ - public static final byte[] serializeObject(Object obj, + public static final byte[] serializeObject(Object obj, boolean replaceObject) throws IOException { @@ -130,8 +130,8 @@ public static final byte[] serializeObject(Object obj) } /** - * Utility method for deserializing EJBs, primary keys and - * container-managed fields, all of which may include Remote + * Utility method for deserializing EJBs, primary keys and + * container-managed fields, all of which may include Remote * EJB references, * Local refs, JNDI Contexts etc which are not Serializable. * @param data @@ -141,7 +141,7 @@ public static final byte[] serializeObject(Object obj) * @return object * @throws java.lang.Exception */ - public static final Object deserializeObject(byte[] data, + public static final Object deserializeObject(byte[] data, ClassLoader loader, boolean resolveObject, long appUniqueId) throws Exception { @@ -159,33 +159,33 @@ public static boolean useStaticCodegen() { if( ejbUseStaticCodegen_ == null ) { String ejbStaticCodegenProp = null; if(System.getSecurityManager() == null) { - ejbStaticCodegenProp = + ejbStaticCodegenProp = System.getProperty(EJB_USE_STATIC_CODEGEN_PROP); } else { ejbStaticCodegenProp = (String) java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { public java.lang.Object run() { - return + return System.getProperty(EJB_USE_STATIC_CODEGEN_PROP); }}); } - - boolean useStaticCodegen = + + boolean useStaticCodegen = ( (ejbStaticCodegenProp != null) && ejbStaticCodegenProp.equalsIgnoreCase("true")); - + ejbUseStaticCodegen_ = useStaticCodegen; _logger.log(Level.FINE, "EJB Static codegen is " + (useStaticCodegen ? "ENABLED" : "DISABLED") + - " ejbUseStaticCodegenProp = " + + " ejbUseStaticCodegenProp = " + ejbStaticCodegenProp); } } return ejbUseStaticCodegen_.booleanValue(); - + } private static String getClassPackageName(String intf) { @@ -210,7 +210,7 @@ public static String getGeneratedSerializableClassName(String beanClass) { String packageName = getClassPackageName(beanClass); String simpleName = getClassSimpleName(beanClass); String generatedSimpleName = "_" + simpleName + "_Serializable"; - return (packageName != null) ? + return (packageName != null) ? packageName + "." + generatedSimpleName : generatedSimpleName; } @@ -218,7 +218,7 @@ public static String getGeneratedRemoteIntfName(String businessIntf) { String packageName = getClassPackageName(businessIntf); String simpleName = getClassSimpleName(businessIntf); String generatedSimpleName = "_" + simpleName + "_Remote"; - return (packageName != null) ? + return (packageName != null) ? packageName + "." + generatedSimpleName : generatedSimpleName; } @@ -226,7 +226,7 @@ public static String getGeneratedRemoteWrapperName(String businessIntf) { String packageName = getClassPackageName(businessIntf); String simpleName = getClassSimpleName(businessIntf); String generatedSimpleName = "_" + simpleName + "_Wrapper"; - return (packageName != null) ? + return (packageName != null) ? packageName + "." + generatedSimpleName : generatedSimpleName; } @@ -243,18 +243,18 @@ public static String getGenericEJBHomeClassName() { * developer can simply deal with a single physical jndi-name. If the * target bean exposes both a Remote Home view and a Remote Business * view, the developer can still use the single physical jndi-name - * to resolve remote ejb-refs, and we will handle the distinction + * to resolve remote ejb-refs, and we will handle the distinction * internally. Of course, this is based on the assumption that the * internal name is generated in a way that will not clash with a - * separate top-level physical jndi-name chosen by the developer. - * + * separate top-level physical jndi-name chosen by the developer. + * * Note that it's better to delay this final jndi name translation as * much as possible and do it right before the NamingManager lookup, * as opposed to changing the jndi-name within the descriptor objects * themselves. This way, the extra indirection will not be exposed * if the descriptors are written out and they won't complicate any * jndi-name equality logic. - * + * */ public static String getRemoteEjbJndiName(EjbReferenceDescriptor refDesc) { @@ -329,7 +329,7 @@ public static String getRemoteEjbJndiName(boolean businessView, // Only in the portable global case, convert to a fully-qualified name if( jndiName.startsWith(JAVA_GLOBAL_PREFIX)) { returnValue = checkFullyQualifiedJndiName(jndiName, portableFullyQualifiedPortion); - } + } } return returnValue; @@ -354,19 +354,19 @@ private static String stripFullyQualifiedJndiName(String origJndiName, String fu public static Object resolveEjbRefObject(EjbReferenceDescriptor refDesc, - Object jndiObj) + Object jndiObj) throws NamingException { Object returnObject = jndiObj; if( refDesc.isLocal() ) { - EjbDescriptor target = refDesc.getEjbDescriptor(); + EjbDescriptor target = refDesc.getEjbDescriptor(); BaseContainer container = EjbContainerUtilImpl.getInstance().getContainer(target.getUniqueId()); if( refDesc.isEJB30ClientView() ) { - GenericEJBLocalHome genericLocalHome = + GenericEJBLocalHome genericLocalHome = container.getEJBLocalBusinessHome(refDesc.getEjbInterface()); returnObject = genericLocalHome.create(refDesc.getEjbInterface()); } else { @@ -375,8 +375,8 @@ public static Object resolveEjbRefObject(EjbReferenceDescriptor refDesc, } else { - // For the Remote case, the only time we have to do - // something extra with the given jndiObj is if the lookup + // For the Remote case, the only time we have to do + // something extra with the given jndiObj is if the lookup // is for a Remote 3.0 object and it was made through a // corba interoperable name. In that case, // the jndiObj refers to the internal Remote 3.0 Home so we @@ -397,38 +397,38 @@ public static Object resolveEjbRefObject(EjbReferenceDescriptor refDesc, public static Object lookupRemote30BusinessObject(Object jndiObj, String businessInterface) throws NamingException - + { Object returnObject = null; try { - + ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class genericEJBHome = loadGeneratedGenericEJBHomeClass (loader); - + final Object genericHomeObj = PortableRemoteObject.narrow(jndiObj, genericEJBHome); - + // The generated remote business interface and the // client wrapper for the business interface are produced // dynamically. The following call must be made before // any EJB 3.0 Remote business interface runtime behavior - // is needed in a given JVM. + // is needed in a given JVM. loadGeneratedRemoteBusinessClasses(businessInterface); - + String generatedRemoteIntfName = EJBUtils. getGeneratedRemoteIntfName(businessInterface); - + Method createMethod = genericEJBHome.getMethod ("create", String.class); - + java.rmi.Remote delegate = (java.rmi.Remote) - createMethod.invoke(genericHomeObj, + createMethod.invoke(genericHomeObj, generatedRemoteIntfName); - - + + returnObject = createRemoteBusinessObject (loader, businessInterface, delegate); @@ -437,16 +437,16 @@ public static Object lookupRemote30BusinessObject(Object jndiObj, } catch(Exception e) { NamingException ne = new NamingException - ("ejb ref resolution error for remote business interface" + ("ejb ref resolution error for remote business interface" + businessInterface); - + ne.initCause(e instanceof InvocationTargetException ? e.getCause() : e); throw ne; } return returnObject; - + } public static Class loadGeneratedSerializableClass(ClassLoader loader, String className) @@ -456,7 +456,7 @@ public static Class loadGeneratedSerializableClass(ClassLoader loader, String cl Class developerClass = loader.loadClass(className); AsmSerializableBeanGenerator gen = new AsmSerializableBeanGenerator (loader, developerClass, generatedSerializableClassName); - + Class serializableClass = gen.generateSerializableSubclass(); return serializableClass; @@ -465,38 +465,38 @@ public static Class loadGeneratedSerializableClass(ClassLoader loader, String cl public static void loadGeneratedRemoteBusinessClasses (String businessInterfaceName) throws Exception { - ClassLoader appClassLoader = + ClassLoader appClassLoader = getBusinessIntfClassLoader(businessInterfaceName); - - loadGeneratedRemoteBusinessClasses(appClassLoader, + + loadGeneratedRemoteBusinessClasses(appClassLoader, businessInterfaceName); } public static void loadGeneratedRemoteBusinessClasses - (ClassLoader appClassLoader, String businessInterfaceName) + (ClassLoader appClassLoader, String businessInterfaceName) throws Exception { String generatedRemoteIntfName = EJBUtils. getGeneratedRemoteIntfName(businessInterfaceName); - + String wrapperClassName = EJBUtils. getGeneratedRemoteWrapperName(businessInterfaceName); Class generatedRemoteIntf = null; try { - generatedRemoteIntf = + generatedRemoteIntf = appClassLoader.loadClass(generatedRemoteIntfName); } catch(Exception e) { } - + Class generatedRemoteWrapper = null; try { - generatedRemoteWrapper = + generatedRemoteWrapper = appClassLoader.loadClass(wrapperClassName); } catch(Exception e) { } - - if( (generatedRemoteIntf != null) && + + if( (generatedRemoteIntf != null) && (generatedRemoteWrapper != null) ) { return; } @@ -505,7 +505,7 @@ public static Class loadGeneratedSerializableClass(ClassLoader loader, String cl try { if( generatedRemoteIntf == null ) { - + RemoteGenerator gen = new RemoteGenerator(appClassLoader, businessInterfaceName); @@ -515,11 +515,11 @@ public static Class loadGeneratedSerializableClass(ClassLoader loader, String cl } if( generatedRemoteWrapper == null ) { - + Remote30WrapperGenerator gen = new Remote30WrapperGenerator - (appClassLoader, businessInterfaceName, + (appClassLoader, businessInterfaceName, generatedRemoteIntfName); - + Class developerClass = appClassLoader.loadClass(businessInterfaceName); generateAndLoad(gen, wrapperClassName, appClassLoader, developerClass); } @@ -542,11 +542,11 @@ public static Class loadGeneratedSerializableClass(ClassLoader loader, String cl generatedGenericEJBHomeClass = appClassLoader.loadClass(className); } catch(Exception e) { } - + if( generatedGenericEJBHomeClass == null ) { - + GenericHomeGenerator gen =new GenericHomeGenerator(appClassLoader); - + generatedGenericEJBHomeClass =generateAndLoad(gen, className, appClassLoader, EJBUtils.class); @@ -564,7 +564,7 @@ public static Class generateSEI(ClassGeneratorFactory cgf, } - + private static Class generateAndLoad(ClassGeneratorFactory cgf, final String actualClassName, final ClassLoader loader, @@ -592,7 +592,7 @@ private static Class generateAndLoad(ClassGeneratorFactory cgf, } } - + Class result = null; try { if(System.getSecurityManager() == null) { @@ -619,54 +619,51 @@ public java.lang.Object run() { throw runEx; } } - + return result; } public static RemoteBusinessWrapperBase createRemoteBusinessObject - (String businessInterface, java.rmi.Remote delegate) + (String businessInterface, java.rmi.Remote delegate) throws Exception { - ClassLoader appClassLoader = + ClassLoader appClassLoader = getBusinessIntfClassLoader(businessInterface); - + return createRemoteBusinessObject(appClassLoader, businessInterface, delegate); } - public static RemoteBusinessWrapperBase createRemoteBusinessObject - (ClassLoader loader, String businessInterface, - java.rmi.Remote delegate) - - throws Exception { + public static RemoteBusinessWrapperBase createRemoteBusinessObject( + ClassLoader loader, String businessInterface, java.rmi.Remote delegate + ) throws Exception { String wrapperClassName = EJBUtils.getGeneratedRemoteWrapperName (businessInterface); Class clientWrapperClass = loader.loadClass(wrapperClassName); - Constructor ctors[] = clientWrapperClass.getConstructors(); - Constructor ctor = null; - for(Constructor next : ctors) { + for(Constructor next : clientWrapperClass.getConstructors()) { if (next.getParameterTypes().length > 0 ) { ctor = next; break; } } - - Object obj = ctor.newInstance(new Object[] - { delegate, businessInterface } ); - return (RemoteBusinessWrapperBase) obj; + if (ctor == null) { + throw new IllegalStateException("Missing ctor with parameters in " + clientWrapperClass); + } + + return (RemoteBusinessWrapperBase) ctor.newInstance(delegate, businessInterface); } private static ClassLoader getBusinessIntfClassLoader (String businessInterface) throws Exception { - + ClassLoader contextLoader = null; if(System.getSecurityManager() == null) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -684,13 +681,13 @@ public java.lang.Object run() { Thread.currentThread().getContextClassLoader(); return (cl != null) ? cl : ClassLoader.getSystemClassLoader(); - + }}); } - final Class businessInterfaceClass = + final Class businessInterfaceClass = contextLoader.loadClass(businessInterface); - + ClassLoader appClassLoader = null; if(System.getSecurityManager() == null) { appClassLoader = businessInterfaceClass.getClassLoader(); @@ -700,7 +697,7 @@ public java.lang.Object run() { (new java.security.PrivilegedAction() { public java.lang.Object run() { return businessInterfaceClass.getClassLoader(); - + }}); } @@ -709,7 +706,7 @@ public java.lang.Object run() { public static void serializeObjectFields( Object instance, - ObjectOutputStream oos) + ObjectOutputStream oos) throws IOException { serializeObjectFields(instance, oos, true); @@ -718,7 +715,7 @@ public static void serializeObjectFields( public static void serializeObjectFields( Object instance, ObjectOutputStream oos, - boolean usesSuperClass) + boolean usesSuperClass) throws IOException { Class clazz = (usesSuperClass)? instance.getClass().getSuperclass() : instance.getClass(); @@ -754,9 +751,9 @@ public java.lang.Object run() throws Exception { objOutStream.writeObject(value); } catch(Throwable t) { if( _logger.isLoggable(Level.FINE) ) { - _logger.log(Level.FINE, "=====> failed serializing field: " + nextField + - " =====> of class: " + clazz + " =====> using: " + oos.getClass() + - " =====> serializing value of type: " + ((value == null)? null : value.getClass().getName()) + + _logger.log(Level.FINE, "=====> failed serializing field: " + nextField + + " =====> of class: " + clazz + " =====> using: " + oos.getClass() + + " =====> serializing value of type: " + ((value == null)? null : value.getClass().getName()) + " ===> Error: " + t); _logger.log(Level.FINE, "", t); } @@ -771,7 +768,7 @@ public java.lang.Object run() throws Exception { public static void deserializeObjectFields( Object instance, - ObjectInputStream ois) + ObjectInputStream ois) throws IOException { deserializeObjectFields(instance, ois, null, true); @@ -782,7 +779,7 @@ public static void deserializeObjectFields( Object instance, ObjectInputStream ois, Object replaceValue, - boolean usesSuperClass) + boolean usesSuperClass) throws IOException { Class clazz = (usesSuperClass)? instance.getClass().getSuperclass() : instance.getClass(); @@ -815,7 +812,7 @@ public static void deserializeObjectFields( } final Object newValue = value; final Object theInstance = instance; - + if(System.getSecurityManager() == null) { if( !nextField.isAccessible() ) { nextField.setAccessible(true); @@ -852,7 +849,7 @@ private static Collection getSerializationFields(Class clazz) { for(Field next : fields) { int modifiers = next.getModifiers(); - if( Modifier.isStatic(modifiers) || + if( Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers) ) { continue; } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/base/io/EJBObjectOutputStreamHandler.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/base/io/EJBObjectOutputStreamHandler.java index 3a1eeb6274a..ac6bdb14b03 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/base/io/EJBObjectOutputStreamHandler.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/base/io/EJBObjectOutputStreamHandler.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates] package com.sun.ejb.base.io; @@ -55,6 +55,7 @@ import javax.naming.NamingException; import java.io.IOException; import java.io.Serializable; +import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; @@ -97,19 +98,22 @@ public static final void setJavaEEIOUtils(JavaEEIOUtils javaEEIOUtils) { public Object replaceObject(Object obj) throws IOException { Object result = obj; - - // Until we've identified a remote object, we can't assume the orb is - // available in the container. If the orb is not present, this will be null. - ProtocolManager protocolMgr = getProtocolManager(); - if (obj instanceof RemoteBusinessWrapperBase) { result = getRemoteBusinessObjectFactory ((RemoteBusinessWrapperBase) obj); - } else if ((protocolMgr != null) && protocolMgr.isStub(obj) && protocolMgr.isLocal(obj)) { - org.omg.CORBA.Object target = (org.omg.CORBA.Object) obj; - // If we're here, it's always for the 2.x RemoteHome view. - // There is no remote business wrapper class. - result = getSerializableEJBReference(target, protocolMgr, null); + } else { + // Until we've identified a remote object, we can't assume the orb is + // available in the container. If the orb is not present, this will be null. + Optional protocolManager = getProtocolManager(); + if (protocolManager.isPresent() && + protocolManager.get().isStub(obj) && + protocolManager.get().isLocal(obj)) + { + org.omg.CORBA.Object target = (org.omg.CORBA.Object) obj; + // If we're here, it's always for the 2.x RemoteHome view. + // There is no remote business wrapper class. + result = getSerializableEJBReference(target, protocolManager.get(), null); + } } return result; @@ -121,9 +125,9 @@ public Object replaceObject(Object obj) * initialized so that code doesn't make the assumption that an orb is available in * this runtime. */ - private ProtocolManager getProtocolManager() { - GlassFishORBHelper orbHelper = Globals.getDefaultHabitat().getService(GlassFishORBHelper.class); - return orbHelper.isORBInitialized() ? orbHelper.getProtocolManager() : null; + private Optional getProtocolManager() { + GlassFishORBHelper orbHelper = Globals.getDefaultHabitat().getService(GlassFishORBHelper.class); + return orbHelper.isORBInitialized() ? Optional.of(orbHelper.getProtocolManager()) : Optional.empty(); } private Serializable getRemoteBusinessObjectFactory @@ -133,9 +137,11 @@ private ProtocolManager getProtocolManager() { // the name of the client wrapper class. org.omg.CORBA.Object target = (org.omg.CORBA.Object) remoteBusinessWrapper.getStub(); - return getSerializableEJBReference(target, - getProtocolManager(), - remoteBusinessWrapper.getBusinessInterfaceName()); + return getSerializableEJBReference( + target, + getProtocolManager().orElse(null), + remoteBusinessWrapper.getBusinessInterfaceName() + ); } private Serializable getSerializableEJBReference(org.omg.CORBA.Object obj, @@ -144,44 +150,42 @@ private Serializable getSerializableEJBReference(org.omg.CORBA.Object obj, throws IOException { Serializable result = (Serializable) obj; - try { - - - byte[] oid = protocolMgr.getObjectID(obj); - - - if ((oid != null) && (oid.length > INSTANCEKEY_OFFSET)) { - long containerId = Utility.bytesToLong(oid, EJBID_OFFSET); - //To be really sure that is indeed a ref generated - // by our container we do the following checks - int keyLength = Utility.bytesToInt(oid, INSTANCEKEYLEN_OFFSET); - if (oid.length == keyLength + INSTANCEKEY_OFFSET) { - boolean isHomeReference = - ((keyLength == 1) && (oid[INSTANCEKEY_OFFSET] == HOME_KEY)); - if (isHomeReference) { - result = new SerializableS1ASEJBHomeReference(containerId); - } else { - SerializableS1ASEJBObjectReference serRef = - new SerializableS1ASEJBObjectReference(containerId, - oid, keyLength, remoteBusinessInterface); - result = serRef; - /* TODO - if (serRef.isHAEnabled()) { - SimpleKeyGenerator gen = new SimpleKeyGenerator(); - Object key = gen.byteArrayToKey(oid, INSTANCEKEY_OFFSET, 20); - long version = SFSBClientVersionManager.getClientVersion( - containerId, key); - serRef.setSFSBClientVersion(key, version); - } */ + if (protocolMgr != null) { + try { + byte[] oid = protocolMgr.getObjectID(obj); + if ((oid != null) && (oid.length > INSTANCEKEY_OFFSET)) { + long containerId = Utility.bytesToLong(oid, EJBID_OFFSET); + //To be really sure that is indeed a ref generated + // by our container we do the following checks + int keyLength = Utility.bytesToInt(oid, INSTANCEKEYLEN_OFFSET); + if (oid.length == keyLength + INSTANCEKEY_OFFSET) { + boolean isHomeReference = + ((keyLength == 1) && (oid[INSTANCEKEY_OFFSET] == HOME_KEY)); + if (isHomeReference) { + result = new SerializableS1ASEJBHomeReference(containerId); + } else { + SerializableS1ASEJBObjectReference serRef = + new SerializableS1ASEJBObjectReference(containerId, + oid, keyLength, remoteBusinessInterface); + result = serRef; + /* TODO + if (serRef.isHAEnabled()) { + SimpleKeyGenerator gen = new SimpleKeyGenerator(); + Object key = gen.byteArrayToKey(oid, INSTANCEKEY_OFFSET, 20); + long version = SFSBClientVersionManager.getClientVersion( + containerId, key); + serRef.setSFSBClientVersion(key, version); + } */ + } } } + } catch (Exception ex) { + _ejbLogger.log(Level.WARNING, "Exception while getting serializable object", ex); + IOException ioEx = new IOException("Exception during extraction of instance key"); + ioEx.initCause(ex); + throw ioEx; } - } catch (Exception ex) { - _ejbLogger.log(Level.WARNING, "Exception while getting serializable object", ex); - IOException ioEx = new IOException("Exception during extraction of instance key"); - ioEx.initCause(ex); - throw ioEx; - } + } return result; } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java index 803e92b898a..62756243167 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java @@ -165,7 +165,7 @@ * */ public abstract class BaseContainer implements Container, EjbContainerFacade, JavaEEContainer { - + public enum ContainerType { STATELESS, STATEFUL, SINGLETON, MESSAGE_DRIVEN, ENTITY, READ_ONLY }; @@ -225,7 +225,7 @@ public enum ContainerType { cause = "Fail to create MonitorRegistryMediator", action = "Check the exception stack") private static final String COULD_NOT_CREATE_MONITORREGISTRYMEDIATOR = "AS-EJB-00062"; - + @LogMessageInfo( message = "Internal Error", level = "WARNING", @@ -233,9 +233,9 @@ public enum ContainerType { action = "Trying to invoke the ejb application" ) private static final String INTERNAL_ERROR = "AS-EJB-00052"; - + protected static final Class[] NO_PARAMS = new Class[] {}; - + protected Object[] logParams = null; protected ContainerType containerType; @@ -267,9 +267,9 @@ public enum ContainerType { private static final boolean[] EJB_INTF_METHODS_INFO = { true, true, true, true, true, false, false, false, false, false, - false, false, false, false, - true, true }; - + false, false, false, false, + true, true }; + private static final byte HOME_KEY = (byte)0xff; private static final byte[] homeInstanceKey = {HOME_KEY}; @@ -284,17 +284,17 @@ public enum ContainerType { private Method ejbTimeoutMethod = null; protected Class webServiceEndpointIntf = null; - + // true if exposed as a web service endpoint. protected boolean isWebServiceEndpoint = false; - + private boolean isTimedObject_ = false; /***************************************** * Data members for Local views * *****************************************/ - // True if bean has a LocalHome/Local view + // True if bean has a LocalHome/Local view // OR a Local business view OR both. protected boolean isLocal=false; @@ -330,7 +330,7 @@ public enum ContainerType { // // Data members for 3.x Local business view // - + // Internal interface describing operation used to create an // instance of a local business object. (GenericEJBLocalHome) protected Class localBusinessHomeIntf = null; @@ -364,10 +364,10 @@ public enum ContainerType { * Data members for Remote views * *****************************************/ - // True if bean has a RemoteHome/Remote view + // True if bean has a RemoteHome/Remote view // OR a Remote business view OR both. protected boolean isRemote=false; - + // True if bean exposes a RemoteHome view protected boolean hasRemoteHomeView=false; @@ -380,7 +380,7 @@ public enum ContainerType { // Home interface written by developer. protected Class homeIntf = null; - + // Remote interface written by developer. protected Class remoteIntf = null; @@ -388,7 +388,7 @@ public enum ContainerType { // object as ejbHome, for example in the case of dynamic proxies. protected EJBHomeImpl ejbHomeImpl; - // EJB Home reference used by ORB Tie within server to deliver + // EJB Home reference used by ORB Tie within server to deliver // invocation. protected EJBHome ejbHome; @@ -409,15 +409,15 @@ public enum ContainerType { // // Internal interface describing operation used to create an - // instance of a remote business object. + // instance of a remote business object. protected Class remoteBusinessHomeIntf = null; // Container implementation of internal EJB Business Home. May or may - // not be same object as ejbRemoteBusinessHome, for example in the + // not be same object as ejbRemoteBusinessHome, for example in the // case of dynamic proxies. protected EJBHomeImpl ejbRemoteBusinessHomeImpl; - // EJB Remote Business Home reference used by ORB Tie within server + // EJB Remote Business Home reference used by ORB Tie within server // to deliver invocation. protected EJBHome ejbRemoteBusinessHome; @@ -434,13 +434,13 @@ public enum ContainerType { = new HashMap(); // - // END -- Data members for Remote views - // + // END -- Data members for Remote views + // protected EJBMetaData metadata = null; protected final SecurityManager securityManager; - + protected boolean isSession; protected boolean isStatelessSession; protected boolean isStatefulSession; @@ -449,10 +449,10 @@ public enum ContainerType { protected EjbDescriptor ejbDescriptor; protected String componentId; // unique id for java:comp namespace lookup - + protected Map invocationInfoMap = new HashMap(); - - protected Map scheduleIds = + + protected Map scheduleIds = new HashMap(); Map> schedules = @@ -472,13 +472,13 @@ public enum ContainerType { protected Properties envProps; protected boolean isBeanManagedTran=false; - - + + protected boolean debugMonitorFlag = false; - - private static LocalStringManagerImpl localStrings = + + private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(BaseContainer.class); - + private ThreadLocal threadLocalContext = new ThreadLocal(); protected static final int CONTAINER_INITIALIZING = -1; @@ -486,9 +486,9 @@ public enum ContainerType { protected static final int CONTAINER_STOPPED = 1; protected static final int CONTAINER_UNDEPLOYED = 3; protected static final int CONTAINER_ON_HOLD = 4; - + protected volatile int containerState = CONTAINER_INITIALIZING; - + protected HashMap methodMonitorMap; protected boolean monitorOn = false; @@ -503,11 +503,11 @@ public enum ContainerType { protected EjbThreadPoolExecutorStatsProvider executorProbeListener; protected ContainerInfo containerInfo; - + private String _debugDescription; //protected Agent callFlowAgent; - + protected CallFlowInfo callFlowInfo; protected InterceptorManager interceptorManager; @@ -516,11 +516,11 @@ public enum ContainerType { // the order must be the same as CallbackType and getPre30LifecycleMethodNames private static final Class[] lifecycleCallbackAnnotationClasses = { - AroundConstruct.class, - PostConstruct.class, PreDestroy.class, + AroundConstruct.class, + PostConstruct.class, PreDestroy.class, PrePassivate.class, PostActivate.class }; - + private Set monitoredGeneratedClasses = new HashSet(); protected InvocationManager invocationManager; @@ -568,7 +568,7 @@ public enum ContainerType { protected EJBContainerStateManager containerStateManager; protected EJBContainerTransactionManager containerTransactionManager; - + protected JCDIService jcdiService; /** @@ -581,7 +581,7 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l this.containerType = type; this.securityManager = sm; this.requestTracing = Globals.getDefaultHabitat().getService(RequestTracingService.class); - + try { this.loader = loader; this.ejbDescriptor = ejbDesc; @@ -593,10 +593,10 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l injectionManager = ejbContainerUtilImpl.getInjectionManager(); namingManager = ejbContainerUtilImpl.getGlassfishNamingManager(); transactionManager = ejbContainerUtilImpl.getTransactionManager(); - + // get Class objects for creating new EJBs ejbClass = loader.loadClass(ejbDescriptor.getEjbImplClassName()); - + containerStateManager = new EJBContainerStateManager(this); containerTransactionManager = new EJBContainerTransactionManager(this, ejbDesc); @@ -606,22 +606,22 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l { isSession = true; EjbSessionDescriptor sd = (EjbSessionDescriptor) ejbDescriptor; - + if ( !sd.isSessionTypeSet() ) { throw new RuntimeException(localStrings.getLocalString( - "ejb.session_type_not_set", + "ejb.session_type_not_set", "Invalid ejb Descriptor. Session type not set for {0}: {1}", sd.getName(), sd)); } - + if (sd.isSingleton()) { isSingleton = true; } else { isStatelessSession = sd.isStateless(); isStatefulSession = !isStatelessSession; - + if ( isStatefulSession ) { - + /** * If bean class isn't explicitly marked Serializable, generate * a subclass that is. We do this with a generator that uses @@ -664,9 +664,9 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l remoteHomeRefFactory = getProtocolManager().getRemoteReferenceFactory(this, true, id); } - + if ( ejbDescriptor.isRemoteBusinessInterfacesSupported() ) { - + isRemote = true; hasRemoteBusinessView = true; @@ -675,13 +675,13 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l for(String next : ejbDescriptor.getRemoteBusinessClassNames()) { // The generated remote business interface and the - // client wrapper for the business interface are - // produced dynamically. The following call must be - // made before any EJB 3.0 Remote business interface + // client wrapper for the business interface are + // produced dynamically. The following call must be + // made before any EJB 3.0 Remote business interface // runtime behavior is needed for a particular // classloader. EJBUtils.loadGeneratedRemoteBusinessClasses(loader, next); - + String nextGen = EJBUtils.getGeneratedRemoteIntfName(next); Class genRemoteIntf = loader.loadClass(nextGen); @@ -690,18 +690,18 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l info.generatedRemoteIntf = genRemoteIntf; info.remoteBusinessIntf = loader.loadClass(next); - // One remote reference factory for each remote + // One remote reference factory for each remote // business interface. Id must be unique across // all ejb containers. - String id = Long.toString(ejbDescriptor.getUniqueId()) + String id = Long.toString(ejbDescriptor.getUniqueId()) + "_RBusiness" + "_" + genRemoteIntf.getName(); info.referenceFactory = getProtocolManager(). getRemoteReferenceFactory(this, false, id); remoteBusinessIntfInfo.put(genRemoteIntf.getName(), info); - - addToGeneratedMonitoredMethodInfo(nextGen, genRemoteIntf); + + addToGeneratedMonitoredMethodInfo(nextGen, genRemoteIntf); } } @@ -774,7 +774,7 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l warnIfNotFullProfile("use of persistent EJB Timer Service"); - MethodDescriptor ejbTimeoutMethodDesc = + MethodDescriptor ejbTimeoutMethodDesc = ejbDescriptor.getEjbTimeoutMethod(); // Can be a @Timeout or @Schedule or TimedObject if (ejbTimeoutMethodDesc != null) { @@ -790,7 +790,7 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l if (method == null) { // This should've been caught in EjbBundleValidator throw new EJBException(localStrings.getLocalString( - "ejb.no_timeout_method", + "ejb.no_timeout_method", "Class {0} does not define timeout method {1}", ejbClass.getName(), schd.getTimeoutMethod().getFormattedString())); } @@ -807,11 +807,11 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l } list.add(schd); } - + } preInitialize(ejbDesc, loader); - + initializeEjbInterfaceMethods(); if ( needSystemInterceptorProxy() ) { @@ -819,14 +819,14 @@ protected BaseContainer(ContainerType type, EjbDescriptor ejbDesc, ClassLoader l } // NOTE : InterceptorManager initialization delayed until transition to START state. - + addLocalRemoteInvocationInfo(); addWSOrTimedObjectInvocationInfo(); initializeInvocationInfo(); setupEnvironment(); - + ServiceLocator services = ejbContainerUtilImpl.getServices(); jcdiService = services.getService(JCDIService.class); @@ -868,7 +868,7 @@ public void initialize() { protected ProtocolManager getProtocolManager() { return protocolMgr; } - + public ContainerType getContainerType() { return containerType; } @@ -885,7 +885,7 @@ private void addToGeneratedMonitoredMethodInfo(String qualifiedClassName, Class generatedClass) { monitoredGeneratedClasses.add(generatedClass); } - + protected void initializeProtocolManager() { try { @@ -895,15 +895,15 @@ protected void initializeProtocolManager() { } catch(Throwable t) { throw new RuntimeException("IIOP Protocol Manager initialization failed. " + - "Possible cause is that ORB is not available in this " + - ((ejbContainerUtilImpl.isEmbeddedServer())? - "embedded container, or server instance is running and required ports are in use" : + "Possible cause is that ORB is not available in this " + + ((ejbContainerUtilImpl.isEmbeddedServer())? + "embedded container, or server instance is running and required ports are in use" : "container") , t ); } } - + protected void preInitialize(EjbDescriptor ejbDesc, ClassLoader loader) { //Overridden in sub classes } @@ -918,7 +918,7 @@ public void checkUserTransactionLookup(ComponentInvocation inv) } protected final void createCallFlowAgent(ComponentType compType) { - + this.callFlowInfo = new CallFlowInfoImpl( this, ejbDescriptor, compType); } @@ -974,7 +974,7 @@ private void setInterceptorChain(InvocationInfo info) { } } } - + public final void setStoppedState() { containerState = CONTAINER_STOPPED; } @@ -994,19 +994,19 @@ public final boolean isUndeployed() { public final boolean isTimedObject() { return isTimedObject_; } - + public final boolean isLocalObject() { return isLocal; } - + public final boolean isRemoteObject() { return isRemote; } - + public final ClassLoader getContainerClassLoader() { return loader; } - + public final ClassLoader getClassLoader() { return loader; } @@ -1022,15 +1022,15 @@ public final boolean getPassByReference() { protected final long getContainerId() { return ejbDescriptor.getUniqueId(); } - + public final long getApplicationId() { return ejbDescriptor.getApplication().getUniqueId(); } - + public final EjbDescriptor getEjbDescriptor() { return ejbDescriptor; } - + /** * Method defined on JavaEEContainer */ @@ -1041,15 +1041,15 @@ public final Descriptor getDescriptor() { public final EJBMetaData getEJBMetaData() { return metadata; } - + public final UserTransaction getUserTransaction() { return containerTransactionManager.getUserTransaction(); } - + public boolean isHAEnabled() { return false; } - + /** * EJB spec makes a distinction between access to the UserTransaction * object itself and access to its methods. getUserTransaction covers @@ -1060,11 +1060,11 @@ public boolean userTransactionMethodsAllowed(ComponentInvocation inv) { // Overridden by containers that allowed BMT; return false; } - + public final EJBHome getEJBHomeStub() { return ejbHomeStub; } - + public final EJBHome getEJBHome() { return ejbHome; } @@ -1098,15 +1098,15 @@ boolean isLocalBeanClass(String className) { public final Class getEJBClass() { return ejbClass; } - + public final SecurityManager getSecurityManager() { return securityManager; } - + final Properties getEnvironmentProperties() { return envProps; } - + /** * Create an EJBObject reference from the instanceKey * Called from EJBObjectOutputStream.SerializableRemoteRef @@ -1118,7 +1118,7 @@ final Properties getEnvironmentProperties() { */ public java.rmi.Remote createRemoteReferenceWithId (byte[] instanceKey, String generatedRemoteBusinessIntf) { - + final Thread currentThread = Thread.currentThread(); final ClassLoader previousClassLoader = currentThread.getContextClassLoader(); @@ -1167,7 +1167,7 @@ public java.lang.Object run() { private void assertFullProfile(String description) { if ( ejbContainerUtilImpl.isEJBLite() ) { throw new RuntimeException(localStrings.getLocalString( - "ejb.assert_full_profile", + "ejb.assert_full_profile", "Invalid application. EJB {0} {1}. This feature is not part of the EJB 3.1 Lite API", ejbDescriptor.getName(), description)); } @@ -1210,7 +1210,7 @@ protected void initializeHome() loader, this.ejbClass); if (serviceEndpointIntfClass==null) { throw new RuntimeException(localStrings.getLocalString( - "ejb.error_generating_sei", + "ejb.error_generating_sei", "Error in generating service endpoint interface class for EJB class {0}", this.ejbClass)); } } @@ -1243,7 +1243,7 @@ protected void initializeHome() wsejbEndpointRegistry.registerEndpoint(webServiceEndpoint,endpointFacade,servant,tieClass); } else { throw new DeploymentException(localStrings.getLocalString( - "ejb.no_webservices_module", + "ejb.no_webservices_module", "EJB-based Webservice endpoint is detected but there is no webservices module installed to handle it")); } } @@ -1280,25 +1280,25 @@ protected void initializeHome() glassfishSpecificJndiName = null; } } - + if ( hasRemoteHomeView ) { this.ejbHomeImpl = instantiateEJBHomeImpl(); - this.ejbHome = ejbHomeImpl.getEJBHome(); + this.ejbHome = ejbHomeImpl.getEJBHome(); // Since some containers might create multiple EJBObjects for - // the same ejb, make sure we use the same Proxy class to - // instantiate all the proxy instances. - ejbObjectProxyClass = + // the same ejb, make sure we use the same Proxy class to + // instantiate all the proxy instances. + ejbObjectProxyClass = Proxy.getProxyClass(loader, new Class[] { remoteIntf }); ejbObjectProxyCtor = ejbObjectProxyClass. getConstructor(new Class[] { InvocationHandler.class }); // // Make sure all Home/Remote interfaces conform to RMI-IIOP - // rules. Checking for conformance here keeps the exposed - // deployment/startup error behavior consistent since when + // rules. Checking for conformance here keeps the exposed + // deployment/startup error behavior consistent since when // rmic is used during codegen it makes equivalent checks and - // treats any validation problems as fatal errors. + // treats any validation problems as fatal errors. // // These same checks will be made when setTarget is called // in POARemoteReferenceFactory.preinvoke, but that happens @@ -1321,7 +1321,7 @@ protected void initializeHome() // stubs and ties. This must be done before any Home or Remote // references are created. remoteHomeRefFactory.setRepositoryIds(homeIntf, remoteIntf); - + // get a remote ref for the EJBHome ejbHomeStub = (EJBHome) remoteHomeRefFactory.createHomeReference(homeInstanceKey); @@ -1339,30 +1339,30 @@ protected void initializeHome() } - + if ( hasRemoteBusinessView ) { - this.ejbRemoteBusinessHomeImpl = + this.ejbRemoteBusinessHomeImpl = instantiateEJBRemoteBusinessHomeImpl(); - this.ejbRemoteBusinessHome = + this.ejbRemoteBusinessHome = ejbRemoteBusinessHomeImpl.getEJBHome(); // RMI-IIOP validation getProtocolManager().validateTargetObjectInterfaces(this.ejbRemoteBusinessHome); - for(RemoteBusinessIntfInfo next : + for(RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) { - + next.proxyClass = Proxy.getProxyClass (loader, new Class[] { next.generatedRemoteIntf }); - + next.proxyCtor = next.proxyClass. getConstructor(new Class[] { InvocationHandler.class }); // Remotereference factory needs instances of - // Home and Remote to get repository Ids since it - // doesn't have stubs and ties. This must be done before + // Home and Remote to get repository Ids since it + // doesn't have stubs and ties. This must be done before // any Home or Remote references are created. next.referenceFactory.setRepositoryIds (remoteBusinessHomeIntf, next.generatedRemoteIntf); @@ -1419,7 +1419,7 @@ protected void initializeHome() java.rmi.Remote dummyEJBObject = dummyEJBObjectImpl. getEJBObject(next.generatedRemoteIntf.getName()); - + getProtocolManager().validateTargetObjectInterfaces(dummyEJBObject); if ( glassfishSpecificJndiName != null ) { @@ -1492,10 +1492,10 @@ protected void initializeHome() this.ejbLocalHome = ejbLocalHomeImpl.getEJBLocalHome(); // Since some containers might create multiple EJBLocalObjects - // for the same ejb, make sure we use the same Proxy class to - // instantiate all the proxy instances. - Class ejbLocalObjectProxyClass = - Proxy.getProxyClass(loader, + // for the same ejb, make sure we use the same Proxy class to + // instantiate all the proxy instances. + Class ejbLocalObjectProxyClass = + Proxy.getProxyClass(loader, new Class[] { IndirectlySerializable.class, localIntf }); ejbLocalObjectProxyCtor = ejbLocalObjectProxyClass. @@ -1568,7 +1568,7 @@ protected void initializeHome() intfsForPortableJndi.put(ejbClass.getName(), namingProxy); } - + } @@ -1614,8 +1614,8 @@ protected void initializeHome() } } catch(Exception e) { throw new RuntimeException(localStrings.getLocalString( - "ejb.error_binding_jndi_name", - "Error while binding JNDI name {0} for EJB {1}", + "ejb.error_binding_jndi_name", + "Error while binding JNDI name {0} for EJB {1}", jndiInfo.name, this.ejbDescriptor.getName()), e); } } @@ -1631,7 +1631,7 @@ protected void initializeHome() if ( !publishedInternalGlobalJndiNames.isEmpty() ) { _logger.log(Level.FINE, "Internal container JNDI names for EJB {0}: {1}", new Object[]{this.ejbDescriptor.getName(), publishedInternalGlobalJndiNames}); } - + // set EJBMetaData setEJBMetaData(); } @@ -1661,7 +1661,7 @@ protected String getJavaGlobalJndiNamePrefix() { javaGlobalPrefix.append(appName); javaGlobalPrefix.append("/"); } - + javaGlobalPrefix.append(modName); javaGlobalPrefix.append("/"); javaGlobalPrefix.append(ejbName); @@ -1836,19 +1836,19 @@ protected void cleanupInstance(EJBContextImpl context) { } } - + /** * Return the EJBObject/EJBHome Proxy for the given ejbId and instanceKey. * Called from the ProtocolManager when a remote invocation arrives. * @exception NoSuchObjectLocalException if the target object does not exist */ - public java.rmi.Remote getTargetObject(byte[] instanceKey, + public java.rmi.Remote getTargetObject(byte[] instanceKey, String generatedRemoteBusinessIntf) { - + externalPreInvoke(); boolean remoteHomeView = (generatedRemoteBusinessIntf == null); if ( instanceKey.length == 1 && instanceKey[0] == HOME_KEY ) { - return remoteHomeView ? + return remoteHomeView ? ejbHomeImpl.getEJBHome() : ejbRemoteBusinessHomeImpl.getEJBHome(); } else { @@ -1871,7 +1871,7 @@ public java.rmi.Remote getTargetObject(byte[] instanceKey, getEJBObject(generatedRemoteBusinessIntf); } } - + return targetObject; } } @@ -1906,11 +1906,11 @@ public java.lang.Object run() { ArrayDeque beanContextStack = (ArrayDeque) threadLocalContext.get(); - + if ( beanContextStack == null ) { beanContextStack = new ArrayDeque(); threadLocalContext.set(beanContextStack); - } + } beanContextStack.push(bc); } @@ -1918,7 +1918,7 @@ public void externalPostInvoke() { try { ArrayDeque beanContextStack = (ArrayDeque) threadLocalContext.get(); - + final BeanContext bc = (BeanContext) beanContextStack.pop(); if ( bc.classLoaderSwitched == true ) { if (System.getSecurityManager() == null) { @@ -1979,14 +1979,14 @@ public void preInvoke(EjbInvocation inv) { try { if (containerState != CONTAINER_STARTED) { throw new EJBException(localStrings.getLocalString( - "ejb.container_not_started", - "Attempt to invoke when container is in {0}", + "ejb.container_not_started", + "Attempt to invoke when container is in {0}", containerStateToString(containerState))); } - + if ( inv.method == null ) { throw new EJBException(localStrings.getLocalString( - "ejb.null_invocation_method", + "ejb.null_invocation_method", "Attempt to invoke container with null invocation method")); } @@ -1994,7 +1994,7 @@ public void preInvoke(EjbInvocation inv) { inv.invocationInfo = getInvocationInfo(inv); if ( inv.invocationInfo == null ) { throw new EJBException(localStrings.getLocalString( - "ejb.null_invocation_info", + "ejb.null_invocation_info", "EjbInvocation Info lookup failed for method {0}", inv.method)); } } @@ -2021,13 +2021,13 @@ public void preInvoke(EjbInvocation inv) { ComponentContext ctx = getContext(inv); inv.context = ctx; - + inv.instance = inv.ejb = ctx.getEJB(); InvocationInfo info = inv.invocationInfo; - + inv.useFastPath = (info.isTxRequiredLocalCMPField) && (inv.foundInTxCache); // _logger.log(Level.INFO, "Use fastPath() ==> " + info.method); - + if (!inv.useFastPath) { // Sets thread-specific state for Transaction, Naming, Security, // etc @@ -2042,19 +2042,19 @@ public void preInvoke(EjbInvocation inv) { enlistExtendedEntityManagers(ctx); } - + } catch ( Exception ex ) { _logger.log(Level.FINE, "Exception while running pre-invoke : ejbName = [{0}]", logParams); _logger.log(Level.FINE, "", ex); - + EJBException ejbEx; if ( ex instanceof EJBException ) { ejbEx = (EJBException)ex; } else { ejbEx = new EJBException(ex); } - + throw new PreInvokeException(ejbEx); } } @@ -2064,15 +2064,15 @@ public boolean intercept(CallbackType eventType, EJBContextImpl ctx) return interceptorManager.intercept(eventType, ctx); } - + protected void enlistExtendedEntityManagers(ComponentContext ctx) { // Do nothing in general case } - + protected void delistExtendedEntityManagers(ComponentContext ctx) { // Do nothing in general case } - + /** * Containers that allow extended EntityManager will override this method. */ @@ -2098,8 +2098,8 @@ public void postInvoke(EjbInvocation inv) { protected void postInvoke(EjbInvocation inv, boolean doTxProcessing) { if (containerState != CONTAINER_STARTED) { throw new EJBException(localStrings.getLocalString( - "ejb.container_not_started", - "Attempt to invoke when container is in {0}", + "ejb.container_not_started", + "Attempt to invoke when container is in {0}", containerStateToString(containerState))); } @@ -2119,7 +2119,7 @@ protected void postInvoke(EjbInvocation inv, boolean doTxProcessing) { } else { doTxProcessing = doTxProcessing && (inv.exception != null); } - + try { if ( doTxProcessing ) { postInvokeTx(inv); @@ -2135,7 +2135,7 @@ protected void postInvoke(EjbInvocation inv, boolean doTxProcessing) { } if ( inv.exception != null ) { - + // Unwrap the PreInvokeException if necessary if ( inv.exception instanceof PreInvokeException ) { inv.exception = ((PreInvokeException)inv.exception).exception; @@ -2151,7 +2151,7 @@ protected void postInvoke(EjbInvocation inv, boolean doTxProcessing) { _logger.log(Level.FINE, "An application exception occurred during an invocation on EJB {0}, method: {1}", new Object[]{ejbDescriptor.getName(), inv.beanMethod}); _logger.log(Level.FINE, "", inv.exception); } - + if ( inv.isRemote ) { if ( protocolMgr != null ) { @@ -2161,16 +2161,16 @@ protected void postInvoke(EjbInvocation inv, boolean doTxProcessing) { // (ParallelAccessEXCeption etc. that used to be handled by iiop glue code inv.exception = mapRemoteException(inv); } - - // The most useful portion of the system exception is logged - // above. Only log mapped form when log level is FINE or + + // The most useful portion of the system exception is logged + // above. Only log mapped form when log level is FINE or // higher. _logger.log(Level.FINE, "", inv.exception); } else { if ( inv.isBusinessInterface ) { - inv.exception = + inv.exception = mapLocal3xException(inv.exception); } @@ -2215,7 +2215,7 @@ protected void authorizeLocalMethod(int method) { "Client not authorized for this invocation")); } } - + /** * Check if caller is authorized to invoke the method. * Only called for EJBObject and EJBHome methods, @@ -2247,7 +2247,7 @@ else if ( t instanceof RemoteException ) } /** - * Call back from the timer migration process to add + * Call back from the timer migration process to add * automatic timers to the map of scheduleIds */ void addSchedule(TimerPrimaryKey timerId, EJBTimerSchedule ts) { @@ -2272,7 +2272,7 @@ private void processEjbTimeoutMethod(Method method) throws Exception { if ( (params.length == 0 || (params.length == 1 && params[0] == javax.ejb.Timer.class)) && (method.getReturnType() == Void.TYPE) ) { - + isTimedObject_ = true; final Method ejbTimeoutAccessible = method; @@ -2309,7 +2309,7 @@ public java.lang.Object run() throws Exception { private InvocationInfo getInvocationInfo(EjbInvocation inv) { return inv.isWebService ? (InvocationInfo) webServiceInvocationInfoMap.get(inv.method) : - (InvocationInfo) invocationInfoMap.get(inv.method); + (InvocationInfo) invocationInfoMap.get(inv.method); } private Throwable mapRemoteException(EjbInvocation inv) { @@ -2340,7 +2340,7 @@ private Throwable mapRemoteException(EjbInvocation inv) { } else { mappedException = mapLocal3xException(originalException); - + } } else { @@ -2367,10 +2367,10 @@ private Throwable mapRemoteException(EjbInvocation inv) { if ( originalException instanceof EJBException ) { mappedException = new RemoteException (originalException.getMessage(), originalException); - } + } } } - + } if ( _logger.isLoggable(Level.FINE)) { @@ -2401,7 +2401,7 @@ private Throwable mapLocal3xException(Throwable t) { mappedException = new EJBAccessException(); mappedException.initCause(t); } - + return (mappedException != null) ? mappedException : t; } @@ -2411,7 +2411,7 @@ private Throwable mapLocal3xException(Throwable t) { */ public boolean authorize(EjbInvocation inv) { - // There are a few paths (e.g. authorizeLocalMethod, + // There are a few paths (e.g. authorizeLocalMethod, // authorizeRemoteMethod, Ejb endpoint pre-handler ) // for which invocationInfo is not set. We get better // performance with the security manager on subsequent @@ -2419,30 +2419,30 @@ public boolean authorize(EjbInvocation inv) { // set on the invocation. However, the authorization // does not depend on it being set. So, try to set // invocationInfo but in this case don't treat it as - // an error if it's not available. + // an error if it's not available. if ( inv.invocationInfo == null ) { - + inv.invocationInfo = getInvocationInfo(inv); - + } - // Internal methods for 3.0 bean creation so there won't - // be corresponding permissions in the security policy file. + // Internal methods for 3.0 bean creation so there won't + // be corresponding permissions in the security policy file. if ( (inv.method.getDeclaringClass() == localBusinessHomeIntf) || (inv.method.getDeclaringClass() == remoteBusinessHomeIntf) ) { return true; } - + boolean authorized = securityManager.authorize(inv); - + if ( !authorized ) { if ( inv.context != null ) { // This means that an enterprise bean context was created // during the authorization call because of a callback from - // a JACC enterprise bean handler. Since the invocation will - // not proceed due to the authorization failure, we need + // a JACC enterprise bean handler. Since the invocation will + // not proceed due to the authorization failure, we need // to release the enterprise bean context. releaseContext(inv); } @@ -2459,7 +2459,7 @@ private void initializeEjbInterfaceMethods() throws Exception { ejbIntfMethods = new Method[EJB_INTF_METHODS_LENGTH]; - + if ( isRemote ) { ejbIntfMethods[ EJBHome_remove_Handle ] = EJBHome.class.getMethod("remove", @@ -2471,7 +2471,7 @@ private void initializeEjbInterfaceMethods() EJBHome.class.getMethod("getEJBMetaData", NO_PARAMS); ejbIntfMethods[ EJBHome_getHomeHandle ] = EJBHome.class.getMethod("getHomeHandle", NO_PARAMS); - + ejbIntfMethods[ EJBObject_getEJBHome ] = EJBObject.class.getMethod("getEJBHome", NO_PARAMS); ejbIntfMethods[ EJBObject_getPrimaryKey ] = @@ -2483,7 +2483,7 @@ private void initializeEjbInterfaceMethods() ejbIntfMethods[ EJBObject_isIdentical ] = EJBObject.class.getMethod("isIdentical", new Class[]{javax.ejb.EJBObject.class}); - + if ( isStatelessSession ) { if ( hasRemoteHomeView ) { ejbIntfMethods[ EJBHome_create ] = @@ -2491,12 +2491,12 @@ private void initializeEjbInterfaceMethods() } } } - + if ( isLocal ) { ejbIntfMethods[ EJBLocalHome_remove_Pkey ] = EJBLocalHome.class.getMethod("remove", new Class[]{java.lang.Object.class}); - + ejbIntfMethods[ EJBLocalObject_getEJBLocalHome ] = EJBLocalObject.class.getMethod("getEJBLocalHome", NO_PARAMS); ejbIntfMethods[ EJBLocalObject_getPrimaryKey ] = @@ -2506,7 +2506,7 @@ private void initializeEjbInterfaceMethods() ejbIntfMethods[ EJBLocalObject_isIdentical ] = EJBLocalObject.class.getMethod("isIdentical", new Class[]{javax.ejb.EJBLocalObject.class}); - + if ( isStatelessSession ) { if ( hasLocalHomeView ) { Method m = localHomeIntf.getMethod("create", NO_PARAMS); @@ -2514,9 +2514,9 @@ private void initializeEjbInterfaceMethods() } } } - + } - + protected void cancelTimers(Object key) { if ( isTimedObject() ) { // EJBTimerService should be accessed only if needed @@ -2546,13 +2546,13 @@ protected abstract EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException; // Only applies to concrete session containers - EJBObjectImpl createRemoteBusinessObjectImpl() throws CreateException, + EJBObjectImpl createRemoteBusinessObjectImpl() throws CreateException, RemoteException { throw new EJBException( "Internal ERROR: BaseContainer.createRemoteBusinessObject called"); } - + // internal API, implemented in subclasses protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException @@ -2583,7 +2583,7 @@ EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(String clientIntf) * Implemented in subclasses. */ protected abstract EJBObjectImpl getEJBObjectImpl(byte[] streamKey); - + EJBObjectImpl getEJBRemoteBusinessObjectImpl(byte[] streamKey) { throw new EJBException(localStrings.getLocalString( "ejb.basecontainer_internal_error", @@ -2629,11 +2629,11 @@ protected final ComponentContext getContext(EjbInvocation inv) return (inv.context == null) ? _getContext(inv) : inv.context; } - + protected final Object getInvocationKey(EjbInvocation inv) { return (inv.ejbObject == null) ? null : inv.ejbObject.getKey(); } - + // internal API, implemented in subclasses protected abstract ComponentContext _getContext(EjbInvocation inv) throws EJBException; @@ -2641,31 +2641,31 @@ protected abstract ComponentContext _getContext(EjbInvocation inv) // internal API, implemented in subclasses protected abstract void releaseContext(EjbInvocation inv) throws EJBException; - + protected abstract boolean passivateEJB(ComponentContext context); - + // internal API, implemented in subclasses protected abstract void forceDestroyBean(EJBContextImpl sc) throws EJBException; - + protected abstract void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws RemoveException, EJBException, RemoteException; - + // default implementation protected void authorizeLocalGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws EJBException { throw new EJBException(localStrings.getLocalString( "containers.invalid_operation", "Invalid operation for Session EJBs.")); } - + // default implementation protected void authorizeRemoteGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws RemoteException { throw new RemoteException(localStrings.getLocalString( "containers.invalid_operation", "Invalid operation for Session EJBs.")); } - + // default implementation protected Object invokeFindByPrimaryKey(Method method, EjbInvocation inv, Object[] args) throws Throwable { @@ -2691,13 +2691,13 @@ public EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey, EJBContext ctx assertSupportedOption("getEJBLocalObjectForPrimaryKey(pkey, ctx)"); return null; } - + // default implementation public EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey) { assertSupportedOption("getEJBLocalObjectForPrimaryKey"); return null; } - + // default implementation public EJBObject getEJBObjectForPrimaryKey(Object pkey) { assertSupportedOption("getEJBObjectForPrimaryKey"); @@ -2708,7 +2708,7 @@ private void assertSupportedOption(String name) { throw new EJBException(localStrings.getLocalString( "ejb.entity_container_only", "{0} only works for EntityContainer", name)); } - + // internal API, implemented in subclasses protected boolean isIdentical(EJBObjectImpl ejbo, EJBObject other) throws RemoteException @@ -2731,7 +2731,7 @@ public Object getJaccEjb(EjbInvocation inv) { // Remote , Local, and ServiceEndpoint interfaces. if ( ( (inv.invocationInfo != null) && inv.invocationInfo.isBusinessMethod ) - || + || inv.isWebService ) { // In the typical case the context will not have been @@ -2745,17 +2745,17 @@ public Object getJaccEjb(EjbInvocation inv) { inv.context = getContext(inv); bean = inv.context.getEJB(); // NOTE : inv.ejb is not set here. Post-invoke logic for - // BaseContainer and webservices uses the fact that + // BaseContainer and webservices uses the fact that // inv.ejb is non-null as an indication that that - // BaseContainer.preInvoke() proceeded past a certain - // point, which affects which cleanup needs to be - // performed. It would be better to have explicit - // state in the invocation that says which cleanup + // BaseContainer.preInvoke() proceeded past a certain + // point, which affects which cleanup needs to be + // performed. It would be better to have explicit + // state in the invocation that says which cleanup // steps are necessary(e.g. for invocationMgr.postInvoke - // , postInvokeTx, etc) but I'm keeping the logic the - // same for now. BaseContainer.authorize() will - // explicitly handle the case where a context was - // created as a result of this call and the + // , postInvokeTx, etc) but I'm keeping the logic the + // same for now. BaseContainer.authorize() will + // explicitly handle the case where a context was + // created as a result of this call and the // authorization failed, which means the context needs // be released. @@ -2772,7 +2772,7 @@ public Object getJaccEjb(EjbInvocation inv) { return bean; } - public void assertValidLocalObject(Object o) throws EJBException + public void assertValidLocalObject(Object o) throws EJBException { boolean valid = false; String errorMsg = ""; @@ -2781,9 +2781,9 @@ public void assertValidLocalObject(Object o) throws EJBException // Given object is always the client view EJBLocalObject. // Use utility method to translate it to EJBLocalObjectImpl // so we handle both the generated and proxy case. - EJBLocalObjectImpl ejbLocalObjImpl = + EJBLocalObjectImpl ejbLocalObjImpl = EJBLocalObjectImpl.toEJBLocalObjectImpl( (EJBLocalObject) o); - BaseContainer otherContainer = + BaseContainer otherContainer = (BaseContainer) ejbLocalObjImpl.getContainer(); if ( otherContainer.getContainerId() == getContainerId() ) { valid = true; @@ -2801,18 +2801,18 @@ public void assertValidLocalObject(Object o) throws EJBException : "A null parameter is not a valid local interface of bean " + ejbDescriptor.getName(); } - + if ( !valid ) { throw new EJBException(errorMsg); } - + } /** * Asserts validity of RemoteHome objects. This was defined for the * J2EE 1.4 implementation and is exposed through Container SPI. - */ - public void assertValidRemoteObject(Object o) throws EJBException + */ + public void assertValidRemoteObject(Object o) throws EJBException { boolean valid = false; String errorMsg = ""; @@ -2859,11 +2859,11 @@ public void assertValidRemoteObject(Object o) throws EJBException } /** - * + * */ protected final int getTxAttr(Method method, String methodIntf) throws EJBException { - InvocationInfo invInfo = methodIntf.equals(EJB_WEB_SERVICE) ? + InvocationInfo invInfo = methodIntf.equals(EJB_WEB_SERVICE) ? (InvocationInfo) webServiceInvocationInfoMap.get(method) : (InvocationInfo) invocationInfoMap.get(method); @@ -2873,7 +2873,7 @@ protected final int getTxAttr(Method method, String methodIntf) throws EJBExcept throw new EJBException("Transaction Attribute not found for method" + method); } } - + // Get the transaction attribute for a method. // Note: this method object is of the remote/EJBHome interface // class, not the EJB class. (except for MDB's message listener @@ -2886,26 +2886,26 @@ protected final int getTxAttr(EjbInvocation inv) throws EJBException { inv.transactionAttribute = getTxAttr(inv.method, inv.getMethodInterface()); return inv.transactionAttribute; } - - + + // Check if a method is a business method. // Note: this method object is of the EJB's remote/home/local interfaces, // not the EJB class. final boolean isBusinessMethod(Method method) { Class methodClass = method.getDeclaringClass(); - + // All methods on the Home/LocalHome & super-interfaces // are not business methods. // All methods on javax.ejb.EJBObject and EJBLocalObject // (e.g. remove) are not business methods. // All remaining methods are business methods - + if ( isRemote ) { - if ( (hasRemoteHomeView && + if ( (hasRemoteHomeView && ( (methodClass == homeIntf) || methodClass.isAssignableFrom(homeIntf) )) || - (hasRemoteBusinessView && + (hasRemoteBusinessView && ( (methodClass == remoteBusinessHomeIntf) || methodClass.isAssignableFrom(remoteBusinessHomeIntf) )) || @@ -2914,43 +2914,43 @@ final boolean isBusinessMethod(Method method) { } } if ( isLocal ) { - if ( (hasLocalHomeView && + if ( (hasLocalHomeView && ( (methodClass == localHomeIntf) || - methodClass.isAssignableFrom(localHomeIntf) )) + methodClass.isAssignableFrom(localHomeIntf) )) || (hasLocalBusinessView && ( (methodClass == localBusinessHomeIntf) || - methodClass.isAssignableFrom(localBusinessHomeIntf) )) - || + methodClass.isAssignableFrom(localBusinessHomeIntf) )) + || (methodClass == EJBLocalObject.class)) { return false; } } // NOTE : Web Service client view contains ONLY // business methods - + return true; } - + // Check if a method is a create / finder / home method. // Note: this method object is of the EJB's remote/home/local interfaces, // not the EJB class. protected boolean isCreateHomeFinder(Method method) { Class methodClass = method.getDeclaringClass(); - - if ( hasRemoteHomeView + + if ( hasRemoteHomeView && methodClass.isAssignableFrom(homeIntf) && (methodClass != EJBHome.class) ) { return true; } - + if ( hasRemoteBusinessView && methodClass.isAssignableFrom(remoteBusinessHomeIntf) && (methodClass != EJBHome.class) ) { return true; } - if ( hasLocalHomeView + if ( hasLocalHomeView && methodClass.isAssignableFrom(localHomeIntf) && (methodClass != EJBLocalHome.class) ) { return true; @@ -2961,8 +2961,8 @@ protected boolean isCreateHomeFinder(Method method) { && (methodClass != EJBLocalHome.class) ) { return true; } - - + + return false; } @@ -2980,10 +2980,10 @@ private InvocationInfo addInvocationInfo(Method method, String methodIntf, } private InvocationInfo addInvocationInfo(Method method, String methodIntf, - Class originalIntf, boolean isEjbTimeout, + Class originalIntf, boolean isEjbTimeout, boolean optionalLocalBusView) throws EJBException - + { MethodDescriptor md = new MethodDescriptor(method, methodIntf); boolean flushEnabled = findFlushEnabledAttr(md); @@ -3009,13 +3009,13 @@ private InvocationInfo addInvocationInfo(Method method, String methodIntf, if ( beanMethod != null ) { // Can't set AroundInvoke/AroundTimeout chains here, but set up some // state on info object so it can be done right after InterceptorManager - // is initialized. + // is initialized. info.aroundMethod = beanMethod; info.isEjbTimeout = isEjbTimeout; } - // Asynchronous method initialization + // Asynchronous method initialization if ( isEligibleForAsync(originalIntf, methodIntf) ) { Method targetMethod = optionalLocalBusView ? beanMethod : method; @@ -3026,7 +3026,7 @@ private InvocationInfo addInvocationInfo(Method method, String methodIntf, if ( isAsync ) { // Check return type - if ( optionalLocalBusView ) { + if ( optionalLocalBusView && beanMethod != null ) { boolean beanMethodReturnTypeVoid = beanMethod.getReturnType().equals(Void.TYPE); boolean beanMethodReturnTypeFuture = beanMethod.getReturnType().equals(Future.class); @@ -3086,13 +3086,13 @@ private InvocationInfo addInvocationInfo(Method method, String methodIntf, } } } - + if ( methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE) ) { webServiceInvocationInfoMap.put(method, info); } else { - invocationInfoMap.put(method, info); + invocationInfoMap.put(method, info); } - + return info; } @@ -3108,19 +3108,19 @@ private boolean isEligibleForAsync(Class originalIntf, String methodIntf) { eligibleForAsync = !is2xClientView; } - return eligibleForAsync; + return eligibleForAsync; } /** - * Create invocation info for one method. + * Create invocation info for one method. * * @param originalIntf Leaf interface for the given view. Not set for - * methodIntf == bean. + * methodIntf == bean. */ - private final InvocationInfo createInvocationInfo(Method method, int txAttr, + private final InvocationInfo createInvocationInfo(Method method, int txAttr, boolean flushEnabled, String methodIntf, - Class originalIntf) + Class originalIntf) throws EJBException { InvocationInfo invInfo = new InvocationInfo(method); @@ -3136,7 +3136,7 @@ private final InvocationInfo createInvocationInfo(Method method, int txAttr, invInfo.startsWithCreate = method.getName().startsWith("create"); invInfo.startsWithFind = method.getName().startsWith("find"); invInfo.startsWithRemove = method.getName().startsWith("remove"); - invInfo.startsWithFindByPrimaryKey = + invInfo.startsWithFindByPrimaryKey = method.getName().startsWith("findByPrimaryKey"); invInfo.flushEnabled = flushEnabled; @@ -3156,7 +3156,7 @@ private final InvocationInfo createInvocationInfo(Method method, int txAttr, if ( method.getDeclaringClass() != EJBObject.class ) { setEJBObjectTargetMethodInfo(invInfo, false, originalIntf); } - } + } setConcurrencyInvInfo(method, methodIntf, invInfo); @@ -3279,18 +3279,18 @@ protected InvocationInfo postProcessInvocationInfo( InvocationInfo invInfo) { return invInfo; } - + // default impl - protected void adjustHomeTargetMethodInfo(InvocationInfo invInfo, String methodName, + protected void adjustHomeTargetMethodInfo(InvocationInfo invInfo, String methodName, Class[] paramTypes) throws NoSuchMethodException { // Nothing todo } - private void setHomeTargetMethodInfo(InvocationInfo invInfo, - boolean isLocal) + private void setHomeTargetMethodInfo(InvocationInfo invInfo, + boolean isLocal) throws EJBException { - - Class homeIntfClazz = isLocal ? + + Class homeIntfClazz = isLocal ? javax.ejb.EJBLocalHome.class : javax.ejb.EJBHome.class; Class methodClass = invInfo.method.getDeclaringClass(); @@ -3300,7 +3300,7 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, try { Method m = homeIntfClazz.getMethod(methodName, paramTypes); // Attempt to override Home/LocalHome method. Print warning - // but don't treat it as a fatal error. At runtime, + // but don't treat it as a fatal error. At runtime, // the EJBHome/EJBLocalHome method will be called. String[] params = { m.toString(),invInfo.method.toString() }; _logger.log(Level.WARNING, ILLEGAL_EJB_INTERFACE_OVERRIDE, params); @@ -3311,32 +3311,32 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, try { if ( invInfo.startsWithCreate ) { - - String extraCreateChars = + + String extraCreateChars = methodName.substring("create".length()); invInfo.targetMethod1 = ejbClass.getMethod ("ejbCreate" + extraCreateChars, paramTypes); - + adjustHomeTargetMethodInfo(invInfo, methodName, paramTypes); - + } else if ( invInfo.startsWithFind ) { - + String extraFinderChars = methodName.substring("find".length()); invInfo.targetMethod1 = ejbClass.getMethod ("ejbFind" + extraFinderChars, paramTypes); - + } else { // HOME method - String upperCasedName = + String upperCasedName = methodName.substring(0,1).toUpperCase(Locale.US) + methodName.substring(1); invInfo.targetMethod1 = ejbClass.getMethod ("ejbHome" + upperCasedName, paramTypes); } } catch(NoSuchMethodException nsme) { - + if ( (methodClass == localBusinessHomeIntf) || (methodClass == remoteBusinessHomeIntf) || (methodClass == ejbOptionalLocalBusinessHomeIntf || @@ -3345,14 +3345,14 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, // client view is being used and there is no corresponding // create/init method. } else if (isStatelessSession || isSingleton) { - // Ignore. Not an error. + // Ignore. Not an error. // EJB 3.0 Stateless session ejbCreate/PostConstruct // is decoupled from RemoteHome/LocalHome create(). } else { Method initMethod = null; if ( isSession ) { - EjbSessionDescriptor sessionDesc = + EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor; for(EjbInitInfo next : sessionDesc.getInitMethods()) { @@ -3366,18 +3366,18 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, } } } - + if ( initMethod != null ) { invInfo.targetMethod1 = initMethod; } else { - Object[] params = { logParams[0], + Object[] params = { logParams[0], (isLocal ? "LocalHome" : "Home"), invInfo.method.toString() }; _logger.log(Level.WARNING, BEAN_CLASS_METHOD_NOT_FOUND, params); // Treat this as a warning instead of a fatal error. // That matches the behavior of the generated code. // Mark the target methods as null. If this method is - // invoked at runtime it will be result in an exception + // invoked at runtime it will be result in an exception // from the invocation handlers. invInfo.targetMethod1 = null; invInfo.targetMethod2 = null; @@ -3388,21 +3388,21 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, private void setEJBObjectTargetMethodInfo(InvocationInfo invInfo, boolean isLocal, - Class originalIntf) + Class originalIntf) throws EJBException { - Class ejbIntfClazz = isLocal ? + Class ejbIntfClazz = isLocal ? javax.ejb.EJBLocalObject.class : javax.ejb.EJBObject.class; Class[] paramTypes = invInfo.method.getParameterTypes(); String methodName = invInfo.method.getName(); - // Check for 2.x Remote/Local bean attempts to override - // EJBObject/EJBLocalObject operations. + // Check for 2.x Remote/Local bean attempts to override + // EJBObject/EJBLocalObject operations. if ( ejbIntfClazz.isAssignableFrom(originalIntf) ) { try { Method m = ejbIntfClazz.getMethod(methodName, paramTypes); - // Attempt to override EJBObject/EJBLocalObject method. Print + // Attempt to override EJBObject/EJBLocalObject method. Print // warning but don't treat it as a fatal error. At runtime, the // EJBObject/EJBLocalObject method will be called. String[] params = { m.toString(),invInfo.method.toString() }; @@ -3427,7 +3427,7 @@ private void setEJBObjectTargetMethodInfo(InvocationInfo invInfo, } } catch(NoSuchMethodException nsme) { - Object[] params = { logParams[0] + ":" + nsme.toString(), + Object[] params = { logParams[0] + ":" + nsme.toString(), (isLocal ? "Local" : "Remote"), invInfo.method.toString() }; _logger.log(Level.WARNING, BEAN_CLASS_METHOD_NOT_FOUND, params); @@ -3436,7 +3436,7 @@ private void setEJBObjectTargetMethodInfo(InvocationInfo invInfo, // Mark the target methods as null. If this method is // invoked at runtime it will be result in an exception from // the invocation handlers. - invInfo.targetMethod1 = null; + invInfo.targetMethod1 = null; } } @@ -3447,7 +3447,7 @@ protected String[] getPre30LifecycleMethodNames() { null, "ejbCreate", "ejbRemove", "ejbPassivate", "ejbActivate" }; }; - + private synchronized void initializeInterceptorManager() throws Exception { this.interceptorManager = new InterceptorManager(_logger, this, lifecycleCallbackAnnotationClasses, @@ -3486,7 +3486,7 @@ private void addSystemInterceptorProxy() { ejbDescriptor.addFrameworkInterceptor(interceptorDesc); } - + protected void addLocalRemoteInvocationInfo() throws Exception { if ( isRemote ) { @@ -3495,15 +3495,15 @@ protected void addLocalRemoteInvocationInfo() throws Exception // Process Remote intf Method[] methods = remoteIntf.getMethods(); for ( int i=0; i invocationInfo) lookup has been measured to be + // the (method -> invocationInfo) lookup has been measured to be // 6X greater than the overhead of the reflective call itself. proxyInvocationInfoMap = new MethodMap(invocationInfoMap); - + // Store InvocationInfo by standard ejb interface method type // to avoid an invocation info map lookup during authorizeLocalMethod // and authorizeRemoteMethod. @@ -3658,7 +3658,7 @@ private void initializeInvocationInfo() throws Exception ejbIntfMethodInfo[i] = (InvocationInfo) invocationInfoMap.get(m); } } - + /** * Validate transaction attribute value. Allow subclasses to add their own validation. */ @@ -3684,21 +3684,21 @@ private void processTxAttrForScheduledTimeoutMethod(Method m) { ejbDescriptor.getName()); } } - + // Check if the user has enabled flush at end of method flag - // This is only used during container initialization and set into + // This is only used during container initialization and set into // the invocation info object. This method is over-riden in the // EntityContainer. protected boolean findFlushEnabledAttr(MethodDescriptor md) { - + //Get the flushMethodDescriptor and then find if flush has been //enabled for this method - boolean flushEnabled = + boolean flushEnabled = ejbDescriptor.getIASEjbExtraDescriptors().isFlushEnabledFor(md); return flushEnabled; } - + // default impl protected void addProxyInterfacesSetClass(Set proxyInterfacesSet, boolean local) { // no-op @@ -3720,7 +3720,7 @@ private EJBHomeImpl instantiateEJBHomeImpl() throws Exception { addProxyInterfacesSetClass(proxyInterfacesSet, false); - proxyInterfacesSet.add(homeIntf); + proxyInterfacesSet.add(homeIntf); Class[] proxyInterfaces = (Class []) proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]); @@ -3738,7 +3738,7 @@ private EJBHomeImpl instantiateEJBHomeImpl() throws Exception { return homeImpl; } - private EJBHomeImpl instantiateEJBRemoteBusinessHomeImpl() + private EJBHomeImpl instantiateEJBRemoteBusinessHomeImpl() throws Exception { EJBHomeInvocationHandler handler = getEJBHomeInvocationHandler(remoteBusinessHomeIntf); @@ -3746,15 +3746,15 @@ private EJBHomeImpl instantiateEJBRemoteBusinessHomeImpl() EJBHomeImpl remoteBusinessHomeImpl = handler; - EJBHome ejbRemoteBusinessHomeProxy = (EJBHome) - Proxy.newProxyInstance(loader, + EJBHome ejbRemoteBusinessHomeProxy = (EJBHome) + Proxy.newProxyInstance(loader, new Class[] { remoteBusinessHomeIntf }, handler); - + handler.setProxy(ejbRemoteBusinessHomeProxy); remoteBusinessHomeImpl.setContainer(this); - + return remoteBusinessHomeImpl; } @@ -3778,19 +3778,19 @@ private EJBLocalHomeImpl instantiateEJBLocalHomeImpl() // LocalHome impl EJBLocalHomeInvocationHandler invHandler = getEJBLocalHomeInvocationHandler(localHomeIntf); invHandler.setMethodMap(proxyInvocationInfoMap); - + EJBLocalHomeImpl homeImpl = invHandler; - + // Maintain insertion order Set proxyInterfacesSet = new LinkedHashSet(); - + proxyInterfacesSet.add(IndirectlySerializable.class); addProxyInterfacesSetClass(proxyInterfacesSet, true); proxyInterfacesSet.add(localHomeIntf); - + Class[] proxyInterfaces = (Class[]) proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]); - + // Client's EJBLocalHome object try { EJBLocalHome proxy = (EJBLocalHome) Proxy.newProxyInstance(loader, proxyInterfaces, invHandler); @@ -3844,19 +3844,19 @@ private EJBLocalHomeImpl instantiateEJBOptionalLocalBusinessHomeImpl() return homeImpl; } - protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl() + protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl() throws Exception { return instantiateEJBLocalObjectImpl(null); } - protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl(Object key) + protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl(Object key) throws Exception { EJBLocalObjectImpl localObjImpl = null; - EJBLocalObjectInvocationHandler handler = + EJBLocalObjectInvocationHandler handler = new EJBLocalObjectInvocationHandler(proxyInvocationInfoMap, localIntf); localObjImpl = handler; - + try { EJBLocalObject localObjectProxy = (EJBLocalObject) ejbLocalObjectProxyCtor.newInstance(new Object[]{handler}); handler.setProxy(localObjectProxy); @@ -3926,7 +3926,7 @@ protected EJBLocalObjectImpl instantiateOptionalEJBLocalBusinessObjectImpl() ejbClass, beanSubClassName, ejbGeneratedOptionalLocalBusinessIntfClass); optIntfClassLoader.loadClass(ejbGeneratedOptionalLocalBusinessIntfClass.getName()); - + Class subClass = optIntfClassLoader.loadClass(beanSubClassName); OptionalLocalInterfaceProvider provider = (OptionalLocalInterfaceProvider) subClass.newInstance(); @@ -3935,22 +3935,22 @@ protected EJBLocalObjectImpl instantiateOptionalEJBLocalBusinessObjectImpl() return localBusinessObjImpl; } - + protected EJBObjectImpl instantiateEJBObjectImpl() throws Exception { return instantiateEJBObjectImpl(null, null); } - + protected EJBObjectImpl instantiateEJBObjectImpl(EJBObject ejbStub, Object key) throws Exception { EJBObjectInvocationHandler handler = new EJBObjectInvocationHandler(proxyInvocationInfoMap, - remoteIntf); + remoteIntf); EJBObjectImpl ejbObjImpl = handler; try { EJBObject ejbObjectProxy = (EJBObject) ejbObjectProxyCtor.newInstance(new Object[]{handler}); handler.setEJBObject(ejbObjectProxy); } catch (ClassCastException e) { - String msg = localStrings.getLocalString("ejb.basecontainer_invalid_remote_interface", + String msg = localStrings.getLocalString("ejb.basecontainer_invalid_remote_interface", "Remote component interface [{0}] is invalid since it does not extend javax.ejb.EJBObject.", remoteIntf); throw new IllegalArgumentException(msg, e); } @@ -3969,25 +3969,25 @@ protected EJBObjectImpl instantiateEJBObjectImpl(EJBObject ejbStub, Object key) return ejbObjImpl; } - protected EJBObjectImpl instantiateRemoteBusinessObjectImpl() + protected EJBObjectImpl instantiateRemoteBusinessObjectImpl() throws Exception { - + // There is one EJBObjectImpl instance, which is an instance of // the handler. That handler instance is shared by the dynamic // proxy for each remote business interface. We need to create a - // different proxy for each remote business interface because + // different proxy for each remote business interface because // otherwise the target object given to the orb will be invalid // if the same method happens to be declared on multiple remote // business interfaces. EJBObjectInvocationHandler handler = - new EJBObjectInvocationHandler(proxyInvocationInfoMap); + new EJBObjectInvocationHandler(proxyInvocationInfoMap); EJBObjectImpl ejbBusinessObjImpl = handler; - for(RemoteBusinessIntfInfo next : + for(RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) { - EJBObjectInvocationHandlerDelegate delegate = + EJBObjectInvocationHandlerDelegate delegate = new EJBObjectInvocationHandlerDelegate(next.remoteBusinessIntf, handler); @@ -4015,7 +4015,7 @@ public void postCreate(EjbInvocation inv, Object primaryKey) { throw new EJBException("Internal error"); } - + // default implementation public Object postFind(EjbInvocation inv, Object primaryKeys, Object[] findParams) @@ -4023,8 +4023,8 @@ public Object postFind(EjbInvocation inv, Object primaryKeys, { throw new EJBException("Internal error"); } - - + + private void setupEnvironment() throws javax.naming.NamingException { @@ -4041,25 +4041,25 @@ private void setupEnvironment() safeProps.copy(env); envProps = safeProps; } - + /** * Called from NamingManagerImpl during java:comp/env lookup. */ public String getComponentId() { return componentId; } - + /** * Called after all the components in the container's application * have deployed successfully. */ public void startApplication(boolean deploy) { - _logger.log(Level.FINE,"Application deployment successful : " + + _logger.log(Level.FINE,"Application deployment successful : " + this); // By now all existing timers should have been restored. if ( isTimedObject_ ) { - // EJBTimerService should be accessed only if needed + // EJBTimerService should be accessed only if needed // not to cause it to be loaded if it's not used. EJBTimerService timerService = EJBTimerService.getEJBTimerService(); if (timerService != null) { @@ -4077,27 +4077,27 @@ public void startApplication(boolean deploy) { setStartedState(); } - + /** * */ protected boolean callEJBTimeout(RuntimeTimerState timerState, EJBTimerService timerService) throws Exception { - + boolean redeliver = false; - + if (containerState != CONTAINER_STARTED) { throw new EJBException("Attempt to invoke when container is in " + containerStateToString(containerState)); } - + EjbInvocation inv = createEjbInvocation(); inv.isTimerCallback = true; - + // Let preInvoke do tx attribute lookup. inv.transactionAttribute = Container.TX_NOT_INITIALIZED; - + inv.method = getTimeoutMethod(timerState); inv.beanMethod = inv.method; @@ -4107,20 +4107,20 @@ protected boolean callEJBTimeout(RuntimeTimerState timerState, // Delegate to subclass for i.ejbObject / i.isLocal setup. doTimerInvocationInit(inv, timerState.getTimedObjectPrimaryKey()); - + originalClassLoader = Utility.setContextClassLoader(loader); preInvoke(inv); // AroundTimeout interceptors will be checked for timeout methods intercept(inv); - + if ( !isBeanManagedTran && (transactionManager.getStatus() == Status.STATUS_MARKED_ROLLBACK) ) { redeliver = true; _logger.log(Level.FINE, "ejbTimeout called setRollbackOnly"); } - + } catch(InvocationTargetException ite) { // A runtime exception thrown from ejbTimeout, independent of // its transactional setting(CMT, BMT, etc.), should result in @@ -4141,7 +4141,7 @@ protected boolean callEJBTimeout(RuntimeTimerState timerState, boolean success = postEjbTimeout(timerState, timerService); redeliver = !success; } - + postInvoke(inv); // If transaction commit fails, set redeliver flag. @@ -4154,7 +4154,7 @@ protected boolean callEJBTimeout(RuntimeTimerState timerState, } } - + return redeliver; } @@ -4184,7 +4184,7 @@ protected void prepareEjbTimeoutParams(EjbInvocation inv, RuntimeTimerState time public final void onEnteringContainer() { ejbProbeNotifier.ejbContainerEnteringEvent(getContainerId(), - containerInfo.appName, containerInfo.modName, + containerInfo.appName, containerInfo.modName, containerInfo.ejbName); enteringEjbContainer(); //callFlowAgent.startTime(ContainerTypeOrApplicationType.EJB_CONTAINER); @@ -4192,7 +4192,7 @@ public final void onEnteringContainer() { public final void onLeavingContainer() { ejbProbeNotifier.ejbContainerLeavingEvent(getContainerId(), - containerInfo.appName, containerInfo.modName, + containerInfo.appName, containerInfo.modName, containerInfo.ejbName); leavingEjbContainer(); //callFlowAgent.endTime(); @@ -4230,7 +4230,7 @@ private void initEjbInterceptors() { _logger.log(Level.SEVERE, FAILED_TO_INITIALIZE_INTERCEPTOR, th); } } - + final void onEjbMethodStart(int methodIndex) { InvocationInfo info = ejbIntfMethodInfo[methodIndex]; if (info != null) { @@ -4257,7 +4257,7 @@ final void onEjbMethodStart(String method_sig) { } //callFlowAgent.ejbMethodStart(callFlowInfo); } - + final void onEjbMethodEnd(String method_sig, Throwable th) { ejbProbeNotifier.ejbMethodEndEvent(getContainerId(), callFlowInfo.getApplicationName(), @@ -4269,7 +4269,7 @@ final void onEjbMethodEnd(String method_sig, Throwable th) { if (requestTracing.isRequestTracingEnabled()) { RequestTraceSpanLog spanLog = constructEjbMethodSpanLog(callFlowInfo, false); requestTracing.addSpanLog(spanLog); - } + } } private RequestTraceSpanLog constructEjbMethodSpanLog(CallFlowInfo info, boolean callEnter) { @@ -4311,7 +4311,7 @@ protected Object invokeTargetBeanMethod(Method beanClassMethod, EjbInvocation in onEjbMethodEnd(inv.invocationInfo.str_method_sig, inv.exception); } } - + /** * This is implemented by concrete containers that support TimedObjects. */ @@ -4319,19 +4319,19 @@ protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey ) throws Exception { throw new EJBException("This container doesn't support TimedObjects"); } - + /** * Undeploy event. * Code must be able to gracefully handle redundant undeploy/shutdown * calls for the same container instance. - * + * */ public final void undeploy() { try { - + if ( !isUndeployed() ) { - + setUndeployedState(); try { @@ -4367,7 +4367,7 @@ public final void onShutdown() { try { if ( !isStopped() ) { - + setStoppedState(); try { @@ -4430,7 +4430,7 @@ private void doContainerCleanup() { ((EjbContainerUtilImpl) ejbContainerUtilImpl).getEjbAsyncInvocationManager(); asyncManager.cleanupContainerTasks(this); } - + final Thread currentThread = Thread.currentThread(); final ClassLoader previousClassLoader = @@ -4474,7 +4474,7 @@ public java.lang.Object run() { remoteHomeRefFactory.cleanupClass(remoteIntf); remoteHomeRefFactory.cleanupClass(ejbHome.getClass()); remoteHomeRefFactory.cleanupClass(ejbObjectProxyClass); - + // destroy the factory itself remoteHomeRefFactory.destroy(); } @@ -4497,13 +4497,13 @@ public java.lang.Object run() { next.referenceFactory.cleanupClass(next.generatedRemoteIntf); next.referenceFactory.cleanupClass(next.proxyClass); - + // destroy the factory itself next.referenceFactory.destroy(); } - + } - + } catch ( Exception ex ) { _logger.log(Level.FINE, "Exception during undeploy", logParams); _logger.log(Level.FINE, "", ex); @@ -4519,7 +4519,7 @@ public java.lang.Object run() { } ejbContainerUtilImpl.unregisterContainer(this); - + unregisterProbeListeners(); } finally { @@ -4538,10 +4538,10 @@ public java.lang.Object run() { baseContainerCleanupDone = true; - + _logger.log(Level.FINE, "**** [BaseContainer]: Successfully Undeployed " + ejbDescriptor.getName() + " ..."); - + } @@ -4564,7 +4564,7 @@ private void unregisterProbeListeners() { probeFactory.unregisterProbeProvider(cacheProbeNotifier); } } - + executorProbeListener.unregister(); } catch (Exception ex) { if (_logger.isLoggable(Level.FINE)) { @@ -4577,19 +4577,19 @@ private void unregisterProbeListeners() { */ public void onReady() {} - + /** * Called when server instance is terminating. This method is the last * one called during server shutdown. */ public void onTermination() {} - - + + /*************************************************************************** * The following methods implement transaction management machinery * in a reusable way for both SessionBeans and EntityBeans **************************************************************************/ - + /** * This is called from preInvoke before every method invocation * on the EJB instance, including ejbCreate, ejbFind*, ejbRemove. @@ -4612,28 +4612,28 @@ protected final void preInvokeTx(EjbInvocation inv) inv.transactionAttribute = inv.invocationInfo.txAttr; } } - + containerTransactionManager.preInvokeTx(inv); } - - + + // Called before invoking a bean with no Tx or with a new Tx. // Check if the bean is associated with an unfinished tx. protected void checkUnfinishedTx(Transaction prevTx, EjbInvocation inv) { } - - // Called from preInvokeTx to check if transaction needs to be suspended + + // Called from preInvokeTx to check if transaction needs to be suspended protected boolean suspendTransaction(EjbInvocation inv) throws Exception { // Overridden in subclass that needs it return false; } - + // Called from postInvokeTx if transaction needs to be resumed protected boolean resumeTransaction(EjbInvocation inv) throws Exception { // Overridden in subclass that needs it return false; } - + // Called from preInvokeTx before invoking the bean with the client's Tx // Also called from EntityContainer.removeBean for cascaded deletes protected void useClientTx(Transaction prevTx, EjbInvocation inv) { @@ -4643,8 +4643,8 @@ protected void useClientTx(Transaction prevTx, EjbInvocation inv) { protected void validateEMForClientTx(EjbInvocation inv, JavaEETransaction t) { // Do nothing in general case } - - + + /** * postInvokeTx is called after every invocation on the EJB instance, * including ejbCreate/ejbFind---/ejbRemove. @@ -4654,10 +4654,10 @@ protected void validateEMForClientTx(EjbInvocation inv, JavaEETransaction t) { protected void postInvokeTx(EjbInvocation inv) throws Exception { - + containerTransactionManager.postInvokeTx(inv); } - + // this is the counterpart of useClientTx // Called from postInvokeTx after invoking the bean with the client's Tx // Also called from EntityContainer.removeBean for cascaded deletes @@ -4667,7 +4667,7 @@ protected Throwable checkExceptionClientTx(EJBContextImpl context, { return containerTransactionManager.checkExceptionClientTx(context, exception); } - + // Implementation of Container method. // Called from UserTransactionImpl after the EJB started a Tx, // for TX_BEAN_MANAGED EJBs only. @@ -4682,11 +4682,11 @@ public final void doAfterBegin(ComponentInvocation ci) { if (! isSingleton) { sc.setTransaction(tx); } - + // Register Synchronization with TM so that we can // dissociate the context from tx in afterCompletion ejbContainerUtilImpl.getContainerSync(tx).addBean(sc); - + enlistExtendedEntityManagers(sc); // Dont call container.afterBegin() because // TX_BEAN_MANAGED EntityBeans are not allowed, @@ -4700,20 +4700,20 @@ public final void doAfterBegin(ComponentInvocation ci) { throw new EJBException(ex); } } - + // internal APIs, called from ContainerSync, implemented in subclasses protected abstract void afterBegin(EJBContextImpl context); protected abstract void beforeCompletion(EJBContextImpl context); protected abstract void afterCompletion(EJBContextImpl context, int status); - + protected void preInvokeNoTx(EjbInvocation inv) { // No-op by default } - + protected void postInvokeNoTx(EjbInvocation inv) { // No-op by default } - + protected boolean isApplicationException(Throwable exception) { return !isSystemUncheckedException(exception); } @@ -4726,7 +4726,7 @@ protected boolean isSystemUncheckedException(Throwable exception) { Class clazz = exception.getClass(); String exceptionClassName = clazz.getName(); - Map appExceptions = + Map appExceptions = ejbDescriptor.getEjbBundleDescriptor().getApplicationExceptions(); while (clazz != null) { String eClassName = clazz.getName(); @@ -4751,11 +4751,11 @@ protected boolean isSystemUncheckedException(Throwable exception) { public boolean getDebugMonitorFlag() { return debugMonitorFlag; } - + public void setDebugMonitorFlag(boolean flag) { debugMonitorFlag = flag; } - + protected static final String containerStateToString(int state) { switch (state) { case CONTAINER_INITIALIZING: @@ -4779,8 +4779,8 @@ protected final boolean isRemoteInterfaceSupported() { protected final boolean isLocalInterfaceSupported() { return hasLocalHomeView; } - - protected int getTxAttrForLifecycleCallback(Set lifecycleCallbackDescriptors, + + protected int getTxAttrForLifecycleCallback(Set lifecycleCallbackDescriptors, int defaultTxAttr, int... validateTxAttr) throws Exception { int txAttr = isBeanManagedTran ? Container.TX_BEAN_MANAGED : defaultTxAttr; @@ -4797,7 +4797,7 @@ protected int getTxAttrForLifecycleCallback(Set lif if ( lcTxAttr == t ) { txAttr = t; if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, "Found callback method " + ejbDescriptor.getEjbClassName() + + _logger.log(Level.FINE, "Found callback method " + ejbDescriptor.getEjbClassName() + "<>" + callbackMethod + " : " + txAttr); } break; @@ -4820,9 +4820,9 @@ protected int getTxAttrForLifecycleCallback(Set lif * for dispatching invocations to business methods. This method has * the exception semantics of Method.invoke(). Any exception that * originated from the business method or application code within an - * interceptor will be propagated as the cause within an + * interceptor will be propagated as the cause within an * InvocationTargetException. - * + * */ protected Object intercept(EjbInvocation inv) throws Throwable { Object result = null; @@ -4877,12 +4877,12 @@ public Object invokeBeanMethod(EjbInvocation inv) return securityManager.invoke(inv.getBeanMethod(), inv.isLocal, inv.ejb, inv.getParameters()); - + } catch(InvocationTargetException ite) { throw ite.getCause(); } } - + protected abstract EjbMonitoringStatsProvider getMonitoringStatsProvider( String appName, String modName, String ejbName); @@ -4974,7 +4974,7 @@ protected void registerMonitorableComponents() { createMonitoringRegistry(); registerTimerMonitorableComponent(); executorProbeListener = new EjbThreadPoolExecutorStatsProvider(null); - + executorProbeListener.register(); } @@ -5099,9 +5099,9 @@ private static boolean isCosNamingObject(Object obj) { * method will not be called. */ public final static class PreInvokeException extends EJBException { - + Exception exception; - + public PreInvokeException(Exception ex) { this.exception = ex; } @@ -5131,24 +5131,24 @@ private static class BeanContext { final class CallFlowInfoImpl implements CallFlowInfo { - + private final BaseContainer container; - + private final EjbDescriptor ejbDescriptor; - + private final String appName; - + private final String modName; - + private final String ejbName; - + private final ComponentType componentType; - + CallFlowInfoImpl(BaseContainer container, EjbDescriptor descriptor, ComponentType compType) { this.container = container; this.ejbDescriptor = descriptor; - + this.appName = (ejbDescriptor.getApplication().isVirtual()) ? null : ejbDescriptor.getApplication().getRegistrationName(); String archiveuri = ejbDescriptor.getEjbBundleDescriptor() @@ -5156,33 +5156,33 @@ final class CallFlowInfoImpl this.modName = com.sun.enterprise.util.io.FileUtils .makeFriendlyFilename(archiveuri); this.ejbName = ejbDescriptor.getName(); - + this.componentType = compType; } - + public String getApplicationName() { return appName; } - + public String getModuleName() { return modName; } - + public String getComponentName() { return ejbName; } - + public ComponentType getComponentType() { return componentType; } - + public java.lang.reflect.Method getMethod() { EjbInvocation inv = (EjbInvocation) EjbContainerUtilImpl.getInstance().getCurrentInvocation(); - + return inv.method; } - + public String getTransactionId() { JavaEETransaction tx = null; try { @@ -5192,17 +5192,17 @@ public String getTransactionId() { } catch (Exception ex) { //TODO: Log exception } - + return (tx == null) ? null : ""+tx; //TODO tx.getTransactionId(); } - + public String getCallerPrincipal() { - java.security.Principal principal = + java.security.Principal principal = container.getSecurityManager().getCallerPrincipal(); - + return (principal != null) ? principal.getName() : null; } - + public Throwable getException() { return ((EjbInvocation) EjbContainerUtilImpl.getInstance().getCurrentInvocation()).exception; } @@ -5224,7 +5224,7 @@ final class SafeProperties extends Properties { private static final String errstr = "Environment properties cannot be modified"; private static final String ejb10Prefix = "ejb10-properties/"; - + public void load(java.io.InputStream inStream) { throw new RuntimeException(errstr); } @@ -5251,13 +5251,13 @@ void copy(Set s) { } } } - + private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, ClassNotFoundException { defaults = (Properties)stream.readObject(); } - + private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/CallbackInvocationContext.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/CallbackInvocationContext.java index 9e5245a9795..66ba50007c7 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/CallbackInvocationContext.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/CallbackInvocationContext.java @@ -55,7 +55,7 @@ /** - * Concrete InvocationContext implementation passed to callback methods + * Concrete InvocationContext implementation passed to callback methods * defined in interceptor classes. */ public class CallbackInvocationContext implements InvocationContext { @@ -117,7 +117,7 @@ public CallbackInvocationContext(Class targetObjectClass, } ctorParamTypes = ctor.getParameterTypes(); - ctorParams = new Object[ctorParamTypes.length]; + ctorParams = new Object[ctorParamTypes.length]; this.interceptorInfo = interceptorInfo; } @@ -169,7 +169,7 @@ public Method getMethod() { return method; } - + @Override public Object[] getParameters() { if (eventType == CallbackType.AROUND_CONSTRUCT) { @@ -198,7 +198,7 @@ public Map getContextData() { return contextData; } - + @Override public Object proceed() throws Exception { try { @@ -233,7 +233,7 @@ private void checkSetParameters(Object[] params) { throw new IllegalArgumentException("Wrong number of parameters for " + " constructor: " + ctor); } - if (ctorParamTypes.length != params.length) { + if (ctorParamTypes.length != (params != null ? params.length : 0)) { throw new IllegalArgumentException("Wrong number of parameters for " + " constructor: " + ctor); } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorUtil.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorUtil.java index 74daa118348..84fc4f877c5 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorUtil.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorUtil.java @@ -37,9 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ - -/* - */ +// Portions Copyright [2018] [Payara Foundation and/or its affiliates] package com.sun.ejb.containers.interceptors; import java.lang.reflect.Method; @@ -53,26 +51,25 @@ */ public class InterceptorUtil { - private static Map> compatiblePrimitiveWrapper - = new HashMap>(); + private static Map> compatiblePrimitiveWrapper = new HashMap<>(); static { - Set smallerPrimitiveWrappers = null; + Set smallerPrimitiveWrappers; - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); compatiblePrimitiveWrapper.put(byte.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Boolean.class); compatiblePrimitiveWrapper.put(boolean.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Character.class); compatiblePrimitiveWrapper.put(char.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); smallerPrimitiveWrappers.add(Short.class); smallerPrimitiveWrappers.add(Integer.class); @@ -80,27 +77,27 @@ public class InterceptorUtil { smallerPrimitiveWrappers.add(Double.class); compatiblePrimitiveWrapper.put(double.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); smallerPrimitiveWrappers.add(Short.class); smallerPrimitiveWrappers.add(Integer.class); smallerPrimitiveWrappers.add(Float.class); compatiblePrimitiveWrapper.put(float.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); smallerPrimitiveWrappers.add(Short.class); smallerPrimitiveWrappers.add(Integer.class); compatiblePrimitiveWrapper.put(int.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); smallerPrimitiveWrappers.add(Short.class); smallerPrimitiveWrappers.add(Integer.class); smallerPrimitiveWrappers.add(Long.class); compatiblePrimitiveWrapper.put(long.class, smallerPrimitiveWrappers); - smallerPrimitiveWrappers = new HashSet(); + smallerPrimitiveWrappers = new HashSet<>(); smallerPrimitiveWrappers.add(Byte.class); smallerPrimitiveWrappers.add(Short.class); compatiblePrimitiveWrapper.put(short.class, smallerPrimitiveWrappers); @@ -120,7 +117,7 @@ public static void checkSetParameters(Object[] params, Method method) { throw new IllegalArgumentException("Wrong number of parameters for " + " method: " + method); } - if (paramTypes.length != params.length) { + if (paramTypes.length != (params != null ? params.length : 0)) { throw new IllegalArgumentException("Wrong number of parameters for " + " method: " + method); } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/BlockingPool.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/BlockingPool.java index eeb8cb4f5cf..dccdd84d512 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/BlockingPool.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/BlockingPool.java @@ -37,10 +37,10 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2018] [Payara Foundation and/or its affiliates] package com.sun.ejb.containers.util.pool; -import static com.sun.ejb.containers.util.pool.AbstractPool._logger; import java.util.logging.Level; /** @@ -63,7 +63,7 @@ public Object getObject(Object param) { long t1, totalWaitTime = 0; synchronized (list) { - while (singletonBeanPool == false) { + while (!singletonBeanPool) { if (list.size() > 0) { return super.getObject(param); } else if ((createdCount - destroyedCount) < maxPoolSize) { @@ -84,9 +84,7 @@ public Object getObject(Object param) totalWaitTime += System.currentTimeMillis() - t1; if (list.size() > 0) { return super.getObject(param); - } else if (maxWaitTimeInMillis == 0) { - // nothing special to do in this case - } else if (totalWaitTime >= maxWaitTimeInMillis) { + } else if (maxWaitTimeInMillis > 0 && totalWaitTime >= maxWaitTimeInMillis) { throw new PoolException("Pool Instance not obtained" + " within given time interval."); } @@ -109,7 +107,7 @@ public void returnObject(Object object) { synchronized (list) { poolReturned++; if (waitCount > 0) { - list.notify(); + list.notifyAll(); } } } @@ -127,7 +125,7 @@ public void destroyObject(Object object) { super.destroyObject(object); synchronized (list) { if (waitCount > 0) { - list.notify(); + list.notifyAll(); } } } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/NonBlockingPool.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/NonBlockingPool.java index 482e38fd0ef..3362ffaf3d3 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/NonBlockingPool.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/util/pool/NonBlockingPool.java @@ -37,14 +37,14 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates] /** *
$Source: /cvs/glassfish/appserv-core/src/java/com/sun/ejb/containers/util/pool/NonBlockingPool.java,v $ * @author $Author: cf126330 $ * @version $Revision: 1.4 $ $Date: 2007/03/30 19:10:26 $ */ - + package com.sun.ejb.containers.util.pool; @@ -52,27 +52,26 @@ import com.sun.ejb.containers.EjbContainerUtilImpl; import com.sun.enterprise.util.Utility; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.TimerTask; import java.util.logging.Level; /** - *

NonBlockingPool pool provides the basic implementation of an object - * pool. The implementation uses a linked list to maintain a list of + *

NonBlockingPool pool provides the basic implementation of an object + * pool. The implementation uses a linked list to maintain a list of * (available) objects. If the pool is empty it simply creates one using the * ObjectFactory instance. Subclasses can change this behaviour by overriding - * getObject(...) and returnObject(....) methods. This class provides basic + * getObject(...) and returnObject(....) methods. This class provides basic * support for synchronization, event notification, pool shutdown * and pool object recycling. It also does some very basic bookkeeping like the * number of objects created, number of threads waiting for object. - *

Subclasses can make use of these book-keeping data to provide complex - * pooling mechanism like LRU / MRU / Random. Also, note that AbstractPool - * does not have a notion of pool limit. It is upto to the derived classes + *

Subclasses can make use of these book-keeping data to provide complex + * pooling mechanism like LRU / MRU / Random. Also, note that AbstractPool + * does not have a notion of pool limit. It is upto to the derived classes * to implement these features. - * + * */ - - public class NonBlockingPool extends AbstractPool { @@ -94,15 +93,15 @@ public class NonBlockingPool // Set to true after close(). Prevents race condition // of async resize task kicking in after close(). private boolean poolClosed = false; - + private int resizeTaskCount; protected NonBlockingPool() { } - public NonBlockingPool(long beanId, String poolName, ObjectFactory factory, + public NonBlockingPool(long beanId, String poolName, ObjectFactory factory, int steadyPoolSize, int resizeQuantity, - int maxPoolSize, int idleTimeoutInSeconds, + int maxPoolSize, int idleTimeoutInSeconds, ClassLoader loader) { this(beanId, poolName, factory, @@ -135,29 +134,29 @@ private void initializePool(ObjectFactory factory, int steadyPoolSize, ? Integer.MAX_VALUE : maxPoolSize; this.steadyPoolSize = (this.steadyPoolSize > this.maxPoolSize) ? this.maxPoolSize : this.steadyPoolSize; - this.idleTimeoutInSeconds = + this.idleTimeoutInSeconds = (idleTimeoutInSeconds <= 0 || this.singletonBeanPool) ? 0 : idleTimeoutInSeconds; - + this.containerClassLoader = loader; - - this.maintainSteadySize = this.singletonBeanPool ? false : (this.steadyPoolSize > 0); + + this.maintainSteadySize = !this.singletonBeanPool && (this.steadyPoolSize > 0); if ((this.idleTimeoutInSeconds > 0) && (this.resizeQuantity > 0)) { try { this.poolTimerTask = new PoolResizeTimerTask(); EjbContainerUtilImpl.getInstance().getTimer().scheduleAtFixedRate - (poolTimerTask, idleTimeoutInSeconds*1000L, + (poolTimerTask, idleTimeoutInSeconds*1000L, idleTimeoutInSeconds*1000L); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "[Pool-{0}]: Added PoolResizeTimerTask...", poolName); } } catch (Throwable th) { - _logger.log(Level.WARNING,"[Pool-" + + _logger.log(Level.WARNING,"[Pool-" + poolName + "]: Could not add" + " PoolTimerTask. Continuing anyway...", th); } } } - + @Override public Object getObject(Object param) @@ -171,25 +170,25 @@ public Object getObject(Object param) return list.remove(size-1); } else if (size > 0) { poolSuccess++; - if ((maintainSteadySize) && (addedResizeTask == false)) { + if ((maintainSteadySize) && !addedResizeTask) { toAddResizeTask = addedResizeTask = true; obj = list.remove(size-1); } else { return list.remove(size-1); } } else if(!singletonBeanPool){ - if ((maintainSteadySize) && (addedResizeTask == false)) { + if ((maintainSteadySize) && !addedResizeTask) { toAddResizeTask = addedResizeTask = true; } poolProbeNotifier.ejbObjectAddedEvent(beanId, appName, modName, ejbName); createdCount++; //hope that everything will be OK. } } - + if (toAddResizeTask) { addResizeTaskForImmediateExecution(); } - + if (obj != null) { return obj; } @@ -227,7 +226,7 @@ public Object getObject(Object param) } } } - + private void addResizeTaskForImmediateExecution() { try { ReSizeWork work = new ReSizeWork(); @@ -241,7 +240,7 @@ private void addResizeTaskForImmediateExecution() { addedResizeTask = false; } if(_logger.isLoggable(Level.WARNING)) { - _logger.log(Level.WARNING, + _logger.log(Level.WARNING, "[Pool-"+poolName+"]: Cannot perform " + " pool resize task", ex); } @@ -250,7 +249,7 @@ private void addResizeTaskForImmediateExecution() { /** * Return an object back to the pool. An object that is obtained through - * getObject() must always be returned back to the pool using either + * getObject() must always be returned back to the pool using either * returnObject(obj) or through destroyObject(obj). * @param object */ @@ -260,7 +259,7 @@ public void returnObject(Object object) { if (list.size() < maxPoolSize) { list.add(object); if(this.singletonBeanPool) { - list.notify(); + list.notifyAll(); } return; } else { @@ -268,22 +267,22 @@ public void returnObject(Object object) { destroyedCount++; } } - + try { factory.destroy(object); } catch (Exception ex) { - _logger.log(Level.FINE, "exception in returnObj", ex); + _logger.log(Level.FINE, "exception in returnObj", ex); } } /** - * Destroys an Object. Note that applications should not ignore - * the reference to the object that they got from getObject(). An object - * that is obtained through getObject() must always be returned back to - * the pool using either returnObject(obj) or through destroyObject(obj). - * This method tells that the object should be destroyed and cannot + * Destroys an Object. Note that applications should not ignore + * the reference to the object that they got from getObject(). An object + * that is obtained through getObject() must always be returned back to + * the pool using either returnObject(obj) or through destroyObject(obj). + * This method tells that the object should be destroyed and cannot * be reused. - * @param object + * @param object Object to be destroyed. */ @Override public void destroyObject(Object object) { @@ -291,7 +290,7 @@ public void destroyObject(Object object) { poolProbeNotifier.ejbObjectDestroyedEvent(beanId, appName, modName, ejbName); destroyedCount++; if (this.singletonBeanPool) { - list.notify(); + list.notifyAll(); } } @@ -301,13 +300,13 @@ public void destroyObject(Object object) { _logger.log(Level.FINE, "exception in destroyObject", ex); } } - + /** * Preload the pool with objects. * @param count the number of objects to be added. */ protected void preload(int count) { - + ArrayList instances = new ArrayList<>(count); try { for (int i=0; i this.maxPoolSize) ? this.maxPoolSize : this.steadyPoolSize; - + if (this.steadyPoolSize > 0) { preload(this.steadyPoolSize); } - + } - + /** * Close the pool */ @@ -364,7 +363,7 @@ public void close() { synchronized (list) { if (poolTimerTask != null) { try { - poolTimerTask.cancel(); + poolTimerTask.cancel(); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "[Pool-{0}" @@ -374,14 +373,14 @@ public void close() { //Can safely ignore this!! } } - + if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "[Pool-{0}]: Destroying {1} beans from the pool...", new Object[]{poolName, list.size()}); } - + // since we're calling into ejb code, we need to set context // class loader - ClassLoader origLoader = + ClassLoader origLoader = Utility.setContextClassLoader(containerClassLoader); Object[] array = list.toArray(); @@ -402,7 +401,7 @@ public void close() { if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Pool-{0}]: Pool closed....", poolName); } - list.clear(); + list.clear(); unregisterProbeProvider(); Utility.setContextClassLoader(origLoader); @@ -414,7 +413,7 @@ public void close() { this.poolTimerTask = null; this.containerClassLoader = null; } - + } protected void remove(int count) { @@ -427,7 +426,7 @@ protected void remove(int count) { destroyedCount++; } } - + int sz = removeList.size(); for (int i=0; i removeList = new ArrayList<>(); long populateCount = 0; synchronized (list) { - if ((inResizing == true) || poolClosed) { + if (inResizing || poolClosed) { return; } enteredResizeBlock = true; inResizing = true; - + int curSize = list.size(); if (curSize > steadyPoolSize) { //possible to reduce pool size.... - if ((idleTimeoutInSeconds <= 0) || + if ((idleTimeoutInSeconds <= 0) || (resizeQuantity <= 0)) { return; } - int victimCount = + int victimCount = (curSize > (steadyPoolSize + resizeQuantity) ) ? resizeQuantity : (curSize - steadyPoolSize); long allowedIdleTime = System.currentTimeMillis() - idleTimeoutInSeconds*1000L; if(_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, + _logger.log(Level.FINE, "[Pool-{0}]: Resize:: reducing " + " pool size by: {1}", new Object[]{poolName, victimCount}); } for (int i=0; i 0) { - int sz = removeList.size(); - for (int i=0; i() { - @Override - public java.lang.Object run() { - currentThread.setContextClassLoader(previousClassLoader); - return null; - } - }); + (PrivilegedAction) () -> { + currentThread.setContextClassLoader(previousClassLoader); + return null; + }); } } long endTime = System.currentTimeMillis(); if(_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, "[Pool-{0}]: Resize completed at: {1}; after reSize: {2}", + _logger.log(Level.FINE, "[Pool-{0}]: Resize completed at: {1}; after reSize: {2}", new Object[]{poolName, new java.util.Date(), getAllAttrValues()}); - _logger.log(Level.FINE, "[Pool-{0}]: Resize took: {1} seconds.", + _logger.log(Level.FINE, "[Pool-{0}]: Resize took: {1} seconds.", new Object[]{poolName, (endTime-startTime)/1000.0}); } } @@ -615,11 +610,11 @@ private class ReSizeWork { public void prolog() { } - + public void service() { run(); } - + public void epilog() { } @@ -643,14 +638,14 @@ private class IdleBeanWork { public void prolog() { } - + public void service() { run(); } - + public void epilog() { } - + @Override public void run() { try { @@ -666,12 +661,12 @@ private class PoolResizeTimerTask extends java.util.TimerTask { PoolResizeTimerTask() {} - + @Override public void run() { - + try { - if (addedIdleBeanWork == true) { + if (addedIdleBeanWork) { return; } addedIdleBeanWork = true; @@ -679,11 +674,11 @@ public void run() { EjbContainerUtilImpl.getInstance().addWork(work); } catch (Exception ex) { addedIdleBeanWork = false; - _logger.log(Level.WARNING, + _logger.log(Level.WARNING, "[Pool-"+poolName+"]: Cannot perform " + " pool idle bean cleanup", ex); } - + } } // End of class PoolResizeTimerTask diff --git a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/descriptor/ContainerTransaction.java b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/descriptor/ContainerTransaction.java index d59e661ec63..4f48dd28b39 100644 --- a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/descriptor/ContainerTransaction.java +++ b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/descriptor/ContainerTransaction.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2018] [Payara Foundation and/or its affiliates] package org.glassfish.ejb.deployment.descriptor; @@ -45,7 +46,7 @@ /** * This descriptor represents a specification of a transactional behavior. - * + * * @author Danny Coward */ @@ -65,44 +66,43 @@ public final class ContainerTransaction extends Descriptor { public static final String NEVER = "Never"; private static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl(ContainerTransaction.class); - + /** * Copy constructor. */ public ContainerTransaction(ContainerTransaction other) { - if (other != null) { - this.transactionAttribute = other.transactionAttribute; - this.setDescription(other.getDescription()); - } + if (other != null) { + this.transactionAttribute = other.transactionAttribute; + this.setDescription(other.getDescription()); + } } - + /** - * Create a new transaction descriptor with the given attribute. Throws - * an IllegalArgumentException if the attribute is not an allowed type. + * Create a new transaction descriptor with the given attribute. Throws + * an IllegalArgumentException if the attribute is not an allowed type. * The allowed types are enumeration ny this class. * @param transactionAttribute . * @param description . */ - public ContainerTransaction(String transactionAttribute, + public ContainerTransaction(String transactionAttribute, String description) { super("a Container Transaction", description); boolean isValidAttribute = (NOT_SUPPORTED.equals(transactionAttribute) || SUPPORTS.equals(transactionAttribute) || REQUIRED.equals(transactionAttribute) - || REQUIRED.equals(transactionAttribute) - || REQUIRES_NEW.equals(transactionAttribute) - || MANDATORY.equals(transactionAttribute) - || NEVER.equals(transactionAttribute) ); - if (!isValidAttribute && this.isBoundsChecking()) { - throw new IllegalArgumentException(localStrings.getLocalString( - "enterprise.deployment.exceptionunknowncontainertxtype", - "Unknown ContainerTransaction type: {0}", - new Object[] {transactionAttribute})); - } else { - this.transactionAttribute = transactionAttribute; - } + || REQUIRES_NEW.equals(transactionAttribute) + || MANDATORY.equals(transactionAttribute) + || NEVER.equals(transactionAttribute) ); + if (!isValidAttribute && isBoundsChecking()) { + throw new IllegalArgumentException(localStrings.getLocalString( + "enterprise.deployment.exceptionunknowncontainertxtype", + "Unknown ContainerTransaction type: {0}", + transactionAttribute)); + } else { + this.transactionAttribute = transactionAttribute; + } } - + /** * The transaction attribute that I specify. * @return the transaction attribute. @@ -110,22 +110,20 @@ public ContainerTransaction(String transactionAttribute, public String getTransactionAttribute() { return this.transactionAttribute; } - - /** - * Equality iff the other object is another container transaction with the + + /** + * Equality iff the other object is another container transaction with the * same transaction attribute. * @return true if the objects are equal, false otherwise. */ public boolean equals(Object other) { - if (other != null && other instanceof ContainerTransaction) { - ContainerTransaction otherContainerTransaction = - (ContainerTransaction) other; - if (otherContainerTransaction.getTransactionAttribute().equals( - this.getTransactionAttribute())) { - return true; - } - } - return false; + if (other instanceof ContainerTransaction) { + ContainerTransaction otherContainerTransaction = + (ContainerTransaction) other; + return otherContainerTransaction.getTransactionAttribute().equals( + this.getTransactionAttribute()); + } + return false; } public int hashCode() { @@ -134,12 +132,12 @@ public int hashCode() { return result; } - + /** * Returns a formatted String representing my state. */ public void print(StringBuffer toStringBuffer) { - toStringBuffer.append("Container Transaction: ").append(this.getTransactionAttribute()).append("@").append(this.getDescription()); + toStringBuffer.append("Container Transaction: ").append(this.getTransactionAttribute()).append("@").append(this.getDescription()); } }