Two Laptop Bag*
The moose likes Java in General and the fly likes Passing a parameter to a class outside your control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing a parameter to a class outside your control" Watch "Passing a parameter to a class outside your control" New topic
Author

Passing a parameter to a class outside your control

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Implementors are required to implement an interface, IView.

The container will do a newInstance on contributed implementations; then call createPartControl. In my implementation of IView, I need to use a String value inside createPartControl & this value must be passed in to me via some mechanism. Obviously I'm NOT able to provide another constructor that can accept a parameter.

My initial thought is to use a ThreadLocal. Ideas ?

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

It looks like you're writing an Eclipse plugin...

The information to provide is too vague to give you good advice. Where does this string that you need in createPartControl(...) come from? ThreadLocal is for thread-local storage, i.e. if you need one copy of some data for each thread that uses your implementation of IView. Why do you think that that is what you need? You don't specify anything about multi-threading in the rest of your question.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
 
subject: Passing a parameter to a class outside your control
 
Similar Threads
Ch-5 Q No.5 Coffee Cram Mock Exam
How many objects are being created?
Custom CellRenderer
Doubt in spec(reg Session bean's Business interface)
Need Help, can only show the composite when resize the view manually