Package org.objectweb.celtix.management

Examples of org.objectweb.celtix.management.Instrumentation


   
    // find out the related JMX managed component do register and unregister things  
    
    public void processEvent(BusEvent event) throws BusException {
        if (meFilter.isEventEnabled(event)) {
            Instrumentation instrumentation = (Instrumentation)event.getSource();
               
            if (meFilter.isCreateEvent(event)) {
                   
                ModelMBeanInfo mbi = mbAssembler.getModelMbeanInfo(instrumentation.getClass());
               
                if (mbi != null) {                   
                    RequiredModelMBean rtMBean;
                    try {
                                               
                        rtMBean = (RequiredModelMBean)mbs.instantiate(
                            "javax.management.modelmbean.RequiredModelMBean");
                                      
                        rtMBean.setModelMBeanInfo(mbi);
                       
                        rtMBean.setManagedResource(instrumentation, "ObjectReference");
                                              
                        registerMBean(rtMBean,
                            JMXUtils.getObjectName(instrumentation.getInstrumentationName(),
                                                   instrumentation.getUniqueInstrumentationName(),
                                                   busID));
                                              
                        if (LOG.isLoggable(Level.INFO)) {
                            LOG.info("registered the object to MBserver "
                                               + instrumentation.getUniqueInstrumentationName());
                        }
                           
                          
                    } catch (ReflectionException e) {
                        LOG.log(Level.SEVERE, "INSTANTIANTE_FAILURE_MSG", new Object[]{e});
                    } catch (MBeanException e) {
                        LOG.log(Level.SEVERE, "MBEAN_FAILURE_MSG", new Object[]{e});
                    } catch (InstanceNotFoundException e) {
                        LOG.log(Level.SEVERE, "SET_MANAGED_RESOURCE_FAILURE_MSG", new Object[]{e});
                    } catch (InvalidTargetObjectTypeException e) {
                        LOG.log(Level.SEVERE, "SET_MANAGED_RESOURCE_FAILURE_MSG", new Object[]{e});
                    }
                } else {
                    LOG.log(Level.SEVERE, "GET_MANAGED_INFORMATION_FAILURE_MSG",
                            new Object[]{instrumentation.getInstrumentationName()});
                }               
            }               

          
            if (meFilter.isRemovedEvent(event)) {
               // unregist the component and distroy it.
                ObjectName name;                
                name = JMXUtils.getObjectName(instrumentation.getInstrumentationName(),
                    instrumentation.getUniqueInstrumentationName(),
                    busID);              
                unregisterMBean(name);
                if (LOG.isLoggable(Level.INFO)) {
                    LOG.info("unregistered the object to MBserver"
                                       + instrumentation.getUniqueInstrumentationName());
                }  
                   
            } 
        }      
    }
View Full Code Here


        }       
    }

    public void unregister(Object component) {
        for (Iterator<Instrumentation> i = instrumentations.iterator(); i.hasNext();) {
            Instrumentation it = i.next();
            if (it.getComponent() == component) {
                i.remove();  
                if (it != null) {
                    //create the instrumentation remove event          
                    bus.sendEvent(new InstrumentationRemovedEvent(it));              
                }
View Full Code Here

        }
    }

    // get the instance and create the right component
    public void processEvent(BusEvent e) throws BusException {
        Instrumentation it;
        if (e.getID().equals(ComponentCreatedEvent.COMPONENT_CREATED_EVENT)) {           
            it = createInstrumentation(e.getSource());
            if (LOG.isLoggable(Level.INFO)) {
                LOG.info("Instrumentation register " + e.getSource().getClass().getName());
            }  
View Full Code Here

        }
    }
   
   
    private Instrumentation createInstrumentation(Object component) {
        Instrumentation it = null;
        // if the componenet implements the instrumentation interface,
        // just return the object itself
       
        if (Instrumentation.class.isAssignableFrom(component.getClass())) {
            it = (Instrumentation)component;           
View Full Code Here

        //create with bus , this test could be failed.
        List<Instrumentation> list = im.getAllInstrumentation();  
        //NOTE: change for the BindingManager and TransportFactoryManager instrumentation
        // create with the bus.
        assertEquals("Too many instrumented items", 4, list.size());
        Instrumentation it1 = list.get(2);
        Instrumentation it2 = list.get(3);
        assertTrue("Item 1 not a WorkQueueInstrumentation",
                   WorkQueueInstrumentation.class.isAssignableFrom(it1.getClass()));
        assertTrue("Item 2 not a WorkQueueInstrumentation",
                   WorkQueueInstrumentation.class.isAssignableFrom(it2.getClass()));
       
        // not check for the instrumentation unique name
        // sleep for the MBServer connector thread startup
        try {
            Thread.sleep(100);
View Full Code Here

       
        List<Instrumentation> list = im.getAllInstrumentation();
        assertEquals("Not exactly the number of instrumented item", 3, list.size());
       
        // get the ati for more assert
        Instrumentation instr = list.get(2);
        assertEquals("Not exactly the name of AnnotationTestInstrumentation",
                     "AnnotationTestInstrumentation",
                     instr.getInstrumentationName());
        bus.sendEvent(new ComponentRemovedEvent(ati));
        assertEquals("AnnotationTestInstrumented stuff not removed from list", 2, list.size());
        bus.shutdown(true);
        assertEquals("Instrumented stuff not removed from list", 0, list.size());
       
View Full Code Here

       
        List<Instrumentation> list = im.getAllInstrumentation();
        assertEquals("Not exactly the number of instrumented item", 3, list.size());
       
        // get the ati for more assert
        Instrumentation instr = list.get(2);
        assertEquals("Not exactly the name of AnnotationTestInstrumentation",
                     "AnnotationTestInstrumentation",
                     instr.getInstrumentationName());
        im.unregister(ati);
        assertEquals("AnnotationTestInstrumented stuff not removed from list", 2, list.size());
        bus.shutdown(true);
        assertEquals("Instrumented stuff not removed from list", 0, list.size());
    }
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.management.Instrumentation

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.