Package org.jboss.as.server.deployment.annotation

Examples of org.jboss.as.server.deployment.annotation.CompositeIndex


    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

        final Map<Class<? extends Annotation>, Set<Class<?>>> instances = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();

        final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
        if (compositeIndex == null) {
            return; // Can not continue without index
        }

        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        if (module == null) {
            return; // Can not continue without module
        }
        final ClassLoader classLoader = module.getClassLoader();

        for (FacesAnnotation annotation : FacesAnnotation.values()) {
            final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(annotation.indexName);
            if (annotationInstances == null || annotationInstances.isEmpty()) {
                continue;
            }
            final Set<Class<?>> discoveredClasses = new HashSet<Class<?>>();
            instances.put(annotation.annotationClass, discoveredClasses);
View Full Code Here


    private static final String CONFIG_FILES = "javax.faces.CONFIG_FILES";

    @Override
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        if (index == null) {
            return;
View Full Code Here

                }
            }
        }
        Class<?>[] typesArray = typesMap.keySet().toArray(new Class<?>[0]);

        final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
        if(index == null) {
            throw new DeploymentUnitProcessingException("Unable to resolve annotation index for deployment unit " + deploymentUnit);
        }

        // Find classes which extend, implement, or are annotated by HandlesTypes
View Full Code Here

        // Create the {@link BundleInstallService}
        if (deployment != null) {

            // Process annotations to modify the generated {@link Deployment}
            final DotName runWithName = DotName.createSimple("org.junit.runner.RunWith");
            final CompositeIndex compositeIndex = depUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
            final List<AnnotationInstance> runWithList = compositeIndex.getAnnotations(runWithName);
            if (runWithList.isEmpty() == false) {
                deployment.setAutoStart(false);
            }

            OSGiDeploymentAttachment.attachDeployment(depUnit, deployment);
View Full Code Here

        final EEModuleDescription moduleDesc = depUnit.getAttachment(EE_MODULE_DESCRIPTION);
        if (moduleDesc == null) {
            return;
        }

        final CompositeIndex compositeIndex = depUnit.getAttachment(COMPOSITE_ANNOTATION_INDEX);
        if (compositeIndex == null) {
            ROOT_LOGGER.cannotFindAnnotationIndex(depUnit);
            return;
        }

        // Check if we have a BundleContext injection point
        boolean hasBundleContextResource = false;
        final DotName resourceDotName = DotName.createSimple(Resource.class.getName());
        final DotName targetDotName = DotName.createSimple(BundleContext.class.getName());
        final List<AnnotationInstance> anList = compositeIndex.getAnnotations(resourceDotName);
        for (AnnotationInstance an : anList) {
            AnnotationTarget anTarget = an.target();
            if (anTarget instanceof FieldInfo) {
                FieldInfo fieldInfo = (FieldInfo) anTarget;
                Type targetType = fieldInfo.type();
View Full Code Here

    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME);

        for (AnnotationInstance annotation : resourceAnnotations) {
            final AnnotationTarget annotationTarget = annotation.target();
            final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation);
            if (annotationTarget instanceof FieldInfo) {
                processField(deploymentUnit, annotationWrapper, (FieldInfo) annotationTarget, moduleDescription);
            } else if (annotationTarget instanceof MethodInfo) {
                processMethod(deploymentUnit, annotationWrapper, (MethodInfo) annotationTarget, moduleDescription);
            } else if (annotationTarget instanceof ClassInfo) {
                processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
            }
        }
        final List<AnnotationInstance> ejbsAnnotations = index.getAnnotations(EJBS_ANNOTATION_NAME);
        for (AnnotationInstance annotation : ejbsAnnotations) {
            final AnnotationTarget annotationTarget = annotation.target();
            if (annotationTarget instanceof ClassInfo) {
                final AnnotationValue annotationValue = annotation.value();
                final AnnotationInstance[] ejbAnnotations = annotationValue.asNestedArray();
View Full Code Here

        final EEModuleDescription moduleDesc = depUnit.getAttachment(EE_MODULE_DESCRIPTION);
        if (moduleDesc == null) {
            return;
        }

        final CompositeIndex compositeIndex = depUnit.getAttachment(COMPOSITE_ANNOTATION_INDEX);
        if (compositeIndex == null) {
            ROOT_LOGGER.cannotFindAnnotationIndex(depUnit);
            return;
        }

        // Check if we have a BundleContext injection point
        boolean hasBundleContextResource = false;
        final DotName resourceDotName = DotName.createSimple(Resource.class.getName());
        final DotName targetDotName = DotName.createSimple(BundleContext.class.getName());
        final List<AnnotationInstance> anList = compositeIndex.getAnnotations(resourceDotName);
        for (AnnotationInstance an : anList) {
            AnnotationTarget anTarget = an.target();
            if (anTarget instanceof FieldInfo) {
                FieldInfo fieldInfo = (FieldInfo) anTarget;
                Type targetType = fieldInfo.type();
View Full Code Here

   */
  protected ComponentDescription detectExistingComponent(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
   
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
   
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);

    // extract deployment metadata
    List<AnnotationInstance> processApplicationAnnotations = null;
    List<AnnotationInstance> postDeployAnnnotations = null;
    List<AnnotationInstance> preUndeployAnnnotations = null;
    Set<ClassInfo> servletProcessApplications = null;
   
    if(compositeIndex != null) {
      processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ProcessApplication.class.getName()));
      postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PostDeploy.class.getName()));
      preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PreUndeploy.class.getName()));
      servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(ServletProcessApplication.class.getName()));
    } else {
      return null;
    }
           
    if(processApplicationAnnotations.isEmpty()) {
View Full Code Here

   */
  protected ComponentDescription detectExistingComponent(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
   
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
   
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);

    // extract deployment metadata
    List<AnnotationInstance> processApplicationAnnotations = null;
    List<AnnotationInstance> postDeployAnnnotations = null;
    List<AnnotationInstance> preUndeployAnnnotations = null;
    Set<ClassInfo> servletProcessApplications = null;
   
    if(compositeIndex != null) {
      processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ProcessApplication.class.getName()));
      postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PostDeploy.class.getName()));
      preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PreUndeploy.class.getName()));
      servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(ServletProcessApplication.class.getName()));
    } else {
      return null;
    }
           
    if(processApplicationAnnotations.isEmpty()) {
View Full Code Here

    }

    protected void scan(final DeploymentUnit du, final ClassLoader classLoader, final ResteasyDeploymentData resteasyDeploymentData, final ModuleIndexService moduleIndexService, boolean webDeployment)
            throws DeploymentUnitProcessingException, ModuleLoadException {

        final CompositeIndex index = du.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);

        if (!resteasyDeploymentData.shouldScan()) {
            return;
        }

        final Set<ClassInfo> applicationClass = index.getAllKnownSubclasses(APPLICATION);
        try {
            if (applicationClass.size() > 1) {
                StringBuilder builder = new StringBuilder();
                Set<ClassInfo> aClasses = new HashSet<ClassInfo>();
                for (ClassInfo c : applicationClass) {
                    if (!Modifier.isAbstract(c.flags())) {
                        aClasses.add(c);
                    }
                    builder.append(" ").append(c.name().toString());
                }
                if (aClasses.size() > 1) {
                    throw new DeploymentUnitProcessingException(MESSAGES.onlyOneApplicationClassAllowed(builder));
                } else if (aClasses.size() == 1) {
                    ClassInfo aClass = applicationClass.iterator().next();
                    resteasyDeploymentData.setScannedApplicationClass((Class<? extends Application>) classLoader
                            .loadClass(aClass.name().toString()));
                }
            } else if (applicationClass.size() == 1) {
                ClassInfo aClass = applicationClass.iterator().next();
                resteasyDeploymentData.setScannedApplicationClass((Class<? extends Application>) classLoader
                        .loadClass(aClass.name().toString()));
            }
        } catch (ClassNotFoundException e) {
            throw MESSAGES.cannotLoadApplicationClass(e);
        }

        List<AnnotationInstance> resources = null;
        List<AnnotationInstance> providers = null;
        if (resteasyDeploymentData.isScanResources()) {
            resources = index.getAnnotations(JaxrsAnnotations.PATH.getDotName());
        }
        if (resteasyDeploymentData.isScanProviders()) {
            providers = index.getAnnotations(JaxrsAnnotations.PROVIDER.getDotName());
        }

        if ((resources == null || resources.isEmpty()) && (providers == null || providers.isEmpty()))
            return;
        final Set<ClassInfo> pathInterfaces = new HashSet<ClassInfo>();
        if (resources != null) {
            for (AnnotationInstance e : resources) {
                final ClassInfo info;
                if (e.target() instanceof ClassInfo) {
                    info = (ClassInfo) e.target();
                } else if (e.target() instanceof MethodInfo) {
                    //ignore
                    continue;
                } else {
                    JAXRS_LOGGER.classOrMethodAnnotationNotFound("@Path", e.target());
                    continue;
                }
                if (!Modifier.isInterface(info.flags())) {
                    resteasyDeploymentData.getScannedResourceClasses().add(info.name().toString());
                } else {
                    pathInterfaces.add(info);
                }
            }
        }
        if (providers != null) {
            for (AnnotationInstance e : providers) {
                if (e.target() instanceof ClassInfo) {
                    ClassInfo info = (ClassInfo) e.target();
                    if (!Modifier.isInterface(info.flags())) {
                        resteasyDeploymentData.getScannedProviderClasses().add(info.name().toString());
                    }
                } else {
                    JAXRS_LOGGER.classAnnotationNotFound("@Provider", e.target());
                }
            }
        }

        // look for all implementations of interfaces annotated @Path
        for (final ClassInfo iface : pathInterfaces) {
            final Set<ClassInfo> implementors = index.getAllKnownImplementors(iface.name());
            for (final ClassInfo implementor : implementors) {
                resteasyDeploymentData.getScannedResourceClasses().add(implementor.name().toString());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.server.deployment.annotation.CompositeIndex

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.