File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 14114
    
  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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing a parameter to a class outside your control