// Activation Spec object
String activationSpecName = getActivationSpec(messageDrivenBean);
// get Activation spec object
ActivationSpec activationSpec = null;
try {
activationSpec = (ActivationSpec) new InitialContext().lookup(activationSpecName);
} catch (NamingException e1) {
throw new EZBContainerException("Cannot get the activation spec with the name '"
+ activationSpecName + "'.", e1);
}
// Marshall the given object in order to be sure to get a new Object each time
if (activationSpec instanceof Serializable) {
byte[] byteArgs;
try {
byteArgs = storeObject((Serializable) activationSpec);
} catch (IOException e) {
throw new EZBContainerException("Cannot serialize the activation spec object '" + activationSpec + "'.", e);
}
// Then load object from this array of bytes
try {
activationSpec = (ActivationSpec) loadObject(byteArgs);
} catch (IOException e) {
throw new EZBContainerException("Cannot load activation spec from the serialized object.", e);
} catch (ClassNotFoundException e) {
throw new EZBContainerException("Cannot load activation spec from the serialized object.", e);
}
}
// get ResourceAdapter object
ResourceAdapter resourceAdapter = null;
try {
resourceAdapter = MDBResourceAdapterHelper.getResourceAdapter(activationSpecName,
(Embedded) getConfiguration().getEZBServer());
} catch (ResourceException e) {
throw new EZBContainerException("Cannot get the resource adapter for this MDB factory", e);
}
// Associate Resource Adapter with ActivationSpec object (if not set)
if (activationSpec.getResourceAdapter() == null) {
try {
activationSpec.setResourceAdapter(resourceAdapter);
} catch (ResourceException e) {
throw new EZBContainerException("Cannot associate resource adapter with activation spec object", e);
}
}