Package org.apache.camel

Examples of org.apache.camel.Component


    }

    public void testAutoCreateComponentsOff() {
        DefaultCamelContext ctx = new DefaultCamelContext();
        ctx.setAutoCreateComponents(false);
        Component component = ctx.getComponent("bean");
        assertNull(component);
    }
View Full Code Here


        Object value = context.lookup("foo");
        assertNotNull("Should have found a value for foo!", value);

        CamelContext camelContext = injector.getInstance(CamelContext.class);
        Component component = camelContext.getComponent("foo");
        assertThat(component, is(MockComponent.class));

        Endpoint endpoint = camelContext.getEndpoint("foo:cheese");
        assertThat(endpoint, is(MockEndpoint.class));
    }
View Full Code Here

            // not an URIConfiguration
            return null;
        }
        String scheme = uri.substring(0, schemeSeparator);
       
        Component component = context.getComponent(scheme);
        if (LOG.isTraceEnabled()) {
            LOG.trace("Lookup for Component handling \"{}:\" configuration returned {}",
                new Object[]{scheme, component != null ? component.getClass().getName() : "<null>"});
        }
        if (component != null) {
            EndpointConfiguration config = component.createConfiguration(scheme);
            if (config instanceof DefaultEndpointConfiguration) {
                ((DefaultEndpointConfiguration) config).setURI(uri);
            }
            return config;
        } else {
View Full Code Here

            public Object evaluate(Exchange exchange) {
                try {
                    if (locations != null) {
                        // the properties component is optional as we got locations
                        // getComponent will create a new component if none already exists
                        Component component = exchange.getContext().getComponent("properties");
                        PropertiesComponent pc = exchange.getContext().getTypeConverter()
                                .mandatoryConvertTo(PropertiesComponent.class, component);
                        // enclose key with {{ }} to force parsing
                        String[] paths = locations.split(",");
                        return pc.parseUri(pc.getPrefixToken() + key + pc.getSuffixToken(), paths);
                    } else {
                        // the properties component is mandatory if no locations provided
                        Component component = exchange.getContext().hasComponent("properties");
                        if (component == null) {
                            throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
                                    + " in CamelContext to support property placeholders in expressions");
                        }
                        PropertiesComponent pc = exchange.getContext().getTypeConverter()
View Full Code Here

    public Component getComponent(String name) {
        // synchronize the look up and auto create so that 2 threads can't
        // concurrently auto create the same component.
        synchronized (components) {
            Component component = components.get(name);
            if (component == null && autoCreateComponents) {
                try {
                    component = getComponentResolver().resolveComponent(name, this);
                    if (component != null) {
                        addComponent(name, component);
View Full Code Here

            return component;
        }
    }

    public <T extends Component> T getComponent(String name, Class<T> componentType) {
        Component component = getComponent(name);
        if (componentType.isInstance(component)) {
            return componentType.cast(component);
        } else {
            String message;
            if (component == null) {
                message = "Did not find component given by the name: " + name;
            } else {
                message = "Found component of type: " + component.getClass() + " instead of expected: " + componentType;
            }
            throw new IllegalArgumentException(message);
        }
    }
View Full Code Here

        }
    }

    public Component removeComponent(String componentName) {
        synchronized (components) {
            Component answer = components.remove(componentName);
            if (answer != null) {
                for (LifecycleStrategy strategy : lifecycleStrategies) {
                    strategy.onComponentRemove(componentName, answer);
                }
            }
View Full Code Here

            try {
                // Use the URI prefix to find the component.
                String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 2);
                if (splitURI[1] != null) {
                    scheme = splitURI[0];
                    Component component = getComponent(scheme);

                    // Ask the component to resolve the endpoint.
                    if (component != null) {
                        // Have the component create the endpoint if it can.
                        answer = component.createEndpoint(uri);

                        if (answer != null && log.isDebugEnabled()) {
                            log.debug("{} converted to endpoint: {} by component: {}", new Object[]{URISupport.sanitizeUri(uri), answer, component});
                        }
                    }
View Full Code Here

    /**
     * Looks up the properties component if one may be resolved or has already been created.
     * Returns {@code null} if one was not created or is not in the registry.
     */
    protected PropertiesComponent getPropertiesComponent() {
        Component component = hasComponent("properties");
        if (component == null) {
            // then fallback to lookup the component
            component = getRegistry().lookup("properties", Component.class);
        }
       
View Full Code Here

    public void testMultipleLifecycleStrategies() throws Exception {
        CamelContext context = createCamelContext();
        context.start();

        Component log = new LogComponent();
        context.addComponent("log", log);
        context.addEndpoint("log:/foo", log.createEndpoint("log://foo"));
        context.removeComponent("log");
        context.stop();

        List<String> expectedEvents = Arrays.asList("onServiceAdd", "onThreadPoolAdd", "onContextStart", "onServiceAdd",
                "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd", "onServiceAdd",
View Full Code Here

TOP

Related Classes of org.apache.camel.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.