|
|
|
|
|
Re: How to handle dynamic dependencies at run-time? [message #467566 is a reply to message #467457] |
Mon, 07 May 2007 14:35 |
Eclipse User |
|
|
|
Originally posted by: lamont_gilbert.rigidsoftware.com
On Thu, 03 May 2007 23:07:04 -0700, Gerald Rosenberg wrote:
> I have a plugin that has a JDT dependency needed only to support an
> isolated Java editor specific function. Would like to use the plugin in
> a Ruby development RCP that does not have the JDT installed (the Java
> function is not needed in this case).
>
> Is there any resonable way to detect the absence of the JDT and
> exclude/disable the dependence at run-time? Any way short of having two
> different static versions of the plugin?
>
> What is the best approach to handling this circumstance?
>
> Thanks,
> Gerald
If you do not want two different static plugins, then you will have to
abstract out the difference. This is normally done by using a standard
interface that can be dynamically populated by the dependency if your
tests show the dependency is available.
|
|
|
|
Re: How to handle dynamic dependencies at run-time? [message #467615 is a reply to message #467548] |
Wed, 09 May 2007 05:56 |
Gerald Rosenberg Messages: 106 Registered: July 2009 |
Senior Member |
|
|
In article <f1ledf$p5q$1@build.eclipse.org>, nosp@m.please.org says...
> Gerald Rosenberg wrote:
> > In article <f1es71$8sj$1@build.eclipse.org>, nosp@m.please.org says...
> >> Gerald Rosenberg wrote:
> >>> I have a plugin that has a JDT dependency needed only to support an
> >>> isolated Java editor specific function. Would like to use the plugin in
> >>> a Ruby development RCP that does not have the JDT installed (the Java
> >>> function is not needed in this case).
> >>>
> >>> Is there any resonable way to detect the absence of the JDT and
> >>> exclude/disable the dependence at run-time? Any way short of having two
> >>> different static versions of the plugin?
> >>>
> >>> What is the best approach to handling this circumstance?
> >>>
> >>> Thanks,
> >>> Gerald
> >> How about making your dependency optional?
> >>
> >
> > How would that be done? An implementation hint would be appreciated.
>
> No implementation needed here. In the manifest-Editor, under
> 'Dependencies' right-click the dependency to be made optional. You'll
> see a check-box that does the trick.
Ok, I have
1) the JDT plugins marked optional in the manifest
2) all of the JDT dependent code isolated in a single class 'DocUtils'
3) the plugin class contains a single reference to DocUtils:
// check to see if the JDT is installed & obtain reference
DocUtils docUtils = null;
try {
docUtils = new DocUtils();
} catch (RuntimeException e) {
e.printStackTrace();
}
However, any attempt to load the plugin in an RCP without JDT installed
results in a ClassNotFoundException on the plugin class itself; the
plugin class never even begins execution. When run in Eclipse, the
plugin loads and executes as expected.
So, what am I missing?
Thanks,
Gerald
|
|
|
|
Re: How to handle dynamic dependencies at run-time? [message #467632 is a reply to message #467615] |
Wed, 09 May 2007 10:55 |
Stefan Langer Messages: 236 Registered: July 2009 |
Senior Member |
|
|
Correct me if I'm wrong but optional only means that the plugin doesn't
have to be available at runtime in order to resolve a bundel but as soon
as you call a class that uses code from the optional bundel eclipse will
try to load it. Unable to find it it will throw a ClassNotFoundException.
I think what you need to do is check if the JDT Bundle is available and
only call into the bundel if it is. If not don't call into the
optional bundle.
Or as mentioned in this thread put the optional functionaliy in a
separate plugin which is optional and make sure you never call into it
as long as it is not needed.
Regards
Stefan
Gerald Rosenberg schrieb:
> In article <f1ledf$p5q$1@build.eclipse.org>, nosp@m.please.org says...
>> Gerald Rosenberg wrote:
>>> In article <f1es71$8sj$1@build.eclipse.org>, nosp@m.please.org says...
>>>> Gerald Rosenberg wrote:
>>>>> I have a plugin that has a JDT dependency needed only to support an
>>>>> isolated Java editor specific function. Would like to use the plugin in
>>>>> a Ruby development RCP that does not have the JDT installed (the Java
>>>>> function is not needed in this case).
>>>>>
>>>>> Is there any resonable way to detect the absence of the JDT and
>>>>> exclude/disable the dependence at run-time? Any way short of having two
>>>>> different static versions of the plugin?
>>>>>
>>>>> What is the best approach to handling this circumstance?
>>>>>
>>>>> Thanks,
>>>>> Gerald
>>>> How about making your dependency optional?
>>>>
>>> How would that be done? An implementation hint would be appreciated.
>> No implementation needed here. In the manifest-Editor, under
>> 'Dependencies' right-click the dependency to be made optional. You'll
>> see a check-box that does the trick.
>
> Ok, I have
> 1) the JDT plugins marked optional in the manifest
> 2) all of the JDT dependent code isolated in a single class 'DocUtils'
> 3) the plugin class contains a single reference to DocUtils:
>
> // check to see if the JDT is installed & obtain reference
> DocUtils docUtils = null;
> try {
> docUtils = new DocUtils();
> } catch (RuntimeException e) {
> e.printStackTrace();
> }
>
>
> However, any attempt to load the plugin in an RCP without JDT installed
> results in a ClassNotFoundException on the plugin class itself; the
> plugin class never even begins execution. When run in Eclipse, the
> plugin loads and executes as expected.
>
> So, what am I missing?
>
> Thanks,
> Gerald
>
|
|
|
Re: How to handle dynamic dependencies at run-time? [message #467648 is a reply to message #467632] |
Wed, 09 May 2007 16:01 |
Gerald Rosenberg Messages: 106 Registered: July 2009 |
Senior Member |
|
|
In article <16744865.1178697961875.JavaMail.root@cp1.javalobby.org>,
alex_blewitt@yahoo.com says...
> OK, to check out the dependencies, start up your RCP application with -console -noExit and then use 'ss'. Your bundle, if it can't start, will be in INSTALLED status rather than RESOLVED or ACTIVE.
The RCP is the Aptana Web IDE. The console appears to have been co-
opted: it only shows with the title Aptana Scripting Console and does
not show/allow an osgi command line. Appears to hardwire the console
port to Firefox.
In article <f1s9a9$a0u$1@build.eclipse.org>, mailtolanger@googlemail.com
says...
> Correct me if I'm wrong but optional only means that the plugin doesn't
> have to be available at runtime in order to resolve a bundel but as soon
> as you call a class that uses code from the optional bundel eclipse will
> try to load it. Unable to find it it will throw a ClassNotFoundException.
Trying to catch the obvious 'RuntimeException', 'NullPointerException',
'MissingResourceException', 'BundleException' and even just plain
'Exception' exceptions do not work. But, 'NoClassDefFoundError'
*does*!.
Appears all is good.
> I think what you need to do is check if the JDT Bundle is available and
> only call into the bundel if it is. If not don't call into the
> optional bundle.
Is there a preferred way to directly check if the JDT Bundle is
available? Is there any reason not to just catch the
NoClassDefFoundError and set a flag?
Thanks,
Gerald
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03465 seconds