当前位置: 首页>>代码示例>>Java>>正文


Java DeploymentUnit.getAttachmentList方法代码示例

本文整理汇总了Java中org.jboss.as.server.deployment.DeploymentUnit.getAttachmentList方法的典型用法代码示例。如果您正苦于以下问题:Java DeploymentUnit.getAttachmentList方法的具体用法?Java DeploymentUnit.getAttachmentList怎么用?Java DeploymentUnit.getAttachmentList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.as.server.deployment.DeploymentUnit的用法示例。


在下文中一共展示了DeploymentUnit.getAttachmentList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deploy

import org.jboss.as.server.deployment.DeploymentUnit; //导入方法依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
        final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot root : resourceRoots) {
            VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
            if (child.exists()) {
                moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
                break;
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:DriverDependenciesProcessor.java

示例2: deploy

import org.jboss.as.server.deployment.DeploymentUnit; //导入方法依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);

    VirtualFile descriptor = null;
    for (final String loc : DEPLOYMENT_STRUCTURE_DESCRIPTOR_LOCATIONS) {
        final VirtualFile file = root.getRoot().getChild(loc);
        if (file.exists()) {
            descriptor = file;
            break;
        }
    }
    if(descriptor == null) {
        return;
    }
    final XMLMapper mapper = XMLMapper.Factory.create();
    final Map<QName, AttachmentKey<?>> namespaceAttachments = new HashMap<QName, AttachmentKey<?>>();
    for(final JBossAllXMLParserDescription<?> parser : deploymentUnit.getAttachmentList(JBossAllXMLParserDescription.ATTACHMENT_KEY)) {
        namespaceAttachments.put(parser.getRootElement(), parser.getAttachmentKey());
        mapper.registerRootElement(parser.getRootElement(), new JBossAllXMLElementReader(parser));
    }
    mapper.registerRootElement(new QName(Namespace.JBOSS_1_0.getUriString(), JBOSS), Parser.INSTANCE);
    mapper.registerRootElement(new QName(Namespace.NONE.getUriString(), JBOSS), Parser.INSTANCE);

    final JBossAllXmlParseContext context = new JBossAllXmlParseContext(deploymentUnit);
    parse(descriptor, mapper, context);

    //we use this map to detect the presence of two different but functionally equivalent namespaces
    final Map<AttachmentKey<?>, QName> usedNamespaces = new HashMap<AttachmentKey<?>, QName>();
    for(Map.Entry<QName, Object> entry : context.getParseResults().entrySet()) {
        final AttachmentKey attachmentKey = namespaceAttachments.get(entry.getKey());
        if(usedNamespaces.containsKey(attachmentKey)) {
            throw ServerLogger.ROOT_LOGGER.equivalentNamespacesInJBossXml(entry.getKey(), usedNamespaces.get(attachmentKey));
        }
        usedNamespaces.put(attachmentKey, entry.getKey());
        deploymentUnit.putAttachment(attachmentKey, entry.getValue());
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:40,代码来源:JBossAllXMLParsingProcessor.java

示例3: deploy

import org.jboss.as.server.deployment.DeploymentUnit; //导入方法依赖的package包/类
/**
 * Process the deployment root for module dependency information.
 *
 * @param phaseContext the deployment unit context
 * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
 */
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ServiceModuleLoader deploymentModuleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
    final List<ResourceRoot> allResourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    DeploymentUnit top = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();

    Set<ModuleIdentifier> additionalModules = new HashSet<>();
    for(AdditionalModuleSpecification i : top.getAttachmentList(Attachments.ADDITIONAL_MODULES)) {
        additionalModules.add(i.getModuleIdentifier());
    }
    for (final ResourceRoot resourceRoot : allResourceRoots) {
        final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST);
        if (manifest == null)
            continue;

        final String dependencyString = ManifestHelper.getMainAttributeValue(manifest, DEPENDENCIES_ATTR);
        if (dependencyString == null)
            continue;

        if(deploymentUnit.getParent() == null &&
                SubDeploymentMarker.isSubDeployment(resourceRoot)) {
            //we do not want ears reading sub deployments manifests
            continue;
        }

        final String[] dependencyDefs = dependencyString.split(",");
        for (final String dependencyDef : dependencyDefs) {
            final String trimmed = dependencyDef.trim();
            if(trimmed.isEmpty()) {
                continue;
            }
            final String[] dependencyParts = trimmed.split(" ");

            final ModuleIdentifier dependencyId = ModuleIdentifier.fromString(dependencyParts[0]);
            final boolean export = containsParam(dependencyParts, EXPORT_PARAM);
            final boolean optional = containsParam(dependencyParts, OPTIONAL_PARAM);
            final boolean services = containsParam(dependencyParts, SERVICES_PARAM);
            final boolean annotations = containsParam(dependencyParts, ANNOTATIONS_PARAM);
            final boolean metaInf = containsParam(dependencyParts, META_INF);
            final ModuleLoader dependencyLoader;
            if (dependencyId.getName().startsWith("deployment.")) {
                dependencyLoader = deploymentModuleLoader;
            } else {
                dependencyLoader = Module.getBootModuleLoader();
            }
            if(annotations) {
                deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, dependencyId);
                if(dependencyLoader == deploymentModuleLoader && !additionalModules.contains(dependencyId)) {
                    //additional modules will not be created till much later, a dep on them would fail
                    phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleServiceName(dependencyId));
                }
            }

            final ModuleDependency dependency = new ModuleDependency(dependencyLoader, dependencyId, optional, export, services, true);
            if(metaInf) {
                dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true);
                dependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
            }
            deploymentUnit.addToAttachmentList(Attachments.MANIFEST_DEPENDENCIES, dependency);
        }
    }

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:70,代码来源:ManifestDependencyProcessor.java

