Search in sources :

Example 1 with FileComponent

use of org.apache.camel.component.file.FileComponent in project camel by apache.

the class CamelMockBundleContext method getService.

public Object getService(@SuppressWarnings("rawtypes") ServiceReference reference) {
    String[] classNames = (String[]) reference.getProperty(Constants.OBJECTCLASS);
    String classNames0 = classNames != null ? classNames[0] : null;
    String pid = (String) reference.getProperty(Constants.SERVICE_PID);
    if (classNames0 != null && classNames0.equals("org.apache.camel.core.osgi.test.MyService")) {
        return new MyService();
    } else if (pid != null && pid.equals(SERVICE_PID_PREFIX + "org.apache.camel.core.osgi.test.MyService")) {
        return new MyService();
    } else if (classNames0 != null && classNames0.equals(ComponentResolver.class.getName())) {
        return new ComponentResolver() {

            public Component resolveComponent(String name, CamelContext context) throws Exception {
                if (name.equals("file_test")) {
                    return new FileComponent();
                }
                return null;
            }
        };
    } else if (classNames0 != null && classNames0.equals(LanguageResolver.class.getName())) {
        return new LanguageResolver() {

            public Language resolveLanguage(String name, CamelContext context) {
                if (name.equals("simple")) {
                    return new SimpleLanguage();
                }
                return null;
            }
        };
    } else {
        return null;
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) LanguageResolver(org.apache.camel.spi.LanguageResolver) SimpleLanguage(org.apache.camel.language.simple.SimpleLanguage) Language(org.apache.camel.spi.Language) MyService(org.apache.camel.core.osgi.test.MyService) FileComponent(org.apache.camel.component.file.FileComponent) ComponentResolver(org.apache.camel.spi.ComponentResolver) SimpleLanguage(org.apache.camel.language.simple.SimpleLanguage)

Example 2 with FileComponent

use of org.apache.camel.component.file.FileComponent in project camel by apache.

the class FileComponentAutoConfiguration method configureFileComponent.

@Lazy
@Bean(name = "file-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FileComponent.class)
public FileComponent configureFileComponent(CamelContext camelContext) throws Exception {
    FileComponent component = new FileComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : FileComponent(org.apache.camel.component.file.FileComponent) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with FileComponent

use of org.apache.camel.component.file.FileComponent in project camel by apache.

the class FileComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    FileComponent comp = context.getComponent("file", FileComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("file:target/foo?delete=true");
    assertEquals("true", conf.getParameter("delete"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"directoryName\": { \"kind\": \"path\", \"displayName\": \"Directory Name\", \"group\": \"common\", \"required\": true"));
    assertTrue(json.contains("\"autoCreate\": { \"kind\": \"parameter\", \"displayName\": \"Auto Create\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
    assertTrue(json.contains("\"readLockMinAge\": { \"kind\": \"parameter\", \"displayName\": \"Read Lock Min Age\", \"group\": \"lock\", \"label\": \"consumer,lock\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) FileComponent(org.apache.camel.component.file.FileComponent) EndpointConfiguration(org.apache.camel.EndpointConfiguration) Test(org.junit.Test)

Example 4 with FileComponent

use of org.apache.camel.component.file.FileComponent in project camel by apache.

the class OsgiComponentResolverTest method testOsgiResolverFindComponentTest.

@Test
public void testOsgiResolverFindComponentTest() throws Exception {
    CamelContext camelContext = new DefaultCamelContext();
    OsgiComponentResolver resolver = new OsgiComponentResolver(getBundleContext());
    Component component = resolver.resolveComponent("file_test", camelContext);
    assertNotNull("We should find file_test component", component);
    assertTrue("We should get the file component here", component instanceof FileComponent);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FileComponent(org.apache.camel.component.file.FileComponent) Component(org.apache.camel.Component) FileComponent(org.apache.camel.component.file.FileComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

FileComponent (org.apache.camel.component.file.FileComponent)4 CamelContext (org.apache.camel.CamelContext)2 Test (org.junit.Test)2 Component (org.apache.camel.Component)1 ComponentConfiguration (org.apache.camel.ComponentConfiguration)1 EndpointConfiguration (org.apache.camel.EndpointConfiguration)1 MyService (org.apache.camel.core.osgi.test.MyService)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 SimpleLanguage (org.apache.camel.language.simple.SimpleLanguage)1 ComponentResolver (org.apache.camel.spi.ComponentResolver)1 Language (org.apache.camel.spi.Language)1 LanguageResolver (org.apache.camel.spi.LanguageResolver)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1