List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:org.ops4j.pax.web.service.internal.DefaultPropertyResolver.java
private static Dictionary getDefaltProperties() { Dictionary<String, String> properties = new Hashtable<String, String>(); properties.put(PROPERTY_HTTP_PORT, "8080"); properties.put(PROPERTY_HTTP_USE_NIO, Boolean.TRUE.toString()); properties.put(PROPERTY_HTTP_ENABLED, Boolean.TRUE.toString()); properties.put(PROPERTY_HTTP_SECURE_PORT, "8443"); properties.put(PROPERTY_HTTP_SECURE_ENABLED, Boolean.FALSE.toString()); properties.put(PROPERTY_SSL_KEYSTORE, System.getProperty("user.home") + File.separator + ".keystore"); //properties.put( PROPERTY_SSL_PASSWORD, null ); //properties.put( PROPERTY_SSL_KEYPASSWORD, null ); // create a temporary directory try {/*from w ww .ja va 2s . c o m*/ File temporaryDirectory = File.createTempFile(".paxweb", ""); temporaryDirectory.delete(); temporaryDirectory = new File(temporaryDirectory.getAbsolutePath()); temporaryDirectory.mkdirs(); temporaryDirectory.deleteOnExit(); properties.put(PROPERTY_TEMP_DIR, temporaryDirectory.getCanonicalPath()); } catch (Exception e) { LOG.warn("Could not create temporary directory. Reason: " + e.getMessage()); //properties.put( PROPERTY_TEMP_DIR, null ); } //properties.put( PROPERTY_SESSION_TIMEOUT, null ); // no timeout return properties; }
From source file:org.ops4j.pax.url.commons.handler.OptionalConfigAdminHelper.java
/** * Registers a managed service to listen on configuration updates. * * @param bundleContext bundle context to be used for registration * @param pid PID to be used for registration * @param handlerActivator handler activator doing registration * * @return service registration of registered service *//*w w w . j ava 2 s . c o m*/ static ServiceRegistration registerManagedService(final BundleContext bundleContext, final String pid, final HandlerActivator<?> handlerActivator) { final ManagedService managedService = new ManagedService() { /** * Sets the resolver on handler. * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ public void updated(final Dictionary config) throws ConfigurationException { if (config == null) { handlerActivator.setResolver(new BundleContextPropertyResolver(bundleContext)); } else { handlerActivator.setResolver(new DictionaryPropertyResolver(config, new BundleContextPropertyResolver(bundleContext))); } } }; final Dictionary<String, String> props = new Hashtable<String, String>(); props.put(Constants.SERVICE_PID, pid); ServiceRegistration registration = bundleContext.registerService(ManagedService.class.getName(), managedService, props); synchronized (handlerActivator) { if (handlerActivator.getResolver() == null) { try { managedService.updated(null); } catch (ConfigurationException ignore) { // this should never happen LOG.error("Internal error. Cannot set initial configuration resolver.", ignore); } } } return registration; }
From source file:io.wcm.dam.assetservice.impl.AssetService.java
private static <T extends Servlet> ServiceRegistration registerServlet(BundleContext bundleContext, T servletInstance, String resourceType, String selector) { if (StringUtils.isEmpty(selector)) { throw new IllegalArgumentException("No selector defined for " + servletInstance.getClass().getName() + " - skipping servlet registration."); }//from w w w . j ava2s. c o m Dictionary<String, Object> config = new Hashtable<String, Object>(); config.put("sling.servlet.resourceTypes", resourceType); config.put("sling.servlet.selectors", selector); config.put("sling.servlet.extensions", FileExtension.JSON); return bundleContext.registerService(Servlet.class.getName(), servletInstance, config); }
From source file:com.adeptj.runtime.common.Servlets.java
public static ServiceRegistration<Servlet> osgiServlet(BundleContext ctx, HttpServlet servlet) { Class<? extends HttpServlet> cls = servlet.getClass(); WebServlet webServlet = checkWebServletAnnotation(cls); Dictionary<String, Object> properties = new Hashtable<>(); // NOSONAR properties.put(HTTP_WHITEBOARD_SERVLET_PATTERN, ArrayUtils.isEmpty(webServlet.urlPatterns()) ? webServlet.value() : webServlet.urlPatterns()); properties.put(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, webServlet.asyncSupported()); handleInitParams(webServlet, properties); String servletName = resolveServletName(cls, webServlet.name(), properties); LOGGER.info("Registering OSGi Servlet: [{}]", servletName); return ctx.registerService(Servlet.class, servlet, properties); }
From source file:io.adeptj.runtime.common.Servlets.java
public static ServiceRegistration<Servlet> osgiServlet(BundleContext ctx, HttpServlet servlet) { Class<? extends HttpServlet> cls = servlet.getClass(); WebServlet webServlet = checkWebServletAnnotation(cls); Dictionary<String, Object> properties = new Hashtable<>(); // NOSONAR properties.put(HTTP_WHITEBOARD_SERVLET_PATTERN, ArrayUtils.isEmpty(webServlet.urlPatterns()) ? webServlet.value() : webServlet.urlPatterns()); properties.put(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, webServlet.asyncSupported()); handleInitParams(webServlet, properties); handleName(cls, webServlet.name(), properties); String servletFQCN = cls.getName(); LOGGER.info("Registering OSGi Servlet: [{}]", servletFQCN); return ctx.registerService(Servlet.class, servlet, properties); }
From source file:com.adeptj.runtime.common.Servlets.java
public static ServiceRegistration<Servlet> osgiServlet(BundleContext ctx, HttpServlet errorServlet, List<String> errors) { Class<? extends HttpServlet> cls = errorServlet.getClass(); WebServlet webServlet = checkWebServletAnnotation(cls); Dictionary<String, Object> properties = new Hashtable<>(); // NOSONAR properties.put(HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, errors); // Apply this ErrorServlet to all the ServletContext instances registered with OSGi. properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, ALL_CONTEXT_SELECT_FILTER); properties.put(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, webServlet.asyncSupported()); handleInitParams(webServlet, properties); String servletName = resolveServletName(cls, webServlet.name(), properties); LOGGER.info("Registering OSGi ErrorServlet: [{}]", servletName); return ctx.registerService(Servlet.class, errorServlet, properties); }
From source file:io.adeptj.runtime.common.Servlets.java
public static ServiceRegistration<Servlet> osgiServlet(BundleContext ctx, HttpServlet errorServlet, List<String> errors) { Class<? extends HttpServlet> cls = errorServlet.getClass(); WebServlet webServlet = checkWebServletAnnotation(cls); Dictionary<String, Object> properties = new Hashtable<>(); // NOSONAR properties.put(HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, errors); // Apply this ErrorServlet to all the ServletContext instances registered with OSGi. properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT, ALL_CONTEXT_SELECT_FILTER); properties.put(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, webServlet.asyncSupported()); handleInitParams(webServlet, properties); String servletName = handleName(cls, webServlet.name(), properties); LOGGER.info("Registering OSGi ErrorHandler: [{}]", servletName); return ctx.registerService(Servlet.class, errorServlet, properties); }
From source file:com.adeptj.runtime.common.Servlets.java
private static void handleInitParams(WebServlet webServlet, Dictionary<String, Object> properties) { Stream.of(webServlet.initParams()).forEach(initParam -> properties .put(HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX + initParam.name(), initParam.value())); }
From source file:org.sakaiproject.nakamura.api.activity.ActivityUtils.java
@SuppressWarnings("rawtypes") public static Event createEvent(String user, String activityItemPath) { final Dictionary<String, String> map = new Hashtable<String, String>(1); map.put("userid", user); map.put(ActivityConstants.EVENT_PROP_PATH, activityItemPath); return new Event(EVENT_TOPIC, (Dictionary) map); }
From source file:io.adeptj.runtime.common.Servlets.java
private static void handleInitParams(WebServlet webServlet, Dictionary<String, Object> properties) { Arrays.stream(webServlet.initParams()).forEach(initParam -> properties .put(HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX + initParam.name(), initParam.value())); }