@SuppressWarnings({"unchecked"}) private Service createDefinition(Class<?> service, String name, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { ServiceContract serviceContract = contractProcessor.introspect(service, implClass, context, componentType); Service definition = new Service(name, serviceContract); if (policyIntrospector != null) { policyIntrospector.introspectPolicyOnOperations(serviceContract, implClass, context); } return definition; } }
@SuppressWarnings({"unchecked"}) private Service<ComponentType> createServiceDefinition(Class<?> serviceInterface, Class<?> implClass, ComponentType componentType, IntrospectionContext context) { ServiceContract contract = contractProcessor.introspect(serviceInterface, context, componentType); Service<ComponentType> definition = new Service<>(contract.getInterfaceName(), contract); policyIntrospector.introspectPolicyOnOperations(contract, implClass, context); return definition; }
@SuppressWarnings({"unchecked"}) private ServiceDefinition createDefinition(Class<?> service, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { ServiceContract serviceContract = contractProcessor.introspect(service, implClass, context, componentType); ServiceDefinition definition = new ServiceDefinition(serviceContract.getInterfaceName(), serviceContract); Annotation[] annotations = service.getAnnotations(); if (policyProcessor != null) { for (Annotation annotation : annotations) { policyProcessor.process(annotation, definition, context); } policyIntrospector.introspectPolicyOnOperations(serviceContract, implClass, context); } return definition; } }
public void applyHeuristics(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { // if any services have been defined, just introspect policy if (!componentType.getServices().isEmpty()) { for (Service<ComponentType> definition : componentType.getServices().values()) { JavaServiceContract contract = (JavaServiceContract) definition.getServiceContract(); policyIntrospector.introspectPolicyOnOperations(contract, implClass, context); } return; } Set<Class<?>> interfaces = helper.getImplementedInterfaces(implClass); if (interfaces.isEmpty()) { // no interfaces, use implementation Service<ComponentType> service = createServiceDefinition(implClass, implClass, componentType, context); componentType.add(service); } else { // class implements all interfaces that are not management interfaces or in the Java package for (Class<?> interfaze : interfaces) { Package pkg = interfaze.getPackage(); if (interfaze.isAnnotationPresent(Management.class) || pkg == null || pkg.getName().startsWith("java")) { continue; } Service<ComponentType> service = createServiceDefinition(interfaze, implClass, componentType, context); componentType.add(service); } } }