示例4: deployModuleSpec

import org.jboss.as.server.deployment.DeploymentUnit; //导入方法依赖的package包/类
private void deployModuleSpec(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final DeploymentUnit parentDeployment = deploymentUnit.getParent();

        final ResourceRoot mainRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (mainRoot == null)
            return;

        // Add internal resource roots
        final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final List<ResourceRoot> resourceRoots = new ArrayList<ResourceRoot>();
        if (ModuleRootMarker.isModuleRoot(mainRoot)) {
            resourceRoots.add(mainRoot);
        }
        final List<ResourceRoot> additionalRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (final ResourceRoot additionalRoot : additionalRoots) {
            if (ModuleRootMarker.isModuleRoot(additionalRoot) && !SubDeploymentMarker.isSubDeployment(additionalRoot)) {
                resourceRoots.add(additionalRoot);
            }
        }

        final List<ResourceRoot> parentResourceRoots = new ArrayList<>();
        if (parentDeployment != null) {
            final List<ResourceRoot> additionalParentRoots = parentDeployment.getAttachmentList(Attachments.RESOURCE_ROOTS);
            for (final ResourceRoot additionalParentRoot : additionalParentRoots) {
                if (ModuleRootMarker.isModuleRoot(additionalParentRoot) && !SubDeploymentMarker.isSubDeployment(additionalParentRoot)) {
                    parentResourceRoots.add(additionalParentRoot);
                }
            }
        }

        final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
        if (moduleIdentifier == null) {
            throw ServerLogger.ROOT_LOGGER.noModuleIdentifier(deploymentUnit.getName());
        }

        // create the module service and set it to attach to the deployment in the next phase
        final ServiceName moduleServiceName = createModuleService(phaseContext, deploymentUnit, resourceRoots, parentResourceRoots, moduleSpec, moduleIdentifier);
        phaseContext.addDeploymentDependency(moduleServiceName, Attachments.MODULE);

        for (final DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) {
            ModuleIdentifier moduleId = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER);
            if (moduleId != null) {
                phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, ServiceModuleLoader.moduleSpecServiceName(moduleId));
            }
        }

        if (parentDeployment == null) {
            //only top level deployment adds additional modules
            final List<AdditionalModuleSpecification> additionalModules = deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_MODULES);
            for (final AdditionalModuleSpecification module : additionalModules) {
                addAllDependenciesAndPermissions(moduleSpec, module);
                List<ResourceRoot> roots = module.getResourceRoots();
                ServiceName serviceName = createModuleService(phaseContext, deploymentUnit, roots, parentResourceRoots, module, module.getModuleIdentifier());
                phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, serviceName);
            }
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:60,代码来源:ModuleSpecProcessor.java

示例5: undeploy

import org.jboss.as.server.deployment.DeploymentUnit; //导入方法依赖的package包/类
@Override
public void undeploy(final DeploymentUnit context) {
    for(JBossAllXMLParserDescription<?> parser : context.getAttachmentList(JBossAllXMLParserDescription.ATTACHMENT_KEY)) {
        context.removeAttachment(parser.getAttachmentKey());
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:7,代码来源:JBossAllXMLParsingProcessor.java


注:本文中的org.jboss.as.server.deployment.DeploymentUnit.getAttachmentList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。