Package com.sun.ejb
Class EJBUtils
java.lang.Object
com.sun.ejb.EJBUtils
A handy class with static utility methods.
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RemoteBusinessWrapperBasecreateRemoteBusinessObject(ClassLoader loader, String businessInterface, Remote delegate) static RemoteBusinessWrapperBasecreateRemoteBusinessObject(String businessInterface, Remote delegate) static final ObjectdeserializeObject(byte[] data, ClassLoader loader) static final ObjectdeserializeObject(byte[] data, ClassLoader loader, boolean resolveObject) Utility method for deserializing EJBs, primary keys and container-managed fields, all of which may include Remote EJB references, Local refs, JNDI Contexts etc.static voiddeserializeObjectFields(Object instance, ObjectInputStream ois) static voiddeserializeObjectFields(Object instance, ObjectInputStream ois, Object replaceValue, boolean usesSuperClass) static Class<?> generateSEI(ClassLoader loader, Class<?> ejbClass) static StringgetGeneratedOptionalInterfaceName(String ejbClassName) Prepends __EJB31_Generated__ and adds _Intf__ to the simple class name.static org.glassfish.api.naming.SimpleJndiNamegetRemote30HomeJndiName(org.glassfish.api.naming.SimpleJndiName jndiName) static org.glassfish.api.naming.SimpleJndiNamegetRemoteEjbJndiName(boolean businessView, String interfaceName, org.glassfish.api.naming.SimpleJndiName jndiName) static org.glassfish.api.naming.SimpleJndiNamegetRemoteEjbJndiName(com.sun.enterprise.deployment.EjbReferenceDescriptor refDesc) Actual jndi-name under which Remote ejb factory lives depends on whether it's a Remote Home view or Remote Business view.static Class<?> loadGeneratedGenericEJBHomeClass(ClassLoader appClassLoader, Class<?> anchorClass) static Class<?> loadGeneratedRemoteBusinessClasses(ClassLoader appClassLoader, String businessInterfaceName) static voidloadGeneratedRemoteBusinessClasses(String businessInterfaceName) static Class<?> loadGeneratedSerializableClass(ClassLoader loader, Class<?> originalClass) static ObjectlookupRemote30BusinessObject(Object jndiObj, String businessInterface) static ObjectresolveEjbRefObject(com.sun.enterprise.deployment.EjbReferenceDescriptor refDesc, Object jndiObj) static final byte[]serializeObject(Object obj) static final byte[]serializeObject(Object obj, boolean replaceObject) Utility methods for serializing EJBs, primary keys and container-managed fields, all of which may include Remote EJB references, Local refs, JNDI Contexts etc.static voidserializeObjectFields(Object instance, ObjectOutputStream oos) static voidserializeObjectFields(Object instance, ObjectOutputStream oos, boolean usesSuperClass) static boolean
-
Constructor Details
-
EJBUtils
public EJBUtils()
-
-
Method Details
-
serializeObject
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 or not.- Throws:
IOException
-
serializeObject
- Throws:
IOException
-
deserializeObject
public static final Object deserializeObject(byte[] data, ClassLoader loader, boolean resolveObject) throws Exception 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.- Throws:
Exception
-
deserializeObject
- Throws:
Exception
-
useStaticCodegen
public static boolean useStaticCodegen() -
getGeneratedOptionalInterfaceName
Prepends __EJB31_Generated__ and adds _Intf__ to the simple class name.- Parameters:
ejbClassName- full class name
-
getRemoteEjbJndiName
public static org.glassfish.api.naming.SimpleJndiName getRemoteEjbJndiName(com.sun.enterprise.deployment.EjbReferenceDescriptor refDesc) Actual jndi-name under which Remote ejb factory lives depends on whether it's a Remote Home view or Remote Business view. This is necessary since a single session bean can expose both views and the resulting factory objects are different. These semantics are not exposed to the developer-view to keep things simpler. The 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 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.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.
-
getRemote30HomeJndiName
public static org.glassfish.api.naming.SimpleJndiName getRemote30HomeJndiName(org.glassfish.api.naming.SimpleJndiName jndiName) -
getRemoteEjbJndiName
public static org.glassfish.api.naming.SimpleJndiName getRemoteEjbJndiName(boolean businessView, String interfaceName, org.glassfish.api.naming.SimpleJndiName jndiName) -
resolveEjbRefObject
public static Object resolveEjbRefObject(com.sun.enterprise.deployment.EjbReferenceDescriptor refDesc, Object jndiObj) throws NamingException - Throws:
NamingException
-
lookupRemote30BusinessObject
public static Object lookupRemote30BusinessObject(Object jndiObj, String businessInterface) throws NamingException - Throws:
NamingException
-
loadGeneratedSerializableClass
-
loadGeneratedRemoteBusinessClasses
public static void loadGeneratedRemoteBusinessClasses(String businessInterfaceName) throws Exception - Throws:
Exception
-
loadGeneratedRemoteBusinessClasses
public static Class<?> loadGeneratedRemoteBusinessClasses(ClassLoader appClassLoader, String businessInterfaceName) throws Exception - Parameters:
appClassLoader- used to verify existence of classes and for generating too.businessInterfaceName- this class must exist- Returns:
- full class name of the generated remote interface
- Throws:
Exception- if an error occurred while loading class
-
loadGeneratedGenericEJBHomeClass
public static Class<?> loadGeneratedGenericEJBHomeClass(ClassLoader appClassLoader, Class<?> anchorClass) throws GeneratorException - Throws:
GeneratorException
-
generateSEI
- Throws:
GeneratorException
-
createRemoteBusinessObject
public static RemoteBusinessWrapperBase createRemoteBusinessObject(String businessInterface, Remote delegate) throws Exception - Throws:
Exception
-
createRemoteBusinessObject
public static RemoteBusinessWrapperBase createRemoteBusinessObject(ClassLoader loader, String businessInterface, Remote delegate) throws Exception - Throws:
Exception
-
serializeObjectFields
public static void serializeObjectFields(Object instance, ObjectOutputStream oos) throws IOException - Throws:
IOException
-
serializeObjectFields
public static void serializeObjectFields(Object instance, ObjectOutputStream oos, boolean usesSuperClass) throws IOException - Throws:
IOException
-
deserializeObjectFields
public static void deserializeObjectFields(Object instance, ObjectInputStream ois) throws IOException - Throws:
IOException
-
deserializeObjectFields
public static void deserializeObjectFields(Object instance, ObjectInputStream ois, Object replaceValue, boolean usesSuperClass) throws IOException - Throws:
IOException
-