Refine search
private void attachManagedConnectionFactories(DeploymentUnit unit, Collection<DataSourceDeploymentMetaData> datasourceDeployments) { DeploymentUnit nonComponentDU = unit.isComponent() ? unit.getParent() : unit; ManagedConnectionFactoryDeploymentGroup managedConnectionFactories = nonComponentDU.getAttachment(ManagedConnectionFactoryDeploymentGroup.class); if (managedConnectionFactories == null) { managedConnectionFactories = new ManagedConnectionFactoryDeploymentGroup(); } for (DataSourceDeploymentMetaData dataSourceDeployment : datasourceDeployments) { managedConnectionFactories.addManagedConnectionFactoryDeployment(dataSourceDeployment); } nonComponentDU.addAttachment(ManagedConnectionFactoryDeploymentGroup.class, managedConnectionFactories); }
public ManagedDeployment build(DeploymentUnit unit, Map<String, ManagedObject> unitMOs, ManagedDeployment parent) { DeploymentPhase phase = unit.getAttachment(DeploymentPhase.class); if( phase == null ) phase = DeploymentPhase.APPLICATION; ManagedDeployment md = new ManagedDeploymentImpl(unit.getName(), unit.getSimpleName(), phase, parent, unitMOs); return md; }
public ClassLoader getClassLoader() { return this.unit.getClassLoader(); }
public <T> T search(DeploymentUnit unit, String name, Class<T> expectedType) { DeploymentUnit parent = unit.getParent(); return (parent != null) ? parent.getAttachment(name, expectedType) : null; } }
public String getApplicationName(DeploymentUnit unit) { DeploymentUnit topLevel = unit.getTopLevel(); if(topLevel.isAttachmentPresent(JBossAppMetaData.class)) return topLevel.getSimpleName(); return null; }
/** * Qualify the object name with parent name just to avoid conflicts with deployments with the same name in multiple * archives */ private String getObjectName(DeploymentUnit unit) { String deploymentName = unit.getName(); DeploymentUnit parentDU = unit.getParent(); String parentDeploymentName = parentDU != null ? ",parent=\"" + parentDU.getSimpleName() + "\"" : ""; return BASE_OBJECT_NAME + "\"" + deploymentName + "\"" + parentDeploymentName; } }
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit.getSimpleName().endsWith(".war")) { if (unit.isAttachmentPresent(JBossWebMetaData.class)) return; // only care about true deployments if (unit instanceof VFSDeploymentUnit == false) return; // Detect and ignore OSGi WAR deployments // FIXME Use typed OSGiMetaData when we have it available at runtime String bundleSymbolicName = unit.getAttachment("org.jboss.osgi.bundle.symbolic.name", String.class); if (bundleSymbolicName != null) { log.debug("Ignore OSGi webapp: " + bundleSymbolicName); return; } log.debug("Web archive doesn't contain web.xml: " + unit.getName()); unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData()); } } }
protected ValueMetaData createValidationServices(DeploymentUnit unit) throws DeploymentException { Object validatorFactory = unit.getAttachment(DeployersUtils.JAVAX_VALIDATION_VALIDATOR_FACTORY); if (validatorFactory == null && isValidationFactoryRequired(unit)) { throw new DeploymentException("Missing ValidatorFactory attachment in deployment: " + unit); } String beanName = unit.getName() + "_JBossValidationServices"; BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, "org.jboss.weld.integration.validation.JBossValidationServices"); unit.addAttachment(beanName + "_" + BeanMetaData.class.getSimpleName(), builder.getBeanMetaData()); builder.addConstructorParameter(DeployersUtils.JAVAX_VALIDATION_VALIDATOR_FACTORY, validatorFactory); return builder.createInject(beanName); }
@Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { super.createMetaData(unit, name, suffix); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); // If there no JBossWebMetaData was created from a jboss-web.xml, create one if (metaData == null) { metaData = new JBossWebMetaData(); } unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, metaData); unit.addAttachment("Raw"+JBossWebMetaData.class.getName(), metaData, JBossWebMetaData.class); }
@Override protected void internalDeploy(DeploymentUnit unit) throws DeploymentException { Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class); try { // start the deployment ejb3Deployment.start(); } catch (Exception e) { throw new DeploymentException("Error starting Ejb3Deployment: " + ejb3Deployment.getName(), e); } }
public EJBArchiveMetaData buildMetaData(Deployment dep, DeploymentUnit unit) { JBossMetaData jbossMetaData = unit.getAttachment(JBossMetaData.class); dep.addAttachment(JBossMetaData.class, jbossMetaData); EJBArchiveMetaData ejbMetaData = new EJBArchiveMetaData(); buildEnterpriseBeansMetaData(ejbMetaData, jbossMetaData); buildWebservicesMetaData(ejbMetaData, jbossMetaData); ejbMetaData.setSecurityDomain(jbossMetaData.getSecurityDomain()); return ejbMetaData; }
public void visit(DeploymentUnit unit) throws DeploymentException { if (unit.isTopLevel()) { Context javaComp = getJavaComp(unit); try { Reference reference = new Reference("javax.enterprise.inject.spi.BeanManager", "org.jboss.weld.integration.deployer.jndi.JBossBeanManagerObjectFactory", null); reference.add(new StringRefAddr("id", IdFactory.getIdFromClassLoader(unit.getClassLoader()))); javaComp.bind("BeanManager", reference); _logger.debug("CDI BeanManager successfully bound into JNDI (java:comp) for SwitchYard deployment '" + unit.getName() + "'."); } catch (NamingException e) { throw new DeploymentException("Error binding BeanManager.", e); } } }
/** * Creates web meta data for EJB deployments. * * @param dep webservice deployment */ void create(final Deployment dep) { final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class); final JBossWebMetaData jbossWebMD = new JBossWebMetaData(); this.createWebAppDescriptor(dep, jbossWebMD); this.createJBossWebAppDescriptor(dep, jbossWebMD); dep.addAttachment(JBossWebMetaData.class, jbossWebMD); unit.addAttachment(JBossWebMetaData.class, jbossWebMD); }
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
public void deploy(DeploymentUnit unit, JBossWebMetaData deployment) throws DeploymentException { AnnotationIndex ai = unit.getAttachment(AnnotationIndex.class); if (ai == null) return; HierarchyIndex hi = unit.getAttachment(HierarchyIndex.class); if (hi == null) return; ResourcesIndex ri = new DefaultResourcesIndex(ai, hi); unit.addAttachment(ResourcesIndex.class, ri); } }
private static String getPersistenceUnitSupplier(DeploymentUnit deploymentUnit, PersistenceUnitDependencyResolver persistenceUnitDependencyResolver, String persistenceUnitName) { if ((deploymentUnit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class) != null && deploymentUnit.getAttachment(JBossMetaData.class).isEJB3x()) || (deploymentUnit.getAttachment(JBossWebMetaData.class) != null)) { try { return persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName); } catch (IllegalArgumentException e) { // No-op, means we can't find the PU in this DU } } for (DeploymentUnit child : deploymentUnit.getChildren()) { String beanName = getPersistenceUnitSupplier(child, persistenceUnitDependencyResolver, persistenceUnitName); if (beanName != null) { return beanName; } } return null; }
private static <T> void getAllAttachments(DeploymentUnit unit, Class<T> type, ArrayList<T> attachments) { T attachment = unit.getAttachment(type); if(attachment != null) attachments.add(attachment); List<DeploymentUnit> children = unit.getChildren(); if(children != null) for(DeploymentUnit child : children) getAllAttachments(child, type, attachments); }
private static DeploymentUnit getDeploymentUnit(DeploymentUnit current, String path) { if(path.startsWith("/")) return getDeploymentUnit(current.getTopLevel(), path.substring(1)); if(path.startsWith("./")) return getDeploymentUnit(current, path.substring(2)); if(path.startsWith("../")) return getDeploymentUnit(current.getParent(), path.substring(3)); int i = path.indexOf('/'); String name; if(i == -1) name = path; else name = path.substring(0, i); for(DeploymentUnit child : current.getChildren()) { if(child.getSimpleName().equals(name)) return child; } throw new IllegalArgumentException("Can't find a deployment unit named " + name + " at " + current); }
/** * Obtains the {@link JBossEnterpriseBeansMetaData} associated with the deployment * unit, else null */ private JBossEnterpriseBeansMetaData getEjbModuleMetadata(final DeploymentUnit unit) { assert unit != null : "Deployment Unit must be specified"; // Obtain the Metadata final JBossMetaData md = unit.getAttachment(JBossMetaData.class); final JBossEnterpriseBeansMetaData ejbs; if (md != null) { ejbs = md.getEnterpriseBeans(); } else { return null; } return ejbs; }
@Override protected void attachBarrier(DeploymentUnit deploymentUnit, Barrier switchBoard) { deploymentUnit.addAttachment(Barrier.class, switchBoard); }