This chapter introduces Feature Archive (FAR) files and describes how you can package application feature content into these files for reuse in one or more MAF applications.
This chapter includes the following sections:
Section 8.4, "What Happens When You Add a FAR as a View Controller Project"
Section 8.5, "What You May Need to Know About Enabling the Reuse of Feature Archive Resources"
Application features, when packaged into a JAR file known as a Feature Archive file (FAR), provide reusable content that can be consumed by other MAF applications. A MAF application can consume one or more FAR files. A FAR file contains everything that an application feature requires, such as icon images, resource bundles, HTML files, JavaScript files, and other implementation-specific files.
A FAR also contains one maf-feature.xml
file, which identifies each of the packaged application features by a unique ID. You can edit this file to update application feature properties, such as content implementation (MAF AMX, Local HTML, Remote URL), display properties based on such factors as user roles and privileges, or device properties.
You can add a FAR as either an application library or as a view controller project. You cannot customize the FAR's contents when you add it as project library, nor can you reuse its individual artifacts. A MAF application consumes the FAR in its entirety when it is added as a library file. For example, a FAR's task flow cannot be the target of a task flow call activity. Adding a FAR as a view controller project, however, enables you to customize its artifacts, as described in Chapter 10, "Customizing MAF Application Artifacts with MDS."
You make an application feature available to a MAF application by adding it to the consuming application's class path.
Note:
You can only add the FAR to the application controller project; you cannot add a FAR to the view controller project.Deploy the application feature as a Feature Archive file, as described in Section 27.5.2, "How to Deploy the Feature Archive Deployment Profile."
How to add application feature content to a MAF application as a library:
Open the Resources window, choose New, then IDE Connections, and then choose File System.
Complete the File Systems Connection dialog to create a file connection to the directory that contains the Feature Archive JAR file. For more information, refer to the Oracle JDeveloper Online help.
Right-click the Feature Archive file (which is noted as a JAR file) in the Resources window.
Choose Add to Application As and then choose Library to add the consuming application's classpath, as shown in Figure 8-1.
Tip:
Choose Remove Library from Application to remove the feature archive JAR from the consuming application's classpath.How to add a FAR as a view controller project:
Open the Resources window, choose New, then IDE Connections, and then choose File System.
Complete the File Systems Connection dialog to create a file connection to the directory that contains the Feature Archive JAR file. For more information, refer to the Oracle JDeveloper Online help.
Right-click the Feature Archive file (which is noted as a JAR file) in the Resources window.
Choose Add to Application As and then choose ViewController Project, as shown in Figure 8-2.
After you add a FAR as a library (or manually to the application's classpath):
The contents of the FAR display in the Application Resources under the Libraries node, as shown in Figure 8-3.
Every application feature declared in the maf-feature.xml
files included in the JARs becomes available to the consuming application, as illustrated by Figure 8-4 where the dropdown lists IDs of the available application features in the JAR in addition to one that has already been defined in the application.
Tip:
Manually adding the Feature Archive JAR to the application classpath also results in the application features displaying in the Insert Feature Reference dialog.Alternatively, you can add or remove an application feature from the Resources window as follows:
Expand the feature archive JAR in the Resources window.
From the MAF Features folder, right-click an application feature.
Choose Add Feature Reference to maf-application.xml, as shown in Figure 8-5, or Remove Feature Reference from maf-application.xml, shown in Figure 8-6. Figure 8-5 illustrates adding an application feature called People from MAF_DevGuideExample.jar
.
Figure 8-6 illustrates removing an application feature reference from the maf-application.xml
file.
The information in the connections.xml
file located in the Feature Archive JAR is merged into the consuming application's connections.xml
file. The Log window, shown in Figure 8-7, displays naming conflicts.
Note:
You must verify that the connections are valid in the consuming application.When you add a FAR as a view controller project:
MAF generates a view controller project that bears the same name as the imported FAR. Figure 8-8 illustrates how MAF creates a view controller project (a .jpr
file) for an imported FAR file called StockTracker (which is illustrated as StockTrackerFAR.jar
in Figure 8-2). This view controller project contains the default structure and metadata files of a MAF view controller project, as described in Section C.3, "About the View Controller Project Resources." In particular, the FAR view controller project includes the maf-feature.xml
file. If the MAF application contains other view controller projects, you must ensure that none of these projects include application features with the same ID. See also Section 8.5, "What You May Need to Know About Enabling the Reuse of Feature Archive Resources."
As with a FAR imported as a library, the information in the connections.xml
file located in the Feature Archive JAR is merged into the consuming application's connections.xml
file. MAF will create a connections.xml
file if one does not already exist in the target application.
MAF makes any .class
and JAR files included in the FAR available as a library to the view controller project by copying them into its lib
directory (such as C:\jdeveloper\mywork\
application
\
FAR view controller project
\lib
). MAF compiles these files into a file called classesFromFar.jar
.
Unlike a FAR imported as a library, you can customize the files of a view controller project.
Note:
Because the original resource bundles included in FAR might not be usable in the generated view controller project, you must create new resources bundles within the project as described in Section 10.8, "Enabling Customizations in Resource Bundles."Like a FAR imported as a library, every application feature declared in the FAR's maf-feature.xml
file becomes available to the consuming application.
To ensure that the resources of a FAR can be used by an application, both the name of the FAR and its feature reference IDs must be globally unique; ensure there are no duplicate feature reference IDs in the maf-application.xml
file. Within the FAR itself, the DataControl.dcx
file must be in a unique package directory. Rather than accepting the default names for these package directories, you should instead create a unique package hierarchy for the project. You should likewise use a similar package naming system for the feature reference IDs.