org.apache.camel.spi.ClassResolver Java Examples

The following examples show how to use org.apache.camel.spi.ClassResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Sources.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@Override
public InputStream resolveAsInputStream(CamelContext ctx) {
    if (location == null) {
        throw new IllegalArgumentException("Cannot resolve null URI");
    }

    try {
        final ClassResolver cr = ctx.getClassResolver();
        final InputStream is = ResourceHelper.resolveResourceAsInputStream(cr, location);

        return compressed
            ? new GZIPInputStream(Base64.getDecoder().wrap(is))
            : is;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: ConnectorStepHandler.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private static Optional<ComponentProxyFactory> resolveComponentProxyFactory(CamelContext context, Optional<String> componentProxyFactory) {
    ComponentProxyFactory factory = null;

    if (componentProxyFactory.isPresent()) {
        final String factoryType = componentProxyFactory.get();
        final ClassResolver resolver = context.getClassResolver();

        Class<? extends ComponentProxyFactory> type = resolver.resolveClass(factoryType, ComponentProxyFactory.class);
        if (type == null) {
            throw new IllegalArgumentException("Unable to resolve a ComponentProxyFactory of type: " + factoryType);
        }

        factory = context.getInjector().newInstance(type);
        if (factory == null) {
            throw new IllegalArgumentException("Unable to instantiate a ComponentProxyFactory of type: " + factoryType);
        }
    }

    return Optional.ofNullable(factory);
}
 
Example #3
Source File: ClassLoadingRouteBuilderA.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void configure() throws Exception {
    from("direct:startA")
        .process(exchange -> {
            ClassResolver classResolver = getContext().getClassResolver();
            Class<HelloBean> helloBeanClass = classResolver.resolveClass(HelloBean.class.getName(), HelloBean.class);
            HelloBean helloBean = helloBeanClass.newInstance();
            exchange.getMessage().setBody(helloBean.hello("RouteA"));
        });
}
 
Example #4
Source File: FastFactoryFinderResolver.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public FactoryFinder resolveFactoryFinder(ClassResolver classResolver, String resourcePath) {
    return new FastFactoryFinder(resourcePath);
}