public void startQBean (Q2 server, ObjectName objectName) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedObjectNameException, MalformedURLException, InstanceAlreadyExistsException, InstanceNotFoundException, MBeanException, NotCompliantMBeanException, InvalidAttributeValueException, ReflectionException { MBeanServer mserver = server.getMBeanServer(); mserver.invoke (objectName, "start", null, null); }
public void destroyQBean (Q2 server, ObjectName objectName, Object obj) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedObjectNameException, MalformedURLException, InstanceAlreadyExistsException, InstanceNotFoundException, MBeanException, NotCompliantMBeanException, InvalidAttributeValueException, ReflectionException { MBeanServer mserver = server.getMBeanServer(); if (obj instanceof QBean) { mserver.invoke (objectName, "stop", null, null); mserver.invoke (objectName, "destroy", null, null); } if (objectName != null) mserver.unregisterMBean (objectName); }
protected void stopService () throws Exception { getServer().getMBeanServer().unregisterMBean (objectName); }
public Object newInstance (String clazz) throws ConfigurationException { try { MBeanServer mserver = q2.getMBeanServer(); return mserver.instantiate (clazz, loaderName); } catch (Exception e) { throw new ConfigurationException (clazz, e); } }
@Override public void exec(CLIContext ctx, String[] args) throws Exception { final ObjectName on = new ObjectName("Q2:type=qbean,service=*"); MBeanServer server = ctx.getCLI().getQ2().getMBeanServer(); Set<ObjectInstance> b = server.queryMBeans(on, null); Iterator<ObjectInstance> it = b.iterator(); while (it.hasNext()) { ObjectInstance instance = it.next(); int status = (Integer) server.getAttribute(instance.getObjectName(), "State"); if (status == QBean.STARTED) { ctx.println(instance.getObjectName().getKeyProperty("service") + "\t\t" + instance.getClassName()); } } }
protected void startService () throws Exception { if (spaceName == null) sp = SpaceFactory.getSpace (); else sp = SpaceFactory.getSpace (spaceName); objectName = new ObjectName (Q2.QBEAN_NAME + getName() + ",space=" + (spaceName != null ? spaceName : "default") ); getServer().getMBeanServer().registerMBean (sp, objectName); }
@SuppressWarnings("PMD.EmptyCatchBlock") public Object instantiate (Q2 server, Element e) throws ReflectionException, MBeanException, InstanceNotFoundException { String clazz = e.getAttributeValue ("class"); if (clazz == null) { try { clazz = classMapping.getString (e.getName()); } catch (MissingResourceException ex) { // no class attribute, no mapping // let MBeanServer do the yelling } } MBeanServer mserver = server.getMBeanServer(); getExtraPath (server.getLoader (), e); return mserver.instantiate (clazz, loaderName); }
MBeanServer server = ctx.getCLI().getQ2().getMBeanServer();
@Test public void testGetMBeanServer() throws Throwable { String[] args = new String[0]; MBeanServer result = new Q2(args).getMBeanServer(); assertNull("result", result); }
MBeanServer mserver = server.getMBeanServer(); if(mserver.isRegistered(objectName)) { throw new InstanceAlreadyExistsException (name+" has already been deployed in another file.");