本文整理汇总了Java中org.apache.camel.util.URISupport类的典型用法代码示例。如果您正苦于以下问题:Java URISupport类的具体用法?Java URISupport怎么用?Java URISupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URISupport类属于org.apache.camel.util包,在下文中一共展示了URISupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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.");
}
}
示例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());
}
示例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
}
}
}
示例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;
}
示例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);
}
示例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.");
}
}
}
示例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);
}