[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: Class loader problem
|
Christina,
In general there is no way to add things to the class path of the entire
platform. The application class loader (used to load main()) is purposely
ignored by the platform after startup. Without this behaviour, the platform
would be hard-pressed to generate the plugin lifecycle events (e.g.,
activation) that are important to the scaleability of the platform itself.
That said, there are some options. I have to admit I don't completely
follow your example but I do know that you are free to create/use new class
loaders which are based on your plugin's classloader. For example, in the
plugin P which needs an extended classpath, you might do something like
(excuse the errors, I don't have a Java environment in front of me...):
URLClassloader loader = new URLClassloader(P.getClassloader(),
PurchaseBean.jar);
then if you use this loader to load the Xalan stuff (using reflect calls),
it should automatically find the classes in PurchaseBean.jar and any other
things you put on the loader's classpath.
Hope that helps
Jeff
"Christina Lau" <clau@xxxxxxxxxx> wrote in message
news:9iiejv$7hn$1@xxxxxxxxxxxxxxxx
> Is there a way to affect the classpath at runtime within the workbench?
> Here is the scenario I am trying to develop:
>
> The xalan processor supports calling Java beans. That is, in an XSL
> stylesheet, one can write something like this to declare a bean
> order.PurchaseBean, and then to call a method getOrderId during the
> transform process.
>
> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> ...
> xmlns:user0="class:order.PurchaseBean"
> exclude-result-prefixes="user0">
> <xsl:variable name="getOrderId" select="user0:getOrderId()"/>
>
> If on a command line, I set up my classpath to include the jars for the
> bean, I can invoke xalan passing this XSLT and an XML doc and it will
> create a new XML doc.
>
> However, I am having problem doing this within an XSL Trace Editor that
> runs within the workbench. I can set up my build path to build my bean,
> and I can also invoke xalan correctly, but somehow I cannot affect my
> classpath in such a way that Xalan can find the PurchaseBean.
>
> If I add the PurchaseBean.jar into one of my plugin.xml before I start the
> Workbench, then it will work, but clearly this is not what I want to tell
> the user to do. Is there a programmatic way that I can alter the classpath
> at run time within an editor that runs in an eclipse project?
>