本文整理汇总了Java中org.apache.camel.model.FromDefinition类的典型用法代码示例。如果您正苦于以下问题:Java FromDefinition类的具体用法?Java FromDefinition怎么用?Java FromDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FromDefinition类属于org.apache.camel.model包,在下文中一共展示了FromDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isEipInUse
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
/**
* Checks if any of the Camel routes is using an EIP with the given name
*
* @param camelContext the Camel context
* @param name the name of the EIP
* @return <tt>true</tt> if in use, <tt>false</tt> if not
*/
public static boolean isEipInUse(CamelContext camelContext, String name) {
for (RouteDefinition route : camelContext.getRouteDefinitions()) {
for (FromDefinition from : route.getInputs()) {
if (name.equals(from.getShortName())) {
return true;
}
}
Iterator<ProcessorDefinition> it = ProcessorDefinitionHelper.filterTypeInOutputs(route.getOutputs(), ProcessorDefinition.class);
while (it.hasNext()) {
ProcessorDefinition def = it.next();
if (name.equals(def.getShortName())) {
return true;
}
}
}
return false;
}
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CamelContextHelper.java
示例2: testCustomId
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
@Test
public void testCustomId() {
RouteDefinition route = context.getRouteDefinition("myRoute");
assertNotNull(route);
assertTrue(route.hasCustomIdAssigned());
FromDefinition from = route.getInputs().get(0);
assertEquals("fromFile", from.getId());
assertTrue(from.hasCustomIdAssigned());
ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
assertEquals("myChoice", choice.getId());
assertTrue(choice.hasCustomIdAssigned());
WhenDefinition when = choice.getWhenClauses().get(0);
assertTrue(when.hasCustomIdAssigned());
assertEquals("UK", when.getId());
LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
assertFalse(log.hasCustomIdAssigned());
}
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CustomIdIssuesTest.java
示例3: registerEndpointsWithIdsDefinedInFromOrToTypes
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
/**
* Used for auto registering endpoints from the <tt>from</tt> or <tt>to</tt> DSL if they have an id attribute set
*/
protected void registerEndpointsWithIdsDefinedInFromOrToTypes(Element element, ParserContext parserContext, String contextId, Binder<Node> binder) {
NodeList list = element.getChildNodes();
int size = list.getLength();
for (int i = 0; i < size; i++) {
Node child = list.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
Object object = binder.getJAXBNode(child);
// we only want from/to types to be registered as endpoints
if (object instanceof FromDefinition || object instanceof SendDefinition) {
registerEndpoint(childElement, parserContext, contextId);
}
// recursive
registerEndpointsWithIdsDefinedInFromOrToTypes(childElement, parserContext, contextId, binder);
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CamelNamespaceHandler.java
示例4: testCustomId
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public void testCustomId() {
RouteDefinition route = context.getRouteDefinition("myRoute");
assertNotNull(route);
assertTrue(route.hasCustomIdAssigned());
FromDefinition from = route.getInputs().get(0);
assertEquals("fromFile", from.getId());
assertTrue(from.hasCustomIdAssigned());
ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
assertEquals("myChoice", choice.getId());
assertTrue(choice.hasCustomIdAssigned());
WhenDefinition when = choice.getWhenClauses().get(0);
assertTrue(when.hasCustomIdAssigned());
assertEquals("UK", when.getId());
LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
assertFalse(log.hasCustomIdAssigned());
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CustomIdIssuesTest.java
示例5: assertValidContext
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
protected void assertValidContext(CamelContext context) {
assertNotNull("No context found!", context);
List<RouteDefinition> routes = ((ModelCamelContext)context).getRouteDefinitions();
LOG.debug("Found routes: " + routes);
assertEquals("One Route should be found", 1, routes.size());
for (RouteDefinition route : routes) {
List<FromDefinition> inputs = route.getInputs();
assertEquals("Number of inputs", 1, inputs.size());
FromDefinition fromType = inputs.get(0);
assertEquals("from URI", "seda:test.a", fromType.getUri());
List<?> outputs = route.getOutputs();
assertEquals("Number of outputs", 1, outputs.size());
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XmlConfigTestSupport.java
示例6: getUri
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public static String getUri(FromDefinition input) {
String key = input.getUri();
if (Strings2.isEmpty(key)) {
String ref = input.getRef();
if (!Strings2.isEmpty(ref)) {
return "ref:" + ref;
}
}
return key;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:11,代码来源:CamelModelHelper.java
示例7: replaceInputs
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
private static void replaceInputs(Iterable<RouteDefinition> definitions,
String oldFrom, String newFrom) {
for (RouteDefinition definition : definitions) {
List<FromDefinition> inputs = definition.getInputs();
for (int i = 0; i < inputs.size(); i++) {
if (oldFrom.equals(inputs.get(i).getEndpointUri())) {
inputs.set(i, new FromDefinition(newFrom));
}
}
}
}
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:12,代码来源:MqttOnCamelMqttToLinkIntegrationTest.java
示例8: replaceFromWith
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public static AdviceWithTask replaceFromWith(final RouteDefinition route, final String uri) {
return new AdviceWithTask() {
public void task() throws Exception {
FromDefinition from = route.getInputs().get(0);
LOG.info("AdviceWith replace input from [{}] --> [{}]", from.getUriOrRef(), uri);
from.setEndpoint(null);
from.setRef(null);
from.setUri(uri);
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:AdviceWithTasks.java
示例9: replaceFrom
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public static AdviceWithTask replaceFrom(final RouteDefinition route, final Endpoint endpoint) {
return new AdviceWithTask() {
public void task() throws Exception {
FromDefinition from = route.getInputs().get(0);
LOG.info("AdviceWith replace input from [{}] --> [{}]", from.getUriOrRef(), endpoint.getEndpointUri());
from.setRef(null);
from.setUri(null);
from.setEndpoint(endpoint);
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:AdviceWithTasks.java
示例10: testStartRouteThenStopMutateAndStartRouteAgain
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public void testStartRouteThenStopMutateAndStartRouteAgain() throws Exception {
List<RouteDefinition> routes = context.getRouteDefinitions();
assertCollectionSize("Route", routes, 1);
RouteDefinition route = routes.get(0);
endpointA = getMandatoryEndpoint("seda:test.a", SedaEndpoint.class);
endpointB = getMandatoryEndpoint("seda:test.b", SedaEndpoint.class);
endpointC = getMandatoryEndpoint("seda:test.C", SedaEndpoint.class);
// send from A over B to results
MockEndpoint results = getMockEndpoint("mock:results");
results.expectedBodiesReceived(expectedBody);
template.sendBody(endpointA, expectedBody);
assertMockEndpointsSatisfied();
// stop the route
context.stopRoute(route);
// lets mutate the route...
FromDefinition fromType = assertOneElement(route.getInputs());
fromType.setUri("seda:test.C");
context.startRoute(route);
// now lets check it works
// send from C over B to results
results.reset();
results = getMockEndpoint("mock:results");
results.expectedBodiesReceived(expectedBody);
template.sendBody(endpointC, expectedBody);
assertMockEndpointsSatisfied();
}
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:StartAndStopRoutesTest.java
示例11: findInputComponents
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
private void findInputComponents(List<FromDefinition> defs, Set<String> components, Set<String> languages, Set<String> dataformats) {
if (defs != null) {
for (FromDefinition def : defs) {
findUriComponent(def.getUri(), components);
findSchedulerUriComponent(def.getUri(), components);
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:CamelNamespaceHandler.java
示例12: getInnerContextConsumerList
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected List<URI> getInnerContextConsumerList(CamelContext context) throws URISyntaxException {
List<URI> consumerList = new ArrayList<URI>();
List<RouteDefinition> routeDefinitions = context.getRouteDefinitions();
for (RouteDefinition routeDefinition : routeDefinitions) {
List<FromDefinition> inputs = routeDefinition.getInputs();
for (FromDefinition input : inputs) {
consumerList.add(new URI(input.getUri()));
}
}
return consumerList;
}
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:RouteboxDispatcher.java
示例13: getRouteToEndpointPriority
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
/**
* Get a map with the route id (key) and the priority (value) for 'from' endpoint
*
* @return
*/
protected Map<String, String> getRouteToEndpointPriority() {
Map<String, String> answer = new HashMap<String, String>();
List<RouteDefinition> routes = context.getRouteDefinitions();
Assert.assertNotNull(routes);
for (RouteDefinition current : routes) {
Assert.assertEquals(new Integer(1), new Integer(current.getInputs().size()));
Assert.assertNotNull(current.getInputs().get(0));
Assert.assertNotNull(current.getId());
Assert.assertTrue(current.getId().trim().length() > 0);
FromDefinition from = current.getInputs().get(0);
Endpoint endpoint = getMandatoryEndpoint(from.getUri());
Assert.assertNotNull(endpoint);
Assert.assertTrue(endpoint instanceof LoadBalancedFileEndpoint);
LoadBalancedFileEndpoint lbEndpoint = (LoadBalancedFileEndpoint)endpoint;
GenericFileFilter filter = lbEndpoint.getFilter();
Assert.assertNotNull(filter);
Assert.assertTrue(filter instanceof PriorityFileFilter);
PriorityFileFilter priorityFileFilter = (PriorityFileFilter)filter;
Assert.assertNotNull(priorityFileFilter.getPriorityName());
answer.put(current.getId(), priorityFileFilter.getPriorityName());
}
return answer;
}
开发者ID:garethahealy,项目名称:camel-file-loadbalancer,代码行数:40,代码来源:BaseCamelBlueprintTestSupport.java
示例14: formatInputFromDefinition
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public static String formatInputFromDefinition(FromDefinition from) {
URI uri = URI.create(from.getEndpointUri());
if (uri.getScheme().startsWith("twitter")) {
return formatInputFromURI(uri);
}
return uri.toString();
}
开发者ID:tarilabs,项目名称:reex2014,代码行数:8,代码来源:CamelRoutesAPI.java
示例15: testNotification
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
@Test
public void testNotification() throws InterruptedException, IOException {
String body = readFile(NOTIFICATION_JSON,Charset.defaultCharset());
out.setExpectedMessageCount(1);
CamelContext context = context();
RouteDefinition routeDefinition = context.getRouteDefinition("WEBHOOK-TEST");
assertNotNull("RouteDefinition is null",routeDefinition);
List<FromDefinition> inputs = routeDefinition.getInputs();
FromDefinition from = inputs.get(0);
String uri = from.getEndpointUri();
uri = uri.replaceFirst("jetty:","");
LOG.debug("uri: {}", uri);
// Send HTTP notification
HttpClient httpclient = new HttpClient();
PostMethod httppost = new PostMethod(uri);
Header contentHeader = new Header("Content-Type", "application/json");
httppost.setRequestHeader(contentHeader);
StringRequestEntity reqEntity = new StringRequestEntity(body,null,null);
httppost.setRequestEntity(reqEntity);
int status = httpclient.executeMethod(httppost);
assertEquals("Received wrong response status", 200, status);
out.assertIsSatisfied();
List<Exchange> exchanges = out.getExchanges();
LOG.debug("EXCHANGE COUNT: {}",exchanges.size());
for (Exchange exchange : exchanges) {
Message message = exchange.getIn();
String messageBody = message.getBody(String.class);
Object o = message.getBody();
LOG.debug("class: " + o.getClass().toString());
LOG.debug("messageBody: " + messageBody);
LOG.debug("id: " + exchange.getExchangeId());
//assertEquals("Body not equal",body,messageBody);
}
}
开发者ID:boundary,项目名称:boundary-event-sdk,代码行数:41,代码来源:WebhookNotificationTest.java
示例16: addInputs
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
protected static void addInputs(CamelCatalog camelCatalog, NodeDto owner, List<FromDefinition> inputs) {
Map<String, Integer> nodeCounts = new HashMap<>();
for (FromDefinition input : inputs) {
addChild(camelCatalog, owner, input, nodeCounts);
}
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:7,代码来源:CamelXmlHelper.java
示例17: DefaultRouteContext
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public DefaultRouteContext(CamelContext camelContext, RouteDefinition route, FromDefinition from, Collection<Route> routes) {
this.camelContext = camelContext;
this.route = route;
this.from = from;
this.routes = routes;
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:DefaultRouteContext.java
示例18: getFrom
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
public FromDefinition getFrom() {
return from;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:DefaultRouteContext.java
示例19: verifyRouteDefinitions
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
private void verifyRouteDefinitions(List<RouteDefinition> routeDefinitions, CamelComponentImplementationModel ccim) throws Exception {
// service name & namespace
// TODO what happens when we have multiple services?
String serviceName = ccim.getComponent().getServices().get(0).getName();
String compositeNs = ccim.getComponent().getComposite().getTargetNamespace();
// number of switchyard:// consumers/from statements
int serviceConsumer = 0;
for (RouteDefinition routeDefinition : routeDefinitions) {
if (routeDefinition.getInputs().isEmpty()) {
throw CamelComponentMessages.MESSAGES.mustHaveAtLeastOneInput();
}
for (FromDefinition fromDefinition : routeDefinition.getInputs()) {
URI from = URI.create(this.getCamelContext().resolvePropertyPlaceholders(fromDefinition.getUri()));
if (from.getScheme().equals(CamelConstants.SWITCHYARD_COMPONENT_NAME)) {
if (serviceConsumer > 0) {
throw CamelComponentMessages.MESSAGES.onlyOneSwitchYardInputPerImpl();
}
String authority = from.getAuthority();
if (!serviceName.equals(authority)) {
throw CamelComponentMessages.MESSAGES.implementationConsumerDoesNotMatchService(serviceName);
}
serviceConsumer++;
}
}
List<ProcessorDefinition<?>> outputs = routeDefinition.getOutputs();
for (ProcessorDefinition<?> processorDefinition : outputs) {
if (processorDefinition instanceof ToDefinition) {
ToDefinition to = (ToDefinition) processorDefinition;
URI componentUri = null;
if (to.getRef() != null) {
componentUri = URI.create(getCamelContext().getRegistry().lookupByNameAndType(to.getRef(), Endpoint.class).getEndpointUri());
} else if (to.getUri() != null) {
componentUri = URI.create(this.getCamelContext().resolvePropertyPlaceholders(to.getUri()));
} else {
throw CamelComponentMessages.MESSAGES.couldNotResolveToEndpointUri(to.toString());
}
if (componentUri.getScheme().equals(CamelConstants.SWITCHYARD_COMPONENT_NAME)) {
final String referenceName = componentUri.getAuthority();
final QName refServiceName = new QName(compositeNs, referenceName);
if (!containsServiceRef(ccim.getComponent().getReferences(), referenceName)) {
throw CamelComponentMessages.MESSAGES.couldNotFindServiceReference(referenceName, to.toString());
}
QName qualifiedRefName = ComponentNames.qualify(
ccim.getComponent().getQName(), refServiceName);
final ServiceReference service = getServiceDomain().getServiceReference(qualifiedRefName);
if (service == null) {
throw CamelComponentMessages.MESSAGES.couldNotFindServiceName(qualifiedRefName.toString(), to.toString());
}
}
}
}
}
if (serviceConsumer != 1) {
throw CamelComponentMessages.MESSAGES.cannotCreateComponentImpl();
}
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:61,代码来源:CamelActivator.java
示例20: getFrom
import org.apache.camel.model.FromDefinition; //导入依赖的package包/类
/**
* Gets the from type
*
* @return the from type
*/
FromDefinition getFrom();
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:RouteContext.java
注:本文中的org.apache.camel.model.FromDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论