String resourceAdapterName = geronimoResourceAdapter.getResourceadapterInstance().getResourceadapterName();
// Create the resource adapter gbean
GBeanInfoBuilder resourceAdapterInfoFactory = new GBeanInfoBuilder("org.apache.geronimo.connector.ResourceAdapterWrapper", cl);
ConfigProperty[] configProperties = getConfigProperties(resourceadapter.getConfigPropertyArray(), geronimoResourceAdapter.getResourceadapterInstance().getConfigPropertySettingArray());
GBeanMBean resourceAdapterGBean = setUpDynamicGBean(resourceAdapterInfoFactory, configProperties, cl);
// set the resource adapter class and activationSpec info map
try {
resourceAdapterGBean.setAttribute("resourceAdapterClass", cl.loadClass(resourceadapter.getResourceadapterClass().getStringValue()));
if (resourceadapter.isSetInboundResourceadapter() && resourceadapter.getInboundResourceadapter().isSetMessageadapter()) {
//get the ActivationSpec metadata as GBeanInfos
Map activationSpecInfoMap = getActivationSpecInfoMap(resourceadapter.getInboundResourceadapter().getMessageadapter().getMessagelistenerArray(), cl);
resourceAdapterGBean.setAttribute("activationSpecInfoMap", activationSpecInfoMap);
}
} catch (Exception e) {
throw new DeploymentException("Could not set ResourceAdapterClass", e);
}
// set the work manager name
ObjectName workManagerName = null;
try {
workManagerName = NameFactory.getComponentName(null, null, geronimoResourceAdapter.getResourceadapterInstance().getWorkmanagerName().trim(), NameFactory.JCA_WORK_MANAGER, moduleJ2eeContext);
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct work manager object name", e);
}
resourceAdapterGBean.setReferencePattern("WorkManager", workManagerName);
// add it
try {
resourceAdapterObjectName = NameFactory.getResourceComponentName(null, null, null, null, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER, moduleJ2eeContext);
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct resource adapter object name", e);
}
earContext.addGBean(resourceAdapterObjectName, resourceAdapterGBean);
}
//
// Outbound Managed Connectopn Factories (think JDBC data source or JMS connection factory)
//
// first we need a map of the published outbound adaptors by connection factory interface type
Map connectionDefinitions = new HashMap();
if (resourceadapter.isSetOutboundResourceadapter()) {
for (int j = 0; j < resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; j++) {
ConnectionDefinitionType connectionDefinition = resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray(j);
connectionDefinitions.put(connectionDefinition.getConnectionfactoryInterface().getStringValue(), connectionDefinition);
}
// ManagedConnectionFactory setup
if (geronimoResourceAdapter.isSetOutboundResourceadapter()) {
for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) {
GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i);
assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
String connectionFactoryInterfaceName = geronimoConnectionDefinition.getConnectionfactoryInterface().getStringValue();
ConnectionDefinitionType connectionDefinition = (ConnectionDefinitionType) connectionDefinitions.get(connectionFactoryInterfaceName);
if (connectionDefinition == null) {
throw new DeploymentException("No connection definition for ConnectionFactory class: " + connectionFactoryInterfaceName);
}
String managedConnectionFactoryClass = connectionDefinition.getManagedconnectionfactoryClass().getStringValue().trim();
String connectionFactoryInterface = connectionDefinition.getConnectionfactoryInterface().getStringValue().trim();
String connectionFactoryImplClass = connectionDefinition.getConnectionfactoryImplClass().getStringValue().trim();
String connectionInterface = connectionDefinition.getConnectionInterface().getStringValue().trim();
String connectionImplClass = connectionDefinition.getConnectionImplClass().getStringValue().trim();
for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) {
GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j];
ConfigProperty[] configProperties = getConfigProperties(connectionDefinition.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray());
addOutboundGBeans(earContext, moduleJ2eeContext, resourceAdapterObjectName, connectionfactoryInstance, configProperties, managedConnectionFactoryClass, connectionFactoryInterface, connectionFactoryImplClass, connectionInterface, connectionImplClass, transactionSupport, cl);
}
}
}
}
}
//
// admin objects (think message queuse and topics)
//
// first we need a map of the published admin objects by interface type
Map adminObjectInterfaceMap = new HashMap();
for (int i = 0; i < resourceadapter.getAdminobjectArray().length; i++) {
AdminobjectType adminobject = resourceadapter.getAdminobjectArray()[i];
adminObjectInterfaceMap.put(adminobject.getAdminobjectInterface().getStringValue(), adminobject);
}
// add configured admin objects
for (int i = 0; i < geronimoConnector.getAdminobjectArray().length; i++) {
GerAdminobjectType gerAdminObject = geronimoConnector.getAdminobjectArray()[i];
String adminObjectInterface = gerAdminObject.getAdminobjectInterface().getStringValue();
AdminobjectType adminObject = (AdminobjectType) adminObjectInterfaceMap.get(adminObjectInterface);
if (adminObject == null) {
throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface);
}
for (int j = 0; j < gerAdminObject.getAdminobjectInstanceArray().length; j++) {
GerAdminobjectInstanceType gerAdminObjectInstance = gerAdminObject.getAdminobjectInstanceArray()[j];
// create the adminObjectGBean
GBeanInfoBuilder adminObjectInfoFactory = new GBeanInfoBuilder("org.apache.geronimo.connector.AdminObjectWrapper", cl);
ConfigProperty[] configProperties = getConfigProperties(adminObject.getConfigPropertyArray(), gerAdminObjectInstance.getConfigPropertySettingArray());
GBeanMBean adminObjectGBean = setUpDynamicGBean(adminObjectInfoFactory, configProperties, cl);
// set the standard properties
try {
adminObjectGBean.setAttribute("adminObjectInterface", cl.loadClass(adminObjectInterface));
adminObjectGBean.setAttribute("adminObjectClass", cl.loadClass(adminObject.getAdminobjectClass().getStringValue()));
} catch (Exception e) {
throw new DeploymentException("Could not initialize AdminObject", e);
}
// add it