Package javax.management

Examples of javax.management.NotificationListener


       
        // notifications
       
        final List<Notification> received = new ArrayList<Notification>();
     
        mbeanServer.addNotificationListener(new ObjectName(BundleStateMBean.OBJECTNAME), new NotificationListener() {
            public void handleNotification(Notification notification, Object handback) {
               received.add(notification);
            }
        }, null, null);
       
View Full Code Here


       
        // notifications
       
        final List<Notification> received = new ArrayList<Notification>();
     
        mbeanServer.addNotificationListener(new ObjectName(ServiceStateMBean.OBJECTNAME), new NotificationListener() {
            public void handleNotification(Notification notification, Object handback) {
               received.add(notification);
            }
        }, null, null);
       
View Full Code Here

                return makeClient;
            }
        };

        // Create a Listener responsible for removing the map entries add by the #makeClient entry above.
        final NotificationListener mapCleanupListener = new NotificationListener()
        {

            public void handleNotification(Notification notification, Object handback)
            {
                final String connectionId = ((JMXConnectionNotification) notification).getConnectionId();
                connectionIdUsernameMap.remove(connectionId);
            }
        };

        String localHost;
        try
        {
            localHost = InetAddress.getLocalHost().getHostName();
        }
        catch(UnknownHostException ex)
        {
            localHost="127.0.0.1";
        }
        final String hostname = localHost;
        final JMXServiceURL externalUrl = new JMXServiceURL(
                "service:jmx:rmi://"+hostname+":"+(_jmxPortConnectorServer)+"/jndi/rmi://"+hostname+":"+_jmxPortRegistryServer+"/jmxrmi");

        final JMXServiceURL internalUrl = new JMXServiceURL("rmi", hostname, _jmxPortConnectorServer);
        _cs = new RMIConnectorServer(internalUrl, env, rmiConnectorServerStub, _mbeanServer)
        {
            @Override
            public synchronized void start() throws IOException
            {
                try
                {
                    //manually bind the connector server to the registry at key 'jmxrmi', like the out-of-the-box agent
                    _rmiRegistry.bind("jmxrmi", rmiConnectorServerStub);
                }
                catch (AlreadyBoundException abe)
                {
                    //key was already in use. shouldnt happen here as its a new registry, unbindable by normal means.

                    //IOExceptions are the only checked type throwable by the method, wrap and rethrow
                    IOException ioe = new IOException(abe.getMessage());
                    ioe.initCause(abe);
                    throw ioe;
                }

                //now do the normal tasks
                super.start();
            }

            @Override
            public synchronized void stop() throws IOException
            {
                try
                {
                    if (_rmiRegistry != null)
                    {
                        _rmiRegistry.unbind("jmxrmi");
                    }
                }
                catch (NotBoundException nbe)
                {
                    // TODO consider if we want to keep new logging
                    _log.error("Failed to unbind jmxrmi", nbe);
                    //ignore
                }

                //now do the normal tasks
                super.stop();
            }

            @Override
            public JMXServiceURL getAddress()
            {
                //must return our pre-crafted url that includes the full details, inc JNDI details
                return externalUrl;
            }

        };


        //Add the custom invoker as an MBeanServerForwarder, and start the RMIConnectorServer.
        MBeanServerForwarder mbsf = MBeanInvocationHandlerImpl.newProxyInstance();
        _cs.setMBeanServerForwarder(mbsf);


        // Get the handler that is used by the above MBInvocationHandler Proxy.
        // which is the MBeanInvocationHandlerImpl and so also a NotificationListener.
        final NotificationListener invocationHandler = (NotificationListener) Proxy.getInvocationHandler(mbsf);

        // Install a notification listener on OPENED, CLOSED, and FAILED,
        // passing the map of connection-ids to usernames as hand-back data.
        final NotificationFilterSupport invocationHandlerFilter = new NotificationFilterSupport();
        invocationHandlerFilter.enableType(JMXConnectionNotification.OPENED);
