Search in sources :

Example 71 with Hashtable

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);
}
Also used : Hashtable(java.util.Hashtable) Injector(com.google.inject.Injector) GuiceInitialContextFactory(org.apache.camel.guice.jndi.GuiceInitialContextFactory) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 72 with Hashtable

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);
        }
    }
}
Also used : MockServiceReference(org.springframework.osgi.mock.MockServiceReference) Dictionary(java.util.Dictionary) Hashtable(java.util.Hashtable) MockServiceReference(org.springframework.osgi.mock.MockServiceReference) ServiceReference(org.osgi.framework.ServiceReference)

Example 73 with Hashtable

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));
}
Also used : EventAdmin(org.osgi.service.event.EventAdmin) Hashtable(java.util.Hashtable) Event(org.osgi.service.event.Event) EventObject(java.util.EventObject)

Example 74 with Hashtable

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();
}
Also used : Hashtable(java.util.Hashtable) NameClassPair(javax.naming.NameClassPair) NamingEnumeration(javax.naming.NamingEnumeration) DirContext(javax.naming.directory.DirContext) InitialDirContext(javax.naming.directory.InitialDirContext) InitialDirContext(javax.naming.directory.InitialDirContext)

Example 75 with Hashtable

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());
            }
        }
    }
}
Also used : Hashtable(java.util.Hashtable) Method(java.lang.reflect.Method)

Aggregations

Hashtable (java.util.Hashtable)1752 Test (org.junit.Test)374 ArrayList (java.util.ArrayList)355 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)219 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)142 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)137 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)136 HashMap (java.util.HashMap)104 IOException (java.io.IOException)91 Dictionary (java.util.Dictionary)91 Vector (java.util.Vector)88 File (java.io.File)86 Map (java.util.Map)84 Bundle (org.osgi.framework.Bundle)84 BundleContext (org.osgi.framework.BundleContext)78 Configuration (org.osgi.service.cm.Configuration)75 Enumeration (java.util.Enumeration)70 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)70 State (org.eclipse.osgi.service.resolver.State)70 ServiceRegistration (org.osgi.framework.ServiceRegistration)65