@Override
  public List<CamelEndpointMBean> getEndpoints(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query =
        ObjectName.getInstance("org.apache.camel:context=" + id + ",type=endpoints,*");

    Set<ObjectInstance> names = queryNames(query, null);
    List<CamelEndpointMBean> answer = new ArrayList<CamelEndpointMBean>();
    for (ObjectInstance on : names) {
      CamelEndpointMBean endpoint;
      if (ManagedBrowsableEndpoint.class.getName().equals(on.getClassName())
          || SedaEndpoint.class.getName().equals(on.getClassName())) {
        endpoint =
            (CamelEndpointMBean)
                newProxyInstance(on.getObjectName(), CamelBrowsableEndpointMBean.class, true);
      } else if (on.getClassName().startsWith("org.apache.camel.component.jms")) {
        // special for JMS endpoints as they are browsable as well
        endpoint =
            (CamelEndpointMBean)
                newProxyInstance(on.getObjectName(), CamelBrowsableEndpointMBean.class, true);
      } else {
        endpoint =
            (CamelEndpointMBean)
                newProxyInstance(on.getObjectName(), CamelEndpointMBean.class, true);
      }
      answer.add(endpoint);
    }
    return answer;
  }
  @Override
  public List<CamelProcessorMBean> getProcessors(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query =
        ObjectName.getInstance("org.apache.camel:context=" + id + ",type=processors,*");

    Set<ObjectInstance> names = queryNames(query, null);
    List<CamelProcessorMBean> answer = new ArrayList<CamelProcessorMBean>();
    for (ObjectInstance on : names) {
      CamelProcessorMBean processor;
      if (ManagedSendProcessor.class.getName().equals(on.getClassName())) {
        processor =
            (CamelProcessorMBean)
                newProxyInstance(on.getObjectName(), CamelSendProcessorMBean.class, true);
      } else if (ManagedDelayer.class.getName().equals(on.getClassName())) {
        processor =
            (CamelProcessorMBean)
                newProxyInstance(on.getObjectName(), CamelDelayProcessorMBean.class, true);
      } else if (ManagedThrottler.class.getName().equals(on.getClassName())) {
        processor =
            (CamelProcessorMBean)
                newProxyInstance(on.getObjectName(), CamelThrottleProcessorMBean.class, true);
      } else {
        processor =
            (CamelProcessorMBean)
                newProxyInstance(on.getObjectName(), CamelProcessorMBean.class, true);
      }
      answer.add(processor);
    }
    return answer;
  }
Example #3
0
 private void start(ObjectInstance instance) {
   try {
     factory.startQBean(this, instance.getObjectName());
   } catch (Exception e) {
     getLog().warn("start", e);
   }
 }
  @Override
  public List<CamelRouteMBean> getRoutes(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query = ObjectName.getInstance("org.apache.camel:context=" + id + ",type=routes,*");

    Set<ObjectInstance> names = queryNames(query, null);
    List<CamelRouteMBean> answer = new ArrayList<CamelRouteMBean>();
    for (ObjectInstance on : names) {
      CamelRouteMBean route;
      if (ManagedSuspendableRoute.class.getName().equals(on.getClassName())) {
        route =
            (CamelRouteMBean)
                newProxyInstance(on.getObjectName(), CamelSuspendableRouteMBean.class, true);
      } else {
        route = (CamelRouteMBean) newProxyInstance(on.getObjectName(), CamelRouteMBean.class, true);
      }
      answer.add(route);
    }
    return answer;
  }
  @Override
  public List<CamelConsumerMBean> getConsumers(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query =
        ObjectName.getInstance("org.apache.camel:context=" + id + ",type=consumers,*");

    Set<ObjectInstance> names = queryNames(query, null);
    List<CamelConsumerMBean> answer = new ArrayList<CamelConsumerMBean>();
    for (ObjectInstance on : names) {
      CamelConsumerMBean consumer;
      if (ManagedScheduledPollConsumer.class.getName().equals(on.getClassName())) {
        consumer =
            (CamelConsumerMBean)
                newProxyInstance(on.getObjectName(), CamelScheduledPollConsumerMBean.class, true);
      } else {
        consumer =
            (CamelConsumerMBean)
                newProxyInstance(on.getObjectName(), CamelConsumerMBean.class, true);
      }
      answer.add(consumer);
    }
    return answer;
  }
  @Override
  public List<CamelThreadPoolMBean> getThreadPools(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query =
        ObjectName.getInstance("org.apache.camel:context=" + id + ",type=threadpools,*");

    Set<ObjectInstance> names = queryNames(query, null);
    List<CamelThreadPoolMBean> answer = new ArrayList<CamelThreadPoolMBean>();
    for (ObjectInstance on : names) {
      CamelThreadPoolMBean pool =
          (CamelThreadPoolMBean)
              newProxyInstance(on.getObjectName(), CamelThreadPoolMBean.class, true);
      answer.add(pool);
    }
    return answer;
  }
  @Override
  public ManagedBacklogTracerMBean getCamelTracer(String managementName) throws Exception {
    String id = managementName != null ? managementName : camelContextManagementName;

    ObjectName query = ObjectName.getInstance("org.apache.camel:context=" + id + ",type=tracer,*");

    Set<ObjectInstance> names = queryNames(query, null);
    for (ObjectInstance on : names) {
      if (on.getClassName().equals("org.apache.camel.management.mbean.ManagedBacklogTracer")) {
        ManagedBacklogTracerMBean tracer =
            (ManagedBacklogTracerMBean)
                newProxyInstance(on.getObjectName(), ManagedBacklogTracerMBean.class, true);
        return tracer;
      }
    }

    // tracer not found
    return null;
  }
Example #8
0
 public ObjectName getObjectName() {
   return instance != null ? instance.getObjectName() : null;
 }