public Object getAttachment(String name) { return unit.getAttachment(name); } public Object removeAttachment(String name)
public void deploy(VFSDeploymentUnit unit, T deployment) throws DeploymentException { Collection<VirtualFile> wbXml = unit.getAttachment(DeployersUtils.WELD_FILES, Collection.class); if (wbXml != null || optionalWeldXml) internalDeploy(unit, deployment, wbXml); }
/** * Returns true if this <code>unit</code> represents an .ear deployment * * @param unit * @return */ private boolean isEar(VFSDeploymentUnit unit) { return unit.getSimpleName().endsWith(".ear") || unit.getAttachment(JBossAppMetaData.class) != null; } }
@Override protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception { // First look for an existing Document attachment Document document = unit.getAttachment(Document.class); if( document == null ) { // Next parse the metadata file document = doParse(unit, file); } // Transform the document into a T instance return parse(unit, file, document); }
@SuppressWarnings("unchecked") public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar) { this.isEar = isEar; this.shortName = parent.getSimpleName(); baseName = null; if(isEar) { this.baseName = shortName; int idx = shortName.lastIndexOf('.'); if( idx > 0 ) baseName = shortName.substring(0, idx); } // Create the deployment map attachment if it does not exist deployments = (ConcurrentHashMap<String, Ejb3Deployment>)parent.getAttachment(ATTACHMENT_KEY); if (deployments == null) { deployments = new ConcurrentHashMap<String, Ejb3Deployment>(); parent.addAttachment(ATTACHMENT_KEY, deployments); } // MappedReferenceMetaDataResolverDeployer output, Look for the endpoint resolver endpointResolver = parent.getAttachment(DeploymentEndpointResolver.class); /* if(endpointResolver == null) throw new IllegalStateException("No DeploymentEndpointResolver found in deployment: "+parent); */ } /**
@Override protected AbstractRequirement hasIntegrationModuleRequirement(VFSDeploymentUnit unit, RequirementsMetaData requirements) { AbstractRequirement abstractRequirement = unit.getAttachment(REQUIREMENT_KEY, AbstractRequirement.class); if (abstractRequirement == null) { abstractRequirement = super.hasIntegrationModuleRequirement(unit, requirements); if (cacheRequirement) unit.addAttachment(REQUIREMENT_KEY, abstractRequirement, AbstractRequirement.class); } return abstractRequirement; } }
@Override public void undeploy(VFSDeploymentUnit unit, JBossMetaData metadata) { Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class); if(deployment == null) return; try { deployment.stop(); } catch(Exception e) { log.warn("Failed to stop deployment " + deployment, e); } try { deployment.destroy(); } catch(Exception e) { log.warn("Failed to destroy deployment " + deployment, e); } }
public static boolean isEJBDeployment(VFSDeploymentUnit du) { // TODO: this is temporary EJB3 logic Boolean ignoreMe = du.getAttachment(IGNORE_ME_NAME, Boolean.class); if(ignoreMe != null && ignoreMe) return false; boolean ejbxml = du.getMetaDataFile("ejb-jar.xml") != null; boolean jbossxml = du.getMetaDataFile("jboss.xml") != null; return ejbxml || jbossxml; }
@Override protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception { // First look for an existing Document attachment Document document = unit.getAttachment(Document.class); if( document == null ) { // Next parse the metadata file document = doParse(unit, file); } // Transform the document into a T instance return parse(unit, file, document); }
public void undeploy(VFSDeploymentUnit unit) { Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class); if (deployment == null) return; try { deployment.stop(); } catch (Exception e) { log.error("failed to stop deployment", e); } try { deployment.destroy(); } catch (Exception e) { log.error("failed to destroy deployment", e); } } }
Boolean flag = unit.getAttachment("EJB.callByValue", Boolean.class); DeploymentUnit temp = unit; while (flag == null && temp != null) String unauthenticatedPrincipal = unit.getAttachment("EJB.unauthenticatedIdentity", String.class); if (unauthenticatedPrincipal == null) unauthenticatedPrincipal = unit.getAttachment("EAR.unauthenticatedIdentity", String.class); metaData.getJBossMetaData().setUnauthenticatedPrincipal(unauthenticatedPrincipal); if (unit.getAttachment(ApplicationMetaData.class) == null) unit.addAttachment(ApplicationMetaData.class, metaData);
/** * Get the class path entries which have been determined by the EARStructure. * Will return null if this unit is not part of an ear deployment. */ private List<ClassPathEntry> getClassPathEntries(VFSDeploymentUnit unit) { // log.info("class path = " + unit.getTopLevel().getAttachment(StructureMetaData.class).getContext("").getClassPath()); StructureMetaData smd = unit.getTopLevel().getAttachment(StructureMetaData.class); if(smd == null) return null; // A context without a path is the one we want (see AbstractStructureDeployer) return smd.getContext("").getClassPath(); }
@Override public void undeploy(VFSDeploymentUnit unit, T metaData) { Boolean isIntegrationDeployment = unit.getAttachment(isIntegrationFlagKey, Boolean.class); if (isIntegrationDeployment != null && isIntegrationDeployment) { for (URL integrationURL : integrationURLs) { try { VirtualFile integration = VFS.getChild(integrationURL); unit.removeClassPath(integration); } catch (Throwable t) { log.warn("Error removing integration from classpath: " + integrationURL, t); } } // remove integration flag unit.removeAttachment(isIntegrationFlagKey); } }
/** * Get metadata file. * First try altDD, then fallback to original name. * * @param unit the vfs deployment unit * @param altExpectedClass the expected class of altDD * @param originalName the original file name * @param checkMetaDataFile should we fall back to metadata file * @return metadata file or null if it doesn't exist */ protected VirtualFile getMetadataFile(VFSDeploymentUnit unit, Class<?> altExpectedClass, String originalName, boolean checkMetaDataFile) { String altPrefix = (altExpectedClass != null ? altExpectedClass.getName() : originalName); VirtualFile file = unit.getAttachment(altPrefix + ".altDD", VirtualFile.class); if (file != null && altExpectedClass != null) { Map<String, Class<?>> altMappingsMap = getAltMappings(unit); if (altMappingsMap == null) { altMappingsMap = new HashMap<String, Class<?>>(); unit.addAttachment(ALT_MAPPINGS_MAP_KEY, altMappingsMap, Map.class); } altMappingsMap.put(file.getName(), altExpectedClass); } if(checkMetaDataFile && file == null) file = unit.getMetaDataFile(originalName, getMetaDataTypeFilter(unit)); return file; }
ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class); if(container != null) getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
@Override public void undeploy(VFSDeploymentUnit unit, T deployment) { ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class); if (clmd != null) { RequirementsMetaData requirements = clmd.getRequirements(); AbstractRequirement integrationModule = hasIntegrationModuleRequirement(unit, requirements); if (integrationModule != null) { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); for (String integrationModuleName : integrationModuleNames) { try { Requirement integrationRequirement = factory.createRequireModule(integrationModuleName, integrationModule.getVersionRange()); requirements.removeRequirement(integrationRequirement); } catch (Throwable t) { log.warn("Error during requirement removal: " + integrationModuleName, t); } } } } }
/** * Process jboss meta data. * * @param unit the deployment unit * @param finder the finder */ protected void processJBossMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder) { // Create the metadata model from the annotations EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBoss50Creator creator = new JBoss50Creator(ejbJarMetaData, unit.getClassLoader(), finder); Collection<Class<?>> classes = getClasses(unit, creator); JBossMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(EJB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, JBossMetaData.class); }
boolean isComplete = this.isMetaDataCompleteIsDefault(); SipMetaData sipMetaData = unit.getAttachment(SipMetaData.class); if (sipMetaData != null && sipMetaData instanceof Sip11MetaData) { isComplete |= ((Sip11MetaData) sipMetaData).isMetadataComplete();
/** * Visit module. * * Util method to add some behavior to Module * before we visit it. * * @param unit the deployment unit * @throws DeploymentException for any error */ protected void visitModule(VFSDeploymentUnit unit) throws DeploymentException { try { URL[] urls = ClasspathUtils.getUrls(unit); DeploymentUnitScanner scanner = new DeploymentUnitScanner(unit, urls); AnnotationsScanningPlugin plugin = createPlugin(unit); scanner.addPlugin(plugin); configureScanner(scanner); scanner.scan(); AnnotationRepository repository = unit.getAttachment(plugin.getAttachmentKey(), AnnotationRepository.class); unit.addAttachment(AnnotationRepository.class, repository); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Exception visiting module", e); } }
protected void internalDeploy(VFSDeploymentUnit unit, T deployment, Collection<VirtualFile> wbXml) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; if (isClassLoadingMetadataPresent(deployment)) return; if (isIsolated(unit, wbXml) == false) return; String domain = getJMXName(deployment, unit) + ",extension=LoaderRepository"; classLoadingMetaData = new ClassLoadingMetaData(); classLoadingMetaData.setName(unit.getName()); classLoadingMetaData.setDomain(domain); classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY); classLoadingMetaData.setImportAll(true); classLoadingMetaData.setVersion(Version.DEFAULT_VERSION); classLoadingMetaData.setJ2seClassLoadingCompliance(false); unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData); }