public SpringImplementationLoader(@Reference SpringImplementationProcessor processor) { this.processor = processor; addAttributes("location", "requires", "policySets"); }
/** * Performs heuristic introspection and validation. * * @param type the component type * @param context the context for reporting errors */ private void postProcess(SpringComponentType type, IntrospectionContext context) { if (type.getServices().isEmpty() && type.getReferences().isEmpty() && type.getProperties().isEmpty()) { processHueristics(type, context); return; } // introspect service contracts for service elements that do not explicitly have a type element postProcessServices(type, context); }
Location start = reader.getLocation(); processStream(context, reader, type); for (Source contextSource : multiSource.getSources()) { stream = contextSource.openStream(); reader = xmlInputFactory.createXMLStreamReader(stream); processStream(context, reader, type); validate(type, context, start);
case START_ELEMENT: if (BEAN.equals(reader.getName().getLocalPart())) { if (!processBean(type, reader, context)) { return; if (!processService(type, reader, context)) { return; if (!processReference(type, reader, context)) { return; if (!processProperty(type, reader, context)) { return; if (!processProducer(type, reader, context)) { return; if (!processConsumer(type, reader, context)) { return; postProcess(type, context); return;
/** * Performs heuristic introspection and validation of services. * * @param type the component type * @param context the context for reporting errors */ private void postProcessServices(SpringComponentType type, IntrospectionContext context) { for (SpringService service : type.getSpringServices().values()) { String target = service.getTarget(); BeanDefinition definition = type.getBeansById().get(target); if (definition == null) { definition = type.getBeansByName().get(target); } if (definition == null) { ServiceTargetNotFound failure = new ServiceTargetNotFound(service.getName(), target, type); context.addError(failure); continue; } if (service.getServiceContract() == null) { introspectContract(service, definition, type, context); } } }
DuplicateConsumer failure = new DuplicateConsumer(name, startLocation, type); context.addError(failure); return false; try { ClassLoader loader = context.getClassLoader(); consumerType = cast(loader.loadClass(typeAttr)); } catch (ClassNotFoundException e) { InvalidValue failure = new InvalidValue("Consumer interface not found: " + typeAttr, startLocation);
/** * Performs validation. * * @param type the component type * @param context the context */ private void validate(SpringComponentType type, IntrospectionContext context, Location location) { Collection<ReferenceDefinition> references = type.getReferences().values(); for (ReferenceDefinition reference : references) { String defaultStr = ((SpringReferenceDefinition) reference).getDefaultValue(); if (defaultStr != null) { if (!type.getBeansById().containsKey(defaultStr) && !type.getBeansByName().containsKey(defaultStr)) { InvalidValue error = new InvalidValue("Default value '" + defaultStr + "' does not reference a valid bean", location, type); context.addError(error); } } } if (strictValidation) { // SCA spec validation if (type.getSpringServices().isEmpty()) { // if no services defined, check remotables for (BeanDefinition beanDefinition : type.getBeansByName().values()) { validateBean(type, beanDefinition, context, location); } for (BeanDefinition beanDefinition : type.getBeansById().values()) { validateBean(type, beanDefinition, context, location); } } } }
String serviceName = service.getName(); if (beanClass == null) { UnknownServiceType failure = new UnknownServiceType(serviceName, beanClass, type); context.addError(failure); return; UnknownServiceType failure = new UnknownServiceType(serviceName, beanClass, type); context.addError(failure);
case START_ELEMENT: if (BEAN.equals(reader.getName().getLocalPart())) { if (!processBean(type, reader, context)) { return; if (!processService(type, reader, context)) { return; if (!processReference(type, reader, context)) { return; if (!processProperty(type, reader, context)) { return; if (!processProducer(type, reader, context)) { return; if (!processConsumer(type, reader, context)) { return; postProcess(type, context); return;
Location start = reader.getLocation(); processStream(context, reader, type); for (Source contextSource : multiSource.getSources()) { stream = contextSource.openStream(); reader = xmlInputFactory.createXMLStreamReader(stream); processStream(context, reader, type); validate(type, context, start);
/** * Performs heuristic introspection and validation. * * @param type the component type * @param context the context for reporting errors */ private void postProcess(SpringComponentType type, IntrospectionContext context) { if (type.getServices().isEmpty() && type.getReferences().isEmpty() && type.getProperties().isEmpty()) { processHueristics(type, context); return; } // introspect service contracts for service elements that do not explicitly have a type element postProcessServices(type, context); }
/** * Performs heuristic introspection and validation of services. * * @param type the component type * @param context the context for reporting errors */ private void postProcessServices(SpringComponentType type, IntrospectionContext context) { for (SpringService service : type.getSpringServices().values()) { String target = service.getTarget(); BeanDefinition definition = type.getBeansById().get(target); if (definition == null) { definition = type.getBeansByName().get(target); } if (definition == null) { ServiceTargetNotFound failure = new ServiceTargetNotFound(service.getName(), target, type); context.addError(failure); continue; } if (service.getServiceContract() == null) { introspectContract(service, definition, type, context); } } }
public SpringImplementationLoader(@Reference SpringImplementationProcessor processor) { this.processor = processor; addAttributes("location", "requires", "policySets"); }
/** * Performs validation. * * @param type the component type * @param context the context */ private void validate(SpringComponentType type, IntrospectionContext context, Location location) { Collection<Reference<ComponentType>> references = type.getReferences().values(); for (Reference reference : references) { String defaultStr = ((SpringReference) reference).getDefaultValue(); if (defaultStr != null) { if (!type.getBeansById().containsKey(defaultStr) && !type.getBeansByName().containsKey(defaultStr)) { InvalidValue error = new InvalidValue("Default value '" + defaultStr + "' does not reference a valid bean", location, type); context.addError(error); } } } if (strictValidation) { // SCA spec validation if (type.getSpringServices().isEmpty()) { // if no services defined, check remotables for (BeanDefinition beanDefinition : type.getBeansByName().values()) { validateBean(type, beanDefinition, context, location); } for (BeanDefinition beanDefinition : type.getBeansById().values()) { validateBean(type, beanDefinition, context, location); } } } }
case START_ELEMENT: if (BEAN.equals(reader.getName().getLocalPart())) { if (!processBean(type, reader, context)) { return; if (!processService(type, reader, context)) { return; if (!processReference(type, reader, context)) { return; if (!processProperty(type, reader, context)) { return; if (!processProducer(type, reader, context)) { return; if (!processConsumer(type, reader, context)) { return; postProcess(type, context); return;
Location start = reader.getLocation(); processStream(context, reader, type); for (Source contextSource : multiSource.getSources()) { stream = contextSource.openStream(); reader = xmlInputFactory.createXMLStreamReader(stream); processStream(context, reader, type); validate(type, context, start);
/** * Performs heuristic introspection and validation. * * @param type the component type * @param context the context for reporting errors */ private void postProcess(SpringComponentType type, IntrospectionContext context) { if (type.getServices().isEmpty() && type.getReferences().isEmpty() && type.getProperties().isEmpty()) { processHueristics(type, context); return; } // introspect service contracts for service elements that do not explicitly have a type element postProcessServices(type, context); }
/** * Performs heuristic introspection and validation of services. * * @param type the component type * @param context the context for reporting errors */ private void postProcessServices(SpringComponentType type, IntrospectionContext context) { for (SpringService service : type.getSpringServices().values()) { String target = service.getTarget(); BeanDefinition definition = type.getBeansById().get(target); if (definition == null) { definition = type.getBeansByName().get(target); } if (definition == null) { ServiceTargetNotFound failure = new ServiceTargetNotFound(service.getName(), target, type); context.addError(failure); continue; } if (service.getServiceContract() == null) { introspectContract(service, definition, type, context); } } }
public SpringImplementationLoader(@Reference SpringImplementationProcessor processor, @Reference LoaderHelper loaderHelper) { this.processor = processor; this.loaderHelper = loaderHelper; addAttributes("location", "requires", "policySets"); }
/** * Performs validation. * * @param type the component type * @param context the context */ private void validate(SpringComponentType type, IntrospectionContext context, Location location) { Collection<Reference<ComponentType>> references = type.getReferences().values(); for (Reference reference : references) { String defaultStr = ((SpringReference) reference).getDefaultValue(); if (defaultStr != null) { if (!type.getBeansById().containsKey(defaultStr) && !type.getBeansByName().containsKey(defaultStr)) { InvalidValue error = new InvalidValue("Default value '" + defaultStr + "' does not reference a valid bean", location, type); context.addError(error); } } } if (strictValidation) { // SCA spec validation if (type.getSpringServices().isEmpty()) { // if no services defined, check remotables for (BeanDefinition beanDefinition : type.getBeansByName().values()) { validateBean(type, beanDefinition, context, location); } for (BeanDefinition beanDefinition : type.getBeansById().values()) { validateBean(type, beanDefinition, context, location); } } } }