Search in sources :

Example 6 with Properties

use of java.util.Properties in project camel by apache.

the class GreaterCamelEjbPropertiesTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    // use simple registry to not conflict with jndi used by EJB
    CamelContext answer = new DefaultCamelContext(new SimpleRegistry());
    // enlist EJB component using JndiContext
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    EjbComponent ejb = answer.getComponent("ejb", EjbComponent.class);
    ejb.setProperties(properties);
    return answer;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) Properties(java.util.Properties) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 7 with Properties

use of java.util.Properties in project camel by apache.

the class GreaterCamelEjbTest method createEjbContext.

private static Context createEjbContext() throws NamingException {
    // here we need to define our context factory to use OpenEJB for our testing
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    return new InitialContext(properties);
}
Also used : Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 8 with Properties

use of java.util.Properties in project camel by apache.

the class GreaterTest method setUp.

protected void setUp() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    initialContext = new InitialContext(properties);
}
Also used : Properties(java.util.Properties) InitialContext(javax.naming.InitialContext)

Example 9 with Properties

use of java.util.Properties in project camel by apache.

the class DefaultPropertiesResolver method loadPropertiesFromRegistry.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected Properties loadPropertiesFromRegistry(CamelContext context, boolean ignoreMissingLocation, PropertiesLocation location) throws IOException {
    String path = location.getPath();
    Properties answer;
    try {
        answer = context.getRegistry().lookupByNameAndType(path, Properties.class);
    } catch (Exception ex) {
        // just look up the Map as a fault back
        Map map = context.getRegistry().lookupByNameAndType(path, Map.class);
        answer = new Properties();
        answer.putAll(map);
    }
    if (answer == null && (!ignoreMissingLocation && !location.isOptional())) {
        throw new FileNotFoundException("Properties " + path + " not found in registry");
    }
    return answer != null ? answer : new Properties();
}
Also used : FileNotFoundException(java.io.FileNotFoundException) Properties(java.util.Properties) Map(java.util.Map) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 10 with Properties

use of java.util.Properties in project camel by apache.

the class DefaultPropertiesResolver method resolveProperties.

public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, List<PropertiesLocation> locations) throws Exception {
    Properties answer = new Properties();
    Properties prop;
    for (PropertiesLocation location : locations) {
        switch(location.getResolver()) {
            case "ref":
                prop = loadPropertiesFromRegistry(context, ignoreMissingLocation, location);
                prop = prepareLoadedProperties(prop);
                answer.putAll(prop);
                break;
            case "file":
                prop = loadPropertiesFromFilePath(context, ignoreMissingLocation, location);
                prop = prepareLoadedProperties(prop);
                answer.putAll(prop);
                break;
            case "classpath":
            default:
                // default to classpath
                prop = loadPropertiesFromClasspath(context, ignoreMissingLocation, location);
                prop = prepareLoadedProperties(prop);
                answer.putAll(prop);
                break;
        }
    }
    return answer;
}
Also used : Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)9354 Test (org.junit.Test)3005 IOException (java.io.IOException)1277 Connection (java.sql.Connection)1179 File (java.io.File)1013 ResultSet (java.sql.ResultSet)860 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)819 PreparedStatement (java.sql.PreparedStatement)791 InputStream (java.io.InputStream)614 FileInputStream (java.io.FileInputStream)598 HashMap (java.util.HashMap)475 Map (java.util.Map)387 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)387 ArrayList (java.util.ArrayList)371 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)321 SQLException (java.sql.SQLException)308 Before (org.junit.Before)272 AttributesFactory (org.apache.geode.cache.AttributesFactory)245 InitialContext (javax.naming.InitialContext)214 Configuration (org.apache.hadoop.conf.Configuration)187