List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:org.wso2.carbon.core.util.Utils.java
/** * Given a bundleContext this method will register any HTTPGetRequestProcessors found in that * bundle//ww w. java 2 s . co m * @param bundleContext The bundleContext of the bundle that may have HTTPGetRequestProcessors * @throws Exception Thrown in case the component.xml cannot be processes */ public static void registerHTTPGetRequestProcessors(BundleContext bundleContext) throws Exception { URL url = bundleContext.getBundle().getEntry("META-INF/component.xml"); if (url == null) { return; } InputStream inputStream = url.openStream(); Component component = ComponentConfigFactory.build(inputStream); HTTPGetRequestProcessorConfig[] getRequestProcessorConfigs = null; if (component != null) { getRequestProcessorConfigs = (HTTPGetRequestProcessorConfig[]) component .getComponentConfig(ComponentConstants.HTTP_GET_REQUEST_PROCESSORS); } if (getRequestProcessorConfigs != null) { for (HTTPGetRequestProcessorConfig getRequestProcessorConfig : getRequestProcessorConfigs) { Class getRequestProcessorClass; try { getRequestProcessorClass = bundleContext.getBundle() .loadClass(getRequestProcessorConfig.getClassName()); } catch (ClassNotFoundException e) { getRequestProcessorClass = Class.forName(getRequestProcessorConfig.getClassName()); } HttpGetRequestProcessor getRequestProcessor = (HttpGetRequestProcessor) getRequestProcessorClass .newInstance(); String item = getRequestProcessorConfig.getItem(); Dictionary<String, String> propsMap = new Hashtable<String, String>(2); propsMap.put(ComponentConstants.ELE_ITEM, item); propsMap.put(CarbonConstants.HTTP_GET_REQUEST_PROCESSOR_SERVICE, HttpGetRequestProcessor.class.getName()); //Registering the HttpGetRequestProcessor implementation in the OSGi registry bundleContext.registerService(HttpGetRequestProcessor.class.getName(), getRequestProcessor, propsMap); } } }
From source file:com.adeptj.runtime.common.Servlets.java
private static String resolveServletName(Class<? extends HttpServlet> cls, String name, Dictionary<String, Object> props) { String servletName = name.isEmpty() ? cls.getSimpleName() : name; props.put(HTTP_WHITEBOARD_SERVLET_NAME, servletName); return servletName; }
From source file:io.adeptj.runtime.common.Servlets.java
private static String handleName(Class<? extends HttpServlet> cls, String name, Dictionary<String, Object> props) { String servletName = name.isEmpty() ? cls.getSimpleName() : name; props.put(HTTP_WHITEBOARD_SERVLET_NAME, servletName); return servletName; }
From source file:org.nuxeo.osgi.BundleManifestReader.java
public static Dictionary<String, String> getDefaultHeaders(String symbolicName) { Dictionary<String, String> headers = new Hashtable<String, String>(); headers.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName); headers.put(Constants.BUNDLE_ACTIVATOR, NullActivator.class.getName()); return headers; }
From source file:org.nuxeo.osgi.BundleManifestReader.java
private static void parseSymbolicName(Dictionary<String, String> headers, String name) { int p = name.indexOf(';'); if (p > 0) { headers.put(Constants.BUNDLE_SYMBOLICNAME, name.substring(0, p).trim()); String tail = name.substring(p + 1); Matcher m = PARAMS_PATTERN.matcher(tail); while (m.find()) { headers.put(m.group(1), m.group(2)); }//from w w w . ja v a 2s. c o m } else { headers.put(Constants.BUNDLE_SYMBOLICNAME, name.trim()); } }
From source file:org.wso2.carbon.identity.provider.internal.ServletContextListener.java
private static void registerServlets(BundleContext bundleContext) { Dictionary dictionaryResourceParams = null; OpenIDUserServlet userServlet = null; OpenIDProviderServlet providerServlet = null; // Register OpenIDUserServlet dictionaryResourceParams = new Hashtable(1); dictionaryResourceParams.put("url-pattern", "/openid"); userServlet = new OpenIDUserServlet(); bundleContext.registerService(Servlet.class.getName(), userServlet, dictionaryResourceParams); // Register OpenIDServerServlet dictionaryResourceParams = new Hashtable(1); dictionaryResourceParams.put("url-pattern", "/openidserver"); providerServlet = new OpenIDProviderServlet(); bundleContext.registerService(Servlet.class.getName(), providerServlet, dictionaryResourceParams); }
From source file:de.dfki.iui.mmds.scxml.engine.SCXMLEngineActivator.java
/** * Register an event handler to be able to listen for osgi events like from * the <code>Scxml Debug View</code>. * //from ww w . ja va2 s . c o m * @param handler * - The handler to call in case of an event match. * @param topics * - An array of topics that will be used to check on which * events the handler should be called. * @return The service registration to be able to change the properties or * to unregister the handler by using * {@link #unregisterEventHandler(ServiceReference) }. */ public static ServiceRegistration<?> registerEventHandler(EventHandler handler, String... topics) { if (context != null) { Dictionary<String, Object> ht = new Hashtable<String, Object>(1); ht.put(EventConstants.EVENT_TOPIC, topics); return context.registerService(EVENT_HANDLER_CLASS, handler, ht); } return null; }
From source file:uk.org.openeyes.oink.itest.karaf.OinkKarafITSupport.java
public static Dictionary<String, Object> convertToDictionary(Properties props) { Dictionary<String, Object> d = new Hashtable<String, Object>(); for (Entry<Object, Object> entry : props.entrySet()) { d.put((String) entry.getKey(), entry.getValue()); }/*w w w.j av a 2 s. c o m*/ return d; }
From source file:org.opencastproject.staticfiles.endpoint.StaticFileRestServiceTest.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private static ComponentContext getComponentContext(String useWebserver, long maxSize) { // Create BundleContext BundleContext bundleContext = EasyMock.createMock(BundleContext.class); EasyMock.expect(bundleContext.getProperty(MatterhornConstants.SERVER_URL_PROPERTY)).andReturn(SERVER_URL); // EasyMock.expect(bundleContext.getProperty(StaticFileServiceImpl.STATICFILES_ROOT_DIRECTORY_KEY)).andReturn( // rootDir.getAbsolutePath()); EasyMock.expect(bundleContext.getProperty(StaticFileRestService.STATICFILES_UPLOAD_MAX_SIZE_KEY)) .andReturn(Long.toString(maxSize)); EasyMock.replay(bundleContext);// w w w . j a v a2 s .com // Create ComponentContext Dictionary properties = new Properties(); if (useWebserver != null) { properties.put(StaticFileRestService.STATICFILES_WEBSERVER_ENABLED_KEY, useWebserver); } properties.put(StaticFileRestService.STATICFILES_WEBSERVER_URL_KEY, WEBSERVER_URL); ComponentContext cc = EasyMock.createMock(ComponentContext.class); EasyMock.expect(cc.getProperties()).andReturn(properties).anyTimes(); EasyMock.expect(cc.getBundleContext()).andReturn(bundleContext).anyTimes(); EasyMock.replay(cc); return cc; }
From source file:org.wso2.carbon.utils.Utils.java
/** * Registers the Deployer services by using values defined in the corresonding bundles component.xml file.. * * @param bundleContext/* www . ja v a 2 s.c om*/ */ public static void registerDeployerServices(BundleContext bundleContext) throws Exception { URL url = bundleContext.getBundle().getEntry("META-INF/component.xml"); if (url == null) { return; } InputStream inputStream = url.openStream(); Component component = ComponentConfigFactory.build(inputStream); DeployerConfig[] deployerConfigs = null; if (component != null) { deployerConfigs = (DeployerConfig[]) component.getComponentConfig(ComponentConstants.DEPLOYER_CONFIG); } if (deployerConfigs != null) { for (DeployerConfig deployerConfig : deployerConfigs) { Class deployerClass = null; try { deployerClass = bundleContext.getBundle().loadClass(deployerConfig.getClassStr()); } catch (ClassNotFoundException e) { deployerClass = Class.forName(deployerConfig.getClassStr()); } Deployer deployer = (Deployer) deployerClass.newInstance(); String directory = deployerConfig.getDirectory(); String extension = deployerConfig.getExtension(); deployer.setDirectory(directory); deployer.setExtension(extension); Dictionary propsMap = new Hashtable(2); propsMap.put(DeploymentConstants.DIRECTORY, directory); propsMap.put(DeploymentConstants.EXTENSION, extension); propsMap.put(CarbonConstants.AXIS2_CONFIG_SERVICE, Deployer.class.getName()); //Registering the Axis1 deployer in the OSGi registry bundleContext.registerService(Deployer.class.getName(), deployer, propsMap); } } }