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;
}
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);
}
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);
}
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();
}
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;
}
Aggregations