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

项目:Camel    文件:OsgiComponentResolver.java   
protected Component getComponent(String name, CamelContext context) throws Exception {
    LOG.trace("Finding Component: {}", name);
    try {
        ServiceReference<?>[] refs = bundleContext.getServiceReferences(ComponentResolver.class.getName(), "(component=" + name + ")");
        if (refs != null) {
            for (ServiceReference<?> ref : refs) {
                Object service = bundleContext.getService(ref);
                if (ComponentResolver.class.isAssignableFrom(service.getClass())) {
                    ComponentResolver resolver = (ComponentResolver) service;
                    return resolver.resolveComponent(name, context);
                }
            }
        }
        return null;
    } catch (InvalidSyntaxException e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:CamelNamespaceHandler.java   
private static ComponentMetadata getComponentResolverReference(ParserContext context, String component) {
    // we cannot resolve component names using property placeholders at this point in time
    if (component.startsWith(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {
        return null;
    }
    ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
    ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.componentResolver." + component);
    if (cm == null) {
        MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
        svc.setId(".camelBlueprint.componentResolver." + component);
        svc.setFilter("(component=" + component + ")");
        svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(component) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
        try {
            // Try to set the runtime interface (only with aries blueprint > 0.1
            svc.getClass().getMethod("setRuntimeInterface", Class.class).invoke(svc, ComponentResolver.class);
        } catch (Throwable t) {
            // Check if the bundle can see the class
            try {
                PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                Bundle b = (Bundle) ptm.getObject();
                if (b.loadClass(ComponentResolver.class.getName()) != ComponentResolver.class) {
                    throw new UnsupportedOperationException();
                }
                svc.setInterface(ComponentResolver.class.getName());
            } catch (Throwable t2) {
                throw new UnsupportedOperationException();
            }
        }
        componentDefinitionRegistry.registerComponentDefinition(svc);
        cm = svc;
    }
    return cm;
}
项目:Camel    文件:BlueprintMultipleServiceTest.java   
@Override
@SuppressWarnings("rawtypes")
protected void addServicesOnStartup(List<KeyValueHolder<String, KeyValueHolder<Object, Dictionary>>> services) {
    Dictionary<String, String> dict1 = new Hashtable<String, String>();
    dict1.put("component", "fakeservice1");

    Dictionary<String, String> dict2 = new Hashtable<String, String>();
    dict2.put("component", "fakeservice2");

    services.add(asKeyValueService(ComponentResolver.class.getName(), mockComponentOne, dict1));
    services.add(asKeyValueService(ComponentResolver.class.getName(), mockComponentTwo, dict2));

}
项目:wildfly-camel    文件:ComponentResolverAssociationHandler.java   
@Override
public void setup(final CamelContext camelctx) {
    if (camelctx instanceof DefaultCamelContext) {
        DefaultCamelContext defaultctx = (DefaultCamelContext) camelctx;
        ComponentResolver delegate = defaultctx.getComponentResolver();
        defaultctx.setComponentResolver(new WildFlyComponentResolver(delegate));
    }
}
项目:Camel    文件:DefaultCamelContext.java   
public ComponentResolver getComponentResolver() {
    if (componentResolver == null) {
        componentResolver = createComponentResolver();
    }
    return componentResolver;
}
项目:Camel    文件:DefaultCamelContext.java   
public void setComponentResolver(ComponentResolver componentResolver) {
    this.componentResolver = componentResolver;
}
项目:Camel    文件:DefaultCamelContext.java   
/**
 * Lazily create a default implementation
 */
protected ComponentResolver createComponentResolver() {
    return new DefaultComponentResolver();
}
项目:Camel    文件:Activator.java   
public void register() {
    doRegister(ComponentResolver.class, "component", components.keySet());
}
项目:Camel    文件:MllpTcpClientProducerBlueprintTest.java   
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    ComponentResolver testResolver = new DefaultComponentResolver();

    services.put(ComponentResolver.class.getName(), asService(testResolver, "component", "mllp"));
}
项目:Camel    文件:MllpTcpServerConsumerBlueprintTest.java   
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    ComponentResolver testResolver = new DefaultComponentResolver();

    services.put(ComponentResolver.class.getName(), asService(testResolver, "component", "mllp"));
}
项目:Camel    文件:GuiceCamelContext.java   
@Override
@Inject(optional = true)
public void setComponentResolver(ComponentResolver componentResolver) {
    super.setComponentResolver(componentResolver);
}
项目:wildfly-camel    文件:ComponentResolverAssociationHandler.java   
WildFlyComponentResolver(ComponentResolver delegate) {
    this.delegate = delegate;
}