/** * Adds a callback proxy definition and its associated injection site * * @param definition the callback proxy definition * @param injectionSite the proxy injection site */ public void add(Callback definition, InjectionSite injectionSite) { definition.setParent(this); String name = definition.getName(); callbacks.put(name, definition); Injectable injectable = new Injectable(InjectableType.CALLBACK, name); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(definition, injectionSite); }
public void generateCallbackWireSource(JavaWireSource source, LogicalComponent<? extends JavaImplementation> component, JavaServiceContract contract) { InjectingComponentType type = component.getDefinition().getImplementation().getComponentType(); String name = null; for (Callback entry : type.getCallbacks().values()) { // NB: This currently only supports the case where one callback injection site of the same type is on an implementation. ServiceContract candidate = entry.getServiceContract(); MatchResult result = matcher.isAssignableFrom(candidate, contract, false); if (result.isAssignable()) { name = entry.getName(); break; } } if (name == null) { String interfaze = contract.getQualifiedInterfaceName(); throw new Fabric3Exception("Callback injection site not found for type: " + interfaze); } Injectable injectable = new Injectable(InjectableType.CALLBACK, name); source.setInjectable(injectable); source.setInterfaceClass(contract.getInterfaceClass()); URI uri = URI.create(component.getUri().toString() + "#" + name); source.setUri(uri); source.setOptimizable(false); }
private Callback createDefinition(String name, Type type, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> baseType = helper.getBaseType(type, typeMapping); ServiceContract contract = contractProcessor.introspect(baseType, implClass, context, componentType); return new Callback(name, contract); }