private void generateReferenceInjectionMapping(AbstractReference definition, WebComponentType type, Map<String, Map<String, InjectionSite>> mappings) { Map<String, InjectionSite> mapping = mappings.get(definition.getName()); if (mapping == null) { mapping = new HashMap<String, InjectionSite>(); mappings.put(definition.getName(), mapping); } for (Map.Entry<String, Map<InjectionSite, Injectable>> entry : type.getInjectionSites().entrySet()) { for (Map.Entry<InjectionSite, Injectable> siteMap : entry.getValue().entrySet()) { if (siteMap.getValue().getName().equals(definition.getName())) { mapping.put(entry.getKey(), siteMap.getKey()); } } } ServiceContract contract = definition.getServiceContract(); String interfaceClass = contract.getQualifiedInterfaceName(); // inject the reference into the session context WebContextInjectionSite site = new WebContextInjectionSite(interfaceClass, SESSION_CONTEXT); mapping.put(SESSION_CONTEXT_SITE, site); // also inject the reference into the servlet context WebContextInjectionSite servletContextsite = new WebContextInjectionSite(interfaceClass, SERVLET_CONTEXT); mapping.put(SERVLET_CONTEXT_SITE, servletContextsite); }
public URI createCallbackUri(LogicalReference source) { LogicalComponent<?> component = source.getParent(); String name = source.getDefinition().getServiceContract().getCallbackContract().getInterfaceName(); return URI.create(component.getUri() + "#" + name); }
/** * Merges the POJO component type into the web component type. * * @param webType the web component type to merge into * @param componentType the component type to merge * @param context the introspection context */ private void mergeComponentTypes(WebComponentType webType, InjectingComponentType componentType, IntrospectionContext context) { for (Map.Entry<String, ReferenceDefinition> entry : componentType.getReferences().entrySet()) { String name = entry.getKey(); AbstractReference reference = webType.getReferences().get(name); if (reference != null) { ServiceContract source = reference.getServiceContract(); ServiceContract target = entry.getValue().getServiceContract(); MatchResult result = matcher.isAssignableFrom(source, target, false); if (!result.isAssignable()) { // TODO display areas where it was not matching IncompatibleReferenceDefinitions failure = new IncompatibleReferenceDefinitions(name); context.addError(failure); } } else { webType.add(entry.getValue()); } } // apply all injection sites for (Map.Entry<InjectionSite, Injectable> entry : componentType.getInjectionSites().entrySet()) { webType.addMapping(componentType.getImplClass(), entry.getKey(), entry.getValue()); } }
public PhysicalSourceDefinition generateSource(LogicalReference reference, EffectivePolicy policy) throws GenerationException { URI uri = reference.getUri(); ServiceContract serviceContract = reference.getDefinition().getServiceContract(); String interfaceName = getInterfaceName(serviceContract); JavaSourceDefinition wireDefinition = new JavaSourceDefinition(); wireDefinition.setUri(uri); wireDefinition.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); wireDefinition.setInterfaceName(interfaceName); // assume for now that any wire from a JUnit component can be optimized wireDefinition.setOptimizable(true); if (reference.getDefinition().isKeyed()) { wireDefinition.setKeyed(true); DataType<?> type = reference.getDefinition().getKeyDataType(); String className = type.getPhysical().getName(); wireDefinition.setKeyClassName(className); } return wireDefinition; }
|| (componentReference.getAutowire() == Autowire.INHERITED && component.getAutowire() == Autowire.ON)) { AbstractReference referenceDefinition = logicalReference.getDefinition(); ServiceContract requiredContract = referenceDefinition.getServiceContract(); boolean resolved = resolveByType(component.getParent(), logicalReference, requiredContract); if (!resolved) {