Package org.jboss.as.server.deployment

Examples of org.jboss.as.server.deployment.Attachable


    public static DeploymentUnit mockDeploymentUnit() {
        return mockDeploymentUnit("Mock Deployment Unit");
    }

    public static DeploymentUnit mockDeploymentUnit(String duName) {
        final Attachable attachable = new SimpleAttachable();
        final DeploymentUnit deploymentUnit = mock(DeploymentUnit.class);
        when(deploymentUnit.getName()).thenReturn(duName);

        when(deploymentUnit.getAttachment((AttachmentKey<Object>) any())).thenAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                AttachmentKey<?> key = (AttachmentKey<?>) invocation.getArguments()[0];
                return attachable.getAttachment(key);
            }
        });
        when(deploymentUnit.putAttachment((AttachmentKey<Object>) any(), any())).thenAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                AttachmentKey<Object> key = (AttachmentKey<Object>) invocation.getArguments()[0];
                Object value = invocation.getArguments()[1];
                return attachable.putAttachment(key, value);
            }
        });
        ServiceName deploymentUnitServiceName = Services.deploymentUnitName(duName);
        when(deploymentUnit.getServiceName()).thenReturn(deploymentUnitServiceName);
        return deploymentUnit;
View Full Code Here


            if(SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }
            // if this resource root represents an additional module then we need
            // to add the class path entry to the additional module
            final Attachable target;
            if (additionalModules.containsKey(resourceRoot.getRoot())) {
                target = additionalModules.get(resourceRoot.getRoot());
            } else {
                target = deploymentUnit;
            }
            final String[] items = getClassPathEntries(resourceRoot);
            for (String item : items) {
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                if (isInside(classPathFile, topLevelRoot)) {
                    if (earLibJars.contains(classPathFile)) {
                        log.debugf("Class-Path entry %s in %s ignored, as target is in or referenced by /lib", classPathFile,
                                resourceRoot.getRoot());
                        continue; // we already have access to ear/lib
                    } else if (additionalModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, additionalModules.get(classPathFile)
                                .getModuleIdentifier());
                    } else if (subDeploymentModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, subDeploymentModules.get(classPathFile));
                    } else {
                        log.warn("Class Path entry " + item + " in "
                                + resourceRoot.getRoot() + "  does not point to a valid jar for a Class-Path reference.");
                    }
                }  else if(item.startsWith("/")) {
                    ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    log.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    //ignore
                    log.debugf("Ignoring missing Class-Path entry %s", classPathFile);
                }
