Skip to main content

ADF Maven : A little bit of mojo Model project

I was testing the much improved maven stuff in Jdev for my ADF project and found a couple of differences in my produced jar and the ADF ojdeploy produced one.

First I needed to include the xml, jpx and properties stuff in my jar in the build\resources tag:


<resource>     <directory>src/</directory>      <includes>       <include>**/*.xml</include>        <include>**/*.jpx</include>       <include>**/*.xcfg</include>       <include>**/*.properties</include>     </includes> </resource>
Then I needed the adfm.xml and oracle.adf.common.services.ResourceService.sva files all the other files where just text files so I am ignoring them for now.

So for this I created a mojo plugin and included it in my build step

 

      <plugin>         <groupId>za.co.test.plugins</groupId>
        <artifactId>my-plugins</artifactId>
       <version>1.0-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>compile</phase>             <goals>               <goal>adfJarMetadataGenerator</goal>             </goals>           </execution>         </executions>       </plugin>



Onto the plugin:
Create a new maven project in Jdev and make surte the packaging is of type maven-plugin.

Then create a java class (your mojo) and extend org.apache.maven.plugin.AbstractMojo
The @goal sudo annotation denotes the name of your plugin that you will use in the calling project.

/**
 * This should generate the extra meta data for adf jar projects.
 * @goal adfJarMetadataGenerator
 * @phase compile
 */
public class ADFClassMetaDataGenerator extends AbstractMojo {

The @parameter annotation denotes and xml tag that you can pass data to your mojo from the calling project.http://maven.apache.org/guides/plugin/guide-java-plugin-development.html

/**
 * @parameter
 */
private String adfmFileName = "classes/adfm.xml";
/**
 * @parameter  expression="${project.build.sourceDirectory}"
 */
private File srcDirectory = new File("src/");
 /**
 * @parameter
 */
private String svaFileName = "classes/oracle.adf.common.services.ResourceService.sva";


You then need an   public void execute() throws MojoExecutionException { method.
This will go though your project and find the location of your Model.jpx file and your bc4j.xcfg this will allow you to generate the adfm.xml.

adfm.xml
      StringBuilder adfmBuilder =
        new StringBuilder("\n").append("\n").append("  
          bc4jFormatName).append("\"/>\n").append("
          "\"/>\n").append("
\n");


Then parse the Model.jpx to find all the application modules for the ResourceService.sva.

oracle.adf.common.services.ResourceService.sva
StringBuilder svaBuilder =  new StringBuilder("#:__PROLOG__:ADF_LibraryDependencies:!;ADF_DataControl:ADF_BusComps\n");
      //for each data control
for(DataControl dc : dcs) {
svaBuilder.append("#:ADF_DataControl:oracle.adf.library.rc.appmodules.AppModuleURLDescriptor:0,").append(dc.getAmName()).append(",").append(dc.getDataContolName()).append(",").append(dc.getFormattedJpxFileName()).append("\n");
      }
      svaBuilder.append("#:__EPILOG__:\n").append("oracle.adf.library.rc.dependencies.LibDepsServiceStrategy ADF_LibraryDependencies\n").append("oracle.adf.library.rc.dcxdatacontrols.DataControlServiceStrategy ADF_DataControl\n").append("oracle.adf.library.rc.buscomp.BusCompServiceStrategy ADF_BusComps\n");

Then just create these files and you are done.

Do a clean install and you can now use the generator in any of your projects.

Note: This is still a work in progress hopefully I get time to finish it off and I will publish the plugin. But it should give you a good idea of what to do.

Comments

  1. Great post!
    BTW, does your mojo have any dependency to Oracle ADF library?
    Have you made any progress after this post? If so, is there any chance you could make it available?
    Thanks a lot.

    ReplyDelete
    Replies
    1. Sorry I did not get any further - project timelines did not allow and I am on a different project now.

      Hopefully I will get back to this at some stage though then I will let you know.

      Delete
    2. Not a problem.
      Would you mind making make the current code available anyway? I would like to see how you've obtained the data control objects via API.
      Any help will be appreaciated.

      Regards.

      Delete
    3. Email me at the email address on my profile and I will see what I can do.

      Delete

Post a Comment

Popular posts from this blog

MANIFEST.MF merge JDeveloper for an executable jar

Goto your project > properties. Then click on deployment in the menu. Edit or add a jar deployment profile. Fill in the details under jar options (select Include manifest and give it a main class name) Also remember that the merge functionality only works with a BLANK line at the end of the merge file. REALLY this caught me. My merge file contents: Class-Path: commons-codec-1.3.jar [...empty line here CRLF...]

JBO-25013: TooManyObjectsException

oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[Key null ]. Ok so for you it may be trying to insert a duplicate record this should explain your problem (also check trigger they could be the cause.) NOTE: You can also try to create a new duplicate EO if you have a page with two VO's using the same EO. This could sort your problems. For me I needed to add a launch listener on my LOV and clear the cache of my vo. LOV <af:inputListOfValues id="NameId" popupTitle="#{bindings.Name.hints.label}" value="#{bindings.RolName1.inputValue}" label="#{bindings.RolName1.hints.label}" model="#{bindings.RolName1.listOfValuesModel}" required="#{bindings.RolName1.hints.mandatory}" columns="#{bindings.RolName1.hints.displayWidth}" shortDesc="#{bindings.RolName1.hints.tooltip}" launchPopupListener="#{backingBeanScope.backingBean.launchPop...

ADF Encountered deferred syntax #{ in template text.

OracleJSP error: oracle.jsp.parse.JspParseException:  Error: Encountered deferred syntax #{ in template text.  If intended as a literal, escape it or set directive  deferredSyntaxAllowedAsLiteral This normally happens when you have some tag lib dependancy problems but this was  not the case for me... My problem: For some reason my model project had web stuff in it(public html etc)  so I had to remove the public html stuff from my project and manually edit the Model.jpr project file and remove the tag lib entries at the bottom o the file. Go figure.