Rakesh s Verma

Greenhorn
+ Follow
since Dec 29, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rakesh s Verma

Thanks a lot for your time and reply.

Jaikiran Pai wrote:By the way, that article mentions only a few ways of breaking a singleton and ways to prevent that. But there are other ways too, which can easily break the singleton semantics. I am sure a search for "singleton" in this forum will provide you enough information.



I am on it

15 years ago

Jaikiran Pai wrote:

Creating a singleton doesn't require any use of clone(). You haven't yet told us why you are after the clone method?


It could be interesting then!!
Ok Read this heading on the link Preventing thread problems with your singleton. where it is written about cloning.
15 years ago
As suggested by you guys , I am changing the name as it does not work as it should be.
But I had my own reason as I wanted to make a singleton class.
But as far as I know my code still does not create a singleton that I am trying to.

So can anybody tell me how I can create the singleton of TwoTon class in TwoTonMain class.
when I make line e1, a comment it works fine but not otherwise.


15 years ago
And the problem is persistent even by implementing Cloneable interface if i do not override the clone() method in Singleton1 which I should as written on Cloneable interface.
But by simple OO it must work. And if it is not working there must be a logic behind it.
but when I checked the code in Object class, I found this.

protected native Object clone()
throws CloneNotSupportedException;
but the logic is not defined there and the cone() methos is declared native also. So where might I find the exact reason for this happening.
15 years ago

seetharaman venkatasamy wrote:Singleton1 is not implemented Clonable interface



Is that mandatory?
We can always access other methods of Object class without that kind of obligation!!!
So why in the case of clone() method ?
And the problem is persistent even by implementing Cloneable interface
15 years ago
HI Ranchers,
I am facing a difficulty while trying to create a clone(just to test) of singleton(Singleton1) class. I am getting an error of "clone() has protected access in java.lang.Object".
And I don't understand this error.
I know by default Object is a super class of every one that we create(directly or indirectly).
And hence when I test instanceof , it result in a true(as expected).
So my Singleton is also a subclass of Object class. Now I try to use clone() method of Object class which has protected access(that means either through inheritance or always with the object of inheriting class).
And it will be accessible, as my class is a subclass of Object class and protected members can be accessed in subclass regardless of the directory structure.

So why does it not work

15 years ago
Hi guys,
I want to know what is so special about EJB technologies?
What on the basic thing can we achieve with the help of EJB?
Is there any other similar technologies in the market yet?
Is the roal of EJB is to exchange data in an OO manner?
if so XML is so widely used..then why to use EJB!..just because it is written in java!!!
What is the most beautiful concept in EJB...if any!!

Please help big guys..
I need to clear it in my mind before I begin with it....