@Override @SuppressWarnings("unchecked") public <T> List<ServiceHolder<T>> getAllServiceHolders(Class<T> contract, Annotation... qualifiers) { return getServiceLocator().getAllServiceHandles(contract, qualifiers).stream() .map(sh -> new ServiceHolderImpl<>( sh.getService(), (Class<T>) sh.getActiveDescriptor().getImplementationClass(), sh.getActiveDescriptor().getContractTypes(), sh.getActiveDescriptor().getRanking())) .collect(Collectors.toList()); }
@Override @SuppressWarnings("unchecked") public <T> List<ServiceHolder<T>> getAllServiceHolders(Class<T> contract, Annotation... qualifiers) { return getServiceLocator().getAllServiceHandles(contract, qualifiers).stream() .map(sh -> new ServiceHolderImpl<>( sh.getService(), (Class<T>) sh.getActiveDescriptor().getImplementationClass(), sh.getActiveDescriptor().getContractTypes(), sh.getActiveDescriptor().getRanking())) .collect(Collectors.toList()); }
@Override public Set<Type> getTypes() { return descriptor.getContractTypes(); }
@Override public Set<Type> getContractTypes() { checkState(); if (activeDescriptor != null) { return activeDescriptor.getContractTypes(); } return contracts; }
@Override public Set<Type> getContractTypes() { checkState(); if (activeDescriptor != null) { return activeDescriptor.getContractTypes(); } return contracts; }
@Override public Set<Type> getContractTypes() { checkState(); if (activeDescriptor != null) { return activeDescriptor.getContractTypes(); } return contracts; }
@Override public Set<Type> getContractTypes() { checkState(); if (activeDescriptor != null) { return activeDescriptor.getContractTypes(); } return contracts; }
public Class getClassFromDescriptor(ActiveDescriptor<?> descriptor) { Class<?> defaultReturnValue = descriptor.getImplementationClass(); String name = descriptor.getName(); if (name == null) return defaultReturnValue; Class<?> foundContract = null; for (Type contract : descriptor.getContractTypes()) { if (!(contract instanceof Class)) continue; Class<?> cc = (Class<?>) contract; if (cc.getName().equals(name)) { foundContract = cc; break; } } if (foundContract == null) return defaultReturnValue; return foundContract; }
/** * This method returns the class associated with the type of the factory. * * @param descriptor The descriptor (reified and not null) that will be used to find the implementation. * @return the CLASS version of what the factory produces. Will not be null. * @throws MultiException if there was an error analyzing the class. */ private static Class<?> getFactoryProductionClass(ActiveDescriptor<?> descriptor) { Class<?> factoryClass = descriptor.getImplementationClass(); Type factoryProvidedType = getFactoryProductionType(factoryClass); Class<?> retVal = ReflectionHelper.getRawClass(factoryProvidedType); if (retVal == null && descriptor.getContractTypes().size() == 1) { // If the type was not resolved from a generic type, try to use // contract type if only one was registered. Type contract = descriptor.getContractTypes().iterator().next(); retVal = ReflectionHelper.getRawClass(contract); } if (retVal == null) { throw new MultiException(new AssertionError("Could not find true produced type of factory " + factoryClass.getName())); } return retVal; }
/** * Will return the class of the injection resolver annotation type, or null if * no injection resolver annotation can be found * * @param desc The reified descriptor to find the injection resolution on * @return The annotation type for this injection resolver */ @SuppressWarnings("unchecked") public static Class<? extends Annotation> getInjectionResolverType(ActiveDescriptor<?> desc) { for (Type advertisedType : desc.getContractTypes()) { Class<?> rawClass = ReflectionHelper.getRawClass(advertisedType); if (!InjectionResolver.class.equals(rawClass)) continue; // Found the InjectionResolver if (!(advertisedType instanceof ParameterizedType)) { return null; } Type firstType = ReflectionHelper.getFirstTypeArgument(advertisedType); if (!(firstType instanceof Class)) { return null; } Class<?> retVal = (Class<?>) firstType; if (!Annotation.class.isAssignableFrom(retVal)) { return null; } return (Class<? extends Annotation>) retVal; } return null; }
/** * Will return the class of the injection resolver annotation type, or null if * no injection resolver annotation can be found * * @param desc The reified descriptor to find the injection resolution on * @return The annotation type for this injection resolver */ @SuppressWarnings("unchecked") public static Class<? extends Annotation> getInjectionResolverType(ActiveDescriptor<?> desc) { for (Type advertisedType : desc.getContractTypes()) { Class<?> rawClass = ReflectionHelper.getRawClass(advertisedType); if (!InjectionResolver.class.equals(rawClass)) continue; // Found the InjectionResolver if (!(advertisedType instanceof ParameterizedType)) { return null; } Type firstType = ReflectionHelper.getFirstTypeArgument(advertisedType); if (!(firstType instanceof Class)) { return null; } Class<?> retVal = (Class<?>) firstType; if (!Annotation.class.isAssignableFrom(retVal)) { return null; } return (Class<? extends Annotation>) retVal; } return null; }
/** * Will return the class of the injection resolver annotation type, or null if * no injection resolver annotation can be found * * @param desc The reified descriptor to find the injection resolution on * @return The annotation type for this injection resolver */ @SuppressWarnings("unchecked") public static Class<? extends Annotation> getInjectionResolverType(ActiveDescriptor<?> desc) { for (Type advertisedType : desc.getContractTypes()) { Class<?> rawClass = ReflectionHelper.getRawClass(advertisedType); if (!InjectionResolver.class.equals(rawClass)) continue; // Found the InjectionResolver if (!(advertisedType instanceof ParameterizedType)) { return null; } Type firstType = ReflectionHelper.getFirstTypeArgument(advertisedType); if (!(firstType instanceof Class)) { return null; } Class<?> retVal = (Class<?>) firstType; if (!Annotation.class.isAssignableFrom(retVal)) { return null; } return (Class<? extends Annotation>) retVal; } return null; }
/** * Will return the class of the injection resolver annotation type, or null if * no injection resolver annotation can be found * * @param desc The reified descriptor to find the injection resolution on * @return The annotation type for this injection resolver */ @SuppressWarnings("unchecked") public static Class<? extends Annotation> getInjectionResolverType(ActiveDescriptor<?> desc) { for (Type advertisedType : desc.getContractTypes()) { Class<?> rawClass = ReflectionHelper.getRawClass(advertisedType); if (!InjectionResolver.class.equals(rawClass)) continue; // Found the InjectionResolver if (!(advertisedType instanceof ParameterizedType)) { return null; } Type firstType = ReflectionHelper.getFirstTypeArgument(advertisedType); if (!(firstType instanceof Class)) { return null; } Class<?> retVal = (Class<?>) firstType; if (!Annotation.class.isAssignableFrom(retVal)) { return null; } return (Class<? extends Annotation>) retVal; } return null; }
@Override @SuppressWarnings("unchecked") public <T> List<ServiceHolder<T>> getAllServiceHolders(Class<T> contract, Annotation... qualifiers) { return getServiceLocator().getAllServiceHandles(contract, qualifiers).stream() .map(sh -> new ServiceHolderImpl<>( sh.getService(), (Class<T>) sh.getActiveDescriptor().getImplementationClass(), sh.getActiveDescriptor().getContractTypes(), sh.getActiveDescriptor().getRanking())) .collect(Collectors.toList()); }
@Override @SuppressWarnings("unchecked") public <T> List<ServiceHolder<T>> getAllServiceHolders(Class<T> contract, Annotation... qualifiers) { return getServiceLocator().getAllServiceHandles(contract, qualifiers).stream() .map(sh -> new ServiceHolderImpl<>( sh.getService(), (Class<T>) sh.getActiveDescriptor().getImplementationClass(), sh.getActiveDescriptor().getContractTypes(), sh.getActiveDescriptor().getRanking())) .collect(Collectors.toList()); }
final ActiveDescriptor<T> key = provider.getActiveDescriptor(); if (!providerMap.containsKey(key)) { final Set<Type> contractTypes = key.getContractTypes(); final Class<?> implementationClass = key.getImplementationClass(); boolean proxyGenerated = true;
final ActiveDescriptor<T> key = provider.getActiveDescriptor(); if (!providerMap.containsKey(key)) { final Set<Type> contractTypes = key.getContractTypes(); final Class<?> implementationClass = key.getImplementationClass(); boolean proxyGenerated = true;
final ActiveDescriptor<T> key = provider.getActiveDescriptor(); if (!providerMap.containsKey(key)) { final Set<Type> contractTypes = key.getContractTypes(); final Class<?> implementationClass = key.getImplementationClass(); boolean proxyGenerated = true;
scopeAnnotation = active.getScopeAsAnnotation(); scope = active.getScopeAnnotation(); contracts = Collections.unmodifiableSet(active.getContractTypes()); qualifiers = Collections.unmodifiableSet(active.getQualifierAnnotations());
scopeAnnotation = active.getScopeAsAnnotation(); scope = active.getScopeAnnotation(); contracts = Collections.unmodifiableSet(active.getContractTypes()); qualifiers = Collections.unmodifiableSet(active.getQualifierAnnotations());