View Full Code Here

        String testClass = testMethodExecutor.getInstance().getClass().getName();
        String testMethod = testMethodExecutor.getMethod().getName();
        String testCanonicalName = testClass + "." + testMethod;

        NotificationListener commandListener = null;
        ObjectName objectName = null;
        TestResult result = null;
        try {
            objectName = new ObjectName(JMXTestRunnerMBean.OBJECT_NAME);
            commandListener = new CallbackNotificationListener(objectName);
View Full Code Here

            int code=reg.getId(null, names[i]);
            if( hooks.length < code ) {
                // XXX reallocate
                throw new RuntimeException( "Too many hooks " + code );
            }
            NotificationListener listeners[]=hooks[code];
            if( listeners== null ) {

            }

View Full Code Here

            int code=reg.getId(null, names[i]);
            if( hooks.length < code ) {
                // XXX reallocate
                throw new RuntimeException( "Too many hooks " + code );
            }
            NotificationListener listeners[]=hooks[code];
            if( listeners== null ) {

            }

View Full Code Here

                return makeClient;
            }
        };

        // Create a Listener responsible for removing the map entries add by the #makeClient entry above.
        final NotificationListener mapCleanupListener = new NotificationListener()
        {

            public void handleNotification(Notification notification, Object handback)
            {
                final String connectionId = ((JMXConnectionNotification) notification).getConnectionId();
                connectionIdUsernameMap.remove(connectionId);
            }
        };

        String localHost;
        try
        {
            localHost = InetAddress.getLocalHost().getHostName();
        }
        catch(UnknownHostException ex)
        {
            localHost="127.0.0.1";
        }
        final String hostname = localHost;
        final JMXServiceURL externalUrl = new JMXServiceURL(
                "service:jmx:rmi://"+hostname+":"+(_jmxPortConnectorServer)+"/jndi/rmi://"+hostname+":"+_jmxPortRegistryServer+"/jmxrmi");

        final JMXServiceURL internalUrl = new JMXServiceURL("rmi", hostname, _jmxPortConnectorServer);
        _cs = new RMIConnectorServer(internalUrl, env, rmiConnectorServerStub, _mbeanServer)
        {
            @Override
            public synchronized void start() throws IOException
            {
                try
                {
                    //manually bind the connector server to the registry at key 'jmxrmi', like the out-of-the-box agent
                    _rmiRegistry.bind("jmxrmi", rmiConnectorServerStub);
                }
                catch (AlreadyBoundException abe)
                {
                    //key was already in use. shouldnt happen here as its a new registry, unbindable by normal means.

                    //IOExceptions are the only checked type throwable by the method, wrap and rethrow
                    IOException ioe = new IOException(abe.getMessage());
                    ioe.initCause(abe);
                    throw ioe;
                }

                //now do the normal tasks
                super.start();
            }

            @Override
            public synchronized void stop() throws IOException
            {
                try
                {
                    if (_rmiRegistry != null)
                    {
                        _rmiRegistry.unbind("jmxrmi");
                    }
                }
                catch (NotBoundException nbe)
                {
                    // TODO consider if we want to keep new logging
                    _log.error("Failed to unbind jmxrmi", nbe);
                    //ignore
                }

                //now do the normal tasks
                super.stop();
            }

            @Override
            public JMXServiceURL getAddress()
            {
                //must return our pre-crafted url that includes the full details, inc JNDI details
                return externalUrl;
            }

        };


        //Add the custom invoker as an MBeanServerForwarder, and start the RMIConnectorServer.
        MBeanServerForwarder mbsf = MBeanInvocationHandlerImpl.newProxyInstance();
        _cs.setMBeanServerForwarder(mbsf);


        // Get the handler that is used by the above MBInvocationHandler Proxy.
        // which is the MBeanInvocationHandlerImpl and so also a NotificationListener.
        final NotificationListener invocationHandler = (NotificationListener) Proxy.getInvocationHandler(mbsf);

        // Install a notification listener on OPENED, CLOSED, and FAILED,
        // passing the map of connection-ids to usernames as hand-back data.
        final NotificationFilterSupport invocationHandlerFilter = new NotificationFilterSupport();
        invocationHandlerFilter.enableType(JMXConnectionNotification.OPENED);
View Full Code Here



    public static void main(String[] args) {
        JmxDemo demo=new JmxDemo();
        demo.addNotificationListener(new NotificationListener() {

            @Override
            public void handleNotification(Notification notification, Object handback) {
                System.out.println(">> " + notification + ", handback=" + handback);
            }
View Full Code Here

        String testClass = testMethodExecutor.getInstance().getClass().getName();
        String testMethod = testMethodExecutor.getMethod().getName();
        String testCanonicalName = testClass + "." + testMethod;

        NotificationListener commandListener = null;
        ObjectName objectName = null;
        TestResult result = null;
        try {
            objectName = new ObjectName(JMXTestRunnerMBean.OBJECT_NAME);
            commandListener = new CallbackNotificationListener(objectName);
View Full Code Here

                    Object newInput) {
            }

        });
        viewer.setInput(notifications);
        listener = new NotificationListener() {
            @SuppressWarnings("unchecked")//$NON-NLS-1$
            public void handleNotification(final Notification notification,
                    Object handback) {
                // add notification at the head so that the more recent
                // appears at the top of the table (issue #25)
View Full Code Here

TOP

Related Classes of javax.management.NotificationListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.