List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:org.araqne.main.Araqne.java
private void registerScriptFactory(ScriptFactory scriptFactory, String alias) { Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("alias", alias); context.registerService(ScriptFactory.class.getName(), scriptFactory, props); }
From source file:ch.entwine.weblounge.contentrepository.impl.bundle.WritableBundleContentRepository.java
/** * {@inheritDoc}/* ww w . j av a 2 s .co m*/ * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void updated(Dictionary properties) throws ConfigurationException { // Since the bundle content repository is based on the file system content // repository, the configuration properties need to be adjusted String rootDirPath = (String) properties.get(OPT_ROOT_DIR); if (StringUtils.isNotBlank(rootDirPath)) { properties.put(FileSystemContentRepository.OPT_ROOT_DIR, PathUtils.trim(rootDirPath)); logger.info("Bundle content repository data will be stored at {}", rootDirPath); } super.updated(properties); }
From source file:org.paxle.core.impl.MWComponent.java
/** * {@inheritDoc}//w w w. j a v a2s . com * @see IMWComponent#pause() */ @SuppressWarnings("unchecked") public void pause() { try { final Dictionary props = configuration.getProperties(); props.put(getFullPropertyName(PROP_STATE_ACTIVE), Boolean.FALSE); this.configuration.update(props); } catch (IOException e) { this.logger.error(e); } }
From source file:org.paxle.core.impl.MWComponent.java
/** * {@inheritDoc}// w w w. j av a 2 s .c o m * @see IMWComponent#resume() */ @SuppressWarnings("unchecked") public void resume() { try { final Dictionary props = configuration.getProperties(); props.put(getFullPropertyName(PROP_STATE_ACTIVE), Boolean.TRUE); this.configuration.update(props); } catch (IOException e) { this.logger.error(e); } }
From source file:org.liveSense.service.email.EmailSendJobEventHandler.java
public void run() { Session session = null;//from ww w . ja va 2 s . c o m try { // Searcing in spool for mails session = repository.loginAdministrative(null); QueryManager queryManager = session.getWorkspace().getQueryManager(); Query query = queryManager.createQuery("/jcr:root/" + spoolFolder + "*[@jcr:primaryType='email:email' and @nextTry<" + System.currentTimeMillis() + "]", Query.XPATH); QueryResult res = query.execute(); RowIterator iter = res.getRows(); while (iter.hasNext()) { Row row = iter.nextRow(); String path = row.getPath(); try { log.info("Retry send email: " + path); final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(JobUtil.PROPERTY_JOB_TOPIC, EmailResourceChangeListener.EMAIL_SEND_TOPIC); props.put("resourcePath", path); props.put(EmailResourceChangeListener.PARAM_NODE_TYPE, nodeType); //props.put(EmailResourceChangeListener.PARAM_PROPERTY_NAME, propertyName); org.osgi.service.event.Event emailSendJob = new org.osgi.service.event.Event(JobUtil.TOPIC_JOB, props); eventAdmin.sendEvent(emailSendJob); } catch (Exception e) { log.error("Could not send email: " + path, e); } } } catch (Exception e2) { log.error("Error on periodical run: ", e2); } finally { if (session != null && session.isLive()) { session.logout(); } } }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswSubscriptionEndpoint.java
/** * Persist the subscription to the OSGi ConfigAdmin service. Persisted registeredSubscriptions can then be restored if DDF * is restarted after a DDF outage or DDF is shutdown. * Pass in client-provided subscriptionId and subscription UUID because the filter XML to be persisted for this subscription will be used to * restore this subscription and should consist of the exact values the * client originally provided.//from w ww . j a v a2s . c om */ private void persistSubscription(CswSubscription subscription, String deliveryMethodUrl, String subscriptionUuid) { String methodName = "persistSubscription"; LOGGER.trace("ENTERING: {}", methodName); try { StringWriter sw = new StringWriter(); CswQueryFactory.getJaxBContext().createMarshaller() .marshal(objectFactory.createGetRecords(subscription.getOriginalRequest()), sw); String filterXml = sw.toString(); // Store filter XML, deliveryMethod URL, this endpoint's factory PID, and subscription ID into OSGi CongiAdmin if (filterXml != null) { Configuration config = getConfigAdmin() .createFactoryConfiguration(CswSubscriptionConfigFactory.FACTORY_PID, null); Dictionary<String, String> props = new Hashtable<>(); props.put(CswSubscriptionConfigFactory.SUBSCRIPTION_ID, subscriptionUuid); props.put(CswSubscriptionConfigFactory.FILTER_XML, filterXml); props.put(CswSubscriptionConfigFactory.DELIVERY_METHOD_URL, deliveryMethodUrl); props.put(CswSubscriptionConfigFactory.SUBSCRIPTION_UUID, subscriptionUuid); LOGGER.debug("Done adding persisting subscription to ConfigAdmin"); config.update(props); } } catch (JAXBException | IOException e) { LOGGER.warn("Unable to persist subscription " + subscriptionUuid, e); } LOGGER.trace("EXITING: {}", methodName); }
From source file:ch.entwine.weblounge.kernel.command.SiteCommand.java
/** * Callback for OSGi's declarative services component activation. * /* w w w .j a v a 2s. co m*/ * @param context * the component context * @throws Exception * if component inactivation fails */ void activate(ComponentContext context) throws Exception { BundleContext bundleContext = context.getBundleContext(); logger.debug("Registering site commands"); Dictionary<String, Object> commands = new Hashtable<String, Object>(); commands.put("osgi.command.scope", "weblounge"); commands.put("osgi.command.function", new String[] { "site", "sites" }); bundleContext.registerService(getClass().getName(), this, commands); }
From source file:org.wso2.carbon.security.deployment.SecurityDeploymentInterceptor.java
protected void activate(ComponentContext ctxt) { BundleContext bundleCtx = ctxt.getBundleContext(); try {//from w ww . j a va 2s .c o m PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); loadSecurityScenarios(SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(), bundleCtx); } catch (Exception e) { String msg = "Cannot load security scenarios"; log.error(msg, e); throw new RuntimeException(msg, e); } try { addKeystores(); } catch (Exception e) { String msg = "Cannot add keystores"; log.error(msg, e); throw new RuntimeException(msg, e); } // Publish the OSGi service Dictionary props = new Hashtable(); props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName()); bundleCtx.registerService(AxisObserver.class.getName(), this, props); PreAxisConfigurationPopulationObserver preAxisConfigObserver = new PreAxisConfigurationPopulationObserver() { @Override public void createdAxisConfiguration(AxisConfiguration axisConfiguration) { init(axisConfiguration); axisConfiguration.addObservers(SecurityDeploymentInterceptor.this); } }; bundleCtx.registerService(PreAxisConfigurationPopulationObserver.class.getName(), preAxisConfigObserver, null); // Publish an OSGi service to listen tenant configuration context creation events Dictionary properties = new Hashtable(); properties.put(CarbonConstants.AXIS2_CONFIG_SERVICE, Axis2ConfigurationContextObserver.class.getName()); bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(), new SecurityDeploymentListener(), properties); }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswSubscriptionEndpoint.java
public synchronized String addOrUpdateSubscription(GetRecordsType request, boolean persistSubscription) throws CswException { String methodName = "createSubscription"; LOGGER.trace("ENTERING: {} (persistSubscription = {})", methodName); if (request.getResponseHandler() == null || request.getResponseHandler().isEmpty() || StringUtils.isEmpty(request.getResponseHandler().get(0))) { throw new CswException("Unable to create subscription because deliveryMethodUrl is null or empty"); }/* www . j a v a 2 s . c om*/ String deliveryMethodUrl = request.getResponseHandler().get(0); String subscriptionUuid = getSubscriptionUuid(request.getRequestId()); LOGGER.debug("subscriptionUuid = {}", subscriptionUuid); request.setRequestId(subscriptionUuid); // If this subscription already exists, then delete it and re-add it // to registry if (registeredSubscriptions.containsKey(subscriptionUuid)) { LOGGER.debug("Delete existing subscription {} for re-creation", subscriptionUuid); deleteCswSubscription(subscriptionUuid); } CswSubscription sub = createSubscription(request); Dictionary<String, String> props = new Hashtable<>(); props.put("subscription-id", subscriptionUuid); props.put("event-endpoint", request.getResponseHandler().get(0)); LOGGER.debug("Registering Subscription"); ServiceRegistration serviceRegistration = getBundleContext().registerService(Subscription.class.getName(), sub, props); if (serviceRegistration != null) { LOGGER.debug("Subscription registered with bundle ID = {} ", serviceRegistration.getReference().getBundle().getBundleId()); registeredSubscriptions.put(subscriptionUuid, serviceRegistration); // Pass in client-provided subscriptionId vs. subscription UUID because // the filter XML to be persisted for this subscription will be used to // restore this subscription and should consist of the exact values the // client originally provided. if (persistSubscription) { persistSubscription(sub, deliveryMethodUrl, subscriptionUuid); } } else { LOGGER.debug("Subscription registration failed"); } LOGGER.trace("EXITING: {}", methodName); return subscriptionUuid; }
From source file:org.paxle.parser.impl.SubParserManager.java
@SuppressWarnings("unchecked") public void removeSubParser(final ServiceReference ref) { final String[] mimeTypes = getMimeTypes(ref); if (mimeTypes == null) return;//w w w .j a va2 s.c om for (String mimeType : mimeTypes) { mimeType = mimeType.trim(); TreeSet<ServiceReference> refs = this.subParserList.get(mimeType); if (refs == null) continue; this.services.remove(keyFor(mimeType, ref)); refs.remove(ref); this.logger.info(String.format("Parser for mimetypes '%s' was uninstalled.", mimeType)); } try { final Dictionary props = config.getProperties(); props.put(ENABLED_MIMETYPES, this.enabledServices.toArray(new String[this.enabledServices.size()])); config.update(props); } catch (IOException e) { logger.error("error updating configuration", e); } }