use of com.sun.enterprise.deployment.MessageDestinationDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method updateMDBRuntimeInfo.
/**
* This is the most appropriate time (??) to update the runtime
* info of a 1.3 MDB into 1.4 MDB. <p>
*
* Assumptions : <p>
* 0. Assume it is a 1.3 MDB if no RA mid is specified.
* 1. Use the default system JMS resource adapter. <p>
* 2. The ActivationSpec of the default JMS RA will provide the
* setDestination, setDestinationType, setSubscriptionName methods.
* 3. The jndi-name of the 1.3 MDB is the value for the Destination
* property for the ActivationSpec.
* 4. The ActivationSpec provides setter methods for the properties
* defined in the CF that corresponds to the mdb-connection-factory
* JNDI name.
*
* @param descriptor_
* @param poolDescriptor
* @throws com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
*/
@Override
public void updateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor) throws ConnectorRuntimeException {
String jndiName = descriptor_.getJndiName();
if (jndiName == null || "".equals(jndiName)) {
MessageDestinationDescriptor destDescriptor = descriptor_.getMessageDestination();
if (destDescriptor != null)
jndiName = destDescriptor.getJndiName();
}
String destinationLookup = descriptor_.getActivationConfigValue("destinationLookup");
String destinationProp = descriptor_.getActivationConfigValue("destination");
if (destinationLookup == null && destinationProp == null && (jndiName == null || "".equals(jndiName))) {
if (_logger.isLoggable(Level.SEVERE)) {
_logger.log(Level.SEVERE, JMSLoggerInfo.ERROR_IN_DD);
}
String msg = sm.getString("ajra.error_in_dd");
throw new ConnectorRuntimeException(msg);
}
String resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
descriptor_.setResourceAdapterMid(resourceAdapterMid);
if (destinationLookup == null && destinationProp == null) {
String appName = descriptor_.getApplication().getAppName();
String moduleName = ConnectorsUtil.getModuleName(descriptor_);
JMSDestinationDefinitionDescriptor destination = getJMSDestinationFromDescriptor(jndiName, descriptor_);
String destName = null;
if (isValidDestination(destination)) {
destName = destination.getDestinationName();
} else {
destName = getPhysicalDestinationFromConfiguration(jndiName, appName, moduleName);
}
// 1.3 jndi-name ==> 1.4 setDestination
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION, destName, null));
// XXX Do we really need this???
if (descriptor_.getDestinationType() != null && !"".equals(descriptor_.getDestinationType())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, descriptor_.getDestinationType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { descriptor_.getDestinationType(), jndiName, descriptor_.getName() });
}
} else if (isValidDestination(destination) && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(destination.getResourceAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, destination.getInterfaceName(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { destination.getInterfaceName(), destination.getName(), descriptor_.getName() });
}
} else {
/*
* If destination type is not provided by the MDB component
* [typically used by EJB3.0 styled MDBs which create MDBs without
* a destination type activation-config property] and the MDB is for
* the default JMS RA, attempt to infer the destination type by trying
* to find out if there has been any JMS destination resource already
* defined for default JMS RA. This is a best attempt guess and if there
* are no JMS destination resources/admin-objects defined, AS would pass
* the properties as defined by the MDB.
*/
try {
AdminObjectResource aor = (AdminObjectResource) ResourcesUtil.createInstance().getResource(jndiName, appName, moduleName, AdminObjectResource.class);
if (aor != null && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(aor.getResAdapter())) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, aor.getResType(), null));
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { aor.getResType(), aor.getJndiName(), descriptor_.getName() });
}
}
} catch (Exception e) {
}
}
}
// 1.3 durable-subscription-name == 1.4 setSubscriptionName
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(SUBSCRIPTION_NAME, descriptor_.getDurableSubscriptionName(), null));
String mdbCF = null;
try {
mdbCF = descriptor_.getMdbConnectionFactoryJndiName();
} catch (NullPointerException ne) {
// Dont process connection factory.
}
if (mdbCF != null && !"".equals(mdbCF)) {
setValuesFromConfiguration(mdbCF, descriptor_);
}
if (poolDescriptor != null) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MAXPOOLSIZE, "" + poolDescriptor.getMaxPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MINPOOLSIZE, "" + poolDescriptor.getSteadyPoolSize(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZECOUNT, "" + poolDescriptor.getPoolResizeQuantity(), "", "java.lang.Integer"));
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZETIMEOUT, "" + poolDescriptor.getPoolIdleTimeoutInSeconds(), "", "java.lang.Integer"));
/**
* The runtime activation config property holds all the
* vendor specific properties, unfortunately the vendor
* specific way of configuring exception count and the
* standard way of configuring redelivery attempts is
* through the same property REDELIVERYCOUNT . So, we first
* check if the user (MDB assember) has configured a value
* if not we set the one from mdb-container props
* We have to check for both cases here because it has been
* documented as "endpointExceptionRedeliveryAttempts" but
* used in the code as "EndpointExceptionRedeliveryAttempts"
*/
if ((descriptor_.getActivationConfigValue(REDELIVERYCOUNT) == null) && (descriptor_.getActivationConfigValue(LOWERCASE_REDELIVERYCOUNT) == null)) {
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(REDELIVERYCOUNT, "" + MdbContainerProps.getMaxRuntimeExceptions(), "", "java.lang.Integer"));
}
}
// Set SE/EE specific MQ-RA ActivationSpec properties
try {
boolean clustered = isClustered();
if (_logger.isLoggable(Level.FINE))
logFine("Are we in a Clustered contained ? " + clustered);
if (clustered)
setClusterActivationSpecProperties(descriptor_);
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
Aggregations