3 Replies Latest reply: Nov 14, 2009 4:36 PM by Ramesh Reddy RSS

How can I programaticlly add "config-property" to a Connecti

Ramesh Reddy Master

I am trying to create a connection factory using a program. I could add all the defined properties that are defined on "DeploymentTemplateInfo" object for that ConnectionFactory. I also wanted to add few "config-property" properties, but the resulting template does not seem to write these properties. Here is the sample code I am using

public void addConnectionFactory(String deploymentName, Properties properties) throws AdminException{
 try {

 DeploymentTemplateInfo info = getView().getTemplate("NoTxConnectionFactoryTemplate");

 Map<String, ManagedProperty> propertyMap = info.getProperties();
 for (String key:propertyMap.keySet()) {
 String v = properties.getProperty(key);
 if (v != null) {
 ManagedProperty p = propertyMap.get(key);
 p.setValue(SimpleValueSupport.wrap(v));
 }
 }

 DefaultFieldsImpl fields = new DefaultFieldsImpl("my-property");
 fields.setDescription("My Custom Property");
 fields.setMetaType(SimpleMetaType.STRING);
 fields.setValue(SimpleValueSupport.wrap(properties.getProperty("my-property")));
 fields.setField(Fields.READ_ONLY, Boolean.FALSE);
 ManagedPropertyImpl mp = new ManagedPropertyImpl(fields);

 info.getProperties().put("config-property", mp);
 getView().applyTemplate(deploymentName, info);

 } catch(Exception e) {
 // handle exception
 }
}


surely the above code does not work. Can somebody please tell me how I can insert a "config-property" such that when the "-ds.xml" file is written it is written in there.

Thank you.

Ramesh..