简体   繁体   中英

Replacing classes inside a jar, which is inside an Axis2 aar file

I have an Axis2 aar file, buried within that aar file I have a jar file containing my compiled classes, one of which I'd like to replace.

This is a simplified version of what I have

MyService.aar contains :

lib\\JarJarBinks.jar

JarJarBinks.jar contains :

com\\example\\skywalker\\TheForce.class

I want to replace TheForce.class , the only mechanism that springs to mind, without rebuilding everything is :

  1. List item
  2. Unjar the aar file
  3. Pull out JarJarBinks.jar
  4. Unjar JarJarBinks.jar
  5. Replace TheForce.class with my updated copy
  6. Jar up JarJarBinks , and place it back in the extracted aar layout
  7. Jar up the aar file

I could create a bash script to automate this, but I'm wondering if there is a more cleaner / quicker way.

I've found the update option of jar u but I don't believe it works for nested artefacts.

Thanks

For your Axis2 to work, you don't need an aar file.

services.xml file can be either of the below locations for the Axis2 to work.

  1. repository/services/SimpleService/meta-inf/services.xml
  2. WEB-INF/services/SimpleService/meta-inf/services.xml

This will help us have an extra step of generating the aar file.

ServiceDeployer.java

 * <p>
 * Standard Axis2 service Deployer which use services.xml file to build
 * services. ServiceDeployer can be used with Axis2 archive (.aar) or exploded
 * directory structure. Some of the example formats given below.
 * </p>
 * <p>Examples : <p>
 *        <ul>
 *          <li>repository/services/SimpleService.aar/meta-inf/services.xml</li>
 *          <li>repository/services/SimpleService/meta-inf/services.xml</li>
 *          <li>WEB-INF/services/SimpleService.aar/meta-inf/services.xml</li>
 *          <li>WEB-INF/services/SimpleService/meta-inf/services.xml</li>
 *       </ul>
 
     InputStream servicexmlStream = serviceClassLoader
            .getResourceAsStream("META-INF/services.xml");
    if (servicexmlStream == null) {
        servicexmlStream = serviceClassLoader.getResourceAsStream("meta-inf/services.xml");
    } else {
        metainf = "META-INF";
    }

https://axis.apache.org/axis2/java/core/apidocs/org/apache/axis2/deployment/ServiceDeployer.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM