Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about RemoteDataImp&singleton pattern!

 
sparkle zou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are sure:
For Data, all RemoteDataImps can share one to save system resource and
speed your program.
For LockManage, all RemoteDataImps must share one or they can not
lock each others.
I search this form,there are two points:
1.use singleton pattern to LockManager;pass Data Instance as arguments to the constructor of RemoteDataImp.
2.instantiate Data & Data in ConnectionFactoryImp
and pass them as arguments to the constructor of RemoteDataImp:like this
RemoteDataImp(dataWrapper, lockManager)

I want to implement like fllows:

public class RemoteDataImp extends UnicastRemoteObject
implements RemoteDataInterface,Unreferenced{
private final static Data dataWrapper = null;
private final static LockManager lockManager = null ;

public RemoteDataImp () throws RemoteException,IOException{
dataWrapper = new Data("db.db");
lockManager = new LockManager();
}

Why not???
PLS help me!!
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public class RemoteDataImp extends UnicastRemoteObject
implements RemoteDataInterface,Unreferenced{
private final static Data dataWrapper = null;
private final static LockManager lockManager = null ;
public RemoteDataImp () throws RemoteException,IOException{
dataWrapper = new Data("db.db");
lockManager = new LockManager();
}
Why not???

Since your dataWrapper and lockManager instances are static, you RemoteDataImp object can service only one database. So if your server intent is to serve the remote objects that can wrap different databases, your solution will not work.
Eugene.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic