public Debug(Debugger debugger) { this.debugger = debugger; }
public Debugger getDebugger() { return debugger; }
public void setDebugger(Debugger debugger) { this.debugger = debugger; }
private void setupCustomServices() { ModelJAXBContextFactory modelJAXBContextFactory = getBeanForType(ModelJAXBContextFactory.class); if (modelJAXBContextFactory != null) { LOG.info("Using custom ModelJAXBContextFactory: {}", modelJAXBContextFactory); getContext().setModelJAXBContextFactory(modelJAXBContextFactory); } ClassResolver classResolver = getBeanForType(ClassResolver.class); if (classResolver != null) { LOG.info("Using custom ClassResolver: {}", classResolver); getContext().setClassResolver(classResolver); } FactoryFinderResolver factoryFinderResolver = getBeanForType(FactoryFinderResolver.class); if (factoryFinderResolver != null) { LOG.info("Using custom FactoryFinderResolver: {}", factoryFinderResolver); getContext().setFactoryFinderResolver(factoryFinderResolver); } ExecutorServiceManager executorServiceStrategy = getBeanForType(ExecutorServiceManager.class); if (executorServiceStrategy != null) { LOG.info("Using custom ExecutorServiceStrategy: {}", executorServiceStrategy); getContext().setExecutorServiceManager(executorServiceStrategy); } ThreadPoolFactory threadPoolFactory = getBeanForType(ThreadPoolFactory.class); if (threadPoolFactory != null) { LOG.info("Using custom ThreadPoolFactory: {}", threadPoolFactory); getContext().getExecutorServiceManager().setThreadPoolFactory(threadPoolFactory); } ProcessorFactory processorFactory = getBeanForType(ProcessorFactory.class); if (processorFactory != null) { LOG.info("Using custom ProcessorFactory: {}", processorFactory); getContext().setProcessorFactory(processorFactory); } Debugger debugger = getBeanForType(Debugger.class); if (debugger != null) { LOG.info("Using custom Debugger: {}", debugger); getContext().setDebugger(debugger); } UuidGenerator uuidGenerator = getBeanForType(UuidGenerator.class); if (uuidGenerator != null) { LOG.info("Using custom UuidGenerator: {}", uuidGenerator); getContext().setUuidGenerator(uuidGenerator); } NodeIdFactory nodeIdFactory = getBeanForType(NodeIdFactory.class); if (nodeIdFactory != null) { LOG.info("Using custom NodeIdFactory: {}", nodeIdFactory); getContext().setNodeIdFactory(nodeIdFactory); } StreamCachingStrategy streamCachingStrategy = getBeanForType(StreamCachingStrategy.class); if (streamCachingStrategy != null) { LOG.info("Using custom StreamCachingStrategy: {}", streamCachingStrategy); getContext().setStreamCachingStrategy(streamCachingStrategy); } MessageHistoryFactory messageHistoryFactory = getBeanForType(MessageHistoryFactory.class); if (messageHistoryFactory != null) { LOG.info("Using custom MessageHistoryFactory: {}", messageHistoryFactory); getContext().setMessageHistoryFactory(messageHistoryFactory); } }
public static void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception { Collection<Method> methods = getAllMethods(testClass); final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>(); for (Method method : methods) { if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) { Class<?>[] argTypes = method.getParameterTypes(); if (argTypes.length != 0) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not a no-argument method."); } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint."); } else if (!Modifier.isStatic(method.getModifiers())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not static."); } else if (!Modifier.isPublic(method.getModifiers())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not public."); } try { breakpoints.add((Breakpoint) method.invoke(null)); } catch (Exception e) { throw new RuntimeException("Method [" + method.getName() + "] threw exception during evaluation.", e); } } } if (breakpoints.size() != 0) { CamelSpringTestHelper.doToSpringCamelContexts(context, new CamelSpringTestHelper.DoToSpringCamelContextsStrategy() { public void execute(String contextName, SpringCamelContext camelContext) throws Exception { Debugger debugger = camelContext.getDebugger(); if (debugger == null) { debugger = new DefaultDebugger(); camelContext.setDebugger(debugger); } for (Breakpoint breakpoint : breakpoints) { LOGGER.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName); debugger.addBreakpoint(breakpoint); } } }); } }
/** * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here * as it is needed in * * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into * @param testClass the test class being processed * * @throws Exception if there is an error processing the class */ protected void handleProvidesBreakpoint(GenericApplicationContext context, Class<?> testClass) throws Exception { Collection<Method> methods = getAllMethods(testClass); final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>(); for (Method method : methods) { if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) { Class<?>[] argTypes = method.getParameterTypes(); if (argTypes.length != 0) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not a no-argument method."); } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint."); } else if (!Modifier.isStatic(method.getModifiers())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not static."); } else if (!Modifier.isPublic(method.getModifiers())) { throw new IllegalArgumentException("Method [" + method.getName() + "] is annotated with ProvidesBreakpoint but is not public."); } try { breakpoints.add((Breakpoint) method.invoke(null)); } catch (Exception e) { throw new RuntimeException("Method [" + method.getName() + "] threw exception during evaluation.", e); } } } if (breakpoints.size() != 0) { CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() { @Override public void execute(String contextName, SpringCamelContext camelContext) throws Exception { Debugger debugger = camelContext.getDebugger(); if (debugger == null) { debugger = new DefaultDebugger(); camelContext.setDebugger(debugger); } for (Breakpoint breakpoint : breakpoints) { LOG.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName); debugger.addBreakpoint(breakpoint); } } }); } }
@Override public Debugger getDebugger() { return context.getDebugger(); }
@Override public void setDebugger(Debugger debugger) { context.setDebugger(debugger); }
/** * Gets the current {@link Debugger} * * @return the debugger */ Debugger getDebugger();
/** * Sets a custom {@link Debugger} * * @param debugger the debugger */ void setDebugger(Debugger debugger);