If you have been reading on the ADF framework best practices, you will often read that it's recommended to extend some of the base classes of the framework; so that you can inject your code as required later on in the application development cycle without having to make a huge amount of changes.
in this article I will talk about how to do that.
first, let's start with the tough one: DBTransactionImpl2.
you can override the DBTransactionImpl2 with your custom class by doing the following:
1)create a new java class that extends the DBTransactionImpl2 class. let's name
it MyCustomTransactions.
2) create a new java class that extends the DatabaseTransactionFactory. let's name
it MyCustomTransactionFactory.
3) in the MyCustomTransactionFactory add the following code:
public DBTransactionImpl2 create(){
// return super.create();
return new MyCustomTransactions();
}
as you can see from the above code we return an instance of
our MyCustomTransactions class.
4)go to the application module, open the Configuration tab and
edit the desired configuration.
5)in the Edit Business Components Configuration popup that appeared,
go to the Properties tab.
6)change the value of the TransactionFactory property to the fully qualified name of
the MyCustomTransactions class, i.e.: <package name>.ClassName
with this the framework will now use our custom class instead of the default one. So, when you call the getTransaction() method from the application module, you will get an instance of the custom class.
now that we are done with overriding the DBTransactionImpl2 class, I will explain how to override the other classes.
this can be achieved simply by:
1) writing classes that extend the following:
oracle.jbo.server.EntityCache
oracle.jbo.server.EntityImpl
oracle.jbo.server.EntityDefImpl
oracle.jbo.server.ViewObjectImpl
oracle.jbo.server.ViewRowImpl
oracle.jbo.server.ViewDefImpl
oracle.jbo.server.ApplicationModuleImpl
oracle.jbo.server.ApplicationModuleDefImpl
2)open the project properties of the model project.
3)from the tree to left of the Project Properties popup
expand the Business Components node,
then expand the Base Classes sub-node .
4) now direct the JDeveloper to your base classes.
this is it.
Of course, you don't have to override all the base classes if you feel that it's not necessary.
I will write about some uses in future articles.
No comments:
Post a Comment