public static void registerMBean(final String mBeanObjectName,final Object mBean) { try { final ObjectName name = new ObjectName(mBeanObjectName); mbs.registerMBean(mBean, name); } catch (MalformedObjectNameException badObjectName) { logger.error(badObjectName.getMessage()); } catch (InstanceAlreadyExistsException duplicateMBeanInstance) { logger.error(duplicateMBeanInstance.getMessage()); } catch (MBeanRegistrationException mbeanRegistrationProblem) { logger.error(mbeanRegistrationProblem.getMessage()); } catch (NotCompliantMBeanException badMBean) { logger.error(badMBean.getMessage()); } }
public boolean init() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, FileNotFoundException, NoSuchElementException, IOException { //Initialize SPARQL 1.1 processing service properties endpointProperties = new SPARQL11Properties("endpoint.jpar"); //Initialize SPARQL 1.1 SE processing service properties engineProperties = new EngineProperties("engine.jpar"); //SPARQL 1.1 SE request processor processor = new Processor(endpointProperties); //SPARQL 1.1 SE request scheduler scheduler = new Scheduler(engineProperties,processor); //SPARQL 1.1 Protocol handlers httpGate = new HTTPGate(engineProperties,scheduler); httpsGate = new HTTPSGate(engineProperties,scheduler,am); //SPARQL 1.1 SE Protocol handler for WebSocket based subscriptions websocketApp = new WSGate(engineProperties,scheduler); secureWebsocketApp = new WSSGate(engineProperties,scheduler,am); return true; }
private static ObjectName preRegister( DynamicMBean mbean, MBeanServer mbs, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException { ObjectName newName = null; try { if (mbean instanceof MBeanRegistration) newName = ((MBeanRegistration) mbean).preRegister(mbs, name); } catch (Throwable t) { throwMBeanRegistrationException(t, "in preRegister method"); } if (newName != null) return newName; else return name; }
/** * Registers a DynamicMBean. */ private static void addDynamicMBean(final MBeanServer mbs, final DynamicMBean dmbean, final ObjectName on) { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { mbs.registerMBean(dmbean, on); return null; } }); } catch (PrivilegedActionException e) { throw new RuntimeException(e.getException()); } }
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { return createMBean(className, name, null, true, params, signature); } catch (InstanceNotFoundException e) { /* Can only happen if loaderName doesn't exist, but we just passed null, so we shouldn't get this exception. */ throw EnvHelp.initCause( new IllegalArgumentException("Unexpected exception: " + e), e); } }
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // ------------------------------ // ------------------------------ Class<?> theClass = object.getClass(); Introspector.checkCompliance(theClass); final String infoClassName = getNewMBeanClassName(object); checkMBeanPermission(infoClassName, null, name, "registerMBean"); checkMBeanTrustPermission(theClass); return registerObject(infoClassName, object, name); }
private void doTest(JMXConnector connector) throws IOException, MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException { MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ObjectName objName = new ObjectName("com.redhat.test.jmx:type=NameMBean"); System.out.println("DEBUG: Calling createMBean"); mbsc.createMBean(Name.class.getName(), objName); System.out.println("DEBUG: Calling setAttributes"); AttributeList attList = new AttributeList(); attList.add(new Attribute("FirstName", ANY_NAME)); attList.add(new Attribute("LastName", ANY_NAME)); mbsc.setAttributes(objName, attList); }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name); } }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, params, signature); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, params, signature); } }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, loaderName); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, loaderName); } }
private static void throwMBeanRegistrationException(Throwable t, String where) throws MBeanRegistrationException { if (t instanceof RuntimeException) { throw new RuntimeMBeanException((RuntimeException)t, "RuntimeException thrown " + where); } else if (t instanceof Error) { throw new RuntimeErrorException((Error)t, "Error thrown " + where); } else if (t instanceof MBeanRegistrationException) { throw (MBeanRegistrationException)t; } else if (t instanceof Exception) { throw new MBeanRegistrationException((Exception)t, "Exception thrown " + where); } else // neither Error nor Exception?? throw new RuntimeException(t); }
public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException { if (logger.debugOn()) logger.debug("unregisterMBean", "name=" + name); final ClassLoader old = pushDefaultClassLoader(); try { connection.unregisterMBean(name, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.unregisterMBean(name, delegationSubject); } finally { popDefaultClassLoader(old); } }
public Scheduler(EngineProperties properties,Processor processor) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { requestHandler = new RequestResponseHandler(properties); tokenHandler = new TokenHandler(properties); if (processor == null) logger.error("Processor is null"); else { this.processor = processor; this.processor.addObserver(this); } }
public static void main(String[] args) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, FileNotFoundException, NoSuchElementException, IOException { System.out.println("##########################################################################################"); System.out.println("# SEPA Engine Ver 0.6 Copyright (C) 2016-2017 #"); System.out.println("# University of Bologna (Italy) #"); System.out.println("# #"); System.out.println("# This program comes with ABSOLUTELY NO WARRANTY #"); System.out.println("# This is free software, and you are welcome to redistribute it under certain conditions #"); System.out.println("# GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007 #"); System.out.println("# #"); System.out.println("# GitHub: https://github.com/vaimee/sepatools #"); System.out.println("# Web: http://wot.arces.unibo.it #"); System.out.println("##########################################################################################"); System.out.println(""); System.out.println("Dependencies"); System.out.println("com.google.code.gson 2.8.0 Apache 2.0"); System.out.println("com.nimbusds 4.34.2 The Apache Software License, Version 2.0"); System.out.println("commons-io 2.5 Apache License, Version 2.0"); System.out.println("commons-logging 1.2 The Apache Software License, Version 2.0"); System.out.println("org.apache.httpcomponents 4.5.3 Apache License, Version 2.0"); System.out.println("org.apache.httpcomponents 4.4.6 Apache License, Version 2.0"); System.out.println("org.apache.logging.log4j 2.8.1 Apache License, Version 2.0"); System.out.println("org.bouncycastle 1.56 Bouncy Castle Licence"); System.out.println("org.eclipse.paho 1.1.1 Eclipse Public License - Version 1.0"); System.out.println("org.glassfish.grizzly 2.3.30 CDDL+GPL"); System.out.println("org.glassfish.tyrus.bundles 1.13.1 Dual license consisting of the CDDL v1.1 and GPL v2"); System.out.println("org.jdom 2.0.6 Similar to Apache License but with the acknowledgment clause removed"); System.out.println(""); //Engine creation and initialization Engine engine = new Engine(); engine.init(); //Starting main engine thread engine.start(); }
/** * * @param flag Flag to be exposed through JMX. * @param source MBean or ObjectName of the object where the flag resides. * @param nbs NotificationBroadcasterSupport through which the events will be send. */ public JMXFlagDecorator(Flag<T> flag, ObjectName source, MBeanServer mbs, String flagName) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { this.flag = flag; this.source = source; this.flagName = flagName; ObjectName name = PogamutJMX.getObjectName(source, flagName, PogamutJMX.FLAGS_SUBTYPE); mbs.registerMBean(this, name); flag.addListener(listener); }
@Override public void handleNotification(final Notification notification, final Object handback) { if (notification instanceof MBeanServerNotification && notification.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION) && ((MBeanServerNotification) notification).getMBeanName().equals(objectNameInternal)) { try { internalServer.unregisterMBean(objectNameInternal); configMBeanServer.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this); } catch (MBeanRegistrationException | ListenerNotFoundException | InstanceNotFoundException e) { throw new IllegalStateException(e); } } }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
/** * build jmx controller for client. */ private void buildClientJmxController(){ try{ final ClientJmxController clientJmxController = new ClientJmxController("de.b4sh.byter.client","Controller",this); final JMXBeanWrapper wrapper = new JMXBeanWrapper(clientJmxController); this.mbs.registerMBean(wrapper, clientJmxController.getObjectName()); } catch (IntrospectionException | NotCompliantMBeanException | MBeanRegistrationException | InstanceAlreadyExistsException e) { log.log(Level.WARNING,"Error during initialisation or registration of ClientDiscMBean." + " see Stracktrace for more Information",e); } }
/** * Call <code>checkWrite()</code>, then forward this method to the * wrapped object. */ public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { checkWrite(); return getMBeanServer().registerMBean(object, name); }
/** * Register a static build mbean to the mbean server. * @param objecToRegister object you want to register * @param objectName under which object name it should be available */ public void registerStaticElement(final Object objecToRegister, final ObjectName objectName){ try { this.mbs.registerMBean(objecToRegister,objectName); } catch (InstanceAlreadyExistsException | NotCompliantMBeanException | MBeanRegistrationException e) { log.log(Level.WARNING,"Could not register static example mbean on MBeanServer. Check Stacktrace.", e); } }
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { return createMBean(className, name, loaderName, false, params, signature); }
public static void registerMBean() { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); try { instance = new ShutdownServer(); mBeanServer.registerMBean(instance, new ObjectName("server:type=ShutdownServer")); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { System.out.println("Error registering Shutdown MBean"); } }
public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
/** * Adds a MBean in the repository, * sends MBeanServerNotification.REGISTRATION_NOTIFICATION, * returns ResourceContext for special resources such as ClassLoaders * or JMXNamespaces. For regular MBean this method returns * ResourceContext.NONE. * @return a ResourceContext for special resources such as ClassLoaders * or JMXNamespaces. */ private ResourceContext registerWithRepository( final Object resource, final DynamicMBean object, final ObjectName logicalName) throws InstanceAlreadyExistsException, MBeanRegistrationException { // Creates a registration context, if needed. // final ResourceContext context = makeResourceContextFor(resource, logicalName); repository.addMBean(object, logicalName, context); // May throw InstanceAlreadyExistsException // --------------------- // Send create event // --------------------- if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE, "Send create notification of object " + logicalName.getCanonicalName()); } sendNotification( MBeanServerNotification.REGISTRATION_NOTIFICATION, logicalName); return context; }
private JMXConnector connectToServer(JMXConnectorServer server) throws IOException, MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ReflectionException, MBeanException { JMXServiceURL url = server.getAddress(); Map<String, Object> env = new HashMap<String, Object>(); JMXConnector connector = JMXConnectorFactory.connect(url, env); System.out.println("DEBUG: Client connected to RMI at: " + url); return connector; }
public ObjectInstance createMBean( String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { return createMBean(className, name, loaderName, null, null); }
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug( "createMBean(String,ObjectName,ObjectName,Object[],String[])", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ", signature=" + strings(signature)); final MarshalledObject<Object[]> sParams = new MarshalledObject<Object[]>(params); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, sParams, signature, delegationSubject); } finally { popDefaultClassLoader(old); } }
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { if (logger.debugOn()) logger.debug("createMBean(String,ObjectName,ObjectName)", "className=" + className + ", name=" + name + ", loaderName=" + loaderName + ")"); final ClassLoader old = pushDefaultClassLoader(); try { return connection.createMBean(className, name, loaderName, delegationSubject); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); return connection.createMBean(className, name, loaderName, delegationSubject); } finally { popDefaultClassLoader(old); } }