protected void addUriParamsAsHeaders(Map headers, String uri) { int i = uri.indexOf("?"); String queryString = ""; if(i > -1) { queryString = uri.substring(i + 1); headers.putAll(PropertiesUtils.getPropertiesFromQueryString(queryString)); } headers.put(HttpConnector.HTTP_QUERY_STRING, queryString); }
public MetaTransportServiceDescriptor(String metaScheme, String scheme, Properties props, ClassLoader classLoader) throws ServiceException { super(metaScheme, props, classLoader); this.metaScheme = metaScheme; Properties p = SpiUtils.findServiceDescriptor(ServiceType.TRANSPORT, scheme); //Load any overrides for the for the endpoint scheme if (p == null) { throw new ServiceException(CoreMessages.failedToCreate("transport: " + metaScheme + ":" + scheme)); } Properties temp = new Properties(); PropertiesUtils.getPropertiesWithPrefix(props, scheme + ".", temp); if (temp.size() > 0) { p.putAll(PropertiesUtils.removeNamespaces(temp)); } setOverrides(p); }
public static Properties loadProperties(URL url) throws IOException { if (url == null) { Message error = CoreMessages.objectIsNull("url"); throw new IOException(error.toString()); } return loadProperties(url.openStream()); }
/** * @deprecated We can use a more intelligent strategy for locating the service using the OSGi registry. */ // @Override public String findService(String service, ServiceDescriptor descriptor, Properties props) throws ServiceException { Map finders = new TreeMap(); PropertiesUtils.getPropertiesWithPrefix(props, "finder.class", finders); StringBuffer buf = new StringBuffer(); for (Iterator iterator = finders.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry)iterator.next(); try { ClassUtils.loadClass(entry.getValue().toString(), getClass()); return getProtocolFromKey(entry.getKey().toString()); } catch (ClassNotFoundException e1) { buf.append(entry.getValue().toString()).append("(").append(entry.getKey().toString()).append( ")").append(", "); } } throw new ServiceException(SoapMessages.couldNotFindSoapProvider(buf.toString())); }
private void registerTransactionFactories(Map<String, String> singleTransactionFactories, MuleContext context) throws Exception { for (Map.Entry<String, String> entry : singleTransactionFactories.entrySet()) { String transactionResourceClassNameProperties = entry.getValue(); String transactionFactoryClassName = entry.getKey(); boolean optional = false; // reset int x = transactionResourceClassNameProperties.indexOf(","); if (x > -1) { Properties p = PropertiesUtils.getPropertiesFromString(transactionResourceClassNameProperties.substring(x + 1), ','); optional = p.containsKey("optional"); } final String transactionResourceClassName = (x == -1 ? transactionResourceClassNameProperties : transactionResourceClassNameProperties.substring(0, x)); try { context.getTransactionFactoryManager().registerTransactionFactory(Class.forName(transactionResourceClassName), (TransactionFactory) Class.forName(transactionFactoryClassName).newInstance()); } catch (NoClassDefFoundError ncdfe) { throwExceptionIfNotOptional(optional, ncdfe, "Ignoring optional transaction factory: " + transactionResourceClassName); } catch (ClassNotFoundException cnfe) { throwExceptionIfNotOptional(optional, cnfe, "Ignoring optional transaction factory: " + transactionResourceClassName); } } }
public static Properties getPropertiesFromString(String query, char separator) { Properties props = new Properties(); if (query == null) { return props; } query = new StringBuilder(query.length() + 1).append(separator).append(query).toString(); int x = 0; while ((x = addProperty(query, x, separator, props)) != -1) { // run } return props; }
private static Properties getErrorMappings(String protocol, final MuleContext muleContext) { Properties m = errorMappings.get(getErrorMappingCacheKey(protocol,muleContext)); if (m != null) { return m; } else { String name = SpiUtils.SERVICE_ROOT + ServiceType.EXCEPTION.getPath() + "/" + protocol + "-exception-mappings.properties"; Properties p = PropertiesUtils.loadAllProperties(name, muleContext.getExecutionClassLoader()); errorMappings.put(getErrorMappingCacheKey(protocol, muleContext), p); registerAppDisposeListener(muleContext); return p; } }
if (x > -1) Properties p = PropertiesUtils.getPropertiesFromString(transString.substring(x + 1), ','); name = p.getProperty("name", null); returnClassString = p.getProperty("returnClass", null);
public static Properties getPropertiesFromQueryString(String query) { Properties props = new Properties(); if (StringUtils.isEmpty(query)) { return props; } query = new StringBuilder(query.length() + 1).append('&').append(query).toString(); int x = 0; while ((x = addProperty(query, x, '&', props)) != -1); return props; }
public void setApplicationProperties(ApplicationDescriptor desc, File appPropsFile) throws IOException { // ugh, no straightforward way to convert a HashTable to a map Map<String, String> m = new HashMap<String, String>(); if (appPropsFile.exists() && appPropsFile.canRead()) { final Properties props = PropertiesUtils.loadProperties(appPropsFile.toURI().toURL()); for (Object key : props.keySet()) { m.put(key.toString(), props.getProperty(key.toString())); } } // Override with any system properties prepended with "-O" for ("override")) Properties sysProps = System.getProperties(); for (Map.Entry<Object, Object> entry : sysProps.entrySet()) { String key = entry.getKey().toString(); if (key.startsWith(SYSTEM_PROPERTY_OVERRIDE)) { m.put(key.substring(SYSTEM_PROPERTY_OVERRIDE.length()), entry.getValue().toString()); } } desc.setAppProperties(m); }
protected String getReceiverName(HttpServletRequest httpServletRequest) { String name = httpServletRequest.getPathInfo(); if (name == null) { name = httpServletRequest.getServletPath(); if (name == null) { name = httpServletRequest.getParameter("endpoint"); if (name == null) { Properties params = PropertiesUtils.getPropertiesFromQueryString(httpServletRequest.getQueryString()); name = params.getProperty("endpoint"); if (name == null) { return null; } } } } if (name.startsWith("/")) { name = name.substring(1); } return name; }
@Override public Connector createConnector(EndpointURI endpointURI) throws TransportFactoryException { Connector c; String scheme = endpointURI.getScheme(); Map temp = new Properties(); PropertiesUtils.getPropertiesWithPrefix(overrides, scheme, temp); temp = PropertiesUtils.removeNamespaces(temp); String singleton = (String) temp.remove(SINGLETON_PROPERTY); if (TRUE.equalsIgnoreCase(singleton)) { c = this.getConnectorByProtocol(scheme); if (c != null) { return c; } } c = super.createConnector(endpointURI); BeanUtils.populateWithoutFail(c, temp, true); return c; }
if (x > -1) Properties p = PropertiesUtils.getPropertiesFromString(value.substring(x + 1), ','); if (p.containsKey(ArtifactType.APPLY_TO_ARTIFACT_TYPE_PARAMETER_KEY))
protected void addStartupPropertiesConfigBuilder(List<ConfigurationBuilder> builders) throws IOException { Properties startupProperties = null; if (getStartupPropertiesFile() != null) { startupProperties = PropertiesUtils.loadProperties(getStartupPropertiesFile(), getClass()); } builders.add(new SimpleConfigurationBuilder(startupProperties)); }
public Properties getParams() { // TODO fix this so that the query string properties are not lost. // not sure whats causing this at the moment if (params.size() == 0 && getQuery() != null) { params = PropertiesUtils.getPropertiesFromQueryString(getQuery()); } return params; }
public DomainDescriptor parse(File descriptor) throws IOException { final Properties properties = loadProperties(new FileInputStream(descriptor)); DomainDescriptor domainDescriptor = new DomainDescriptor(); domainDescriptor.setRedeploymentEnabled(BooleanUtils.toBoolean(properties.getProperty(PROPERTY_REDEPLOYMENT_ENABLED, Boolean.TRUE.toString()))); final String overrideString = properties.getProperty(PROPERTY_LOADER_OVERRIDE); if (StringUtils.isNotBlank(overrideString)) { Set<String> values = new HashSet<>(); final String[] overrides = overrideString.split(","); Collections.addAll(values, overrides); domainDescriptor.setLoaderOverride(values); } return domainDescriptor; }
protected Properties getPropertiesForURI(URI uri, MuleContext muleContext) throws MalformedEndpointException Properties properties = PropertiesUtils.getPropertiesFromQueryString(uri.getRawQuery());
public void load(String fileName) { try { InputStream config = IOUtils.getResourceAsStream(fileName, TlsProperties.class); if (config == null) { logger.warn(String.format("File %s not found, using default configuration.", fileName)); } else { logger.info(String.format("Loading configuration file: %s", fileName)); Properties properties = loadProperties(config); String enabledCipherSuitesProperty = properties.getProperty("enabledCipherSuites"); String enabledProtocolsProperty = properties.getProperty("enabledProtocols"); if (enabledCipherSuitesProperty != null) { enabledCipherSuites = StringUtils.splitAndTrim(enabledCipherSuitesProperty, ","); } if (enabledProtocolsProperty != null) { enabledProtocols = StringUtils.splitAndTrim(enabledProtocolsProperty, ","); } } } catch (IOException e) { logger.warn(String.format("Cannot read file %s, using default configuration", fileName), e); } }
Properties p = PropertiesUtils.getPropertiesFromQueryString(query);
extensions.add(loadProperties(url.openStream()));