use of java.util.Hashtable in project camel by apache.
the class FileEndpointReferenceRouteTest method runTest.
@Test
public void runTest() throws Exception {
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.PROVIDER_URL, GuiceInitialContextFactory.class.getName());
env.put(Injectors.MODULE_CLASS_NAMES, MyModule.class.getName());
InitialContext context = new InitialContext(env);
Injector injector = (Injector) context.lookup(Injector.class.getName());
assertNotNull("Found injector", injector);
Object value = context.lookup("fileFilter");
assertNotNull("Should have found a value for foo!", value);
assertCamelContextRunningThenCloseInjector(injector);
}
use of java.util.Hashtable in project camel by apache.
the class CamelMockBundleContext method addServicePID.
private static void addServicePID(ServiceReference[] srs, String filter) {
for (ServiceReference sr : srs) {
if (sr instanceof MockServiceReference) {
Dictionary properties = new Hashtable();
String pid = filter.replace("(" + Constants.SERVICE_PID + "=", "").replace(")", "");
properties.put(Constants.SERVICE_PID, pid);
for (String key : sr.getPropertyKeys()) {
if (properties.get(key) == null) {
properties.put(key, sr.getProperty(key));
}
}
((MockServiceReference) sr).setProperties(properties);
}
}
}
use of java.util.Hashtable in project camel by apache.
the class OsgiEventAdminNotifier method notify.
public void notify(EventObject event) throws Exception {
EventAdmin eventAdmin = tracker.getService();
if (eventAdmin == null) {
return;
}
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(TYPE, getType(event));
props.put(EVENT, event);
props.put(TIMESTAMP, System.currentTimeMillis());
props.put(BUNDLE, bundleContext.getBundle());
props.put(BUNDLE_SYMBOLICNAME, bundleContext.getBundle().getSymbolicName());
props.put(BUNDLE_ID, bundleContext.getBundle().getBundleId());
props.put(BUNDLE_VERSION, getBundleVersion(bundleContext.getBundle()));
try {
props.put(CAUSE, event.getClass().getMethod("getCause").invoke(event));
} catch (Throwable t) {
// ignore
}
eventAdmin.postEvent(new Event(getTopic(event), props));
}
use of java.util.Hashtable in project platformlayer by platformlayer.
the class ITOpenLdapService method testLdap.
private void testLdap(String ldapUrl, Secret adminPassword) throws NamingException {
Hashtable<String, String> env = new Hashtable<String, String>();
String sp = "com.sun.jndi.ldap.LdapCtxFactory";
env.put(Context.INITIAL_CONTEXT_FACTORY, sp);
env.put(Context.PROVIDER_URL, ldapUrl);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=Manager,dc=test,dc=platformlayer,dc=org");
env.put(Context.SECURITY_CREDENTIALS, adminPassword.plaintext());
DirContext ctx = new InitialDirContext(env);
NamingEnumeration results = ctx.list("dc=test,dc=platformlayer,dc=org");
while (results.hasMore()) {
NameClassPair sr = (NameClassPair) results.next();
System.out.println(sr.getNameInNamespace());
}
ctx.close();
}
use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method checkSAXVersion.
/**
* Report version info from SAX interfaces.
*
* Currently distinguishes between SAX 2, SAX 2.0beta2,
* SAX1, and not found.
*
* @param h Hashtable to put information in
*/
protected void checkSAXVersion(Hashtable h) {
if (null == h)
h = new Hashtable();
final String SAX_VERSION1_CLASS = "org.xml.sax.Parser";
// String
final String SAX_VERSION1_METHOD = "parse";
final String SAX_VERSION2_CLASS = "org.xml.sax.XMLReader";
// String
final String SAX_VERSION2_METHOD = "parse";
final String SAX_VERSION2BETA_CLASSNF = "org.xml.sax.helpers.AttributesImpl";
// Attributes
final String SAX_VERSION2BETA_METHODNF = "setAttributes";
final Class[] oneStringArg = { java.lang.String.class };
// Note this introduces a minor compile dependency on SAX...
final Class[] attributesArg = { org.xml.sax.Attributes.class };
try {
// This method was only added in the final SAX 2.0 release;
// see changes.html "Changes from SAX 2.0beta2 to SAX 2.0prerelease"
Class clazz = ObjectFactory.findProviderClass(SAX_VERSION2BETA_CLASSNF, ObjectFactory.findClassLoader(), true);
Method method = clazz.getMethod(SAX_VERSION2BETA_METHODNF, attributesArg);
// If we succeeded, we have loaded interfaces from a
// real, final SAX version 2.0 somewhere
h.put(VERSION + "SAX", "2.0");
} catch (Exception e) {
// If we didn't find the SAX 2.0 class, look for a 2.0beta2
h.put(ERROR + VERSION + "SAX", "ERROR attempting to load SAX version 2 class: " + e.toString());
h.put(ERROR, ERROR_FOUND);
try {
Class clazz = ObjectFactory.findProviderClass(SAX_VERSION2_CLASS, ObjectFactory.findClassLoader(), true);
Method method = clazz.getMethod(SAX_VERSION2_METHOD, oneStringArg);
// If we succeeded, we have loaded interfaces from a
// SAX version 2.0beta2 or earlier; these might work but
// you should really have the final SAX 2.0
h.put(VERSION + "SAX-backlevel", "2.0beta2-or-earlier");
} catch (Exception e2) {
// If we didn't find the SAX 2.0beta2 class, look for a 1.0 one
h.put(ERROR + VERSION + "SAX", "ERROR attempting to load SAX version 2 class: " + e.toString());
h.put(ERROR, ERROR_FOUND);
try {
Class clazz = ObjectFactory.findProviderClass(SAX_VERSION1_CLASS, ObjectFactory.findClassLoader(), true);
Method method = clazz.getMethod(SAX_VERSION1_METHOD, oneStringArg);
// If we succeeded, we have loaded interfaces from a
// SAX version 1.0 somewhere; which won't work very
// well for JAXP 1.1 or beyond!
h.put(VERSION + "SAX-backlevel", "1.0");
} catch (Exception e3) {
// If we didn't find the SAX 2.0 class, look for a 1.0 one
// Note that either 1.0 or no SAX are both errors
h.put(ERROR + VERSION + "SAX-backlevel", "ERROR attempting to load SAX version 1 class: " + e3.toString());
}
}
}
}
Aggregations