Setting up BC base classes
One of the first things to consider when developing large-scale enterprise applications with ADF-BC is to allow for the ability to extend the framework's base classes early on in the development process. It is imperative that you do this before creating any of your business objects, even though you have no practical use of the extended framework classes at that moment. This will guarantee that all of your business objects are correctly derived from your framework classes. In this recipe, you will expand on the previous recipe and add business components framework extension classes to the SharedComponents
workspace.
Getting ready
You will be adding the business components framework extension classes to the SharedComponents
workspace. See the previous recipe for information on how to create one.
How to do it…
1. To create framework extension classes for the commonly used business components, start with the creation of an extension class for the entity objects. Open the
SharedComponents
workspace in JDeveloper and right-click on theSharedBC
business components project.2. From the context menu, select New… to bring up the New Gallery dialog. Select Class from the Java category (under the General category) and click OK.
3. On the Create Java Class dialog that is displayed, enter the name of the custom entity object class, the package where it will be created, and for Extends enter the base framework class, which in this case is
oracle.jbo.server.EntityImpl
.4. Now, repeat the same steps to create framework extension classes for the following components:
Business Component
Framework Class Extended
Entity Definition
oracle.jbo.server.EntityDefImpl
View Object
oracle.jbo.server.ViewObjectImpl
View Row
oracle.jbo.server.ViewRowImpl
Application Module
oracle.jbo.server.ApplicationModuleImpl
Database Transaction Factory
oracle.jbo.server.DatabaseTransactionFactory
Database Transaction
oracle.jbo.server.DBTransactionImpl2
5. Once you are done, your project should look similar to the following:
6. The next step is to configure JDeveloper so that all new business components that you create from this point forward will be inherited from the framework extension classes you've just defined. Open the Preferences dialog from the Tools menu, expand the ADF Business Components node, and select Base Classes.
7. Then enter the framework extension classes that you created previously, each one in its corresponding category.
How it works…
Defining and globally configuring business components framework extension classes via the ADF Business Components Base Classes settings on the Preferences dialog causes all subsequent business components for all projects to be inherited from these classes. This is true for both XML-only components and for components with custom Java implementation classes. For XML-only components observe that the ComponentClass
attribute in the object's XML definition file points to your framework extension class.
There's more…
You can configure your business components framework extension classes at two additional levels: the project level and the individual component level.
Configuration at the project level is done via the Project Properties Base Classes selection under the ADF Business Components node. These configuration changes will affect only the components created for the specific project.
Configuration at the component level is done via the component's Java Options dialog, in the component's definition Java page, by clicking on the Classes Extend… button and overriding the default settings. The changes will only affect the specific component.
Note
Do not attempt to directly change or remove the extends
Java keyword in your component's implementation class. This would only be half the change, because the component's XML definition will still point to the original class. Instead, use the Classes Extend… button on the component's Java Options dialog.
Finally, note that the default package structure for all business components can also be specified in the ADF Business Components | Packages page of the Preferences dialog.
See also
Creating and using generic extension interfaces, Chapter 5,Putting them all together:Application Modules.
Breaking up the application in multiple workspaces, in this chapter