You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "GBivins (JIRA)" <ji...@apache.org> on 2011/01/09 08:20:45 UTC

[jira] Commented: (PIVOT-687) BXMLSerializer, would like to be able to specify a classloader for loading custom components

    [ https://issues.apache.org/jira/browse/PIVOT-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979268#action_12979268 ] 

GBivins commented on PIVOT-687:
-------------------------------

More info here. I tried modifying BXMLSerializer to use the other signature for Class.forName.
Since the default behavior of the current call is to use true with whatever is the current loader I did the following:
 changing the calls:
...~ln 737
propertyClass = Class.forName(propertyClassName);
...~ln 754
Class<?> type = Class.forName(className);

in the processStartElement method of BXMLSerializer to use the signature that includes the classloader:

propertyClass = Class.forName(propertyClassName,true,Thread.currentThread().getContextClassLoader());
Class<?> type = Class.forName(className,true,Thread.currentThread().getContextClassLoader());

This did the trick for me. Since I'm in NBP, there is a system class loader which is (by default, ie can be overriden) the same as the context classloader for any thread in the NB vm.
See here for more details:
http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#syscl


Since using true is the default behavior,
http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#forName(java.lang.String)


> BXMLSerializer, would like to be able to specify a classloader for loading custom components
> --------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-687
>                 URL: https://issues.apache.org/jira/browse/PIVOT-687
>             Project: Pivot
>          Issue Type: Improvement
>          Components: core-beans
>    Affects Versions: 2.0
>         Environment: all
>            Reporter: GBivins
>             Fix For: 2.0.1
>
>
> I'm running into issues trying to load my pivot window into a swing application. Some background,
> since pivot 2.0 can load components into a swing application, I've been trying to integrate pivot into a netbeans platform application.
> Only been at it a couple of hours but I'm stuck on an class loader issue. Basically, because I have pivot wrapped in separate module it's classloader
> can't references classes in any modules that depend on it. See here:
> http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#loader-hier
> I looked briefly in the docs but I'm not sure if I missed a readObject() signature that will allow me to pass in the classloader to use when de-serializing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.