You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Gerrick Bivins <gb...@objectreservoir.com> on 2010/12/17 00:55:11 UTC

BXMLSerializer, can I specify a classloader?

Hello all,
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.
Thanks for any info/help here.
Gerrick

Re: BXMLSerializer, can I specify a classloader?

Posted by Gerrick Bivins <gb...@objectreservoir.com>.
Updated the ticket with some info.
Basically by using the other signature for Class.forName, I was able to get
around the problem I was having.
It doesn't address the issue of needing to use a custom classloader but
because of the module system in
the platform, things work.

Gerrick

On Sat, Dec 18, 2010 at 6:41 PM, Sandro Martini <sa...@gmail.com>wrote:

> Hi to all,
> some year ago I had the same problem inside a Java Enterprise webapp,
> where in a custom bean factory I need to load classes in a different
> layer of the EAR, so (when needed) passing the classloader instance of
> the caller solved the problem.
>
> I'll put some info in the ticket.
>
>
> Uh, of course this in a multi-layered app is a very good feature :-) ,
> and probably not only in the BXMLSerializer but in any place where a
> dynamic loading of classes is done inside Pivot, .. maybe later, so
> BXMLSerializer is without doubt a good start for it.
>
> Bye,
> Sandro
>

Re: BXMLSerializer, can I specify a classloader?

Posted by Sandro Martini <sa...@gmail.com>.
Hi to all,
some year ago I had the same problem inside a Java Enterprise webapp,
where in a custom bean factory I need to load classes in a different
layer of the EAR, so (when needed) passing the classloader instance of
the caller solved the problem.

I'll put some info in the ticket.


Uh, of course this in a multi-layered app is a very good feature :-) ,
and probably not only in the BXMLSerializer but in any place where a
dynamic loading of classes is done inside Pivot, .. maybe later, so
BXMLSerializer is without doubt a good start for it.

Bye,
Sandro

Re: BXMLSerializer, can I specify a classloader?

Posted by Greg Brown <gk...@verizon.net>.
Yup, looks good. Thanks.

On Dec 17, 2010, at 9:35 AM, Gerrick Bivins wrote:

> I haven't used JIRA before but I think I did it correctly:
> https://issues.apache.org/jira/browse/PIVOT-687
> 
> Gerrick
> 
> On Fri, Dec 17, 2010 at 7:58 AM, Greg Brown <gk...@verizon.net> wrote:
> That is an interesting problem. There's currently no way to pass a ClassLoader to BXMLSerializer. I was going to suggest that you create a custom subclass of BXMLSerializer that overrides newTypedObject(), but that won't work - newTypedObject() takes a Class<?> instance, and you would need a String.
> 
> Definitely something that should be fixed - would you mind creating a JIRA ticket for this?
> 
> Thanks,
> Greg
> 
> 
> On Dec 16, 2010, at 6:55 PM, Gerrick Bivins wrote:
> 
>> Hello all,
>> 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.
>> Thanks for any info/help here.
>> Gerrick
> 
> 


Re: BXMLSerializer, can I specify a classloader?

Posted by Gerrick Bivins <gb...@objectreservoir.com>.
I haven't used JIRA before but I think I did it correctly:
https://issues.apache.org/jira/browse/PIVOT-687

Gerrick

On Fri, Dec 17, 2010 at 7:58 AM, Greg Brown <gk...@verizon.net> wrote:

> That is an interesting problem. There's currently no way to pass a
> ClassLoader to BXMLSerializer. I was going to suggest that you create a
> custom subclass of BXMLSerializer that overrides newTypedObject(), but that
> won't work - newTypedObject() takes a Class<?> instance, and you would need
> a String.
>
> Definitely something that should be fixed - would you mind creating a JIRA
> ticket for this?
>
> Thanks,
> Greg
>
>
> On Dec 16, 2010, at 6:55 PM, Gerrick Bivins wrote:
>
> Hello all,
> 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.
> Thanks for any info/help here.
> Gerrick
>
>
>

Re: BXMLSerializer, can I specify a classloader?

Posted by Greg Brown <gk...@verizon.net>.
That is an interesting problem. There's currently no way to pass a ClassLoader to BXMLSerializer. I was going to suggest that you create a custom subclass of BXMLSerializer that overrides newTypedObject(), but that won't work - newTypedObject() takes a Class<?> instance, and you would need a String.

Definitely something that should be fixed - would you mind creating a JIRA ticket for this?

Thanks,
Greg

On Dec 16, 2010, at 6:55 PM, Gerrick Bivins wrote:

> Hello all,
> 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.
> Thanks for any info/help here.
> Gerrick