* @return if successful, the Resource details, otherwise, null
*/
@Nullable
public DiscoveredResourceDetails discoverInProcessJBossAS(ResourceDiscoveryContext discoveryContext) {
ProfileServiceConnectionProvider connectionProvider = new LocalProfileServiceConnectionProvider();
ProfileServiceConnection connection;
try {
connection = connectionProvider.connect();
} catch (Exception e) {
// This most likely just means we're not embedded inside a JBoss 5.x or 6.x app server instance.
log.debug("Unable to connect to in-process ProfileService.", e);
return null;
}
ManagementView managementView = connection.getManagementView();
ManagedComponent serverConfigComponent = ManagedComponentUtils.getSingletonManagedComponent(managementView,
new ComponentType("MCBean", "ServerConfig"));
String serverName = (String) ManagedComponentUtils.getSimplePropertyValue(serverConfigComponent, "serverName");
// serverHomeDir is the full path to the instance's configuration dir, e.g. "/opt/jboss-5.1.0.GA/server/default";