TestServiceMetaDataICF tsicf = new TestServiceMetaDataICF();
mof.setInstanceClassFactory(TestServiceMetaData.class, tsicf);
// Deploy a datasource with local and xa factories
Deployment ctx1 = createSimpleDeployment("deployment1");
MutableAttachments a1 = (MutableAttachments) ctx1.getPredeterminedManagedObjects();
DSMetaData dsmd = new DSMetaData();
dsmd.setDiplayName("deployment1 DS");
// The base LocalDataSourceMeta
LocalDataSourceMetaData ds = new LocalDataSourceMetaData();
ds.setJndiName("java:DefaultDS1");
ds.setMaxSize(100);
ds.setMinSize(10);
ds.setPassword("password1".toCharArray());
ds.setUsername("username1");
SecMetaData smd1 = new SecMetaData();
smd1.setDomain("java:/jaas/domain1");
ds.setSecurityMetaData(smd1);
ArrayList<ConnMetaData> deployments = new ArrayList<ConnMetaData>();
deployments.add(ds);
dsmd.setDeployments(deployments);
a1.addAttachment(DSMetaData.class, dsmd);
// The mbeans associated with the local DS
TestServiceMetaData localMBeans = new TestServiceMetaData();
localMBeans.setObjectName("jboss.jca:service.SecurityDomain");
localMBeans.setCode(SimpleMetaData.class.getName());
ArrayList<TestServiceAttributeMetaData> localMBeanAttrs = new ArrayList<TestServiceAttributeMetaData>();
localMBeanAttrs.add(new TestServiceAttributeMetaData("java:/jaas/domain1", "domain"));
localMBeanAttrs.add(new TestServiceAttributeMetaData("java:DefaultDS1", "jndiName"));
TestServiceAttributeMetaData typeAttribute = new TestServiceAttributeMetaData(SimpleMetaData.SecurityDeploymentType.NONE, "type");
localMBeanAttrs.add(typeAttribute);
localMBeans.setAttributes(localMBeanAttrs);
a1.addAttachment(TestServiceMetaData.class, localMBeans);
ps.addDeployment(ctx1);
Deployment ctx2 = createSimpleDeployment("deployment2");
MutableAttachments a2 = (MutableAttachments)ctx2.getPredeterminedManagedObjects();
TestServiceMetaData localMBeans2 = new TestServiceMetaData();
localMBeans2.setCode(RuntimeComponentMetaData.class.getName());
ArrayList<TestServiceAttributeMetaData> localMBeanAttrs2 = new ArrayList<TestServiceAttributeMetaData>();
localMBeanAttrs2.add(new TestServiceAttributeMetaData("java:/jaas/domain2", "domain"));
CustomName customName = new CustomName("runtime-name-1");
localMBeanAttrs2.add(new TestServiceAttributeMetaData(customName, "customName"));
localMBeans2.setAttributes(localMBeanAttrs2);
a2.addAttachment(TestServiceMetaData.class, localMBeans2);
ps.addDeployment(ctx2);
ps.process();
ManagedObject mo = ps.getManagedObject("java:/jaas/domain1/SecurityDomain");