View Full Code Here

        //additional resource roots may be added as
        while (!resourceRoots.isEmpty()) {
            final RootEntry entry = resourceRoots.pop();
            final ResourceRoot resourceRoot = entry.resourceRoot;
            final Attachable target = entry.target;

            //if this is a top level deployment we do not want to process sub deployments
            if (SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }

            final String[] items = getClassPathEntries(resourceRoot);
            for (final String item : items) {
                if(item.isEmpty()) {
                    continue;
                }
                //first try and resolve relative to the manifest resource root
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                //then resolve relative to the deployment root
                final VirtualFile topLevelClassPathFile = deploymentRoot.getRoot().getParent().getChild(item);
                if (item.startsWith("/")) {
                    final ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    ServerLogger.DEPLOYMENT_LOGGER.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    if (classPathFile.exists()) {
                        handlingExistingClassPathEntry(deploymentUnit, resourceRoots, topLevelDeployment, topLevelRoot, subDeployments, additionalModules, existingAccessibleRoots, resourceRoot, target, classPathFile);
                    } else if (topLevelClassPathFile.exists()) {
View Full Code Here

            if (SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }
            // if this resource root represents an additional module then we need
            // to add the class path entry to the additional module
            final Attachable target;
            if (additionalModules.containsKey(resourceRoot.getRoot())) {
                target = additionalModules.get(resourceRoot.getRoot());
            } else {
                target = deploymentUnit;
            }
            final String[] items = getClassPathEntries(resourceRoot);
            for (String item : items) {
                //first try and resolve relative to the manifest resource root
                boolean found = false;
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                final VirtualFile topLevelClassPathFile = deploymentRoot.getRoot().getParent().getChild(item);
                if (isInside(classPathFile, topLevelRoot)) {
                    if (earLibJars.contains(classPathFile)) {
                        log.debugf("Class-Path entry %s in %s ignored, as target is in or referenced by /lib", classPathFile,
                                resourceRoot.getRoot());
                    } else if (additionalModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, additionalModules.get(classPathFile)
                                .getModuleIdentifier());
                    } else if (subDeploymentModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, subDeploymentModules.get(classPathFile));
                    } else if (additionalModules.containsKey(topLevelClassPathFile)) {
                        //if not found try resolving the class path entry from the deployment root
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, additionalModules.get(topLevelClassPathFile)
                                .getModuleIdentifier());
                    } else if (subDeploymentModules.containsKey(topLevelClassPathFile)) {
                        //if not found try resolving the class path entry from the deployment root
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, subDeploymentModules.get(topLevelClassPathFile));
                    } else if(classPathFile.exists() && classPathFile.isDirectory()) {

                    } else if(topLevelClassPathFile.exists() && topLevelClassPathFile.isDirectory()) {

                    } else {
                        log.warn("Class Path entry " + item + " in " + resourceRoot.getRoot() + "  does not point to a valid jar for a Class-Path reference.");
                    }
                } else if (item.startsWith("/")) {
                    ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    log.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    //ignore
                    log.debugf("Ignoring missing Class-Path entry %s", classPathFile);
                }
View Full Code Here

                    && !SubDeploymentMarker.isSubDeployment(resourceRoot)) {
                continue;
            }
            // if this resource root represents an additional module then we need
            // to add the class path entry to the additional module
            final Attachable target;
            if (additionalModules.containsKey(resourceRoot.getRoot())) {
                target = additionalModules.get(resourceRoot.getRoot());
            } else {
                target = deploymentUnit;
            }
            final String[] items = getClassPathEntries(resourceRoot);
            for (String item : items) {
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                if (isInside(classPathFile, topLevelRoot)) {
                    if (earLibJars.contains(classPathFile)) {
                        log.debugf("Class-Path entry %s in %s ignored, as target is in or referenced by /lib", classPathFile,
                                resourceRoot.getRoot());
                        continue; // we already have access to ear/lib
                    } else if(additionalModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, additionalModules.get(classPathFile)
                                .getModuleIdentifier());
                    } else {
                        log.warn("Class Path entry " + item + " in "
                                + resourceRoot.getRoot() + "  does not point to a valid jar for a Class-Path reference.");
                    }
                }  else if(item.startsWith("/")) {
                    ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    log.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    //this is a dep on another deployment
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES,ModuleIdentifier.create(ServiceModuleLoader.MODULE_PREFIX + classPathFile.getName()));
                }
            }
        }
    }
