return MATCH; if (source.getInterfaceClass().isAssignableFrom(target.getInterfaceClass())) { return MATCH; if ((source.getSuperType() == null && target.getSuperType() != null) || (source.getSuperType() != null && !source.getSuperType().equals(target.getSuperType()))) { if (reportErrors) { return new MatchResult("Types are not in the same type hierarchy"); if (source.getQualifiedInterfaceName().equals(target.getQualifiedInterfaceName())) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature); } else { for (String superType : target.getInterfaces()) { if (superType.equals(source.getInterfaceClass().getName())) { if (!source.isRemotable() || !target.isRemotable()) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature);
private JavaServiceContract introspectInterface(Class<?> interfaze, Class<?> baseClass, IntrospectionContext context, ModelObject... modelObjects) { JavaServiceContract contract = new JavaServiceContract(interfaze); contract.setInterfaceName(interfaze.getSimpleName()); boolean remotable = interfaze.isAnnotationPresent(org.oasisopen.sca.annotation.Remotable.class) || interfaze.isAnnotationPresent(Remotable.class); contract.setRemotable(remotable); List<Operation> operations = introspectOperations(interfaze, baseClass, remotable, context, modelObjects); contract.setOperations(operations); for (InterfaceIntrospector introspector : interfaceIntrospectors) { introspector.introspect(contract, interfaze, context); } return contract; }
private void introspectCallback(Class<?> interfaze, Class<?> callbackClass, JavaServiceContract contract, IntrospectionContext context, ModelObject... modelObjects) { if (Void.class.equals(callbackClass)) { context.addError(new MissingCallback(interfaze, modelObjects)); return; } // the base class for the callback interface is always itself since it is not referenceable in Java from the service implementation // or client implementation where the reference is injected JavaServiceContract callbackContract = introspectInterface(callbackClass, callbackClass, context); if (contract.isRemotable() != callbackContract.isRemotable()) { String forwardName = contract.getInterfaceName(); String callbackName = callbackContract.getInterfaceName(); InvalidCallbackContract error = new InvalidCallbackContract("The remotable attribute on the forward and callback contract do not match: " + forwardName + "," + callbackName, callbackClass, modelObjects); context.addError(error); } contract.setCallbackContract(callbackContract); }
public String getQualifiedInterfaceName() { return getInterfaceClass().getName(); }
public MetroJavaWireSource generateSource(LogicalBinding<WsBinding> binding, JavaServiceContract contract) { Class<?> serviceClass = contract.getInterfaceClass(); WsBinding bindingDefinition = binding.getDefinition(); URL wsdlLocation = getWsdlLocation(bindingDefinition, serviceClass); Class<?> interfaze = contract.getInterfaceClass(); LogicalComponent<?> component = binding.getParent().getParent(); for (LogicalService service : component.getServices()) { if (service.getServiceContract().getQualifiedInterfaceName().equals(contract.getQualifiedInterfaceName())) { try { serviceUri = new URI(component.getUri() + "#" + service.getDefinition().getName()); boolean bidirectional = contract.getCallbackContract() != null && !binding.isCallback();
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 MetroWireTarget generateTarget(LogicalBinding<WsBinding> binding, URL targetUrl, JavaServiceContract contract) { Class<?> serviceClass = contract.getInterfaceClass(); WsBinding bindingDefinition = binding.getDefinition(); URL wsdlLocation = getWsdlLocation(bindingDefinition, serviceClass); Class<?> interfaze = contract.getInterfaceClass(); boolean bidirectional = contract.getCallbackContract() != null && !binding.isCallback();
String interfaze = contract.getQualifiedInterfaceName(); LogicalComponent<?> component = binding.getParent().getParent(); for (LogicalService service : component.getServices()) { if (service.getServiceContract().getQualifiedInterfaceName().equals(contract.getQualifiedInterfaceName())) { try { serviceUri = new URI(component.getUri() + "#" + service.getDefinition().getName()); boolean bidirectional = contract.getCallbackContract() != null && !binding.isCallback();
private JavaServiceContract generateTestContract(Class<?> implClass) { List<Operation> operations = new ArrayList<Operation>(); for (Method method : implClass.getMethods()) { // see if this is a test method if (Modifier.isStatic(method.getModifiers())) { continue; } if (method.getReturnType() != void.class) { continue; } if (method.getParameterTypes().length != 0) { continue; } String name = method.getName(); if (!method.isAnnotationPresent(Test.class) && (name.length() < 5 || !name.startsWith("test"))) { continue; } Operation operation = new Operation(name, INPUT_TYPE, OUTPUT_TYPE, FAULT_TYPE); operations.add(operation); } JavaServiceContract contract = new JavaServiceContract(implClass); contract.setOperations(operations); return contract; } }
/** * Loads a service contract class in either a host environment that supports classloader isolation or one that does not, in which case the TCCL is used. * * @param javaContract the contract * @param contributionUri the contribution URI the contract class is loaded in * @return the loaded class */ private Class<?> loadServiceClass(JavaServiceContract javaContract, URI contributionUri) throws GenerationException { ClassLoader loader = classLoaderRegistry.getClassLoader(contributionUri); try { return loader.loadClass(javaContract.getInterfaceClass()); } catch (ClassNotFoundException e) { throw new GenerationException(e); } }
private void introspectCallback(Class<?> interfaze, Class<?> callbackClass, JavaServiceContract contract, IntrospectionContext context, ModelObject... modelObjects) { if (Void.class.equals(callbackClass)) { context.addError(new MissingCallback(interfaze, modelObjects)); return; } // the base class for the callback interface is always itself since it is not referenceable in Java from the service implementation // or client implementation where the reference is injected JavaServiceContract callbackContract = introspectInterface(callbackClass, callbackClass, context); if (contract.isRemotable() != callbackContract.isRemotable()) { String forwardName = contract.getInterfaceName(); String callbackName = callbackContract.getInterfaceName(); InvalidCallbackContract error = new InvalidCallbackContract( "The remotable attribute on the forward and callback contract do not match: " + forwardName + "," + callbackName, callbackClass, modelObjects); context.addError(error); } contract.setCallbackContract(callbackContract); }
String interfaze = contract.getQualifiedInterfaceName(); boolean bidirectional = contract.getCallbackContract() != null && !binding.isCallback();
return MATCH; if (source.getInterfaceClass().isAssignableFrom(target.getInterfaceClass())) { return MATCH; if ((source.getSuperType() == null && target.getSuperType() != null) || (source.getSuperType() != null && !source.getSuperType().equals(target.getSuperType()))) { if (reportErrors) { return new MatchResult("Types are not in the same type hierarchy"); if (source.getQualifiedInterfaceName().equals(target.getQualifiedInterfaceName())) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature); } else { for (String superType : target.getInterfaces()) { if (superType.equals(source.getInterfaceClass().getName())) { if (!source.isRemotable() || !target.isRemotable()) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature);
public void generateResourceWireSource(JavaWireSource source, LogicalResourceReference<?> resourceReference) { URI uri = resourceReference.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) resourceReference.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.RESOURCE, uri.getFragment())); source.setInterfaceClass(serviceContract.getInterfaceClass()); }
private JavaServiceContract introspectInterface(Class<?> interfaze, Class<?> baseClass, IntrospectionContext context, ModelObject... modelObjects) { JavaServiceContract contract = new JavaServiceContract(interfaze); contract.setInterfaceName(interfaze.getSimpleName()); boolean remotable = interfaze.isAnnotationPresent(org.oasisopen.sca.annotation.Remotable.class) || interfaze.isAnnotationPresent(Remotable.class); contract.setRemotable(remotable); List<Operation> operations = introspectOperations(interfaze, baseClass, remotable, context, modelObjects); contract.setOperations(operations); for (InterfaceIntrospector introspector : interfaceIntrospectors) { introspector.introspect(contract, interfaze, context); } return contract; }
return MATCH; if ((source.getSuperType() == null && target.getSuperType() != null) || (source.getSuperType() != null && !source.getSuperType().equals(target.getSuperType()))) { if (reportErrors) { return new MatchResult("Types are not in the same type hierarchy"); if (source.getInterfaceClass().equals(target.getInterfaceClass())) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature); } else { for (String superType : target.getInterfaces()) { if (superType.equals(source.getInterfaceClass())) { if (!source.isRemotable() || !target.isRemotable()) { for (Signature signature : source.getMethodSignatures()) { if (!target.getMethodSignatures().contains(signature)) { if (reportErrors) { return new MatchResult("Method signature not found on target service contract: " + signature);
public PhysicalConnectionSource generateConnectionSource(LogicalProducer producer) { SystemConnectionSource source = new SystemConnectionSource(); URI uri = producer.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) producer.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.PRODUCER, uri.getFragment())); source.setServiceInterface(serviceContract.getInterfaceClass()); return source; }
public PhysicalConnectionSource generateConnectionSource(LogicalProducer producer) throws Fabric3Exception { String producerName = producer.getDefinition().getName(); URI uri = producer.getParent().getUri(); JavaServiceContract serviceContract = (JavaServiceContract) producer.getDefinition().getServiceContract(); return new SpringConnectionSource(producerName, serviceContract.getInterfaceClass(), uri); }
public PhysicalConnectionSource generateConnectionSource(LogicalProducer producer) throws Fabric3Exception { String producerName = producer.getDefinition().getName(); URI uri = producer.getParent().getUri(); JavaServiceContract serviceContract = (JavaServiceContract) producer.getDefinition().getServiceContract(); return new SpringConnectionSource(producerName, serviceContract.getInterfaceClass(), uri); }
protected Binding processService(ZeroMQ annotation, Service<ComponentType> boundService, InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { if(!isActiveForEnvironment(annotation.environments())) { return null; } Class<?> serviceInterface = ((JavaServiceContract) boundService.getServiceContract()).getInterfaceClass(); ZeroMQMetadata metadata = new ZeroMQMetadata(); String bindingName = "ZMQ" + serviceInterface.getSimpleName(); ZeroMQBinding binding = new ZeroMQBinding(bindingName, metadata); int port = annotation.port(); if (port > 0) { SocketAddressDefinition address = new SocketAddressDefinition("localhost", port); metadata.setSocketAddresses(Collections.singletonList(address)); } else { parseAddresses(annotation, metadata, implClass, context); } processMetadata(annotation, metadata); return binding; }