Does anyone have some JMX code for creating a new websphere datasource?
I'm trying to update the password on a websphere J2C da开发者_如何学JAVAtasource connector using JMX. Does anyone have any source or tips ?
cheers,
Trevor
Here is the code to get the list of datasources configures using JMX:
public synchronized List<String> getDBPools() {
return (List) WSSubject.doAs(this.adminSubject,
new java.security.PrivilegedAction() {
public Object run() {
// Subject is associated with the current thread context
return java.security.AccessController
.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
List<String> result = new ArrayList<String>();
try {
Session session = new Session();
// Get the ConfigService
// implementation.
ConfigService configService = ConfigServiceFactory
.getConfigService();
ObjectName dsType = ConfigServiceHelper
.createObjectName(null,
"DataSource", null);
ObjectName[] datasources = configService
.queryConfigObjects(
session, null,
dsType, null);
for (int i = 0; i < datasources.length; i++) {
ObjectName dsObject = datasources[i];
log
.debug("OBJ NAME = "
+ dsObject
.getKeyProperty(SystemAttributes._WEBSPHERE_CONFIG_DATA_DISPLAY_NAME));
log
.debug("OBJ ID = "
+ dsObject
.getKeyProperty(SystemAttributes._WEBSPHERE_CONFIG_DATA_ID));
log
.debug("OBJ TYPE = "
+ dsObject
.getKeyProperty(SystemAttributes._WEBSPHERE_CONFIG_DATA_TYPE));
String dsName = dsObject
.getKeyProperty(SystemAttributes._WEBSPHERE_CONFIG_DATA_DISPLAY_NAME);
if (!dsName
.equals("DefaultEJBTimerDataSource")) {
result.add(dsName);
}
}
} catch (ConfigServiceException ex) {
log
.error(
"Error in JMX Query string",
ex);
} catch (ConnectorException ex) {
log
.error(
"Error connecting to the admin service",
ex);
}
return result;
}
});
}
});
}
精彩评论