Serialization Vs Externalization

Serialization is the process of converting an object into a sequence of bits so that it can be persisted on a storage medium (such as a file, or a memory buffer) or transmitted across a network connection link. This process of serializing an object is also called deflating or marshalling an object.
The serialization mechanism has been added into the Java language for two reasons:
(1) the JavaBeans mechanism uses serialization.
(2) remote method invocation (RMI) allows you to automatically use objects located at another host in the network just like any local objects.
In order to serialize an object, you need the output stream OutputStream, which must be put into the special serialization stream called ObjectOutputStream. After that, you only need to call the method writeObject() to serialize the object and send it to the output stream. . Classes ObjectInputStream and ObjectOutputStream, which respectively implement the ObjectInput and ObjectOutput interfaces, enable entire objects to be read from or written to a stream (possibly a file). To use serialization with files, we initialize ObjectInputStream and ObjectOutputStream objects with stream objects that read from and write to files—objects of classes FileInputStream and FileOutputStream, respectively
Vinayworld class implements serializable interface.

 
Import java.io.serializable;
Class vinayworld implements Serializable {
Public String vinay_variable;
Private String vinay_add;
}

Other class would be

 
Public class vinayotherClass  {
Public static void main (String args[])
{
FileOutputStream fos=new FileOutputStream("vinay.txt");
    ObjectOutputStream oos=new ObjectOutputStream(fos);
Vinayworld vw = new vinayworld();
oos.writeobject(vw);
oos.flush();
oos.close();

In this code object of the vinayworld class is serialized into a file name vinay.txt
Serialization is a Marker interface -Marker Interface is used by java runtime engine (JVM) to identify the class for special processing.
Use serialization when you need to add data to the serialization stream that is not an object data member.

Externalization is same as Sterilization except that WriteObject() and ReadObject() method are called by JVM during sterilization an desterilization of object. One thing you can do with Externalization is that you can store extra information into object like STATIC variables and transient variables or you can add more information if you have any business need. One good example is compressing and uncompressing of data to send it through network or converting one format to other like a BMP image to JPEG or GIF format.
Externalization allows you to customize how serialization is done. By implementing externalization you are controlling what gets serialized ( and what doesnot ) as versus default serialization where all non-transient attributes get serialized.
For “fat data” classes with a large number of attributes only a few of which needs to persisted, externalization will help you reduce the size of serialized stream and the time taken to serialize the object. But there will be an overhead involved because the runtime has to call your methods to read/write objects.

Performance issue
1. Further more if you are subclassing your externalizable class you will want to invoke your superclass’s implementation. So this causes overhead while you subclass your externalizable class.
2. methods in externalizable interface are public. So any malicious program can invoke which results into lossing the prior serialized state.

Difference between serialization and externalization: When you serialize an Externalizable object, a default constructor will be called automatically; only after that will the readExternal() method be called.Use the Externalizable interface when you need complete control over your bean’s serialization (for example, when writing and reading a specific file format).

http://www.coderanch.com/t/201401/Performance/java/Serialization-Vs-Externalisation
http://en.wikipedia.org/wiki/Serialization
http://www.builderau.com.au/program/java/soa/Understand-when-to-serialize-v-externalize-objects-in-Java/0,339024620,339274531,00.htm
http://www.roseindia.net/java/java-exception/serializable-exception.shtml

Dealing with Multiple Outlook profiles

Recently I was on client site of one of my companies prestigious client for the gathering of some new business requirement and understanding of their existing work model. I faced a typical yet very common problem which i think most of you have faced on your clientele’ visit.

Dealing with multiple outlook profiles specially when you are for a long term client site visit and had to juggle between your company mail account and a new mail id provided by your client to interact with their technical/Business team.

So, here is one common solution which i think most of you might be aware but this blog entry is for those who are still uaware of it. 🙂

The answer is “Extra Outlook”

Steps to configure:

1. Download Extra Outlook from http://www.hammerofgod.com/download/ExtraOutlook.zip,
2. Create a new profile in outlook. Control Panel -> Mail -> Add,
3. Create a bat file with the entry,
extraoutlook.exe “C:\Program Files\Microsoft Office\Office12\outlook.exe” /profile “New Profile”
4. Save the file with extension “.bat”,
5. Open the first instance normally by the outlook icon provided in the start menu,
6. Open second instance by running the bat file from command prompt or by double click.

Note:

1. Keep the bat file in same folder where the extraoutlook.exe is kept,
2. Provide the outlook.exe path as per your machine installation.

What is Ext-Js(Extended JavaScript)

Ext-JS is a open source JavaScript library for building interactive web applications[2] using techniques such as AJAX, DHTML and DOM scripting.It is easy to use,rich user interface and more it can be a desktop application. It includes:
• High performance, customizable UI widgets
• Well designed and extensible Component model
• An intuitive, easy to use API
• Commercial and Open Source licenses available

Ext-js have a vast range of GUI-based form controls for use within web applications, these contains:
• text field and textarea input
• date fields with a pop-up date-picker
• numeric fields
• list box and comboboxes
• radio and checkbox controls
• html editor control
• grid control
• tree control
• tab panels
• toolbars
• desktop-application-style menus
• region panels to allow a form to be divided into multiple sub-sections
• sliders
Many of these controls are able to communicate with a web server using AJAX.

Files you can need in using Ext
Ext-all.css — A stylesheet file that control the look and feel of Ext widgets.This file must be Included without modification.
Ext-base.js — This provide core functionality of Ext.It is basic machinery of EXT.for using other Library like jquery we need to change this file.
ext-all-debug.js/ext-all.js — All of the widgets live in this files.This is primary ext library file.

It is not a other Java Script library. It can work with other java script libararies by using adapters.For that You need to include adapter file that is exist in adpater folder of Ext sdk.

Default Ext adapter :

 
<script src =”lib/extjs/adapter/ext/ext-base.js”></script>

For jquery include these files in top of your document:

 
<script src =”lib/jquery.js”></script>
<script src =”lib/jquery-plugins.js”></script>
<script src =”lib/extjs/adapter/jquery/ext-jquery-adapter.js”></script>

After including adapters and base libraries we need to include ext-all.js or ext-all-debug.js file.Localization is possible in Ext-js.Only you need to include language file in lib folder.

Common elements in Ext-

Ext.onReady – This function makes sures that our document is ready to be work.It make our code to Wait until the DOM is available.This is needed because javaScript starts executing as soon as it enocuntered in the documents,at which point our DOM might not exist.

Ext.MSg.show – This function for creating the dialog.It will handle all care needed to have dialog. It will create appilication style messages boxes for us.

Ext.get – This function accesses and manipulates elements in the DOM.

Adapter: Files that allows you to use to other java script libraries with Ext-Js.

References : www.extjs.com
kick it on DotNetKicks.com

Shout it

pimp it