Java/J2EE interview questions: – Ensure singleton in a clustered environment?

In clustering there are multiple J2EE containers running on multiple JVM’S as a Result maintaining singleton is possible with following steps

1) RMI singleton object is created on only one container

2) Stubs of the same are registered in the cluster by adding the same in JNDI Name tree, thus making itself available to entire cluster

The disadvantage of the above approach as follows:

1) In case the singleton has not been created then the container created one Adds the same to JNDI. If 2 container creates singletons simultaneously then there will be a problem

2) The above problem can be solved by delegating the responsibility of creating the singleton to a single container but will cause problem in case the container in consideration fails

Also see the following video on Java and J2EE Design Pattern – Value List Handler: –

Click for moreJava/J2EE Design Pattern Interview questions.

Regards,

Visit for more author’s blog on Java /J2EE Design Pattern Interview questions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s