Idea behind doing extending classes
One of the benefits of working with a framework is the ability to extend the framework classes to get a built in feature to work differently or enhanced / enrich its behaviour and utilise it all across the application.
- To augument a built in feature
- change how a built in feature works
- workaround a bug in the built in feature
Extending the class is pretty straightforward. Just create a new class and use extends keyword to make it extend the old class.
Including extended classes:
you can created extended classes in a separate project. If you have done that then you would have to include the project which contains the extended classes as a dependency of you project. Go to dependencies property in your project properties and add the extended claasses project in there.
if you have packaged the extended classes in a JAR file then create a named library definition to reference the JAR file and also list the library in library list of the project where you need these extended classes.
Getting ADF components to use the extended classes: For each ADF component there is a java page on the wizard. Here you can choose the base class that you want to extend and create an extended classes that can be used by the component.
Multiple levels of extension classes. In practice there can be and probably will be multiple levels of extension classes which are created for a an application. Some generic functionality is added or altered at the application level and hence an ApplicationCustomAppModuleImpl is created. Furthere there may be a need to add or alter some features at the project level. So ProjectCustomAppModuleImpl will extend ApplicationCustomAppModuleImpl. And at the application module level MyAMAppModuleImpl will extend ProjectCustomAppModuleImpl.
By default defining fwk extension classes for all new components: If you want to use a specific set of base classes upon which the custom classes for your project components should be based then you can define it in project properties > business components > base classes
You can also specify the extension classes for all new projects by going to Tools > Preferences > business components > base classes
Its always a good idea to create customised extension classes for your project or application at the very beginning. As you start writing you very first lines of code you might not have a need for any generic code. Nor you may fathom a requirement in the future. But quite frequently as the application begins to take shape you will come across bits and pieces that you would think can be shared across you various code components. By then it would involve a lot of effort to extend all you existing classes on a new class. So its a good idea to create a set of custom extension classes right at the beginning and add code to them as and when required.
A common set of customized framework base classes in a package name of your own choosing like com.yourcompany.adfextensions, each importing the oracle.jbo.server.* package, would consist of the following classes:
- public class CustomEntityImpl extends EntityImpl
- public class CustomEntityDefImpl extends EntityDefImpl
- public class CustomViewObjectImpl extends ViewObjectImpl
- public class CustomViewRowImpl extends ViewRowImpl
- public class CustomApplicationModuleImpl extends ApplicationModuleImpl
- public class CustomDBTransactionImpl extends DBTransactionImpl2
- public class CustomDatabaseTransactionFactory extends DatabaseTransactionFactory
For completeness, you may also want to create customized framework classes for the following classes as well, note however that overriding anything in these classes would be a fairly rare requirement.
- public class CustomViewDefImpl extends ViewDefImpl
- public class CustomEntityCache extends EntityCache
- public class CustomApplicationModuleDefImpl extends ApplicationModuleDefImpl
It is best to package these framework extension class in a JAR file so that they can be used across projects and applications.
Named libraries are a convenient way to use these JAR files in your code.
Reference:
http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#insertedID0
Sunday, April 25, 2010
Wednesday, April 21, 2010
Username Token security call on web service
Code snippet:
SAD_ADMISSIONS sAD_ADMISSIONS;
SADCREATEAPPLRESP respCreateAppl = new SADCREATEAPPLRESP();
System.out.println("Before Try..in Create Appl");
try {
// Security Policy is set to User Name Token
SecurityPolicyFeature[] securityFeatures =
new SecurityPolicyFeature[] { new SecurityPolicyFeature("oracle/wss_username_token_client_policy") };
sAD_ADMISSIONS = new SAD_ADMISSIONS();
// port object is created passing in the security policy
SAD_ADMISSIONS_PortType sAD_ADMISSIONS_PortType = sAD_ADMISSIONS.getSAD_ADMISSIONS_Port(securityFeatures);
// request context object created
Map requestContext = ((BindingProvider) sAD_ADMISSIONS_PortType).getRequestContext();
SAD_ADMISSIONS_PortClient.setPortCredentialProviderList(requestContext);
System.out.println("Username/password:" + username + "/" +password);
requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
// service operation called
respCreateAppl = sAD_ADMISSIONS_PortType.sadCREATEAPPL(reqCreateAppl);
} catch (Exception ex) {
ex.printStackTrace();
}
SAD_ADMISSIONS sAD_ADMISSIONS;
SADCREATEAPPLRESP respCreateAppl = new SADCREATEAPPLRESP();
System.out.println("Before Try..in Create Appl");
try {
// Security Policy is set to User Name Token
SecurityPolicyFeature[] securityFeatures =
new SecurityPolicyFeature[] { new SecurityPolicyFeature("oracle/wss_username_token_client_policy") };
sAD_ADMISSIONS = new SAD_ADMISSIONS();
// port object is created passing in the security policy
SAD_ADMISSIONS_PortType sAD_ADMISSIONS_PortType = sAD_ADMISSIONS.getSAD_ADMISSIONS_Port(securityFeatures);
// request context object created
Map
SAD_ADMISSIONS_PortClient.setPortCredentialProviderList(requestContext);
System.out.println("Username/password:" + username + "/" +password);
requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
// service operation called
respCreateAppl = sAD_ADMISSIONS_PortType.sadCREATEAPPL(reqCreateAppl);
} catch (Exception ex) {
ex.printStackTrace();
}
Saturday, April 3, 2010
Working with a Non Database AM
Create you view object as one "Rows Populated programmaticaly, not based upon a query"
NoDatabaseApplicationPoolImpl : Custom Application Module Pool Implementation Class. Overrides isSupportsPassivation() method to return False, indicating to runtime that this AM does not support Passivation.
NonDatabaseConnectionStrategy : Custom Connection Strategy Class
CustomSessionImpl : Custom Session Class, returns a custom session transaction handler factory
CustomTxnHandlerFactoryImpl : A custom transaction handler factory, used to return an instance of the CustomTxnHandlerImpl class
CustomTxnHandlerImpl : custom Transaction Handler implementation class
The Session Class Configuration property is set to the name of the Custom Session Implementation Class (CustomSessionImpl)
The PoolClassName configuration property is set to the custom application module pool implementation class (NoDatabaseApplicationPoolImpl)
The jbo.ampool.connectionstrategyclass configuration property is set to the name of the custom connection strategy class which overrides the createApplicationModule() method to set some key properties in the environment hashmap before calling super.
Remove the reference to the Database connection in the Model.jpx file.
Sample App : Application 8
Subscribe to:
Posts (Atom)