private static CamelContextNameStrategy nameStrategy(Annotated annotated) { if (annotated.isAnnotationPresent(ContextName.class)) { return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value()); } else if (annotated.isAnnotationPresent(Named.class)) { // TODO: support stereotype with empty @Named annotation String name = annotated.getAnnotation(Named.class).value(); if (name.isEmpty()) { if (annotated instanceof AnnotatedField) { name = ((AnnotatedField) annotated).getJavaMember().getName(); } else if (annotated instanceof AnnotatedMethod) { name = ((AnnotatedMethod) annotated).getJavaMember().getName(); if (name.startsWith("get")) { name = decapitalize(name.substring(3)); } } else { name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName()); } } return new ExplicitCamelContextNameStrategy(name); } else { // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created return new CdiCamelContextNameStrategy(); } }
@Override public T produce(CreationalContext<T> ctx) { T context = super.produce(ctx); // Register the context in the OSGi registry BundleContext bundle = BundleContextUtils.getBundleContext(getClass()); context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle)); if (!(context instanceof DefaultCamelContext)) { // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext"); } DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle)); CamelContextNameStrategy strategy = context.getNameStrategy(); OsgiCamelContextHelper.osgiUpdate(adapted, bundle); // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely if (!(strategy instanceof DefaultCamelContextNameStrategy)) { context.setNameStrategy(strategy); } return context; }
private static CamelContextNameStrategy nameStrategy(Annotated annotated) { if (annotated.isAnnotationPresent(ContextName.class)) { return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value()); } else if (annotated.isAnnotationPresent(Named.class)) { // TODO: support stereotype with empty @Named annotation String name = annotated.getAnnotation(Named.class).value(); if (name.isEmpty()) { if (annotated instanceof AnnotatedField) { name = ((AnnotatedField) annotated).getJavaMember().getName(); } else if (annotated instanceof AnnotatedMethod) { name = ((AnnotatedMethod) annotated).getJavaMember().getName(); if (name.startsWith("get")) name = decapitalize(name.substring(3)); } else { name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName()); } } return new ExplicitCamelContextNameStrategy(name); } else { // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created return new CdiCamelContextNameStrategy(); } }
@Override public T produce(CreationalContext<T> cc) { T context = super.produce(cc); // Register the context in the OSGi registry BundleContext bundle = BundleContextUtils.getBundleContext(getClass()); context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle)); if (!(context instanceof DefaultCamelContext)) // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface throw new DeploymentException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext"); DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle)); CamelContextNameStrategy strategy = context.getNameStrategy(); OsgiCamelContextHelper.osgiUpdate(adapted, bundle); // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely if (!(strategy instanceof DefaultCamelContextNameStrategy)) context.setNameStrategy(strategy); return context; }
public CamelContextNameStrategy getNameStrategy() { return nameStrategy; }
public void setNameStrategy(CamelContextNameStrategy nameStrategy) { this.nameStrategy = nameStrategy; }
@Override public CamelContextNameStrategy getNameStrategy() { return context.getNameStrategy(); }
@Override public void setNameStrategy(CamelContextNameStrategy nameStrategy) { context.setNameStrategy(nameStrategy); }
/** * Gets the current name strategy * * @return name strategy */ CamelContextNameStrategy getNameStrategy();
/** * Sets a custom name strategy * * @param nameStrategy name strategy */ void setNameStrategy(CamelContextNameStrategy nameStrategy);