+ 1 // CeDistributedInformation ); assertThat(picoContainer.getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF + 8 // level 3 ); assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF + 20 // MigrationConfigurationModule + 17 // level 2 ); assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 26 // level 1
adapterMap.putAll(getMatchingComponentAdapters(parent, adapter, keyType, valueType)); final Collection allAdapters = container.getComponentAdapters(); for (final Iterator iter = allAdapters.iterator(); iter.hasNext();) { final ComponentAdapter componentAdapter = (ComponentAdapter) iter.next();
public Collection getComponentAdapters() { return delegate.getComponentAdapters(); }
@Override protected List<Class<?>> stepsTypes() { List<Class<?>> types = new ArrayList<>(); for (ComponentAdapter<?> adapter : parent.getComponentAdapters()) { if (hasAnnotatedMethods(adapter.getComponentImplementation())) { types.add(adapter.getComponentImplementation()); } } return types; }
/** * Returns all the components currently inside of Pico which are instances of the given class. * * @param clazz the class to search for. * @return a list containing all the instances of the passed class registered in JIRA's pico container. */ public static <T> List<T> getComponentsOfType(final Class<T> clazz) { final PicoContainer pico = getInstance().getContainer(); final List<ComponentAdapter<T>> adapters = pico.getComponentAdapters(clazz); if (adapters.isEmpty()) { return Collections.emptyList(); } else { final List<T> returnList = new ArrayList<T>(adapters.size()); for (final ComponentAdapter<T> adapter : adapters) { // remove cast when we go to a Java5 pico returnList.add(clazz.cast(adapter.getComponentInstance(pico))); } return Collections.unmodifiableList(returnList); } }
/** * Returns all the components currently inside Pico which are instances of the given class, mapping them to their * component key. * * @param iface The class to search for * @return a map, mapping the component key, to the instances of the clas registered in JIRA's pico container. */ public static <T> Map<String, T> getComponentsOfTypeMap(final Class<T> iface) { final PicoContainer picoContainer = getInstance().getContainer(); final List<ComponentAdapter<T>> componentAdaptersOfType = picoContainer.getComponentAdapters(iface); final Map<String, T> implementations = new HashMap<String, T>(); for (final ComponentAdapter<T> componentAdapter : componentAdaptersOfType) { final T componentInstance = iface.cast(componentAdapter.getComponentInstance(picoContainer)); implementations.put(String.valueOf(componentAdapter.getComponentKey()), componentInstance); } return Collections.unmodifiableMap(implementations); }
private void populateContainer(String resourcePath, MutablePicoContainer container) { PicoContainer buildContainer = buildContainer(resourcePath, container.getParent()); for (ComponentAdapter<?> adapter : buildContainer.getComponentAdapters()) { container.addAdapter(adapter); } }
/** * populate container for given path. cache result in container recorders * * @param container the MutablePicoContainer used by the recorder * @param path the String representing the servlet path used as key for the * recorder cache */ private void populateContainer(String resourcePath, MutablePicoContainer container) { PicoContainer buildContainer = buildContainer(resourcePath, container.getParent()); for (ComponentAdapter<?> adapter : buildContainer.getComponentAdapters()) { container.addAdapter(adapter); } }
private void registerEventComponents() { EventPublisher eventPublisher = getComponent(EventPublisher.class); Set<Object> registeredListeners = Sets.newIdentityHashSet(); Collection<ComponentAdapter<?>> componentAdapters = getContainer().getComponentAdapters(); for (ComponentAdapter<?> componentAdapter : componentAdapters) { Class<?> componentKey = componentAdapter.getComponentImplementation(); if (componentKey.getAnnotation(EventComponent.class) != null) { Object instance = componentAdapter.getComponentInstance(container.getPicoContainer(), ComponentAdapter.NOTHING.class); if (registeredListeners.add(instance)) { eventPublisher.register(instance); } } } }