本文整理汇总了Java中org.apache.camel.util.URISupport.normalizeUri方法的典型用法代码示例。如果您正苦于以下问题:Java URISupport.normalizeUri方法的具体用法?Java URISupport.normalizeUri怎么用?Java URISupport.normalizeUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.util.URISupport
的用法示例。
在下文中一共展示了URISupport.normalizeUri方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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.");
}
}
示例2: 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;
}
示例3: 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;
}
示例4: normalizeEndpointUri
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
/**
* Normalize uri so we can do endpoint hits with minor mistakes and parameters is not in the same order.
*
* @param uri the uri
* @return normalized uri
* @throws ResolveEndpointFailedException if uri cannot be normalized
*/
protected static String normalizeEndpointUri(String uri) {
try {
uri = URISupport.normalizeUri(uri);
} catch (Exception e) {
throw new ResolveEndpointFailedException(uri, e);
}
return uri;
}
示例5: testCreateCxfEndpointFromURI
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
@Test
public void testCreateCxfEndpointFromURI() throws Exception {
CxfEndpoint endpoint1 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1", CxfEndpoint.class);
CxfEndpoint endpoint2 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:8000/test2", CxfEndpoint.class);
assertEquals("Get a wrong endpoint address.", "http://localhost:9000/test1", endpoint1.getAddress());
assertEquals("Get a wrong endpoint address.", "http://localhost:8000/test2", endpoint2.getAddress());
// the uri will always be normalized
String uri1 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:9000/test1");
String uri2 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:8000/test2");
assertEquals("Get a wrong endpoint key.", uri1, endpoint1.getEndpointKey());
assertEquals("Get a wrong endpoint key.", uri2, endpoint2.getEndpointKey());
}
示例6: testCreateCxfEndpointFromURI
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
@Test
public void testCreateCxfEndpointFromURI() throws Exception {
CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
CxfEndpoint endpoint1 = camelContext.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1", CxfEndpoint.class);
CxfEndpoint endpoint2 = camelContext.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:8000/test2", CxfEndpoint.class);
assertEquals("Get a wrong endpoint address.", "http://localhost:9000/test1", endpoint1.getAddress());
assertEquals("Get a wrong endpoint address.", "http://localhost:8000/test2", endpoint2.getAddress());
// the uri will always be normalized
String uri1 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:9000/test1");
String uri2 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:8000/test2");
assertEquals("Get a wrong endpoint key.", uri1, endpoint1.getEndpointKey());
assertEquals("Get a wrong endpoint key.", uri2, endpoint2.getEndpointKey());
}
示例7: parseUri
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
private void parseUri(String uri, HipchatEndpoint endpoint) throws Exception {
// strip scheme
uri = ObjectHelper.after(uri, ":");
uri = URISupport.normalizeUri(uri);
URI hipChatUri = new URI(uri);
if (hipChatUri.getHost() != null) {
endpoint.getConfiguration().setHost(hipChatUri.getHost());
if (hipChatUri.getPort() != -1) {
endpoint.getConfiguration().setPort(hipChatUri.getPort());
}
endpoint.getConfiguration().setProtocol(hipChatUri.getScheme());
}
}
示例8: createEndpoint
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
ObjectHelper.notNull(getCamelContext(), "Camel Context");
AbstractIgniteEndpoint answer = null;
URI remainingUri = new URI(URISupport.normalizeUri(remaining));
String scheme = remainingUri.getScheme();
switch (scheme) {
case "cache":
answer = new IgniteCacheEndpoint(uri, remainingUri, parameters, this);
break;
case "compute":
answer = new IgniteComputeEndpoint(uri, remainingUri, parameters, this);
break;
case "messaging":
answer = new IgniteMessagingEndpoint(uri, remainingUri, parameters, this);
break;
case "events":
answer = new IgniteEventsEndpoint(uri, remainingUri, parameters, this);
break;
case "set":
answer = new IgniteSetEndpoint(uri, remainingUri, parameters, this);
break;
case "idgen":
answer = new IgniteIdGenEndpoint(uri, remainingUri, parameters, this);
break;
case "queue":
answer = new IgniteQueueEndpoint(uri, remainingUri, parameters, this);
break;
default:
throw new MalformedURLException("An invalid Ignite endpoint URI was provided. Please check that "
+ "it starts with:" + " ignite:[cache/compute/messaging/...]:...");
}
setProperties(answer, parameters);
return answer;
}
示例9: createTransceiver
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
@Override
public Transceiver createTransceiver() throws Exception {
return new HttpTransceiver(new URL(URISupport.normalizeUri(getEndpoint().getEndpointUri())));
}
示例10: createURL
import org.apache.camel.util.URISupport; //导入方法依赖的package包/类
/**
* Creates the URL to invoke.
*
* @param exchange the exchange
* @param endpoint the endpoint
* @return the URL to invoke
* @throws java.net.URISyntaxException is thrown if the URL is invalid
* @throws UnsupportedEncodingException
*/
public static String createURL(Exchange exchange, AhcEndpoint endpoint) throws URISyntaxException, UnsupportedEncodingException {
String url = doCreateURL(exchange, endpoint);
return URISupport.normalizeUri(url);
}