EJBObjectOutputStreampublic class EJBObjectOutputStream extends ObjectOutputStream A class that is used to passivate SFSB conversational state |
Fields Summary |
---|
protected static final Logger | _ejbLogger | protected com.sun.ejb.spi.io.NonSerializableObjectHandler | handler | static final int | EJBID_OFFSET | static final int | INSTANCEKEYLEN_OFFSET | static final int | INSTANCEKEY_OFFSET | private static final byte | HOME_KEY |
Methods Summary |
---|
private java.io.Serializable | getRemoteBusinessObjectFactory(com.sun.ejb.containers.RemoteBusinessWrapperBase remoteBusinessWrapper)
// Create a serializable object with the remote delegate and
// the name of the client wrapper class.
org.omg.CORBA.Object target = (org.omg.CORBA.Object)
remoteBusinessWrapper.getStub();
return getSerializableEJBReference(target,
remoteBusinessWrapper.getBusinessInterfaceName());
| private java.io.Serializable | getSerializableEJBReference(org.omg.CORBA.Object obj, java.lang.String remoteBusinessInterface)
Serializable result = (Serializable) obj;
try {
IOR ior = ((com.sun.corba.ee.spi.orb.ORB)ORBManager.getORB()).getIOR(obj, false);
java.util.Iterator iter = ior.iterator();
byte[] oid = null;
if (iter.hasNext()) {
TaggedProfile profile = (TaggedProfile) iter.next();
ObjectKey objKey = profile.getObjectKey();
oid = objKey.getId().getId();
}
long containerId = -1;
int keyLength = -1;
if ((oid != null) && (oid.length > INSTANCEKEY_OFFSET)) {
containerId = Utility.bytesToLong(oid, EJBID_OFFSET);
//To be really sure that is indeed a ref generated
// by our container we do the following checks
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;
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;
}
return result;
| protected java.lang.Object | replaceObject(java.lang.Object obj)This code is needed to serialize non-Serializable objects that
can be part of a bean's state. See EJB2.0 section 7.4.1.
Object result = obj;
if (obj instanceof IndirectlySerializable) {
result = ((IndirectlySerializable) obj).getSerializableObjectFactory();
} else if (obj instanceof RemoteBusinessWrapperBase) {
result = getRemoteBusinessObjectFactory
((RemoteBusinessWrapperBase)obj);
} else if (StubAdapter.isStub(obj) && StubAdapter.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, null);
} else if ( obj instanceof Serializable ) {
result = obj;
} else if (obj instanceof Context) {
result = new SerializableJNDIContext((Context) obj);
} else {
if (_ejbLogger.isLoggable(Level.FINE)) {
_ejbLogger.log(Level.FINE,
"EJBObjectInputStream_handling_non_serializable_object",
obj.getClass().getName());
}
result = (handler == null)
? obj
: handler.handleNonSerializableObject(obj);
}
return result;
|
|