Package org.jboss.jandex

Examples of org.jboss.jandex.Indexer


    * {@inheritDoc}
    */
   @Override
   public AnnotationRepository scan(URL[] urls, ClassLoader cl)
   {
      Indexer indexer = new Indexer();

      if (urls != null && urls.length > 0)
      {
         for (URL url : urls)
         {
            String externalForm = url.toExternalForm();

            if (externalForm.endsWith(".class"))
            {
               InputStream is = null;
               try
               {
                  is = new FileInputStream(new File(url.toURI()));
                  indexer.index(is);
               }
               catch (Throwable t)
               {
                  log.error("Unable to process: " + externalForm, t);
               }
               finally
               {
                  if (is != null)
                  {
                     try
                     {
                        is.close();
                     }
                     catch (IOException ioe)
                     {
                        // Nothing
                     }
                  }
               }
            }
            else if (externalForm.endsWith(".jar"))
            {
               JarFile jarFile = null;
               try
               {
                  jarFile = new JarFile(new File(url.toURI()));
                  Enumeration<JarEntry> entries = jarFile.entries();
                  while (entries.hasMoreElements())
                  {
                     JarEntry jarEntry = entries.nextElement();
                     if (jarEntry.getName().endsWith(".class"))
                     {
                        InputStream is = null;
                        try
                        {
                           is = jarFile.getInputStream(jarEntry);
                           indexer.index(is);
                        }
                        catch (Throwable t)
                        {
                           log.error("Unable to process: " + jarEntry.getName(), t);
                        }
                        finally
                        {
                           if (is != null)
                           {
                              try
                              {
                                 is.close();
                              }
                              catch (IOException ioe)
                              {
                                 // Nothing
                              }
                           }
                        }
                     }
                  }
               }
               catch (Throwable t)
               {
                  log.error("Unable to process: " + externalForm, t);
               }
               finally
               {
                  if (jarFile != null)
                  {
                     try
                     {
                        jarFile.close();
                     }
                     catch (IOException ioe)
                     {
                        // Nothing
                     }
                  }
               }
            }
         }
      }

      return new AnnotationRepositoryImpl(indexer.complete(), cl);
   }
View Full Code Here


        }

        private Module loadCeylonModuleCar(File file, ZipFile zipFile, ZipEntry moduleDescriptor, String name, String version) throws IOException {
            InputStream inputStream = zipFile.getInputStream(moduleDescriptor);
            try{
                Indexer indexer = new Indexer();
                ClassInfo classInfo = indexer.index(inputStream);
                if(classInfo == null)
                    throw new IOException("Failed to read class info");
               
                Map<DotName, List<AnnotationInstance>> annotations = classInfo.annotations();
                DotName moduleAnnotationName = DotName.createSimple(com.redhat.ceylon.compiler.java.metadata.Module.class.getName());
View Full Code Here

TOP

Related Classes of org.jboss.jandex.Indexer

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.