本文整理汇总了Java中org.apache.camel.util.URISupport类的典型用法代码示例。如果您正苦于以下问题:Java URISupport类的具体用法?Java URISupport怎么用?Java URISupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URISupport类属于org.apache.camel.util包,在下文中一共展示了URISupport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildUri
import org.apache.camel.util.URISupport; //导入依赖的package包/类
private static String buildUri(Endpoint step) {
String uri = step.getUri();
Map<String, Object> properties = step.getProperties();
if (!Strings.isEmpty(uri)) {
if (ObjectHelper.isNotEmpty(properties)) {
try {
uri = URISupport.appendParametersToURI(uri, properties);
} catch (UnsupportedEncodingException|URISyntaxException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
}
return uri;
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:EndpointHandler.java
示例2: createEndpoint
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// grab the regular query parameters
Map<String, String> options = buildEndpointOptions(remaining, parameters);
// create the uri of the base component
String delegateUri = catalog.asEndpointUri(componentSchemeAlias.orElse(componentScheme), options, false);
Endpoint delegate = getCamelContext().getEndpoint(delegateUri);
LOGGER.info("Connector resolved: {} -> {}", URISupport.sanitizeUri(uri), URISupport.sanitizeUri(delegateUri));
ComponentProxyEndpoint answer = new ComponentProxyEndpoint(uri, this, delegate);
answer.setBeforeProducer(getBeforeProducer());
answer.setAfterProducer(getAfterProducer());
answer.setBeforeConsumer(getBeforeConsumer());
answer.setAfterConsumer(getAfterConsumer());
// clean-up parameters so that validation won't fail later on
// in DefaultConnectorComponent.validateParameters()
parameters.clear();
return answer;
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:24,代码来源:ComponentProxyComponent.java
示例3: listEndpoints
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public TabularData listEndpoints() {
try {
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEndpointsTabularType());
Collection<Endpoint> endpoints = endpointRegistry.values();
for (Endpoint endpoint : endpoints) {
CompositeType ct = CamelOpenMBeanTypes.listEndpointsCompositeType();
String url = endpoint.getEndpointUri();
if (sanitize) {
url = URISupport.sanitizeUri(url);
}
boolean fromStatic = endpointRegistry.isStatic(url);
boolean fromDynamic = endpointRegistry.isDynamic(url);
CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "static", "dynamic"}, new Object[]{url, fromStatic, fromDynamic});
answer.put(data);
}
return answer;
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:ManagedEndpointRegistry.java
示例4: populateFromURI
import org.apache.camel.util.URISupport; //导入依赖的package包/类
public static void populateFromURI(CamelContext camelContext, EndpointConfiguration config, ParameterSetter setter) {
URI uri = config.getURI();
setter.set(camelContext, config, EndpointConfiguration.URI_SCHEME, uri.getScheme());
setter.set(camelContext, config, EndpointConfiguration.URI_SCHEME_SPECIFIC_PART, uri.getSchemeSpecificPart());
setter.set(camelContext, config, EndpointConfiguration.URI_AUTHORITY, uri.getAuthority());
setter.set(camelContext, config, EndpointConfiguration.URI_USER_INFO, uri.getUserInfo());
setter.set(camelContext, config, EndpointConfiguration.URI_HOST, uri.getHost());
setter.set(camelContext, config, EndpointConfiguration.URI_PORT, Integer.toString(uri.getPort()));
setter.set(camelContext, config, EndpointConfiguration.URI_PATH, uri.getPath());
setter.set(camelContext, config, EndpointConfiguration.URI_QUERY, uri.getQuery());
setter.set(camelContext, config, EndpointConfiguration.URI_FRAGMENT, uri.getFragment());
// now parse query and set custom parameters
Map<String, Object> parameters;
try {
parameters = URISupport.parseParameters(uri);
for (Map.Entry<String, Object> pair : parameters.entrySet()) {
setter.set(camelContext, config, pair.getKey(), pair.getValue());
}
} catch (URISyntaxException e) {
throw new RuntimeCamelException(e);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:ConfigurationHelper.java
示例5: newThreadPool
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@Override
public ExecutorService newThreadPool(Object source, String name, ThreadPoolProfile profile) {
String sanitizedName = URISupport.sanitizeUri(name);
ObjectHelper.notNull(profile, "ThreadPoolProfile");
ThreadPoolProfile defaultProfile = getDefaultThreadPoolProfile();
profile.addDefaults(defaultProfile);
ThreadFactory threadFactory = createThreadFactory(sanitizedName, true);
ExecutorService executorService = threadPoolFactory.newThreadPool(profile, threadFactory);
onThreadPoolCreated(executorService, source, profile.getId());
if (LOG.isDebugEnabled()) {
LOG.debug("Created new ThreadPool for source: {} with name: {}. -> {}", source, sanitizedName, executorService);
}
return executorService;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:DefaultExecutorServiceManager.java
示例6: createURI
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Creates the URI to invoke.
*
* @param exchange the exchange
* @param url the url to invoke
* @param endpoint the endpoint
* @return the URI to invoke
*/
public static URI createURI(Exchange exchange, String url, NettyHttpEndpoint endpoint) throws URISyntaxException {
URI uri = new URI(url);
// is a query string provided in the endpoint URI or in a header
// (header overrules endpoint, raw query header overrules query header)
String queryString = exchange.getIn().getHeader(Exchange.HTTP_RAW_QUERY, String.class);
if (queryString == null) {
queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
}
if (queryString == null) {
// use raw as we encode just below
queryString = uri.getRawQuery();
}
if (queryString != null) {
// need to encode query string
queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
uri = URISupport.createURIWithQuery(uri, queryString);
}
return uri;
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:NettyHttpHelper.java
示例7: createURI
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Creates the URI to invoke.
*
* @param exchange the exchange
* @param url the url to invoke
* @param endpoint the endpoint
* @return the URI to invoke
*/
public static URI createURI(Exchange exchange, String url, AhcEndpoint endpoint) throws URISyntaxException {
URI uri = new URI(url);
// is a query string provided in the endpoint URI or in a header (header overrules endpoint)
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
if (queryString == null) {
queryString = endpoint.getHttpUri().getRawQuery();
}
// We should user the query string from the HTTP_URI header
if (queryString == null) {
queryString = uri.getQuery();
}
if (queryString != null) {
// need to encode query string
queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
uri = URISupport.createURIWithQuery(uri, queryString);
}
return uri;
}
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:AhcHelper.java
示例8: afterConfiguration
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@Override
protected void afterConfiguration(String uri, String remaining, Endpoint endpoint, Map<String, Object> parameters) throws Exception {
AtomEndpoint atom = (AtomEndpoint) endpoint;
if (atom.getFeedUri() != null) {
// already set so do not change it
return;
}
// recreate feed uri after we have configured the endpoint so we can use the left over parameters
// for the http feed
String feedUri;
if (!parameters.isEmpty()) {
URI remainingUri = URISupport.createRemainingURI(new URI(remaining), parameters);
feedUri = remainingUri.toString();
} else {
feedUri = remaining;
}
atom.setFeedUri(feedUri);
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:AtomComponent.java
示例9: createEndpoint
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* A factory method allowing derived components to create a new endpoint
* from the given URI, remaining path and optional parameters
*
* @param uri the full URI of the endpoint
* @param remaining the remaining part of the URI without the query
* parameters or component prefix
* @param parameters the optional parameters passed in
* @return a newly created endpoint or null if the endpoint cannot be
* created based on the inputs
*/
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
AvroConfiguration config;
if (configuration != null) {
config = configuration.copy();
} else {
config = new AvroConfiguration();
}
URI endpointUri = new URI(URISupport.normalizeUri(remaining));
applyToConfiguration(config, endpointUri, parameters);
if (AvroConstants.AVRO_NETTY_TRANSPORT.equals(endpointUri.getScheme())) {
return new AvroNettyEndpoint(remaining, this, config);
} else if (AvroConstants.AVRO_HTTP_TRANSPORT.equals(endpointUri.getScheme())) {
return new AvroHttpEndpoint(remaining, this, config);
} else {
throw new IllegalArgumentException("Unknown avro scheme. Should use either netty or http.");
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:AvroComponent.java
示例10: testDifferentHttpProxyConfigured
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@Test
public void testDifferentHttpProxyConfigured() throws Exception {
HttpEndpoint http1 = context.getEndpoint("http://www.google.com?proxyHost=myproxy&proxyPort=1234", HttpEndpoint.class);
HttpEndpoint http2 = context.getEndpoint("http://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345", HttpEndpoint.class);
HttpClient client1 = http1.createHttpClient();
assertEquals("myproxy", client1.getHostConfiguration().getProxyHost());
assertEquals(1234, client1.getHostConfiguration().getProxyPort());
HttpClient client2 = http2.createHttpClient();
assertEquals("myotherproxy", client2.getHostConfiguration().getProxyHost());
assertEquals(2345, client2.getHostConfiguration().getProxyPort());
//As the endpointUri is recreated, so the parameter could be in different place, so we use the URISupport.normalizeUri
assertEquals("Get a wrong endpoint uri of http1", "http://www.google.com?proxyHost=myproxy&proxyPort=1234", URISupport.normalizeUri(http1.getEndpointUri()));
assertEquals("Get a wrong endpoint uri of http2", "http://www.google.com?proxyHost=myotherproxy&proxyPort=2345&test=parameter", URISupport.normalizeUri(http2.getEndpointUri()));
assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:HttpProxyTest.java
示例11: findSchedulerUriComponent
import org.apache.camel.util.URISupport; //导入依赖的package包/类
private void findSchedulerUriComponent(String uri, Set<String> components) {
// the input may use a scheduler which can be quartz or spring
if (uri != null) {
try {
URI u = new URI(uri);
Map<String, Object> parameters = URISupport.parseParameters(u);
Object value = parameters.get("scheduler");
if (value == null) {
value = parameters.get("consumer.scheduler");
}
if (value != null) {
// the scheduler can be quartz2 or spring based, so add reference to camel component
// from these components os blueprint knows about the requirement
String name = value.toString();
if ("quartz2".equals(name)) {
components.add("quartz2");
} else if ("spring".equals(name)) {
components.add("spring-event");
}
}
} catch (URISyntaxException e) {
// ignore
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:CamelNamespaceHandler.java
示例12: createURI
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Creates the URI to invoke.
*
* @param exchange the exchange
* @param url the url to invoke
* @param endpoint the endpoint
* @return the URI to invoke
*/
public static URI createURI(Exchange exchange, String url, UndertowEndpoint endpoint) throws URISyntaxException {
URI uri = new URI(url);
// is a query string provided in the endpoint URI or in a header (header overrules endpoint)
String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
if (queryString == null) {
queryString = endpoint.getHttpURI().getRawQuery();
}
// We should user the query string from the HTTP_URI header
if (queryString == null) {
queryString = uri.getRawQuery();
}
if (queryString != null) {
// need to encode query string
queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
uri = URISupport.createURIWithQuery(uri, queryString);
}
return uri;
}
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:UndertowHelper.java
示例13: scheduleDelayedStart
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Schedules execution of the doStart() operation to occur again after the reconnect delay
*/
protected void scheduleDelayedStart() throws Exception {
Runnable startRunnable = new Runnable() {
@Override
public void run() {
try {
doStart();
} catch (Exception e) {
LOG.error("An unrecoverable exception has occurred while starting the JMX consumer"
+ "for endpoint {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), e);
}
}
};
LOG.info("Delaying JMX consumer startup for endpoint {}. Trying again in {} seconds.",
URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), mJmxEndpoint.getReconnectDelay());
getExecutor().schedule(startRunnable, mJmxEndpoint.getReconnectDelay(), TimeUnit.SECONDS);
}
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JMXConsumer.java
示例14: handleNotification
import org.apache.camel.util.URISupport; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification, Object handback) {
JMXConnectionNotification connectionNotification = (JMXConnectionNotification)notification;
// only reset the connection if the notification is for the connection from this endpoint
if (!connectionNotification.getConnectionId().equals(mConnectionId)) {
return;
}
if (connectionNotification.getType().equals(JMXConnectionNotification.NOTIFS_LOST)
|| connectionNotification.getType().equals(JMXConnectionNotification.CLOSED)
|| connectionNotification.getType().equals(JMXConnectionNotification.FAILED)) {
LOG.warn("Lost JMX connection for : {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()));
if (mJmxEndpoint.getReconnectOnConnectionFailure()) {
scheduleReconnect();
} else {
LOG.warn("The JMX consumer will not be reconnected. Use 'reconnectOnConnectionFailure' to "
+ "enable reconnections.");
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JMXConsumer.java
示例15: scheduleReconnect
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Schedules an attempt to re-initialize a lost connection after the reconnect delay
*/
protected void scheduleReconnect() {
Runnable startRunnable = new Runnable() {
@Override
public void run() {
try {
initNetworkConnection();
addNotificationListener();
} catch (Exception e) {
LOG.warn("Failed to reconnect to JMX server. >> {}", e.getMessage());
scheduleReconnect();
}
}
};
LOG.info("Delaying JMX consumer reconnection for endpoint {}. Trying again in {} seconds.",
URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), mJmxEndpoint.getReconnectDelay());
getExecutor().schedule(startRunnable, mJmxEndpoint.getReconnectDelay(), TimeUnit.SECONDS);
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JMXConsumer.java
示例16: computeColumnWidths
import org.apache.camel.util.URISupport; //导入依赖的package包/类
private Map<String, Integer> computeColumnWidths(final Iterable<Map<String, String>> endpoints) throws Exception {
if (endpoints == null) {
throw new IllegalArgumentException("Unable to determine column widths from null Iterable<Endpoint>");
} else {
int maxUriLen = 0;
int maxStatusLen = 0;
for (Map<String, String> row : endpoints) {
String uri = row.get("uri");
if (decode) {
// decode uri so its more human readable
uri = URLDecoder.decode(uri, "UTF-8");
}
// sanitize and mask uri so we dont see passwords
uri = URISupport.sanitizeUri(uri);
maxUriLen = java.lang.Math.max(maxUriLen, uri == null ? 0 : uri.length());
final String status = row.get("state");
maxStatusLen = java.lang.Math.max(maxStatusLen, status == null ? 0 : status.length());
}
final Map<String, Integer> retval = new Hashtable<String, Integer>();
retval.put(URI_COLUMN_LABEL, maxUriLen);
retval.put(STATUS_COLUMN_LABEL, maxStatusLen);
return retval;
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:EndpointListCommand.java
示例17: asRouteApiDefinition
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Transforms the rest api configuration into a {@link org.apache.camel.model.RouteDefinition} which
* Camel routing engine uses to service the rest api docs.
*/
public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, RestConfiguration configuration) {
RouteDefinition answer = new RouteDefinition();
// create the from endpoint uri which is using the rest-api component
String from = "rest-api:" + configuration.getApiContextPath();
// append options
Map<String, Object> options = new HashMap<String, Object>();
String routeId = configuration.getApiContextRouteId();
if (routeId == null) {
routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
}
options.put("routeId", routeId);
if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
options.put("componentName", configuration.getComponent());
}
if (configuration.getApiContextIdPattern() != null) {
options.put("contextIdPattern", configuration.getApiContextIdPattern());
}
if (!options.isEmpty()) {
String query;
try {
query = URISupport.createQueryString(options);
} catch (URISyntaxException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
from = from + "?" + query;
}
// we use the same uri as the producer (so we have a little route for the rest api)
String to = from;
answer.fromRest(from);
answer.id(routeId);
answer.to(to);
return answer;
}
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:RestDefinition.java
示例18: matchPattern
import org.apache.camel.util.URISupport; //导入依赖的package包/类
/**
* Does the uri match the pattern.
*
* @param camelContext the CamelContext
* @param uri the uri
* @param pattern the pattern, which can be an endpoint uri as well
* @return <tt>true</tt> if matched and we should intercept, <tt>false</tt> if not matched, and not intercept.
*/
protected boolean matchPattern(CamelContext camelContext, String uri, String pattern) {
// match using the pattern as-is
boolean match = EndpointHelper.matchEndpoint(camelContext, uri, pattern);
if (!match) {
try {
// the pattern could be an uri, so we need to normalize it before matching again
pattern = URISupport.normalizeUri(pattern);
match = EndpointHelper.matchEndpoint(camelContext, uri, pattern);
} catch (Exception e) {
// ignore
}
}
return match;
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:InterceptSendToEndpointDefinition.java
示例19: doStart
import org.apache.camel.util.URISupport; //导入依赖的package包/类
protected void doStart() throws Exception {
if (producerCache == null) {
// use a single producer cache as we need to only hold reference for one destination
// and use a regular HashMap as we do not want a soft reference store that may get re-claimed when low on memory
// as we want to ensure the producer is kept around, to ensure its lifecycle is fully managed,
// eg stopping the producer when we stop etc.
producerCache = new ProducerCache(this, camelContext, new HashMap<String, Producer>(1));
// do not add as service as we do not want to manage the producer cache
}
ServiceHelper.startService(producerCache);
// the destination could since have been intercepted by a interceptSendToEndpoint so we got to
// lookup this before we can use the destination
Endpoint lookup = camelContext.hasEndpoint(destination.getEndpointKey());
if (lookup instanceof InterceptSendToEndpoint) {
if (LOG.isDebugEnabled()) {
LOG.debug("Intercepted sending to {} -> {}",
URISupport.sanitizeUri(destination.getEndpointUri()), URISupport.sanitizeUri(lookup.getEndpointUri()));
}
destination = lookup;
}
// warm up the producer by starting it so we can fail fast if there was a problem
// however must start endpoint first
ServiceHelper.startService(destination);
// this SendProcessor is used a lot in Camel (eg every .to in the route DSL) and therefore we
// want to optimize for regular producers, by using the producer directly instead of the ProducerCache
// Only for pooled and non singleton producers we have to use the ProducerCache as it supports these
// kind of producer better (though these kind of producer should be rare)
Producer producer = producerCache.acquireProducer(destination);
if (producer instanceof ServicePoolAware || !producer.isSingleton()) {
// no we cannot optimize it - so release the producer back to the producer cache
// and use the producer cache for sending
producerCache.releaseProducer(destination, producer);
} else {
// yes we can optimize and use the producer directly for sending
this.producer = AsyncProcessorConverterHelper.convert(producer);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:SendProcessor.java
示例20: resolveExchangePattern
import org.apache.camel.util.URISupport; //导入依赖的package包/类
protected ExchangePattern resolveExchangePattern(Object recipient) throws UnsupportedEncodingException, URISyntaxException, MalformedURLException {
// trim strings as end users might have added spaces between separators
if (recipient instanceof String) {
String s = ((String) recipient).trim();
// see if exchangePattern is a parameter in the url
s = URISupport.normalizeUri(s);
return EndpointHelper.resolveExchangePatternFromUrl(s);
}
return null;
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:RecipientListProcessor.java
注:本文中的org.apache.camel.util.URISupport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论