List of usage examples for org.apache.commons.collections ExtendedProperties addProperty
public void addProperty(String key, Object value)
From source file:org.sakaiproject.nakamura.proxy.ProxyClientServiceImpl.java
/** * Create resources used by this component. * * @param ctx/* w w w . j a va 2 s . c o m*/ * @throws Exception */ @SuppressWarnings("unchecked") protected void activate(ComponentContext ctx) throws Exception { if (ctx != null) { Dictionary<String, Object> props = ctx.getProperties(); configProperties = new HashMap<String, Object>(); for (Enumeration<String> e = props.keys(); e.hasMoreElements();) { String k = e.nextElement(); configProperties.put(k, props.get(k)); } String[] safePostProcessorNames = (String[]) configProperties.get(SAFE_POSTPROCESSORS); if (safePostProcessorNames == null) { safeOpenProcessors.add("rss"); safeOpenProcessors.add("trustedLoginTokenProxyPostProcessor"); } else { for (String pp : safePostProcessorNames) { safeOpenProcessors.add(pp); } } } else { configProperties = new HashMap<String, Object>(); } velocityEngine = new VelocityEngine(); velocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new VelocityLogger(this.getClass())); velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, JCR_RESOURCE_LOADER); velocityEngine.setProperty(JCR_RESOURCE_LOADER_CLASS, JcrResourceLoader.class.getName()); ExtendedProperties configuration = new ExtendedProperties(); configuration.addProperty(JCR_RESOURCE_LOADER_PATH + ProxyNodeSource.JCR_RESOURCE_LOADER_RESOURCE_SOURCE, this); velocityEngine.setExtendedProperties(configuration); velocityEngine.init(); httpClientConnectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); // could set a whole load of connection properties httpClientConnectionManager.setParams(params); httpClient = new HttpClient(httpClientConnectionManager); // allow communications via a proxy server if command line // java parameters http.proxyHost,http.proxyPort,http.proxyUser, // http.proxyPassword have been provided. externalAuthenticatingProxy = false; String proxyHost = System.getProperty("http.proxyHost", ""); int proxyPort = Integer.parseInt(System.getProperty("http.proxyPort", "80")); if (!proxyHost.equals("")) { // allow communications via a non-authenticating proxy httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort); String proxyUser = System.getProperty("http.proxyUser", ""); String proxyPassword = System.getProperty("http.proxyPassword", ""); if (!proxyUser.equals("")) { // allow communications via an authenticating proxy Credentials credentials = new UsernamePasswordCredentials(proxyUser, proxyPassword); AuthScope authScope = new AuthScope(proxyHost, proxyPort); httpClient.getState().setProxyCredentials(authScope, credentials); externalAuthenticatingProxy = true; } } }
From source file:org.sakaiproject.nakamura.templates.velocity.VelocityTemplateService.java
protected void activate(ComponentContext ctx) throws Exception { velocityEngine = new VelocityEngine(); velocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new VelocityLogger(this.getClass())); velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, "jcr"); velocityEngine.setProperty("jcr.resource.loader.class", JcrResourceLoader.class.getName()); ExtendedProperties configuration = new ExtendedProperties(); configuration.addProperty("jcr.resource.loader.resourceSource", this); velocityEngine.setExtendedProperties(configuration); velocityEngine.init();//from www .j av a 2 s .c o m }