File rarFile = PortletManager.getRepositoryEntry(request, data.getRarURI());
ConnectorDeployable deployable = new ConnectorDeployable(rarFile.toURL());
DeploymentConfiguration config = mgr.createConfiguration(deployable);
final DDBeanRoot ddBeanRoot = deployable.getDDBeanRoot();
Connector15DCBRoot root = (Connector15DCBRoot) config.getDConfigBeanRoot(ddBeanRoot);
ConnectorDCB connector = (ConnectorDCB) root.getDConfigBean(ddBeanRoot.getChildBean(root.getXpaths()[0])[0]);
EnvironmentData environment = new EnvironmentData();
connector.setEnvironment(environment);
org.apache.geronimo.deployment.service.jsr88.Artifact configId = new org.apache.geronimo.deployment.service.jsr88.Artifact();
environment.setConfigId(configId);
configId.setGroupId("console.jms");
configId.setArtifactId(data.instanceName);
configId.setVersion("1.0");
configId.setType("rar");
if(data.dependency != null && !data.dependency.trim().equals("")) {
Artifact artifact = Artifact.create(data.dependency.trim());
org.apache.geronimo.deployment.service.jsr88.Artifact dep = new org.apache.geronimo.deployment.service.jsr88.Artifact();
environment.setDependencies(new org.apache.geronimo.deployment.service.jsr88.Artifact[]{dep});
dep.setArtifactId(artifact.getArtifactId());
if(artifact.getGroupId() != null) {
dep.setGroupId(artifact.getGroupId());
}
if(artifact.getType() != null) {
dep.setType(artifact.getType());
}
if(artifact.getVersion() != null) {
dep.setVersion(artifact.getVersion().toString());
}
}
// Basic settings on RA plan and RA instance
ResourceAdapter ra;
if(connector.getResourceAdapter().length > 0) {
ra = connector.getResourceAdapter(0);
} else {
ra = new ResourceAdapter();
connector.setResourceAdapter(new ResourceAdapter[]{ra});
}
ResourceAdapterInstance raInstance = new ResourceAdapterInstance();
ra.setResourceAdapterInstance(raInstance);
raInstance.setResourceAdapterName(data.instanceName);
for (Iterator it = data.instanceProps.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
String name = getPropertyName((String)entry.getKey(), provider.getInstanceConfigProperties());
for(int i=0; i<raInstance.getConfigPropertySetting().length; i++) {
if(raInstance.getConfigPropertySetting(i).getName().equals(name)) {
raInstance.getConfigPropertySetting(i).setValue((String)entry.getValue());
break;
}
}
}
GBeanLocator workManager = new GBeanLocator();
raInstance.setWorkManager(workManager);
workManager.setGBeanLink(data.workManager); //todo
// Connection Factories
if(data.getConnectionFactoryCount() > 0) {
ConnectionDefinition[] defs = new ConnectionDefinition[data.getConnectionFactoryCount()];
for (int i = 0; i < defs.length; i++) {
defs[i] = new ConnectionDefinition();
}
ra.setConnectionDefinition(defs);
for (int i = 0; i < data.getConnectionFactories().size(); i++) {
JMSConnectionFactoryData factoryData = (JMSConnectionFactoryData) data.getConnectionFactories().get(i);
JMSProviderData.ConnectionDefinition providerData = provider.getConnectionDefinitions()[factoryData.getFactoryType()];
ConnectionDefinition def = defs[i];
def.setConnectionFactoryInterface(providerData.getConnectionFactoryInterface());
ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
def.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
if(providerData.getConnectionFactoryInterface().equals("javax.jms.ConnectionFactory")) {
instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectionFactory","javax.jms.TopicConnectionFactory"});
}
instance.setName(factoryData.getInstanceName());
SinglePool pool = new SinglePool();
instance.getConnectionManager().setPoolSingle(pool);
pool.setMatchOne(true);
pool.setMaxSize(factoryData.getPoolMaxSize());
pool.setMinSize(factoryData.getPoolMinSize());
pool.setBlockingTimeoutMillis(factoryData.getPoolBlockingTimeout());
pool.setIdleTimeoutMinutes(factoryData.getPoolIdleTimeout());
if(factoryData.getTransaction().equals("none")) {
instance.getConnectionManager().setTransactionNone(true);
} else if(factoryData.getTransaction().equals("local")) {
instance.getConnectionManager().setTransactionLocal(true);
} else if(factoryData.getTransaction().equals("xa")) {
instance.getConnectionManager().setTransactionXA(true);
instance.getConnectionManager().setTransactionXACachingThread(factoryData.isXaThreadCaching());
instance.getConnectionManager().setTransactionXACachingTransaction(factoryData.isXaTransactionCaching());
}
for (Iterator it = factoryData.instanceProps.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
String name = getPropertyName((String)entry.getKey(), providerData.getConfigProperties());
for(int j=0; j<instance.getConfigPropertySetting().length; j++) {
if(instance.getConfigPropertySetting(j).getName().equals(name)) {
instance.getConfigPropertySetting(j).setValue((String)entry.getValue());
break;
}
}
}
}
}
// Destinations
DDBean[] ddBeans = connector.getDDBean().getChildBean(connector.getXpaths()[0]);
AdminObjectDCB[] adminDCBs = new AdminObjectDCB[ddBeans.length];
for (int i = 0; i < adminDCBs.length; i++) {
adminDCBs[i] = (AdminObjectDCB) connector.getDConfigBean(ddBeans[i]);
}
for (int i = 0; i < data.getAdminObjects().size(); i++) {
JMSAdminObjectData admin = (JMSAdminObjectData) data.getAdminObjects().get(i);
JMSProviderData.AdminObjectDefinition providerData = provider.getAdminObjectDefinitions()[admin.getDestinationType()];
for (int j = 0; j < adminDCBs.length; j++) {