• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing a parameter to a class outside your control

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic