ObjectName configObjectName = new ObjectName("jboss.system:type=ServerConfig");
Set set = server.queryNames(configObjectName, null);
if (set.iterator().hasNext()) {
// ServerConfig MBean found
File homeDir = (File) server.getAttribute(configObjectName, "HomeDir");
JBossInstallationInfo installInfo;
try {
installInfo = new JBossInstallationInfo(homeDir);
} catch (IOException e) {
throw new IllegalStateException("Failed to determine installation info for JBoss home dir ["
+ homeDir + "].", e);
}
File configDir = (File) server.getAttribute(configObjectName, "ServerHomeDir");
//if (isEmbeddedInServer(configDir)) {
// return null; // abort - we are embedded, but we're inside the enterprise Server
//}
String configName = (String) server.getAttribute(configObjectName, "ServerName");
String version = (String) server.getAttribute(configObjectName, "SpecificationVersion");
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
// Set the connection type (used by JMX plugin to connect to the MBean server).
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
InternalVMTypeDescriptor.class.getName()));
pluginConfiguration.put(new PropertySimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP, homeDir));
pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CONFIGURATION_PATH_CONFIG_PROP,
configDir));
pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CONFIGURATION_SET_CONFIG_PROP,
configName));
// Now set default values on any props that are still not set.
setPluginConfigurationDefaults(pluginConfiguration);
JBossProductType productType = installInfo.getProductType();
String name = formatServerName(bindAddress, jnpPort, context.getSystemInformation().getHostname(),
configName, productType, isRhqServer(configDir));
String description = productType.NAME +
" server that the RHQ Plugin Container is running within";
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(),