/** * @return the class loader for the deployment using this handler. */ protected ClassLoader getDeploymentClassLoader() { return _domain == null ? null : (ClassLoader) _domain.getProperty(CLASSLOADER_PROPERTY); }
/** * initialize. */ public void initialize() { _serviceRef = _domain.getServiceReference(_serviceQName); }
/** * Protected invoker. * @param domain The ServiceDomain. * @param serviceName The Service name. */ protected Invoker(ServiceDomain domain, String serviceName) { this(domain, XMLHelper.createQName(domain.getName().getNamespaceURI(), serviceName)); }
@Override public Smooks createSmooks(ServiceDomain domain, String config) { if (_logger.isDebugEnabled()) { _logger.debug("Creating Smooks instance - Domain: " + domain + ", Smooks Config: " + config); } if (domain != null && domain.getProperties() != null) { Bundle bundle = (Bundle)domain.getProperty(SWITCHYARD_DEPLOYMENT_BUNDLE); if (bundle != null) { try { return new SmooksOSGIFactory(bundle).createInstance(config); } catch (Exception e) { if (_logger.isDebugEnabled()) { _logger.debug(e); } } } } return null; }
ServiceReference ref = exchange.getProvider().getDomain().getServiceReference(serviceName); throw SCAMessages.MESSAGES.serviceReferenceNotFoundInDomain(serviceName.toString(), exchange.getProvider().getDomain().getName().toString());
@Override public Processor create(ServiceDomain domain) { return wrap(new TransformHandler(domain.getTransformerRegistry())); } },
private void deployServicesAndProxies(BeanDeploymentMetaData beanDeploymentMetaData, ServiceDomain domain) { if (!_activateBeans) { return; } if (beanDeploymentMetaData == null) { throw BeanMessages.MESSAGES.failedToLookupBeanDeploymentMetaDataFromNamingContext(); } BeanComponentActivator activator = new BeanComponentActivator(); for (ServiceDescriptor serviceDescriptor : beanDeploymentMetaData.getServiceDescriptors()) { String serviceName = serviceDescriptor.getServiceName(); ServiceProxyHandler handler = serviceDescriptor.getHandler(); ServiceInterface serviceInterface; ServiceReference service; activator.lookupBeanMetaData(); serviceInterface = activator.buildServiceInterface(serviceName); QName serviceQName = XMLHelper.createQName(domain.getName().getNamespaceURI(), serviceName); domain.registerService(serviceQName, serviceInterface, handler); service = domain.registerServiceReference(serviceQName, serviceInterface); handler.addReference(service); handler.start(); } }
@Override public Endpoint publish(ServiceDomain domain, String context, List<Object> instances, Map<String, String> contextParams) throws Exception { OsgiRESTEasyServletRegistry servletRegistry = (OsgiRESTEasyServletRegistry) domain.getProperty(KEY_SERVLET_REGISTRY); if (servletRegistry == null) { if (LOGGER.isDebugEnabled()) { domain.setProperty(KEY_SERVLET_REGISTRY, servletRegistry);
public void onEvent(BpelEvent bpelEvent) { domain.getEventPublisher().publish(bpelEvent); } });
@Override public void init(ServiceDomain domain) { _domain = domain; TransactionHandler transactionHandler = new TransactionHandler(); TransformHandler transformHandler = new TransformHandler(domain.getTransformerRegistry()); ValidateHandler validateHandler = new ValidateHandler(domain.getValidatorRegistry()); // Build out the request and reply handler chains. _requestChain = new DefaultHandlerChain(); _requestChain.addLast("addressing", new AddressingHandler(_domain)); _requestChain.addLast("transaction-pre-invoke", transactionHandler); _requestChain.addLast("security-process", new SecurityHandler(_domain, SecurityAction.PROCESS)); _requestChain.addLast("generic-policy", new PolicyHandler()); _requestChain.addLast("validation-before-transform", validateHandler); _requestChain.addLast("transformation", transformHandler); _requestChain.addLast("validation-after-transform", validateHandler); _requestChain.addLast("provider", new ProviderHandler(_domain)); _requestChain.addLast("security-cleanup", new SecurityHandler(_domain, SecurityAction.CLEANUP)); _requestChain.addLast("transaction-post-invoke", transactionHandler); _replyChain = new DefaultHandlerChain(); _replyChain.addLast("validation-before-transform", validateHandler); _replyChain.addLast("transformation", transformHandler); _replyChain.addLast("validation-after-transform", validateHandler); _replyChain.addLast(HandlerChain.CONSUMER_HANDLER, new BaseHandler()); }
/** * Associates camel context with given service domain. * * @param domain Domain to associate. */ public void setServiceDomain(ServiceDomain domain) { _domain = domain; for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) { if (notifier instanceof CamelEventBridge) { ((CamelEventBridge) notifier).setEventPublisher(domain.getEventPublisher()); } } PackageScanClassResolver packageScanClassResolver = findPackageScanClassResolver(); if (packageScanClassResolver != null) { setPackageScanClassResolver(packageScanClassResolver); } _domain.setProperty(CAMEL_CONTEXT_PROPERTY, this); }
/** * Register an IN_OUT Service. * * @param serviceName The Service name. * @param serviceHandler The service handler. * @param metadata Service interface. */ public void registerInOutService(String serviceName, ExchangeHandler serviceHandler, ServiceInterface metadata) { getServiceDomain().registerService(createQName(serviceName), metadata, serviceHandler); }
@Test public void testTransformerEvents() { _domain.addEventObserver(_observer, TransformerAddedEvent.class) .addEventObserver(_observer, TransformerRemovedEvent.class); Transformer<String, String> t = new BaseTransformer<String, String>() { public String transform(String from) { return null; } }; _domain.getTransformerRegistry().addTransformer(t); Assert.assertTrue(_observer.addTransformerCalled); _domain.getTransformerRegistry().removeTransformer(t); Assert.assertTrue(_observer.removeTransformerCalled); }
/** * Tear everything down. */ public void destroy() { _log.debug("Destroying deployment " + getName()); // Clean up our list of activations, just in case something's left _serviceBindings.clear(); _components.clear(); _referenceBindings.clear(); getValidatorRegistryLoader().unregisterValidators(); getTransformerRegistryLoader().unregisterTransformers(); getDomain().getEventPublisher().publish(new ApplicationUndeployedEvent(this)); getDomain().destroy(); }
.security(getDomain().getServiceSecurity(reference.getSecurity())) .requiredPolicies(requires).registrant(impl) .build(); ServiceReference svcRef = getDomain().registerServiceReference(refName, refIntf, null, metadata); ServiceInterface serviceIntf = getComponentServiceInterface(service); ServiceMetadata metadata = ServiceMetadataBuilder.create() .security(getDomain().getServiceSecurity(service.getSecurity())) .requiredPolicies(requires) .registrant(impl) .build(); Service svc = getDomain().registerService(service.getQName(), serviceIntf, handler, metadata); activation.addService(svc); activation.addReferences(references); Service promotedService = getDomain().registerService( compositeService.getQName(), serviceIntf, handler, metadata); activation.addPromotion(promotedService);
_serviceDomain.setProperty(CLASSLOADER_PROPERTY, Classes.getTCCL()); _transformerRegistryLoader = new TransformerRegistryLoader(appServiceDomain); _transformerRegistryLoader.loadOOTBTransforms(); _validatorRegistryLoader = new ValidatorRegistryLoader(appServiceDomain.getValidatorRegistry()); _validatorRegistryLoader.loadOOTBValidates();
/** * Enables message tracing for the application under test. * @param doTrace true to enable message tracing, false to disable */ public void traceMessages(boolean doTrace) { getServiceDomain().setProperty(MessageTraceHandler.TRACE_ENABLED, true); }
/** * Replaces an existing service registration (e.g. reference binding) with a test handler using * the same contract as the existing service provider. If multiple services are registered with * the specified name, the first one found is used. Generally speaking, it's not a good idea * to use this method if you have multiple services registered with the same name. In that * situation, use the removeService() and registerService() methods instead. * @param name name of the service to replace * @param handler implementation to use as the service provider * @throws SwitchYardException if a service with the specified name does not exist */ public void replaceService(QName name, ExchangeHandler handler) throws SwitchYardException { List<Service> services = getServiceDomain().getServices(name); if (services.isEmpty()) { throw new SwitchYardException("Failed to replace service: " + name + ". No service is registered with that name."); } // select the service to replace Service replacedService = services.get(0); replacedService.unregister(); // add the replacement service getServiceDomain().registerService(name, replacedService.getInterface(), handler, replacedService.getServiceMetadata()); }
private Exchange createExchange(ExchangePattern pattern, ExchangeHandler handler) { ServiceOperation operation = _serviceOperation; ServiceReference reference; if (operation == null) { if (ExchangePattern.IN_ONLY.equals(pattern)) { operation = new InOnlyOperation(_operationName, _inputType); } else { operation = new InOutOperation(_operationName, _inputType, _expectedOutputType, _expectedFaultType); } } reference = _domain.registerServiceReference(_serviceName, new BaseService(operation), handler); return _operationName == null ? reference.createExchange() : reference.createExchange(_operationName); }
@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); }