private static Class<?> getBound(Type bounds[]) { if (bounds == null) return null; if (bounds.length < 1) return null; if (bounds.length > 1) { throw new AssertionError("Do not understand multiple bounds"); } return ReflectionHelper.getRawClass(bounds[0]); }
private static Class<?> getBound(Type bounds[]) { if (bounds == null) return null; if (bounds.length < 1) return null; if (bounds.length > 1) { throw new AssertionError("Do not understand multiple bounds"); } return ReflectionHelper.getRawClass(bounds[0]); }
private static Class<?> getBound(Type bounds[]) { if (bounds == null) return null; if (bounds.length < 1) return null; if (bounds.length > 1) { throw new AssertionError("Do not understand multiple bounds"); } return ReflectionHelper.getRawClass(bounds[0]); }
private static Class<?> getBound(Type bounds[]) { if (bounds == null) return null; if (bounds.length < 1) return null; if (bounds.length > 1) { throw new AssertionError("Do not understand multiple bounds"); } return ReflectionHelper.getRawClass(bounds[0]); }
private static void addAllInterfaceContracts(Type interfaceType, LinkedHashSet<Type> addToMe) { Class<?> interfaceClass = ReflectionHelper.getRawClass(interfaceType); if (interfaceClass == null) return; if (addToMe.contains(interfaceType)) return; addToMe.add(interfaceType); for (Type extendedInterfaces : interfaceClass.getGenericInterfaces()) { addAllInterfaceContracts(extendedInterfaces, addToMe); } }
private static void addAllInterfaceContracts(Type interfaceType, LinkedHashSet<Type> addToMe) { Class<?> interfaceClass = ReflectionHelper.getRawClass(interfaceType); if (interfaceClass == null) return; if (addToMe.contains(interfaceType)) return; addToMe.add(interfaceType); for (Type extendedInterfaces : interfaceClass.getGenericInterfaces()) { addAllInterfaceContracts(extendedInterfaces, addToMe); } }
/** * Returns all the interfaces the proxy must implement * @param contracts All of the advertised contracts * @return The array of contracts to add to the proxy */ public static Class<?>[] getInterfacesForProxy(Set<Type> contracts) { LinkedList<Class<?>> retVal = new LinkedList<Class<?>>(); retVal.add(ProxyCtl.class); // Every proxy implements this interface for (Type type : contracts) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!rawClass.isInterface()) continue; retVal.add(rawClass); } return retVal.toArray(new Class<?>[retVal.size()]); }
/** * Returns all the interfaces the proxy must implement * @param contracts All of the advertised contracts * @return The array of contracts to add to the proxy */ public static Class<?>[] getInterfacesForProxy(Set<Type> contracts) { LinkedList<Class<?>> retVal = new LinkedList<Class<?>>(); retVal.add(ProxyCtl.class); // Every proxy implements this interface for (Type type : contracts) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!rawClass.isInterface()) continue; retVal.add(rawClass); } return retVal.toArray(new Class<?>[retVal.size()]); }
private static void addAllInterfaceContracts(Type interfaceType, LinkedHashSet<Type> addToMe) { Class<?> interfaceClass = ReflectionHelper.getRawClass(interfaceType); if (interfaceClass == null) return; if (addToMe.contains(interfaceType)) return; addToMe.add(interfaceType); for (Type extendedInterfaces : interfaceClass.getGenericInterfaces()) { addAllInterfaceContracts(extendedInterfaces, addToMe); } }
/** * Returns all the interfaces the proxy must implement * @param contracts All of the advertised contracts * @return The array of contracts to add to the proxy */ public static Class<?>[] getInterfacesForProxy(Set<Type> contracts) { LinkedList<Class<?>> retVal = new LinkedList<Class<?>>(); retVal.add(ProxyCtl.class); // Every proxy implements this interface for (Type type : contracts) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!rawClass.isInterface()) continue; retVal.add(rawClass); } return retVal.toArray(new Class<?>[retVal.size()]); }
/** * Returns all the interfaces the proxy must implement * @param contracts All of the advertised contracts * @return The array of contracts to add to the proxy */ public static Class<?>[] getInterfacesForProxy(Set<Type> contracts) { LinkedList<Class<?>> retVal = new LinkedList<Class<?>>(); retVal.add(ProxyCtl.class); // Every proxy implements this interface for (Type type : contracts) { Class<?> rawClass = ReflectionHelper.getRawClass(type); if (rawClass == null) continue; if (!rawClass.isInterface()) continue; retVal.add(rawClass); } return retVal.toArray(new Class<?>[retVal.size()]); }
private static void addAllInterfaceContracts(Type interfaceType, LinkedHashSet<Type> addToMe) { Class<?> interfaceClass = ReflectionHelper.getRawClass(interfaceType); if (interfaceClass == null) return; if (addToMe.contains(interfaceType)) return; addToMe.add(interfaceType); for (Type extendedInterfaces : interfaceClass.getGenericInterfaces()) { addAllInterfaceContracts(extendedInterfaces, addToMe); } }
private static void getAllContractsFromInterfaces(Class<?> clazzOrInterface, Class<? extends Annotation> markerAnnotation, Set<Type> addToMe, Set<Class<?>> alreadyHandled) { Type interfacesAsType[] = clazzOrInterface.getGenericInterfaces(); for (Type interfaceAsType : interfacesAsType) { Class<?> interfaceAsClass = getRawClass(interfaceAsType); if (interfaceAsClass == null) continue; if (alreadyHandled.contains(interfaceAsClass)) continue; alreadyHandled.add(interfaceAsClass); if (interfaceAsClass.isAnnotationPresent(markerAnnotation)) { addToMe.add(interfaceAsType); } getAllContractsFromInterfaces(interfaceAsClass, markerAnnotation, addToMe, alreadyHandled); } }
private static void getAllContractsFromInterfaces(Class<?> clazzOrInterface, Class<? extends Annotation> markerAnnotation, Set<Type> addToMe, Set<Class<?>> alreadyHandled) { Type interfacesAsType[] = clazzOrInterface.getGenericInterfaces(); for (Type interfaceAsType : interfacesAsType) { Class<?> interfaceAsClass = getRawClass(interfaceAsType); if (interfaceAsClass == null) continue; if (alreadyHandled.contains(interfaceAsClass)) continue; alreadyHandled.add(interfaceAsClass); if (interfaceAsClass.isAnnotationPresent(markerAnnotation)) { addToMe.add(interfaceAsType); } getAllContractsFromInterfaces(interfaceAsClass, markerAnnotation, addToMe, alreadyHandled); } }
/** * Removes an advertised contract from the set of contracts advertised by this descriptor * @param removeMe The contract to remove. May not be null * @return true if removeMe was removed from the set */ public boolean removeContractType(Type removeMe) { try { wLock.lock(); if (removeMe == null) return false; boolean retVal = advertisedContracts.remove(removeMe); Class<?> rawClass = ReflectionHelper.getRawClass(removeMe); if (rawClass == null) return retVal; return removeAdvertisedContract(rawClass.getName()); } finally { wLock.unlock(); } }
private static void getAllContractsFromInterfaces(Class<?> clazzOrInterface, Class<? extends Annotation> markerAnnotation, Set<Type> addToMe, Set<Class<?>> alreadyHandled) { Type interfacesAsType[] = clazzOrInterface.getGenericInterfaces(); for (Type interfaceAsType : interfacesAsType) { Class<?> interfaceAsClass = getRawClass(interfaceAsType); if (interfaceAsClass == null) continue; if (alreadyHandled.contains(interfaceAsClass)) continue; alreadyHandled.add(interfaceAsClass); if (interfaceAsClass.isAnnotationPresent(markerAnnotation)) { addToMe.add(interfaceAsType); } getAllContractsFromInterfaces(interfaceAsClass, markerAnnotation, addToMe, alreadyHandled); } }
/** * This method returns the class associated with the type of the * factory * * @param factoryClass The non-null factory class. May not be null * @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(Class<?> factoryClass) { Type factoryProvidedType = getFactoryProductionType(factoryClass); Class<?> retVal = ReflectionHelper.getRawClass(factoryProvidedType); if (retVal != null) return retVal; throw new MultiException(new AssertionError("Could not find true produced type of factory " + factoryClass.getName())); }
/** * This method returns the class associated with the type of the * factory * * @param factoryClass The non-null factory class. May not be null * @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(Class<?> factoryClass) { Type factoryProvidedType = getFactoryProductionType(factoryClass); Class<?> retVal = ReflectionHelper.getRawClass(factoryProvidedType); if (retVal != null) return retVal; throw new MultiException(new AssertionError("Could not find true produced type of factory " + factoryClass.getName())); }
/** * This method returns the class associated with the type of the * factory * * @param factoryClass The non-null factory class. May not be null * @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(Class<?> factoryClass) { Type factoryProvidedType = getFactoryProductionType(factoryClass); Class<?> retVal = ReflectionHelper.getRawClass(factoryProvidedType); if (retVal != null) return retVal; throw new MultiException(new AssertionError("Could not find true produced type of factory " + factoryClass.getName())); }
/** * Create a new service binding builder. * * @param <T> service type. * @param serviceType service class. * @param bindAsContract if {@code true}, the service class will be bound as one of the contracts. * @return initialized binding builder. */ @SuppressWarnings("unchecked") static <T> AbstractBindingBuilder<T> create(Type serviceType, boolean bindAsContract) { return new ClassBasedBindingBuilder<T>( (Class<T>) ReflectionHelper.getRawClass(serviceType), bindAsContract ? serviceType : null).asType(serviceType); } /**