Skip to content
This repository has been archived by the owner on Sep 13, 2020. It is now read-only.

Latest commit

 

History

History
83 lines (55 loc) · 2.03 KB

README.MD

File metadata and controls

83 lines (55 loc) · 2.03 KB

Adding Jarex to your project

You must add a repository and a dependency to your pom.xml

Repository

   <repositories>
        <repository>
            <id>Emerjoin</id>
            <name>maven-repo</name>
            <url>https://github.com/Emerjoin/maven-repo/raw/master</url>
        </repository>
    </repositories>

Dependency

    <dependency>
         <groupId>org.emerjoin</groupId>
         <artifactId>Jarex</artifactId>
         <version>1.0.0</version>
    </dependency>

Usage Examples

Looking for beans.xml in all jars

    
    Query beansXML = Queries.fileEntry("META-INF/beans.xml");
    
    ClassLoader classLoader = //get classloader here
    Jarex.createInstance(classLoader)
         .all(beansXML) //Find all
         .withResults().of(beansXML).forEach(item -> {
            
            InputStream stream = item.getInputStream();
            //do whatever you want here
            
         });
    

Looking for persistence.xml

    
    Query persistenceXML = Queries.fileEntry("META-INF/persistence.xml");
    
    ClassLoader classLoader = //get classloader here
    Optional<ResultsWrapper.Item> persistenceDescriptor = Jarex.createInstance(classLoader)
         .one(persistenceXML)
         .withResults().of(persistenceXML).findFirst();
    

Finding both beans.xml and persistence.xml using a single Jarex Instance

    Query persistenceXML = Queries.fileEntry("META-INF/persistence.xml");
    Query beansXML = Queries.fileEntry("META-INF/beans.xml");
    
    ClassLoader classLoader = //get classloader here
    Jarex jarex = Jarex.createInstance(classLoader)
        .one(persistenceXML)
        .all(beansXML);
   
    Optional<ResultsWrapper.Item> persistenceDescriptor = jarex.withResults()
        .of(persistenceXML).findFirst();
     
    jarex.withResults().of(beansXML).forEach(item -> {
                         
         InputStream stream = item.getInputStream();
         //do whatever you want here
                         
    });