When developing ADF Business Components, we might need a handle to an Application Module (AM) instance. I have used the AM instance in the past to
a) invoke the methods on the Application Module for testing – think quick and dirty Java main for validating configuration is okay or for debugging through the method you implemented in the AM
b) invoke the methods on the Application Module from a Web Services project. We used a separate project to host the invoker classes that has the Webservice methods on them, the methods would create an instance of the AM and release them once done.
Now, to get an instance of the AM we need to invoke the “createRootApplicationModule” method on the “oracle.jbo.client.Configuration” class statically. There are a couple of overloaded methods in the class, I will illustrate using the simplest which takes in two parameters.
Before we start you should have done the following:
1) Created a new Fusion Web Application in JDeveloper
2) Created an Application Module in your Model project
Notice when you create the application module how the file-system looks … look for a “common” folder where your ApplicationModule class is … do you see a “bc4j.xcfg” there? Open this up in your favorite text-editor and study it a little … what configurations do you see defined under “AppModuleConfig” ? what are the some of the application names under “ApplicationName” ?
My project looks something like this
…and my BC4J file looks something like this
Next we will see how to create an instance of the Application Module and invoke a method there.
- Create a method in your AM
- Expose it to the AM Client by editing the AM propertiese
- Create a test client – a simple Java main which has the Configuration.createRootApplicationModule(String, String) method in it
- Invoke the method in the AM from the Java main client
I have illustrated these steps in detail below, click on the thumbnail to see the details:
1) Create a method in your AM
2) Expose it to the AM Client by editing the AM properties
Right click and open the properties dialog by clicking the “Open ApplicationModule”
Select the Java tab for configuring the methods exposed to the client …click on the “pencil” icon to edit
Once the dialog opens up, shuttle the method or methods you want to expose to the client. Note: If the methods use variables that are not serialize-able then you might not be able to shuttle them.
3) Create a test client – a simple Java main which has the Configuration.createRootApplicationModule(String, String) method in it
4) Invoke the method in the AM from the Java main client