Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
As with other Java components, you can create a JAR file containing one of more packages of reusable ADF components. Then, in other projects you can import one or more packages of components from this component library to reference those in a new application.
Note: The examples in this section refer to theReusableComponents , ProjectImportingReusableComponents , and OtherProjectWithComponents projects in the AdvancedExamples workspace. See the note at the beginning of this chapter for download instructions. |
Use the Create Business Components Archive Profile dialog to create a JAR file containing the Java classes and XML component definitions that comprise your business components library. This is available in the New Gallery in the General > Deployment Files category.
Note: If you don't see the Deployment Profiles category in the New Gallery, set the Filter By dropdown list at the top of the dialog to the All Technologies choice to make it visible. |
Give the deployment profile a name like ReusableComponents.bcdeploy
and click OK. As shown in Figure 25-8, the ReusableComponents.bcdeploy
business components deployment archive profile contains two nested JAR deployment profiles:
ReusableComponentsMiddleTier.deploy
ReusableComponentsCommon.deploy
These two nested profiles are standard JAR deployment profiles that are pre-configured to bundle:
All of the business components custom java classes and XML component definitions into a ReusableComponentsCSMT.jar
archive
All of the client interfaces, message bundle classes, and custom domains into a ReusableComponentsCSCommon.jar
They are partitioned this way in order to simplify deployment of ADF Business Components-based applications. The *CSMT.jar
is an archive of components designed to be deployed only on the middle tier application server. The *CSCommon.jar
is common both to the application server and to the remote client tier in the deployment scenario when the client interacting with the application module is running in a different physical server from the application module with which it is working.
To create the JAR files, select the ReusableComponents.bcdeploy
node in the Application Navigator under the Resources folder, and choose Deploy on the context menu. A Deployment tab appears in the JDeveloper Log window that should display feedback like:
---- Deployment started. ---- Apr 28, 2006 7:04:02 PM Running dependency analysis... Wrote JAR file to ...\ReuseableComponents\deploy\ReuseableComponentsCSMT.jar Running dependency analysis... Wrote JAR file to ...\ReuseableComponents\deploy\ReuseableComponentsCSCommon.jar Elapsed time for deployment: less than one second ---- Deployment finished. ---- Apr 28, 2006 7:04:02 PM
Once you have created a reusable library of business components, you can import one or more packages of components from that library in other projects to reference them. When you import a package of business components from a library, the components in that package are available in the various Available lists of the ADF Business Components component wizards and editor, however they do not display in the Application Navigator. The only components that appear in the Application Navigator are the ones in the source path for the current project.
To import a package of business components from a library, do the following:
Define a library for your JAR file on the Libraries tab of the Project Properties dialog of the importing project.
You can define the library as a project-level library or a user-level library. Be sure to include both the *CSMT.jar
and the *CSCommon.jar
in the class path of the library definition.
Include the new library in your importing project's library list.
With the importing project selected in the Application Navigator, choose File | Import from the JDeveloper main menu.
In the Import dialog that appears, select Business Components from the list.
Use the file open dialog to navigate into your library's *CSMT.jar
file — as if it were a directory — and select the XML component definition file from any components in the package whose components you want to import.
Acknowledge the alert that confirms the successful importing of the package.
Repeat steps 3-6 again for each package of components you want to import.
Assuming that there was an entity object like Product
in the package(s) of components you imported, you could then create a new view object in the importing project using the imported Product
component as its entity usage. This is just one example. You can reference any of the imported components as if they were in the source path of your project. The only difference is that you cannot edit the imported components. In fact, the reusable component library JAR file might only contain the XML component definition files and the Java *.class
files for the components without any source code.
When you import a package of components into a project named YourImportingProjectName
, JDeveloper adds a reference to that package in the YourImportingProjectName.jpx
file in the root directory of your importing project's source path. As part of this entry, it includes a design time project named _LocationURL
whose value points to the JAR file in which the imported components reside.
{para}?>
The Application Navigator displays all business components in the source path of your project. If you want to add additional business components from a directory that is not currently part of your project's source path, then open the Project Content page of the Project Properties dialog and add the parent directory for these other components as one of the directories in the Java Content list. In contrast to imported packages of components, these additional components added to your project's source path will be fully editable and will appear in the Application Navigator.
If you make changes to your imported components and update the JAR file that contains them, you need to close and reopen any importing projects in order to pickup the changes. This does not require exiting out of JDeveloper. You can select your importing project in the Application Navigator, choose File | Close from the main menu, and then re-expand the project's nodes to close and reopen the project. When you do this, JDeveloper will reread the components from the updated version of the imported JAR file.
If you mistakenly import a package of components, or wish to remove an imported package of components that you are not using, at this time, JDeveloper provides no interactive way to do this. To unimport a package, you need to follow these steps:
Remove the workspace in question from the Application Navigator.
Use a text editor to edit the YourImportingProjectName.jpx
file.
Remove the Containee element in that file the represents the imported package you want to remove.
This means removing every line in the file between (and including) the appropriate Containee tag for that package and its matching /Containee tag.
Reopen the workspace in JDeveloper.
Caution: Do not remove an imported package if your project still has components that reference it. If you do, JDeveloper will throw exceptions when the project is opened, or your application may have unpredictable behavior. Ensure that there are no references to any of the components in the imported package before manually removing the package entry from the*.jpx file. |