Package org.apache.camel.spi

Examples of org.apache.camel.spi.ManagementAgent


        // If null, provide the default implementation.
        if (mbContainer == null) {
            MBeanServer mbs = null;
           
            final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
            final ManagementAgent mAgent = mStrategy.getManagementAgent();
            if (mAgent != null) {
                mbs = mAgent.getMBeanServer();
            }
           
            if (mbs != null) {
                mbContainer = new MBeanContainer(mbs);
                startMbContainer();
View Full Code Here


        if (getCamelContext().getStatus().isStarting()) {
            return true;
        }

        // register if always is enabled
        ManagementAgent agent = getManagementStrategy().getManagementAgent();
        if (agent.getRegisterAlways()) {
            return true;
        }

        // is it a known route then always accept
        if (route != null && knowRouteIds.contains(route.getId())) {
            return true;
        }

        // only register if we are starting a new route, and current thread is in starting routes mode
        if (agent.getRegisterNewRoutes()) {
            // no specific route, then fallback to see if this thread is starting routes
            // which is kept as state on the camel context
            return getCamelContext().isStartingRoutes();
        }
View Full Code Here

            return false;
        }

        LOG.trace("Checking whether to register {} from route: {}", service, route);

        ManagementAgent agent = getManagementStrategy().getManagementAgent();
        if (agent == null) {
            // do not register if no agent
            return false;
        }

        // always register if we are starting CamelContext
        if (getCamelContext().getStatus().isStarting()) {
            return true;
        }

        // register if always is enabled
        if (agent.getRegisterAlways()) {
            return true;
        }

        // is it a known route then always accept
        if (route != null && knowRouteIds.contains(route.getId())) {
            return true;
        }

        // only register if we are starting a new route, and current thread is in starting routes mode
        if (agent.getRegisterNewRoutes()) {
            // no specific route, then fallback to see if this thread is starting routes
            // which is kept as state on the camel context
            return getCamelContext().isStartingRoutes();
        }
View Full Code Here

    @Test
    public void testObjectNameModification() throws JMException {
        MBeanServer mbeanServer = createStrictMock(MBeanServer.class);
        ObjectInstance instance = createStrictMock(ObjectInstance.class);

        ManagementAgent agent = new DefaultManagementAgent();
        agent.setMBeanServer(mbeanServer);

        Object object = "object";
        ObjectName sourceObjectName = new ObjectName("domain", "key", "value");
        ObjectName registeredObjectName = new ObjectName("domain", "key", "otherValue");

        // Register MBean and return different ObjectName
        expect(mbeanServer.isRegistered(sourceObjectName)).andReturn(false);
        expect(mbeanServer.registerMBean(object, sourceObjectName)).andReturn(instance);
        expect(instance.getObjectName()).andReturn(registeredObjectName);
        expect(mbeanServer.isRegistered(registeredObjectName)).andReturn(true);
        replay(mbeanServer, instance);

        agent.register(object, sourceObjectName);

        assertTrue(agent.isRegistered(sourceObjectName));
        verify(mbeanServer, instance);
        reset(mbeanServer, instance);

        // ... and unregister it again
        expect(mbeanServer.isRegistered(registeredObjectName)).andReturn(true);
        mbeanServer.unregisterMBean(registeredObjectName);
        expect(mbeanServer.isRegistered(sourceObjectName)).andReturn(false);
        replay(mbeanServer);

        agent.unregister(sourceObjectName);

        assertFalse(agent.isRegistered(sourceObjectName));
        verify(mbeanServer);
    }
View Full Code Here

        }
        System.out.println("");
        System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mStatistics\u001B[0m"));
        CamelContext camelContext = camelRoute.getRouteContext().getCamelContext();
        if (camelContext != null) {
            ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
            if (agent != null) {
                MBeanServer mBeanServer = agent.getMBeanServer();
                Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(agent.getMBeanObjectDomainName() + ":type=routes,name=\"" + route + "\",*"), null);
                Iterator<ObjectName> iterator = set.iterator();
                if (iterator.hasNext()) {
                    ObjectName routeMBean = iterator.next();
                    Long exchangesTotal = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesTotal");
                    System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Total: " + exchangesTotal));
View Full Code Here

        // the statistics are in the mbeans
        System.out.println("");
        System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mStatistics\u001B[0m"));
        ObjectName contextMBean = null;
        ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
        if (agent != null) {
            MBeanServer mBeanServer = agent.getMBeanServer();

            Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(agent.getMBeanObjectDomainName() + ":type=context,name=\"" + name + "\",*"), null);
            Iterator<ObjectName> iterator = set.iterator();
            if (iterator.hasNext()) {
                contextMBean = iterator.next();
            }

View Full Code Here

        // If null, provide the default implementation.
        if (mbContainer == null) {
            MBeanServer mbs = null;

            final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
            final ManagementAgent mAgent = mStrategy.getManagementAgent();
            if (mAgent != null) {
                mbs = mAgent.getMBeanServer();
            }

            if (mbs != null) {
                mbContainer = new MBeanContainer(mbs);
                startMbContainer();
View Full Code Here

        // If null, provide the default implementation.
        if (mbContainer == null) {
            MBeanServer mbs = null;
           
            final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
            final ManagementAgent mAgent = mStrategy.getManagementAgent();
            if (mAgent != null) {
                mbs = mAgent.getMBeanServer();
            }
           
            if (mbs != null) {
                mbContainer = new MBeanContainer(mbs);
                startMbContainer();
View Full Code Here

    protected boolean useJmx() {
        return true;
    }

    public void testJmxConfiguration() throws Exception {
        ManagementAgent agent = getMandatoryBean(DefaultManagementAgent.class, "agent");
        assertNotNull("SpringInstrumentationAgent must be configured for JMX support", agent);
        assertNotNull("MBeanServer must be configured for JMX support", agent.getMBeanServer());
        assertEquals("org.apache.camel.test", agent.getMBeanServer().getDefaultDomain());
    }
View Full Code Here

        if (getCamelContext().getStatus().isStarting()) {
            return true;
        }

        // register if always is enabled
        ManagementAgent agent = getManagementStrategy().getManagementAgent();
        if (agent.getRegisterAlways()) {
            return true;
        }

        // is it a known route then always accept
        if (route != null && knowRouteIds.contains(route.getId())) {
            return true;
        }

        // only register if we are starting a new route, and current thread is in starting routes mode
        if (agent.getRegisterNewRoutes()) {
            // no specific route, then fallback to see if this thread is starting routes
            // which is kept as state on the camel context
            return getCamelContext().isStartingRoutes();
        }
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.ManagementAgent

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.