native management api - read-only access types?
brianstark Nov 9, 2011 8:33 PMHello,
Is there any way to configure JBoss AS 7 to allow an attribute to be read-write instead of just read-only?
I am in the middle of migrating a JBoss 3.2 application to JBoss 7.0.2 and have run into a roadblock with the native management API.
The application in question has its own web-based admin front-end that allows the user to specifiy a different port number for use with the data source URL. I am trying to set the "connection-url" attribute of the data-source, but I noticed that it has an access-type of "read-only". My code looks like this:
ModelControllerClient client = ModelControllerClient.Factory.create(hostname, port);
ModelNode op = new ModelNode();
op.get("operation").set("write-attribute");
ModelNode address = op.get("address");
address.add("subsystem", "datasources");
address.add("data-source", dataSourceName);
op.get("name").set("connection-url");
op.get("value").set(theURL);
ModelNode returnValue = client.execute(op);
logger.info("Result: " + returnValue);
I tried making the change via the JBoss Management Console, but also run into the same roadblock. The error message is:
Internal Server Error
{
"outcome" => "failed",
"result" => {"step-1" => {
"outcome" => "failed",
"failure-description" => "Attribute connection-url is not writeable",
"rolled-back" => true
}},
"failure-description" => {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "Attribute connection-url is not writeable"}},
"rolled-back" => true
}
I get I can't update something that is marked read-only, but the odd thing is that the "enabled" attribute is also shown to be "read-only", yet I can use the JBoss Management Console to mark a datasource as enabled/disabled.. So, in effect, the JBoss Management Console is working with a "read-write" version of the enabled attribute. How is that possible? The native management API is not very useful for configuring data sources as the majority of the attributes have an access type of "read-only". Am I missing something?
Reference code to describe the datasources:
ModelControllerClient client = ModelControllerClient.Factory.create(hostname, port);
ModelNode op = new ModelNode();
op.get("operation").set("read-resource-description");
ModelNode address = op.get("address");
address.add("subsystem", "datasources");
ModelNode returnValue = client.execute(op);
logger.info("Result: " + returnValue);
thank you,
Brian