Thanks for the advice. 
To clarify my problem - I have use a library (close source) in my frameworks.
From the developer of the library:
1. the library is not threadsave
2. I have to use the sequence
server starts -> init()
increment global counter
(thread started) -> init()
  increment global counter
  doWork
  release()
  decrement global counter
(thread ended)
(thread started) -> init()
  increment global counter
  doWork
  release()
  decrement global counter
(thread ended)
release() -> server stopped
3. only one thread is possible at a time


On 21.10.2011, at 14:39, Mike Schrag wrote:

> Yes, good call ... I missed the original line that this was from a framework.
> 
> ms
> 
> On Oct 21, 2011, at 8:36 AM, Alexis Tual wrote:
> 
>> If you do that, you need to make your framework depend on your app, which is 
>> wrong.
>> Instead I would create a ERXFrameworkPrincipal to provide the app a unique 
>> Pilot instance... 
>> Less Woish, your framework could also have a IPilotProvider interface 
>> implemented by Application classes and then you could do in your fwk :
>> ((IPilotProvider)WOApplication.application()).pilot();
>> 
>> Cheers,
>> 
>> Alex
>> 
>> Le 21 oct. 2011 à 14:04, Mike Schrag a écrit :
>> 
>>> There's almost never a reason to use a static variable in your Application 
>>> class, because Application is singleton. But beside that, both valueForKey 
>>> and the crazy reflection stuff are totally unnecessary in this case. For a 
>>> static, you don't need an "instance", so just refer to 
>>> your.app.Application.appPilot. For the valueForKey case, I would never use 
>>> valueForKey, because you're just giving up compiler checking for not much 
>>> ... Do ((your.app.Application)WOApplication.application()).whateverKey() 
>>> instead and let the compiler watch your back.
>>> 
>>> ms
>>> 
>>> On Oct 21, 2011, at 6:10 AM, Jürgen Tabert wrote:
>>> 
>>>> I think the problem is that the "variable" is static. (the developer told 
>>>> me to use static)
>>>> 
>>>> from Application.java
>>>> 
>>>> public class Application extends ERXApplication {
>>>> 
>>>>     public static Pilot appPilot = null;
>>>> 
>>>>     ...
>>>> 
>>>>     @Override
>>>>     public void finishInitialization() {
>>>>    ...
>>>>    // init Library
>>>>    appPilot = new Pilot();
>>>>    try {
>>>>        ...
>>>>        appPilot.init(lKey, lKey, libPath, languageId);
>>>>    } catch (PilotException e) {
>>>>        ...
>>>>    }
>>>> 
>>>> 
>>>> inside a class in the framework some ugly code
>>>> 
>>>> ...
>>>> try {
>>>>        ...
>>>>        // works
>>>>             ERXApplication app = ERXApplication.erxApplication();
>>>>        Class<? extends ERXApplication> appClass = app.getClass();
>>>>        Field appField = appClass.getField("appPilot");
>>>>        Pilot appPilot = (Pilot) appField.get(app);
>>>>             ...
>>>> 
>>>> something like app.valueForKey("appPilot") works only if the variable is 
>>>> not static
>>>> 
>>>> 
>>>> On 21.10.2011, at 04:02, Andrew Lindesay wrote:
>>>> 
>>>>> Hello Jürgen;
>>>>> 
>>>>> It depends on the situation.
>>>>> 
>>>>> Can you elaborate what you mean by "variables".
>>>>> 
>>>>> At the very least, you could use KVC;
>>>>> 
>>>>>   WOApplication.application().valueForKey(<key>)
>>>>> 
>>>>> cheers.
>>>>> 
>>>>> On 21/10/11 1:13 PM, Jürgen Tabert wrote:
>>>>>> Hi all,
>>>>>> 
>>>>>> I am looking for the easiest (best?) way to access a WOApplication 
>>>>>> variables from inside a framework.
>>>>>> 
>>>>>> Thanks for any help,
>>>>>> Jürgen
>>>>>>  _______________________________________________
>>>>>> Do not post admin requests to the list. They will be ignored.
>>>>>> Webobjects-dev mailing list      ([email protected])
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>> http://lists.apple.com/mailman/options/webobjects-dev/apl%40lindesay.co.nz
>>>>>> 
>>>>>> This email sent to [email protected]
>>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> Andrew Lindesay
>>>>> www.silvereye.co.nz
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list      ([email protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> http://lists.apple.com/mailman/options/webobjects-dev/jtabert%40htgreenline.de
>>>>> 
>>>>> This email sent to [email protected]
>>>> 
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list      ([email protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40pobox.com
>>>> 
>>>> This email sent to [email protected]
>>> 
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/webobjects-dev/alexis.tual%40gmail.com
>>> 
>>> This email sent to [email protected]
>> 
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to