Saturday, February 22, 2014

Get Original HashCode

In a class, where hashcode() has been overridden, we can still get the actual system generated hashcode of the object using  :
System.identityHashcode(object)
How this info can be useful? when the hashcode() differs from SystemIdentityHashCode() it probably means that the equivalence of the objects is not determined by the memory and has its own implementation.

Monday, February 17, 2014

ADF High Availability

In a cluster of application instances, if a node becomes unavailable any subsequent requests to that instance would be routed to another instance. This new instance is the replication partner of the previous instance which maintains the user's session state.

Following is the excerpt from Oracle documentation which explains the failover in detail
A user makes a request and is routed by a hardware load balancer to instance A of the application.
Instance A of the application becomes unavailable because of node failure, process failure, or network failure.
The hardware load balancer marks instance A as unavailable.
The user makes a subsequent request. The request is routed to instance B.
Instance B is configured as a replication partner of Instance A and has the user's session state.
The application resumes using the session state on Instance B and the user continues working without interruption.
This replication happens by serializing the Users session state from one instance to another. Also all the PageFlowScope Beans are implemented as a collection object inside Session Scope. Now during the session replication, these PageFlow Scopes would be serialized. If these Page Flowscope beans have any bindings to the UI Components, there would be an issue in serializing(UI Components are not serializable). Hence for HighAvailability all the UI Components must be binded to Backing Bean/View Scope Beans which are not part of session.


ADF optimizes the serialization and it wont serialize the beans until they are dirty. As the session bean maintains these beans in a collection and if one of the attribute is modified in the bean, session scope cannot identify that bean as dirty (as the reference to the bean is still intact and it is unaware of the change in the value of the managed bean attributes). Thus whenever we use a Page Flow scope bean, we need to explicitly set the bean as dirty (for high availability) whenever its attributes are modified. It can be achieved by:
ControllerContext.getInstance().markScopeDirty(viewScope/pageFlowScope);

PlaceHolder Attribute for ADF InputText

Now there exists a placeholder attribute on ADF input text which would prompt displayed in the inputfield before user enters a value. As this is a HTML5 attribute, should work in all the modern browsers