use of javax.management.MalformedObjectNameException in project alliance by codice.
the class StreamMonitorHelper method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(StreamMonitorHelper.class.getName() + ":service=stream");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create FMV Stream Monitor Helper MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered FMV Stream Monitor Helper MBean under object name: {}", objectName);
} catch (InstanceAlreadyExistsException e) {
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Re-registered FMV Stream Monitor Helper MBean", e);
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
}
}
use of javax.management.MalformedObjectNameException in project core by weld.
the class ProbeExtension method afterDeploymentValidation.
public void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager);
probe.init(manager);
if (isJMXSupportEnabled(manager)) {
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new ProbeDynamicMBean(jsonDataProvider, JsonDataProvider.class), constructProbeJsonDataMBeanName(manager, probe));
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
event.addDeploymentProblem(ProbeLogger.LOG.unableToRegisterMBean(JsonDataProvider.class, manager.getContextId(), e));
}
}
addContainerLifecycleEvent(event, null, beanManager);
exportDataIfNeeded(manager);
}
use of javax.management.MalformedObjectNameException in project narayana by jbosstm.
the class BTAdmin method main.
public static void main(String[] args) throws IOException {
int exitStatus = -1;
if (System.getProperty("log4j.configuration") == null && !new File("log4cxx.properties").exists() && !new File("log4j.xml").exists()) {
BasicConfigurator.configure();
log.info("BasicConfigurator ran");
}
boolean interactive = args.length == 0;
boolean done = false;
try {
CommandHandler commandHandler = new CommandHandler();
do {
if (interactive) {
System.out.print("> ");
// split on white space
args = br.readLine().split("\\s+");
}
try {
exitStatus = commandHandler.handleCommand(args);
if (exitStatus == 0) {
log.trace("Command was successful");
} else {
log.trace("Command failed");
}
if (args.length > 0 && args[0].equals("quit")) {
done = true;
}
} catch (Exception e) {
log.error("Could not invoke command: " + e.getMessage(), e);
}
} while (interactive && !done);
} catch (MalformedObjectNameException e) {
log.error("MBean name was badly structured: " + e.getMessage(), e);
} catch (ConfigurationException e) {
log.error("BlackTie Configuration invalid: " + e.getMessage(), e);
}
if (!interactive) {
// Exit the launcher with the value of the command
// This must be a halt so that any executed servers are not reaped
// by the JVM. If spawned servers die when launcher does we will
// need to investigate using setppid or something to set the
// spawned process as daemons
Runtime.getRuntime().halt(exitStatus);
}
}
use of javax.management.MalformedObjectNameException in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method setUp.
@Before
public void setUp() {
try {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
new JMXHelper().unregister(objectName);
} catch (MalformedObjectNameException | InstanceNotFoundException e) {
// Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
}
registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
// Creating the configuration and the registration request of the proxy (node)
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
sauceLabsProxy = SauceLabsRemoteProxy.getNewInstance(request, registry);
// we need to register a DockerSeleniumStarter proxy to have a proper functioning SauceLabsProxy
request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
// We add both nodes to the registry
registry.add(sauceLabsProxy);
registry.add(dsStarterProxy);
}
use of javax.management.MalformedObjectNameException in project zalenium by zalando.
the class TestingBotRemoteProxyTest method setUp.
@SuppressWarnings("ConstantConditions")
@Before
public void setUp() throws IOException {
try {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
new JMXHelper().unregister(objectName);
} catch (MalformedObjectNameException | InstanceNotFoundException e) {
// Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
}
registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
// Creating the configuration and the registration request of the proxy (node)
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30002, TestingBotRemoteProxy.class.getCanonicalName());
JsonElement informationSample = TestUtils.getTestInformationSample("testingbot_testinformation.json");
String userInfoUrl = "https://api.testingbot.com/v1/user";
Environment env = new Environment();
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(userInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(null);
String mockTestInfoUrl = "https://api.testingbot.com/v1/tests/2cf5d115-ca6f-4bc4-bc06-a4fca00836ce";
when(commonProxyUtilities.readJSONFromUrl(mockTestInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(informationSample);
TestingBotRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
testingBotProxy = TestingBotRemoteProxy.getNewInstance(request, registry);
// we need to register a DockerSeleniumStarter proxy to have a proper functioning testingBotProxy
request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
// Temporal folder for dashboard files
TestUtils.ensureRequiredInputFilesExist(temporaryFolder);
// We add both nodes to the registry
registry.add(testingBotProxy);
registry.add(dsStarterProxy);
}
Aggregations