@Override protected void camelContextStarted(CamelContextStartedEvent event) { if (reportNonCustomEndpointIDs) { reportNonCustomEndpointIDs(event.getContext()); } }
/** * Listen for event (observe using @Observes) when Camel is started. * <p/> * You can listen for any of the Camel events from org.apache.camel.management.event package. */ void onContextStarted(@Observes CamelContextStartedEvent event) { System.out.println("***************************************"); System.out.println("* Camel started " + event.getContext().getName()); System.out.println("***************************************"); } }
/** * Listen for event (observe using @Observes) when Camel is started. * <p/> * You can listen for any of the Camel events from org.apache.camel.management.event package. */ void onContextStarted(@Observes CamelContextStartedEvent event) { System.out.println("***************************************"); System.out.println("* Camel started " + event.getContext().getName()); System.out.println("***************************************"); } }
public void notify(EventObject event) throws Exception { if (event instanceof CamelContextStartedEvent) { CamelContext context = ((CamelContextStartedEvent) event).getContext(); registerCamelContext(context); } else if (event instanceof CamelContextStoppingEvent) { CamelContext context = ((CamelContextStoppingEvent) event).getContext(); ServiceRegistration<?> reg = registrations.remove(context); if (reg != null) { if (log.isDebugEnabled()) { log.debug("Unregistering CamelContext [{}] from OSGi registry", context.getName()); } try { reg.unregister(); } catch (Exception e) { log.warn("Error unregistering CamelContext [" + context.getName() + "] from OSGi registry. This exception will be ignored.", e); } } } }
@Override public void notify(EventObject event) throws Exception { if (event instanceof CamelContextStartedEvent) { CamelContextStartedEvent contextStartedEvent = (CamelContextStartedEvent) event; publishModel(contextStartedEvent.getContext()); } if (event instanceof RouteAddedEvent) { routeAdded((RouteAddedEvent) event); } else if (event instanceof RouteRemovedEvent) { routeRemoved((RouteRemovedEvent) event); } }
public class ContextStartEventListener extends EventNotifierSupport implements ApplicationContextAware { private ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @Override public void notify(EventObject event) throws Exception { if (event instanceof CamelContextStartedEvent) { try { CamelContextStartedEvent startedEvent = (CamelContextStartedEvent) event; DefaultCamelContext context=(DefaultCamelContext)startedEvent.getContext(); Resource[] xmlResources=applicationContext.getResources("classpath*:net/**/route.xml"); for (int i=0;i<xmlResources.length;i++) { InputStream is = xmlResources[i].getInputStream(); RoutesDefinition routes = context.loadRoutesDefinition(is); context.addRouteDefinitions(routes.getRoutes()); } } catch (Throwable ex) { // do something on error } } } ...