Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
If you deliver packaged applications that can require on-site customization for each potential client of your solution, ADF Business Components offers a useful feature to simplify that task.
Note: The examples in this section refer to theBaseProject and ExtendAndSubstitute projects in the AdvancedExamples workspace. See the note at the beginning of this chapter for download instructions. |
All too often, on-site application customization is performed by making direct changes to the source code of the delivered application. This approach demonstrates its weaknesses whenever you deliver patches or new feature releases of your original application to your clients. Any customizations they had been applied to the base application's source code need to be painstakingly re-applied to the patched or updated version of the base application. Not only does this render the application customization a costly, ongoing maintenance expense, it can introduce subtle bugs due to human errors that occur when reapplying previous customzations to new releases.
ADF Business Components offers a superior, component-based approach to support application customization that doesn't require changing — or even having access to — the base application's source code. To customize your delivered application, your customers can:
Import one or more packages of components from the base application into a new project.
Create new components to effect the application customization, extending appropriate parent components from the base application as necessary.
Define a list of global component substitutions, naming their customized components to substitute for your base application's appropriate parent components.
When the customer runs your delivered application with a global component substitution list defined, their customized application components are used by your delivered application without changing any of its code. When you deliver a patched or updated version of the original application, their component customizations apply to the updated version the next time they restart the application without needing to re-apply any customizations.
To define global component substitutions, use the Business Components > Substitutions page of the Project Properties dialog in the project where you've created extended components based on the imported components from the base application. As shown in Figure 25-10, to define each component substitution:
Select the base application's component in the Available list.
Select the customized, extended component to substitute in the Substitute list.
Click Add.
Note: You can only substitute a component in the base application with an extended component that inherits directly or indirectly from the base one. |
When you define a list of global component substitutions in a project named YourExtendsAndSubstitutesProject
, the substitution list is saved in the YourExtendsAndSubstitutesProject
.jpx
in the root directory of the source path.
The file will contain Substitute elements as shown in Example 25-17, one for each component to be substituted.
Example 25-17 Component Substitution List Saved in the Project's JPX File
<JboProject Name="ExtendAndSubstitute" SeparateXMLFiles="true" PackageName="" > <Containee Name="anotherpkg" FullName="devguide.advanced.anotherpkg.anotherpkg" ObjectType="JboPackage" > </Containee> <Containee Name="extsub" FullName="devguide.advanced.extsub.extsub" ObjectType="JboPackage" > <DesignTime> <Attr Name="_LocationURL" Value="../../BaseProject/deploy/BaseProjectCSMT.jar" /> </DesignTime> </Containee> <Substitutes> <Substitute OldName="devguide.advanced.extsub.Product" NewName="devguide.advanced.anotherpkg.CustomizedProduct" /> <Substitute OldName="devguide.advanced.extsub.Products" NewName="devguide.advanced.anotherpkg.CustomizedProducts" /> </Substitutes> </JboProject>
To have the original application use the set of substituted components, define the Java system property Factory-Substitution-List
and set its value to the name of the project whose *.jpx
file contains the substitution list. The value should be just the project name without any *.jpr
or *.jpx
extension.
Consider a simple example that customizes the Product
entity object and the Products
view object described in Section 25.9.3.1, "You Can Use Parent Classes and Interfaces to Work with Extended Components". To perform the customization, assume you create new project named ExtendsAndSubstitutes
that:
Defines a library for the JAR file containing the base components
Imports the package containing Product
and Products
Creates new extended components in a distinct package name called CustomizedProduct
and CustomizedProducts
Defines a component substitution list to use the extended components.
When creating the extended components, assume that you:
Added an extra view attribute named ExtraViewAttribute
to the CustomizedProducts view object.
Added a new validation rule to the CustomizedProduct
entity object to enforce that the product name cannot be the letter "Q
".
Overrode the getChecksum()
method in the CustomizedProduct.java
class to return "I am the CustomizedProduct Class".
If you define the Factory-Substitution-List
Java system property set to the value ExtendsAndSubstitutes
, then when you run the exact same test client class shown above in Example 25-16 the output of the sample will change to reflect the use of the substituted components:
Printing attribute for a row in VO 'Products' ProdId=100 Name=Washing Machine W001 Checksum=I am the CustomizedProduct Class ExtraViewAttribute=Extra Attr Value The name cannot be Q! Printing attribute for a row in VO 'ProductsById' ProdId=119 Name=Ice Maker I012 Checksum=I am the CustomizedProduct Class SomeExtraAttr=SomeExtraAttrValue ## Called someExtraFeature of ProductsByNameRowImpl The name cannot be Q!
Compared to the output from Example 25-16, notice that in the presence of the factory substitution list, the Products
view object in the original test program now has the additional ExtraViewAttribute
, now reports a Checksum
attribute value of "I am the CustomizedProduct Class", and now disallows the assignment of the product name to have the value "Q". These component behavior changes were performed without needing to modify the original Java or XML source code of the delivered components.