Search in sources :

Example 21 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class WSHandlerChainAnnotationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
        return;
    }
    List<ResourceRoot> resourceRoots = ASHelper.getResourceRoots(unit);
    if (resourceRoots == null) {
        return;
    }
    final WSEndpointHandlersMapping mapping = new WSEndpointHandlersMapping();
    Index index = null;
    for (final ResourceRoot resourceRoot : resourceRoots) {
        index = resourceRoot.getAttachment(ANNOTATION_INDEX);
        if (index != null) {
            // process @HandlerChain annotations
            processHandlerChainAnnotations(resourceRoot, resourceRoots, index, mapping);
        }
    }
    if (!mapping.isEmpty()) {
        unit.putAttachment(WS_ENDPOINT_HANDLERS_MAPPING_KEY, mapping);
    }
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 22 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class AnnotationsTestCase method testProcessConnector.

/**
     * Process: Connector -- verification of the processConnector method
     *
     * @throws Throwable throwable exception
     */
@Test
public void testProcessConnector() throws Throwable {
    try {
        URI uri = getURI("/ra16inoutanno.rar");
        final VirtualFile virtualFile = VFS.getChild(uri);
        final Indexer indexer = new Indexer();
        final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
        for (VirtualFile classFile : classChildren) {
            InputStream inputStream = null;
            try {
                inputStream = classFile.openStream();
                indexer.index(inputStream);
            } finally {
                VFSUtils.safeClose(inputStream);
            }
        }
        final Index index = indexer.complete();
        AnnotationRepository ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
        annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
    } catch (Throwable t) {
        t.printStackTrace();
        fail(t.getMessage());
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) Indexer(org.jboss.jandex.Indexer) InputStream(java.io.InputStream) SuffixMatchFilter(org.jboss.vfs.util.SuffixMatchFilter) AnnotationRepository(org.jboss.jca.common.spi.annotations.repository.AnnotationRepository) Index(org.jboss.jandex.Index) URI(java.net.URI) Test(org.junit.Test)

Example 23 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class AnnotationsTestCase method testProcessAuthenticationMechanism.

/**
     * Process: AuthenticationMechanism -- verification of the
     * processAuthenticationMechanism method
     *
     * @throws Throwable throwable exception
     */
@Test
public void testProcessAuthenticationMechanism() throws Throwable {
    try {
        URI uri = getURI("/ra16annoauthmech.rar");
        final VirtualFile virtualFile = VFS.getChild(uri);
        final Indexer indexer = new Indexer();
        final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
        for (VirtualFile classFile : classChildren) {
            InputStream inputStream = null;
            try {
                inputStream = classFile.openStream();
                indexer.index(inputStream);
            } finally {
                VFSUtils.safeClose(inputStream);
            }
        }
        final Index index = indexer.complete();
        AnnotationRepository ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
        annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
    } catch (Throwable t) {
        fail(t.getMessage());
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) Indexer(org.jboss.jandex.Indexer) InputStream(java.io.InputStream) SuffixMatchFilter(org.jboss.vfs.util.SuffixMatchFilter) AnnotationRepository(org.jboss.jca.common.spi.annotations.repository.AnnotationRepository) Index(org.jboss.jandex.Index) URI(java.net.URI) Test(org.junit.Test)

Example 24 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class AnnotationsTestCase method testProcessAdministeredObject.

/**
     * Process: AdministeredObject -- verification of the
     * processAdministeredObject method
     *
     * @throws Throwable throwable exception
     */
@Test
public void testProcessAdministeredObject() throws Throwable {
    try {
        URI uri = getURI("/ra16annoadminobj.rar");
        final VirtualFile virtualFile = VFS.getChild(uri);
        final Indexer indexer = new Indexer();
        final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
        for (VirtualFile classFile : classChildren) {
            InputStream inputStream = null;
            try {
                inputStream = classFile.openStream();
                indexer.index(inputStream);
            } finally {
                VFSUtils.safeClose(inputStream);
            }
        }
        final Index index = indexer.complete();
        AnnotationRepository ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
        annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
    } catch (Throwable t) {
        fail(t.getMessage());
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) Indexer(org.jboss.jandex.Indexer) InputStream(java.io.InputStream) SuffixMatchFilter(org.jboss.vfs.util.SuffixMatchFilter) AnnotationRepository(org.jboss.jca.common.spi.annotations.repository.AnnotationRepository) Index(org.jboss.jandex.Index) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Index (org.jboss.jandex.Index)24 Indexer (org.jboss.jandex.Indexer)11 InputStream (java.io.InputStream)10 VirtualFile (org.jboss.vfs.VirtualFile)10 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)9 AnnotationRepository (org.jboss.jca.common.spi.annotations.repository.AnnotationRepository)9 URI (java.net.URI)8 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)8 Test (org.junit.Test)8 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)7 URL (java.net.URL)5 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)4 File (java.io.File)3 ClassInfo (org.jboss.jandex.ClassInfo)3 PersistenceUnitMetadata (org.jipijapa.plugin.spi.PersistenceUnitMetadata)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 Map (java.util.Map)2 ConnectorXmlDescriptor (org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor)2