/** * Create a new BaseService from the specified config model. * * @param serviceConfig the composite service config. * @param application the application containing the service. */ public BaseService(CompositeServiceModel serviceConfig, BaseApplication application) { _name = serviceConfig.getQName(); _application = application; if (serviceConfig.getInterface() != null) { _serviceInterface = serviceConfig.getInterface().getInterface(); } _promotedService = getPromotedService(application, serviceConfig); _gateways = new LinkedHashMap<String, Binding>(); int idx = 0; for (BindingModel bindingModel : serviceConfig.getBindings()) { // Generate binding name for now until tooling and config are updated to expose it ++idx; String name = bindingModel.getName() == null ? "_" + _name.getLocalPart() + "_" + bindingModel.getType() + "_" + idx : bindingModel.getName(); _gateways.put(name, new BaseBinding(_application, _name, bindingModel.getType(), name, bindingModel.toString())); } _throttling = new ServiceThrottling(this, serviceConfig.getExtensions()); }
private ServiceInterface getCompositeServiceInterface(CompositeServiceModel compositeServiceModel) { ServiceInterface serviceInterface = null; if (hasCompositeServiceInterface(compositeServiceModel)) { serviceInterface = loadServiceInterface(compositeServiceModel.getInterface()); } else if (hasComponentServiceInterface(compositeServiceModel.getComponentService())) { serviceInterface = loadServiceInterface(compositeServiceModel.getComponentService().getInterface()); } return serviceInterface; }
/** * Retrieve the composite service config for the specified service name. * @param name composite service name * @return composite service config fragment, or null if the service does not exist */ public CompositeServiceModel getCompositeService(String name) { for (CompositeServiceModel service : getSwitchYardConfig().getComposite().getServices()) { if (service.getName().equals(name)) { return service; } } // no matching service return null; }
/** * {@inheritDoc} */ @Override public QName getServiceName() { if (_serviceName == null) { _serviceName = isServiceBinding() ? getService().getQName() : getReference().getQName(); } return _serviceName; }
/** * Lookup camel binding model in SCA configuration and use Switchard model * as root and return first element from it. * * @param config Configuration location. * @return Camel binding. * @throws Exception In case of any problems exception is not handled. */ @SuppressWarnings("unchecked") protected T getFirstCamelBinding(final String config) throws Exception { final InputStream in = Classes.getResourceAsStream(config, getClass()); final SwitchYardModel model = new ModelPuller<SwitchYardModel>().pull(in); final List<CompositeServiceModel> services = model.getComposite().getServices(); final CompositeServiceModel compositeServiceModel = services.get(0); final List<BindingModel> bindings = compositeServiceModel.getBindings(); return (T) bindings.get(0); }
CompositeServiceModel service = null; for (CompositeServiceModel s : switchYard.getSwitchYardConfig().getComposite().getServices()) { if (s.getName().equals(serviceName)) { service = s; if (service.getBindings().size() == 0) { out.println(out.renderColor(ShellColor.YELLOW, "No binding")); return; for (BindingModel binding : service.getBindings()) { bindingList.add(BindingModel.class.cast(binding)); bindingDescList.add(binding.getModelConfiguration().toString());
.registrant(new Binding(service.getBindings())) .build(); ServiceReference reference = getDomain().registerServiceReference( service.getQName(), getCompositeServiceInterface(service), null, metadata); for (BindingModel binding : service.getBindings()) { ++bindingCount; if (binding.getName() == null) { _log.debug("Initializing binding name for binding " + bindingCount + " for service " + service.getQName() + " for deployment " + getName()); binding.setName("_" + service.getName() + "_" + binding.getType() + "_" + bindingCount); + service.getQName() + " for deployment " + getName()); ServiceHandler handler = activator.activateBinding(service.getQName(), binding); Activation activation = new Activation(activator, service.getQName(), binding, handler); activation.addReference(reference); _serviceBindings.add(activation);
out.println(service.getName()); out.print(out.renderColor(ShellColor.BOLD, " interface: ")); if (service.getInterface() != null) { out.println(service.getInterface().getInterface()); } else { out.println(out.renderColor(ShellColor.YELLOW, "inherited")); for (BindingModel binding : service.getBindings()) { out.print(out.renderColor(ShellColor.BOLD, " binding: ")); out.println(binding.getType());
ComponentServiceModel componentService = compositeService.getComponentService(); if (componentService != null && componentService.equals(service)) { if (!service.getQName().equals(compositeService.getQName())) { validateServiceRegistration(compositeService.getQName()); Service promotedService = getDomain().registerService( compositeService.getQName(), serviceIntf, handler, metadata); activation.addPromotion(promotedService);
private ComponentService getPromotedService(Application application, CompositeServiceModel compositeService) { ComponentServiceModel componentServiceModel = compositeService.getComponentService(); if (componentServiceModel == null) { return null; } return application.getComponentService(componentServiceModel.getQName()); }
private boolean hasCompositeServiceInterface(CompositeServiceModel compositeService) { return compositeService != null && compositeService.getInterface() != null; }
private Throttling getCompositeServiceThrottling(CompositeServiceModel compositeServiceModel) { final ExtensionsModel extensions = compositeServiceModel.getExtensions(); if (extensions == null) { return null; } final ThrottlingModel throttling = extensions.getThrottling(); if (throttling == null) { return null; } final Long timePeriod = throttling.getTimePeriod(); final Throttling retVal = new Throttling(); retVal.setMaxRequests(throttling.getMaxRequests()); if (timePeriod != null) { retVal.setTimePeriod(timePeriod); } return retVal; }
private void addServices() { _services = new LinkedHashMap<QName, Service>(); if (getConfig().getComposite().getServices() == null) { return; } for (CompositeServiceModel service : getConfig().getComposite().getServices()) { _services.put(service.getQName(), new BaseService(service, this)); } }
/** * Lookup camel binding model in SCA configuration and use Switchard model * as root and return first element from it. * * @param config Configuration location. * @return Camel binding. * @throws Exception In case of any problems exception is not handled. */ @SuppressWarnings("unchecked") protected T getFirstCamelBinding(final String config) throws Exception { final InputStream in = Classes.getResourceAsStream(config, getClass()); final SwitchYardModel model = new ModelPuller<SwitchYardModel>().pull(in); final List<CompositeServiceModel> services = model.getComposite().getServices(); final CompositeServiceModel compositeServiceModel = services.get(0); final List<BindingModel> bindings = compositeServiceModel.getBindings(); return (T) bindings.get(0); }
CompositeServiceModel service = null; for (CompositeServiceModel s : switchYard.getSwitchYardConfig().getComposite().getServices()) { if (s.getName().equals(serviceName)) { service = s; if (service.getBindings().size() == 0) { out.println(out.renderColor(ShellColor.YELLOW, "No binding")); return; for (BindingModel binding : service.getBindings()) { bindingList.add(BindingModel.class.cast(binding)); bindingDescList.add(binding.getModelConfiguration().toString());
domain.getServiceSecurity(bindingModel.getService().getComponentService().getSecurity()).getSecurityDomain(), ep.getSecurityDomainContext()));
/** * {@inheritDoc} */ @Override public QName getServiceName() { if (_serviceName == null) { _serviceName = isServiceBinding() ? getService().getQName() : getReference().getQName(); } return _serviceName; }
for (BindingModel binding : service.getBindings()) { types.add(binding.getType());
CompositeServiceModel service = null; for (CompositeServiceModel s : switchYard.getSwitchYardConfig().getComposite().getServices()) { if (s.getName().equals(serviceName)) { service = s; List<BindingModel> bindingList = service.getBindings(); if (bindingList.size() == 0) { out.println(out.renderColor(ShellColor.YELLOW, "There is no binding which supports OperationSelector"));
domain.getServiceSecurity(bindingModel.getService().getComponentService().getSecurity()).getSecurityDomain(), ep.getSecurityDomainContext()));