/** * Add a child context * * @param child the child */ public void addChild(ContextInfo child) { if (child == null) throw new IllegalArgumentException("Null child"); getMetaData().addContext(child); }
/** * Remove a child context * * @param child the child */ public void removeChild(ContextInfo child) { if (child == null) throw new IllegalArgumentException("Null child"); getMetaData().removeContext(child); } }
/** * Is the current context already part of metadata path. * * @param context the current structure context * @return true if already part of parent's context metadata path */ protected boolean isMetadataPath(StructureContext context) { StructureContext parentContext = context.getParentContext(); if (parentContext == null) return false; StructureMetaData smd = parentContext.getMetaData(); ContextInfo info = smd.getContext(""); List<MetaDataEntry> metadataPaths = info.getMetaDataPath(); if (metadataPaths != null && metadataPaths.isEmpty() == false) { String relativePath = AbstractStructureDeployer.getRelativePath(context.getParent(), context.getFile()); for (MetaDataEntry entry : metadataPaths) if (relativePath.equalsIgnoreCase(entry.getPath())) return true; } return false; } }
public void visit(VirtualFile file) { String path = AbstractStructureDeployer.getRelativePath(context, file); StructureMetaData metaData = context.getMetaData(); ContextInfo contextInfo = metaData.getContext(path); if (contextInfo == null) { // Ignore directories when asked if (ignoreDirectories && file.isDirectory()) return; // Apply any filter if (filter != null && filter.accepts(file) == false) return; try { // Ask the deployers to process this file context.determineChildStructure(file); } catch (Exception e) { log.debugf("Ignoring %1s reason=%2s", file, e); } } } }
UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); unmarshaller.unmarshal(url.toString(), ofactory, structureContext.getMetaData()); mountChildren(structureContext); isJBossStructure = true;
for (ContextInfo ctx : structureContext.getMetaData().getContexts())
public boolean determineStructure(VirtualFile file, StructureContext parentContext) throws DeploymentException { StructureMetaData structure = StructureMetaDataFactory.createStructureMetaData(); StructureContext context = new StructureContext(file, structure, parentContext); boolean result = doDetermineStructure(context); if (result) { String relativePath = AbstractStructureDeployer.getRelativePath(context.getParent(), file); // Something said it recognised it ContextInfo recognised = structure.getContext(""); if (recognised == null) throw new IllegalStateException("Something recognised the deployment, but there is no context? " + file); // Create the context in the parent structure ContextInfo parentContextInfo; List<MetaDataEntry> metaDataPath = recognised.getMetaDataPath(); if (metaDataPath == null || metaDataPath.isEmpty()) parentContextInfo = StructureMetaDataFactory.createContextInfo(relativePath, recognised.getClassPath()); else parentContextInfo = StructureMetaDataFactory.createContextInfo(recognised.getClassPath(), metaDataPath, relativePath); // copy the modification type information parentContextInfo.setModificationType(recognised.getModificationType()); StructureMetaData structureMetaData = parentContext.getMetaData(); structureMetaData.addContext(parentContextInfo); MutableAttachments attachments = (MutableAttachments) parentContextInfo.getPredeterminedManagedObjects(); attachments.addAttachment(StructureMetaData.class, structure); } return result; }
/** * Iterate through the contexts and mount anything that looks like an archive * * @param structureContext the context * @throws IOException if errors occur during mounting */ protected void mountChildren(StructureContext structureContext) throws IOException { final StructureMetaData structureMetaData = structureContext.getMetaData(); final VirtualFile structureRoot = structureContext.getFile(); for(ContextInfo contextInfo : structureMetaData.getContexts()) { final String contextPath = contextInfo.getPath(); if(hasValidSuffix(contextPath)) { final VirtualFile child = structureRoot.getChild(contextPath); if(child.exists() && child.isFile()) { if ((contextInfo.getModificationType() == ModificationType.EXPLODE) || isWAR(child)) performExpandedMount(child); else performMount(child); } } } }