Previous Next JavaScript must be enabled to correctly display this content

## 3.8 Service Extensibility

This topic provides the systematic instructions to perform the basic operations on the selected records.

Structure of Service Extensions can be seen in below table.

Table 3-1 Service Extensibility - Field Description

Component Name | Component Description
--- | ---
<< micro - service - name >>- extn.jar | Extension jar
<< micro - service - name >> .war | WAR File which refers to << micro - service - name >> -extn .jar during runtime.

For systematic instructions to retrieve a service extensibility record, follow the steps:

1. Add all the required classes from << micro - service - name >>.war to the classpath of `<< micro - service - name >> - extn.jar` project and then build it.
   For creation of war we can use the command obx create-jar
   1. Go to extension home.
   2. Run the command obx create-jar.
   3. It will prompt you with the location of the extended war file. (After giving the location give enter two times).
   4. On providing the war file, it will create a jar for the same in the same location.
2. The build.gradle of the extension project should include the statement.

   compileOnly files("classes").

3. For shared libraries we follow the optional packages approach. The following entries are expected in the MANIFEST.MF of respective war file.

   Extension-List:`<< micro - service - name >> - extn, << micro - service - name >> - extn-Extension-Name : << micro - service - name >> - extn`

   For this, we need to modify the build.gradle of war files to include the below statements.

       war {
         ...
         manifest {
           attributes(
              "Extension-List": "<< micro - service - name >> -extn",
              "<< micro - service - name >>- extn -Extension -Name": "<< micro- service- name >>-extn"
             )
              }
               ...
             }

4. In the extension jar create a new service class that extends the original service class and annotate the class with @Primary annotation to give the service class in the extension jar higher precedence.
   CustomerServiceImplExt

       @Primary
       @Service
       public class CustomerServiceImplExt extends CustomerServiceImpl
           implements CustomerService {.....}

   If the extension jar is provided the methods in the extension jar will be invoked or else the methods in the original war will be invoked.

5. Weblogic deployment

   Deploy the extension jar first in the weblogic then in the same server deploy the war.

   Tomcat deployment

   Modification in server.xml

       <Context ...>
         <Resources>
           <PreResources className = "org.apache.catalina.webresources.DirResourceSet" base="<<directory
       containing the extension jars "webAppMount="/WEB-INF/lib"/>
         </Resources>
       </Context>

6. The class names inside the << micro - service - name >>- extn.jar, should have the naming convention as below,

   `<<basePackageNameOf<< micro - service - name >>.war>>.<<service /controller /model>>`

Parent topic: Service Extensions