/** * Get all {@link GroupConfigurable} components each time so that when JIRA does restart the reference is not held * by this class. */ private Set<GroupConfigurable> getGroupConfigurableComponents() { // getComponents returns the same object reference multiple times if its being registered via different interfaces. // Using Set to reduce duplicates. return newHashSet(picoContainerSupplier.get().getComponents(GroupConfigurable.class)); }
/** * Create a {@link Multicasting} proxy for the components of a {@link PicoContainer}. * * @param pico the container * @param callInInstantiationOrder <code>true</code> if the components will be called in instantiation order * @param proxyFactory the ProxyFactory to use * @return the Multicasting proxy */ public static Object object(final PicoContainer pico, boolean callInInstantiationOrder, final ProxyFactory proxyFactory) { List copy = new ArrayList(pico.getComponents()); if (!callInInstantiationOrder) { // reverse the list Collections.reverse(copy); } Object[] targets = copy.toArray(); return Multicasting.object(proxyFactory, targets); } }
@Override protected ParameterConverters parameterConverters(AnnotationFinder annotationFinder, ResourceLoader resourceLoader, TableTransformers tableTransformers) { ParameterConverters converters = super.parameterConverters(annotationFinder, resourceLoader, tableTransformers); if (container != null) { return converters.addConverters(container.getComponents(ParameterConverter.class)); } return converters; }
private void runInitializingComponents() { // JDEV-31110: Prevent double-afterInstantiation() final Set<InitializingComponent> seen = Sets.newIdentityHashSet(); List<InitializingComponent> components = getContainer().getComponents(InitializingComponent.class); for (InitializingComponent component : components) { try { if (seen.add(component)) { component.afterInstantiation(); } } catch (final Exception e) { log.error("Error occurred while initializing component '" + component.getClass().getName() + "'.", e); throw new InfrastructureException("Error occurred while initializing component '" + component.getClass().getName() + "'.", e); } } }
private void runStartable() { // JDEV-31110: Prevent double-start() final Set<Startable> seen = Sets.newIdentityHashSet(); List<Startable> startables = getContainer().getComponents(Startable.class); for (Startable startable : startables) { try { if (seen.add(startable) && !(startable instanceof PluginSystemLifecycle)) // don't start the plugin manager twice! { startable.start(); } } catch (final Exception e) { log.error("Error occurred while starting component '" + startable.getClass().getName() + "'.", e); throw new InfrastructureException("Error occurred while starting component '" + startable.getClass().getName() + "'.", e); } } }