View Full Code Here

        //additional resource roots may be added as
        while (!resourceRoots.isEmpty()) {
            final RootEntry entry = resourceRoots.pop();
            final ResourceRoot resourceRoot = entry.resourceRoot;
            final Attachable target = entry.target;

            //if this is a top level deployment we do not want to process sub deployments
            if (SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }

            final String[] items = getClassPathEntries(resourceRoot);
            for (final String item : items) {
                if (item.isEmpty()) {
                    continue;
                }
                //first try and resolve relative to the manifest resource root
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                //then resolve relative to the deployment root
                final VirtualFile topLevelClassPathFile = deploymentRoot.getRoot().getParent().getChild(item);
                if (item.startsWith("/")) {
                    if (externalModuleService.isValid(item)) {
                        final ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                        ServerLogger.DEPLOYMENT_LOGGER.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                    } else {
                        ServerLogger.DEPLOYMENT_LOGGER.classPathEntryNotValid(item, resourceRoot.getRoot().getPathName());
                    }
                } else {
View Full Code Here

        //additional resource roots may be added as
        while (!resourceRoots.isEmpty()) {
            final RootEntry entry = resourceRoots.pop();
            final ResourceRoot resourceRoot = entry.resourceRoot;
            final Attachable target = entry.target;

            //if this is a top level deployment we do not want to process sub deployments
            if (SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }

            final String[] items = getClassPathEntries(resourceRoot);
            for (final String item : items) {
                if (item.isEmpty()) {
                    continue;
                }
                //first try and resolve relative to the manifest resource root
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                //then resolve relative to the deployment root
                final VirtualFile topLevelClassPathFile = deploymentRoot.getRoot().getParent().getChild(item);
                if (item.startsWith("/")) {
                    final ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    ServerLogger.DEPLOYMENT_LOGGER.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    if (classPathFile.exists()) {
                        //we need to check that this class path item actually lies within the deployment
                        boolean found = false;
View Full Code Here

            if(SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }
            // if this resource root represents an additional module then we need
            // to add the class path entry to the additional module
            final Attachable target;
            if (additionalModules.containsKey(resourceRoot.getRoot())) {
                target = additionalModules.get(resourceRoot.getRoot());
            } else {
                target = deploymentUnit;
            }
            final String[] items = getClassPathEntries(resourceRoot);
            for (String item : items) {
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                if (isInside(classPathFile, topLevelRoot)) {
                    if (earLibJars.contains(classPathFile)) {
                        log.debugf("Class-Path entry %s in %s ignored, as target is in or referenced by /lib", classPathFile,
                                resourceRoot.getRoot());
                        continue; // we already have access to ear/lib
                    } else if (additionalModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, additionalModules.get(classPathFile)
                                .getModuleIdentifier());
                    } else if (subDeploymentModules.containsKey(classPathFile)) {
                        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, subDeploymentModules.get(classPathFile));
                    } else {
                        log.warn("Class Path entry " + item + " in "
                                + resourceRoot.getRoot() + "  does not point to a valid jar for a Class-Path reference.");
                    }
                }  else if(item.startsWith("/")) {
                    ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    log.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    //this is a dep on another deployment
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES,ModuleIdentifier.create(ServiceModuleLoader.MODULE_PREFIX + classPathFile.getName()));
                }
            }
        }
    }
View Full Code Here

        //additional resource roots may be added as
        while (!resourceRoots.isEmpty()) {
            final RootEntry entry = resourceRoots.pop();
            final ResourceRoot resourceRoot = entry.resourceRoot;
            final Attachable target = entry.target;

            //if this is a top level deployment we do not want to process sub deployments
            if (SubDeploymentMarker.isSubDeployment(resourceRoot) && resourceRoot != deploymentRoot) {
                continue;
            }

            final String[] items = getClassPathEntries(resourceRoot);
            for (final String item : items) {
                if(item.isEmpty()) {
                    continue;
                }
                //first try and resolve relative to the manifest resource root
                final VirtualFile classPathFile = resourceRoot.getRoot().getParent().getChild(item);
                //then resolve relative to the deployment root
                final VirtualFile topLevelClassPathFile = deploymentRoot.getRoot().getParent().getChild(item);
                if (item.startsWith("/")) {
                    final ModuleIdentifier moduleIdentifier = externalModuleService.addExternalModule(item);
                    target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleIdentifier);
                    ServerLogger.DEPLOYMENT_LOGGER.debugf("Resource %s added as external jar %s", classPathFile, resourceRoot.getRoot());
                } else {
                    if (classPathFile.exists()) {
                        handlingExistingClassPathEntry(deploymentUnit, resourceRoots, topLevelDeployment, topLevelRoot, subDeployments, additionalModules, existingAccessibleRoots, resourceRoot, target, classPathFile);
                    } else if (topLevelClassPathFile.exists()) {
View Full Code Here

TOP

Related Classes of org.jboss.as.server.deployment.Attachable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.