private Set<String> getBarrierIdsFromAllDeploymentUnitsInHierarchy(final org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit) { final Set<String> barriers = new HashSet<String>(); // get the top level DU in the hierarchy of the DU final org.jboss.deployers.structure.spi.DeploymentUnit topLevelDU = deploymentUnit.getTopLevel(); final List<org.jboss.deployers.structure.spi.DeploymentUnit> allDUs = new ArrayList<org.jboss.deployers.structure.spi.DeploymentUnit>(); allDUs.add(topLevelDU); // now fetch all the child DUs recursively from the top level DU allDUs.addAll(this.getChildrenRecursively(topLevelDU)); // find any Barrier in each of the DU for (org.jboss.deployers.structure.spi.DeploymentUnit du : allDUs) { final Barrier barrier = du.getAttachment(Barrier.class); if (barrier != null) { barriers.add(barrier.getId()); } } return barriers; }
/** * Creates and returns {@link BeanMetaData} for the passed {@link EEInjector injector} and sets up * dependency on the passed {@link Barrier SwitchBoard barrier}. * * @param injectorMCBeanName * @param injector * @param barrier * @return */ protected BeanMetaData createInjectorBMD(String injectorMCBeanName, EEInjector injector, Barrier barrier) { BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(injectorMCBeanName, injector.getClass().getName()); builder.setConstructorValue(injector); // add dependency on SwitchBoard Barrier builder.addDemand(barrier.getId(), ControllerState.CREATE, ControllerState.START, null); // return the Injector BMD return builder.getBeanMetaData(); }
/** * Creates and returns {@link BeanMetaData} for the passed {@link EEInjector injector} and sets up * dependency on the passed {@link Barrier SwitchBoard barrier}. * * @param injectorMCBeanName * @param injector * @param barrier * @return */ protected BeanMetaData createInjectorBMD(String injectorMCBeanName, EEInjector injector, Barrier barrier) { BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(injectorMCBeanName, injector.getClass().getName()); builder.setConstructorValue(injector); // add dependency on SwitchBoard Barrier builder.addDemand(barrier.getId(), ControllerState.CREATE, ControllerState.START, null); // return the Injector BMD return builder.getBeanMetaData(); }
/** * Creates and returns {@link BeanMetaData} for the passed {@link EEInjector injector} and sets up * dependency on the passed {@link Barrier SwitchBoard barrier}. * * @param injectorMCBeanName * @param injector * @param barrier * @return */ private BeanMetaData createInjectorBMD(String injectorMCBeanName, EEInjector injector, Barrier barrier) { BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(injectorMCBeanName, injector.getClass() .getName()); builder.setConstructorValue(injector); // add dependency on INSTALLED state of SwitchBoard Barrier builder.addDependency(barrier.getId()); // return the Injector BMD return builder.getBeanMetaData(); }
private DemandMetaData createSwitchBoardDependency(EJBContainer container, Barrier switchBoard) { AbstractDemandMetaData switchboardDependency = new AbstractDemandMetaData(); switchboardDependency.setDemand(switchBoard.getId()); switchboardDependency.setWhenRequired(ControllerState.CREATE); // This is really hacky for @Service bean containers. // The issue with ServiceContainer is that it instantiates (and that leads to injection) // the bean instance in its start() lifecycle call. Ideally, like the @Singleton EJB3.1 beans // we should have done it outside of the container, so that the container could just depend // on a START(ed) switchboard which provides only a populated but not invokable ENC. // However, due to the nature of changes involved to support that for @Service and given that // we have deprecated @Service (starting AS6), this is relatively better way to handle @Service // beans. if (container instanceof ServiceContainer) { // ServiceContainer requires a populated and invokable ENC (== INSTALLED state of switchboard) switchboardDependency.setTargetState(ControllerState.INSTALLED); } else { // container requires only a populated ENC (== START state of switchboard) switchboardDependency.setTargetState(ControllerState.START); } return switchboardDependency; }
log.debug("Added dependency on Switchboard " + switchBoard.getId() + " for EJB container " + ejbContainer.getName());