private Exchange createSwitchyardExchange(final org.apache.camel.Exchange camelExchange, final ServiceReference serviceRef, MessageComposer<CamelBindingData> messageComposer) { String opName = lookupOperationNameFor(camelExchange, serviceRef); CamelResponseHandler handler = new CamelResponseHandler(camelExchange, serviceRef, messageComposer); if (opName != null) { return serviceRef.createExchange(opName, handler); } else { return serviceRef.createExchange(handler); } }
@Override public Dispatcher getDispatcher(ServiceReference reference) { return _dispatchers.get(reference.getName()); }
private Exchange createExchange(ServiceReference service, Method method, ExchangeHandler responseExchangeHandler) throws BeanComponentException { String operationName = method.getName(); if (service.getInterface().getOperation(operationName) == null) { throw BeanMessages.MESSAGES.beanComponentInvocationFailureOperationIsNotDefinedOnService(operationName, _serviceName); } return service.createExchange(operationName, responseExchangeHandler); }
Exchange exchange=_serviceReference.createExchange(operationName, rh); exchange = rh.waitForOut(_waitTimeout); } catch (DeliveryException e) { throw BPELMessages.MESSAGES.timedOutAfterMsWaitingOnSynchronousResponseFromTargetService(_waitTimeout, _serviceReference.getName().toString()); throw BPELMessages.MESSAGES.responseNotReturnedFromOperationOnService(operationName, _serviceReference.getName().toString());
private void invokeLocal(Exchange exchange, ServiceReference targetRef) throws HandlerException { SynchronousInOutHandler replyHandler = new SynchronousInOutHandler(); Exchange ex = targetRef.createExchange(exchange.getContract().getProviderOperation().getName(), replyHandler); try { ClassLoader targetCL = (ClassLoader) targetRef.getDomain().getProperty(Deployment.CLASSLOADER_PROPERTY); origCL = Classes.setTCCL(targetCL); ex.send(invokeMsg);
@Override public void dispatch(final Exchange exchange) { // We can only send Camel exchanges through the camel bus if (!CamelExchange.class.isInstance(exchange)) { throw BusMessages.MESSAGES.onlyCamelExchanges(); } CamelExchange camelEx = (CamelExchange)exchange; // For camel exchanges, the only phase we care about is IN. The dispatch method can also // be called on the OUT path, but that should be handled by the IN_OUT filter in the Camel // bus route. if (!exchange.getPhase().equals(ExchangePhase.IN)) { return; } Throttling throttling = _reference.getServiceMetadata().getThrottling(); if (throttling != null && throttling.getMaxRequests() > 0) { exchange.getMessage().getContext().setProperty( Throttling.MAX_REQUESTS, throttling.getMaxRequests()) .addLabels(BehaviorLabel.TRANSIENT.label()); } _producer.send("direct:" + exchange.getConsumer().getName(), camelEx.getExchange()); }
List<Service> services = _domain.getServices(exchange.getConsumer().getTargetServiceName()); if (services == null || services.isEmpty()) { throw RuntimeMessages.MESSAGES.noRegisteredService(exchange.getConsumer().getName().toString());
@Override public ServiceInterface getContract() { return _reference.getInterface(); }
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }
/** * Set the list of regexes of properties that need to be propagated. * * @param context context */ protected void setRegexPropagationList(Context context) { _includeRegexes.clear(); if (!_prefixPropagationSet) { if (context.getProperty(SERVICE_REFERENCE_PROPERTY) != null) { ServiceDomain domain = ((ServiceReference)context.getProperty(SERVICE_REFERENCE_PROPERTY).getValue()).getDomain(); if (domain.getProperty(PropertyConstants.DOMAIN_PROPERTY_PROPAGATE_REGEX) != null) { String regexList = (String) domain.getProperty(PropertyConstants.DOMAIN_PROPERTY_PROPAGATE_REGEX); setPatternList(regexList, _includeRegexes); } } _prefixPropagationSet = true; } Pattern rtGovResubmissionPattern = Pattern.compile(PropertyConstants.RTGOV_HEADER_RESUBMITTED_ID_PATTERN); _includeRegexes.add(rtGovResubmissionPattern); }
private void addThrottling(TryDefinition route) { Throttling throttling = _reference.getServiceMetadata().getThrottling(); long timePeriodMS = throttling != null ? throttling.getTimePeriod() : Throttling.DEFAULT_TIME_PERIOD; route.filter(THROTTLE_CHECK) .throttle(header(Throttling.MAX_REQUESTS)).timePeriodMillis(timePeriodMS) // throttle needs a child process, so we'll just remove the header // using an empty process definition causes some of the interceptors // to blow chunks, specifically audit interceptors .removeHeader(Throttling.MAX_REQUESTS) .end().end(); } }
@Test public void testReferenceEvents() { _domain.addEventObserver(_observer, ReferenceRegistrationEvent.class) .addEventObserver(_observer, ReferenceUnregistrationEvent.class); ServiceReference ref = _domain.registerServiceReference(new QName("test"), new InOutService()); Assert.assertTrue(_observer.referenceRegistrationCalled); ref.unregister(); Assert.assertTrue(_observer.referenceUnregistrationCalled); }
LOGGER.trace("Inbound <-- Request:[" + _service.getName() + "][" + SOAPUtil.soapMessageToString(soapMessage) + "]"); SOAPMessages.MESSAGES.operationNotAvailableTarget(firstBodyElement.toString(), _service.getName() + "'.")); Exchange exchange = _service.createExchange(operationName, inOutHandler); return handleException(oneWay, SOAPMessages.MESSAGES.timedOut(String.valueOf(_waitTimeout), _service.getName().toString()));
private void invokeLocal(Exchange exchange, ServiceReference targetRef) throws HandlerException { SynchronousInOutHandler replyHandler = new SynchronousInOutHandler(); Exchange ex = targetRef.createExchange(exchange.getContract().getProviderOperation().getName(), replyHandler); try { ClassLoader targetCL = (ClassLoader) targetRef.getDomain().getProperty(Deployment.CLASSLOADER_PROPERTY); origCL = Classes.setTCCL(targetCL); ex.send(invokeMsg);
@Override public void dispatch(final Exchange exchange) { // We can only send Camel exchanges through the camel bus if (!CamelExchange.class.isInstance(exchange)) { throw BusMessages.MESSAGES.onlyCamelExchanges(); } CamelExchange camelEx = (CamelExchange)exchange; // For camel exchanges, the only phase we care about is IN. The dispatch method can also // be called on the OUT path, but that should be handled by the IN_OUT filter in the Camel // bus route. if (!exchange.getPhase().equals(ExchangePhase.IN)) { return; } Throttling throttling = _reference.getServiceMetadata().getThrottling(); if (throttling != null && throttling.getMaxRequests() > 0) { exchange.getMessage().getContext().setProperty( Throttling.MAX_REQUESTS, throttling.getMaxRequests()) .addLabels(BehaviorLabel.TRANSIENT.label()); } String uri = "direct:" + exchange.getConsumer().getName(); DirectEndpoint ep = _context.getEndpoint(uri, DirectEndpoint.class); if (ep.getConsumer() == null) { throw BusMessages.MESSAGES.consumerForinternalCamelRouteNotFound(uri); } _producer.send(ep, camelEx.getExchange()); }
List<Service> services = _domain.getServices(exchange.getConsumer().getTargetServiceName()); if (services == null || services.isEmpty()) { throw RuntimeMessages.MESSAGES.noRegisteredService(exchange.getConsumer().getName().toString());
@Override public ServiceInterface getContract() { return _reference.getInterface(); }
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }
if (_service.getDomain().getProperty(PropertyConstants.DOMAIN_PROPERTY_PROPAGATE_REGEX) != null) { String regexList = (String) _service.getDomain().getProperty(PropertyConstants.DOMAIN_PROPERTY_PROPAGATE_REGEX); Set<String> regexSet = Strings.uniqueSplitTrimToNull(regexList, ","); for (String regex : regexSet) {
private void addThrottling(TryDefinition route) { Throttling throttling = _reference.getServiceMetadata().getThrottling(); long timePeriodMS = throttling != null ? throttling.getTimePeriod() : Throttling.DEFAULT_TIME_PERIOD; route.filter(THROTTLE_CHECK) .throttle(header(Throttling.MAX_REQUESTS)).timePeriodMillis(timePeriodMS) // throttle needs a child process, so we'll just remove the header // using an empty process definition causes some of the interceptors // to blow chunks, specifically audit interceptors .removeHeader(Throttling.MAX_REQUESTS) .end().end(); } }