Java 类org.apache.camel.spi.CamelContextNameStrategy 实例源码

项目:Camel    文件:CamelContextProducer.java   
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();
    }
}
项目:Camel    文件:CamelContextOsgiProducer.java   
@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;
}
项目:camel-cdi    文件:CamelContextProducer.java   
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();
    }
}
项目:camel-cdi    文件:CamelContextOsgiProducer.java   
@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;
}
项目:Camel    文件:DefaultCamelContext.java   
public CamelContextNameStrategy getNameStrategy() {
    return nameStrategy;
}
项目:Camel    文件:DefaultCamelContext.java   
public void setNameStrategy(CamelContextNameStrategy nameStrategy) {
    this.nameStrategy = nameStrategy;
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public CamelContextNameStrategy getNameStrategy() {
  return context.getNameStrategy();
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public void setNameStrategy(CamelContextNameStrategy nameStrategy) {
  context.setNameStrategy(nameStrategy);
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public CamelContextNameStrategy getNameStrategy() {
    return context.getNameStrategy();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public void setNameStrategy(CamelContextNameStrategy nameStrategy) {
    context.setNameStrategy(nameStrategy);
}
项目:Camel    文件:CamelContext.java   
/**
 * Gets the current name strategy
 *
 * @return name strategy
 */
CamelContextNameStrategy getNameStrategy();
项目:Camel    文件:CamelContext.java   
/**
 * Sets a custom name strategy
 *
 * @param nameStrategy name strategy
 */
void setNameStrategy(CamelContextNameStrategy nameStrategy);