Thursday, July 4, 2019

ADF : Serializable

ADF : Serializable


All the managed beans should be serializable because the container may occassionally serialize and passivate the beans or send it over the network. This occurs in situations 
such as heavy load (our case) or when clustering is enabled.

Another tip:

- The managed beans with pageFlow or session scope are required to be serialized while backingBean or request scope are not required to be serialized.

- The ADF/JSF Rich UI components are not serializable and hence they should not be present in pageFlow scope managed beans.

Response: Your pageFlowScope bean should implements Serializable.


Eg:


Possibility 1:



Possibility 2:







Possibility 3:








Possibility 4:


Report


By setting this in java option we will get to know the issues in diagnostic or em logs.

-Dorg.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION=all

check : http://hasamali.blogspot.in/2011/09/adf-jsf-adfc-scope-object-serialization.html



About - serialVersionUID


The serialVersionUID is used as a version control in a Serializable class. If you do not explicitly declare a serialVersionUID, JVM will do it for you automatically, based on various aspects of your Serializable class

Check - https://www.mkyong.com/java-best-practices/understand-the-serialversionuid/





How Server does Serialization and Deserialization

A simple way to write / serialize the UserBean object into a file – “c:\\UserBean.ser”.


FileOutputStream fout = new FileOutputStream("c:\\UserBean.ser");
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(UserBean Obj);




A simple way to read / deserialize the UserBean object from file – “c:\\UserBean.ser”.



   FileInputStream fin = new FileInputStream("c:\\UserBean.ser");
   ObjectInputStream ois = new ObjectInputStream(fin);
   UserBean = (UserBean) ois.readObject();

No comments:

Post a Comment