File rarFile = getRAR(request, data.getRarPath());
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.dbpool");
configId.setVersion("1.0");
configId.setType("rar");
String artifactId = data.name;
// simply replace / with _ if / exists within the artifactId
// this is needed because we don't allow / within the artifactId
artifactId = artifactId.replace('/', '_');
// Let's check whether the artifact exists
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(PortletManager.getKernel());
if (configurationManager.isInstalled(new Artifact(configId.getGroupId(), artifactId,
configId.getVersion(), configId.getType()))) {
artifactId = artifactId + "_" + new Random(System.currentTimeMillis()).nextInt(99);
}
configId.setArtifactId(artifactId);
String[] jars = data.getJars();
int length = jars[jars.length - 1].length() == 0 ? jars.length - 1 : jars.length;
org.apache.geronimo.deployment.service.jsr88.Artifact[] dependencies = new org.apache.geronimo.deployment.service.jsr88.Artifact[length];
for (int i = 0; i < dependencies.length; i++) {
dependencies[i] = new org.apache.geronimo.deployment.service.jsr88.Artifact();
}
environment.setDependencies(dependencies);
for (int i = 0; i < dependencies.length; i++) {
Artifact tmp = Artifact.create(jars[i]);
dependencies[i].setGroupId(tmp.getGroupId());
dependencies[i].setArtifactId(tmp.getArtifactId());
dependencies[i].setVersion(tmp.getVersion().toString());
dependencies[i].setType(tmp.getType());
}
ResourceAdapter adapter = connector.getResourceAdapter()[0];
ConnectionDefinition definition = new ConnectionDefinition();
adapter.setConnectionDefinition(new ConnectionDefinition[]{definition});
definition.setConnectionFactoryInterface("javax.sql.DataSource");
ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
definition.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});