@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()); }
/** * probably a bit slow, calculates all the @Configured interfaces subclassing, useful * to find all possible subclasses of a type. * * @throws ClassNotFoundException */ private void initXRef() throws ClassNotFoundException { // force initialization of all the config models. for (ServiceHandle<?> i : habitat.getAllServiceHandles(ConfigInjector.class)) { buildModel((ActiveDescriptor<? extends ConfigInjector>) i.getActiveDescriptor()); } for (ConfigModel cm : models.values()) { Class targetType = cm.classLoaderHolder.loadClass(cm.targetTypeName); do { Class[] intfs = targetType.getInterfaces(); for (Class intf : intfs) { if (intf.isAnnotationPresent(Configured.class)) { addXRef(intf, cm); } } targetType = targetType.getSuperclass(); } while (targetType!=null); } }
public void lookupAllInjectors() { String[] expected = { SimpleConnectorInjector.class.getName(), EjbContainerAvailabilityInjector.class.getName(), WebContainerAvailabilityInjector.class.getName(), GenericContainerInjector.class.getName(), GenericConfigInjector.class.getName() }; List<String> expectedInjectors = Arrays.asList(expected); List<ServiceHandle<ConfigInjector>> inhabitants = habitat.getAllServiceHandles(ConfigInjector.class); Set<String> inhabitantNames = new HashSet<String>(); for (ServiceHandle<?> inh : inhabitants) { inhabitantNames.add(inh.getActiveDescriptor().getImplementation()); } assert(inhabitants.size() == expected.length); assert(inhabitantNames.containsAll(expectedInjectors)); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Type contractOrImpl, Annotation... qualifiers) throws MultiException { return delegate.getAllServiceHandles(contractOrImpl, qualifiers); }
@Override public <T> List<ServiceHandle<T>> getAllServiceHandles(Class<T> contractOrImpl, Annotation... qualifiers) throws MultiException { return delegate.getAllServiceHandles(contractOrImpl, qualifiers); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Annotation qualifier, Annotation... qualifiers) throws MultiException { return delegate.getAllServiceHandles(qualifier, qualifiers); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Type type, Annotation... annotations) throws MultiException { return delegate.getAllServiceHandles(type, annotations); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Filter filter) throws MultiException { return delegate.getAllServiceHandles(filter); }
@Override public <T> List<ServiceHandle<T>> getAllServiceHandles(Class<T> aClass, Annotation... annotations) throws MultiException { return delegate.getAllServiceHandles(aClass, annotations); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Annotation annotation, Annotation... annotations) throws MultiException { return delegate.getAllServiceHandles(annotation, annotations); }
@Override public List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria) throws MultiException { return delegate.getAllServiceHandles(searchCriteria); }
private static <T> List<ServiceHandle<T>> getServiceHandles(final ServiceLocator locator, final Class<T> contract, final Annotation... qualifiers) { final List<ServiceHandle<T>> allServiceHandles = qualifiers == null ? locator.getAllServiceHandles(contract) : locator.getAllServiceHandles(contract, qualifiers); final ArrayList<ServiceHandle<T>> serviceHandles = new ArrayList<ServiceHandle<T>>(); for (final ServiceHandle handle : allServiceHandles) { //noinspection unchecked serviceHandles.add((ServiceHandle<T>) handle); } return serviceHandles; }
private static <T> List<ServiceHandle<T>> getServiceHandles(final ServiceLocator locator, final Class<T> contract, final Annotation... qualifiers) { final List<ServiceHandle<T>> allServiceHandles = qualifiers == null ? locator.getAllServiceHandles(contract) : locator.getAllServiceHandles(contract, qualifiers); final ArrayList<ServiceHandle<T>> serviceHandles = new ArrayList<ServiceHandle<T>>(); for (final ServiceHandle handle : allServiceHandles) { //noinspection unchecked serviceHandles.add((ServiceHandle<T>) handle); } return serviceHandles; }
private static <T> List<ServiceHandle<T>> getServiceHandles(final ServiceLocator locator, final Class<T> contract, final Annotation... qualifiers) { final List<ServiceHandle<T>> allServiceHandles = qualifiers == null ? locator.getAllServiceHandles(contract) : locator.getAllServiceHandles(contract, qualifiers); final ArrayList<ServiceHandle<T>> serviceHandles = new ArrayList<ServiceHandle<T>>(); for (final ServiceHandle handle : allServiceHandles) { //noinspection unchecked serviceHandles.add((ServiceHandle<T>) handle); } return serviceHandles; }
public static List<ConfigurationDeploymentDescriptorFile> getConfigurationDeploymentDescriptorFiles(ServiceLocator habitat, String containerType) { List<ConfigurationDeploymentDescriptorFile> confDDFiles = new ArrayList<ConfigurationDeploymentDescriptorFile>(); for (ServiceHandle<?> serviceHandle : habitat.getAllServiceHandles(ConfigurationDeploymentDescriptorFileFor.class)) { ActiveDescriptor<?> descriptor = serviceHandle.getActiveDescriptor(); String indexedType = descriptor.getMetadata().get(ConfigurationDeploymentDescriptorFileFor.DESCRIPTOR_FOR).get(0); if(indexedType.equals(containerType)) { ConfigurationDeploymentDescriptorFile confDD = (ConfigurationDeploymentDescriptorFile) serviceHandle.getService(); confDDFiles.add(confDD); } } return confDDFiles; }
@SuppressWarnings("unused") @PostConstruct private void postConstruct() { fighterFishHandles = locator.getAllServiceHandles( BuilderHelper.createContractFilter(FIGHTERFISH_START_SERVICE)); for (ServiceHandle<?> fighterFishHandle : fighterFishHandles) { fighterFishHandle.getService(); } }
@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()); }
public void lookupAllInjectors() { String[] expected = { SimpleConnectorInjector.class.getName(), EjbContainerAvailabilityInjector.class.getName(), WebContainerAvailabilityInjector.class.getName(), GenericContainerInjector.class.getName(), GenericConfigInjector.class.getName() }; List<String> expectedInjectors = Arrays.asList(expected); List<ServiceHandle<ConfigInjector>> inhabitants = habitat.getAllServiceHandles(ConfigInjector.class); Set<String> inhabitantNames = new HashSet<String>(); for (ServiceHandle<?> inh : inhabitants) { inhabitantNames.add(inh.getActiveDescriptor().getImplementation()); } assert(inhabitants.size() == expected.length); assert(inhabitantNames.containsAll(expectedInjectors)); }