Interfacing problems using the Activex Bridge
I have a bean that's based on a JPanel. I am packaging it and then using it in Visual Basic as an OCX component.
I have to adhere to an interface on the VB side so that the bean will plug into the rest of our product.
I'm hitting several problems, all of which I'm attributing to to the fact that the packager introspects the interface for the typelib instead of asking me what I want to expose and how I want to expose it.
1) Getter/Setter methods for properties which contain additional attributes arent recognised as such.
e.g. for property foo:
public int getFoo() is fine
but
public int getFoo(int extraCriteria) doesn't work.
The packager doesn't recognise it as a valid getter and so doesn't bind it to Foo in the typelib.
NB: I've also tried explicitly binding the methods in the bean's beanInfo, (using PropertyDescriptors), but to no effect.
2) Typelib is only generated for the top level bean so how do I provide a similar interface for any java object that it returns?
Any java objects that I return from methods in my bean cannot be interfaced:
Therefore I have to deal with them all as VB Object and I'm also back to square one with my getFoo instead of "= Foo" problem.
3) The packager arbitrarily listens to, and exposes, any events that my class throws. This includes events that are fired from any of the classes that I'm extending. Therefore I'm getting 20+ events showing up from my JPanel on the VB side, NONE of which I'm interested in. When the packager finds an event firing method it automatically exposes it AND registers the activex bridge as a listener of it. Again this is a case of the packager introspecting instead of asking the programmer what they want to expose...
Basically I need help in either a) solving these specific problems, or b) coming at it from the opposite end and finding a way of getting control over what is exposed to VB. (Although this doesn't help me with problem 2)
Any suggestions?
Cheers
Paul James
[2120 byte] By [
wetfish] at [2007-9-26 2:08:21]

See inline
>
> I have a bean that's based on a JPanel. I am packaging
> it and then using it in Visual Basic as an OCX
> component.
>
> I have to adhere to an interface on the VB side so
> that the bean will plug into the rest of our product.
>
> I'm hitting several problems, all of which I'm
> attributing to to the fact that the packager
> introspects the interface for the typelib instead of
> asking me what I want to expose and how I want to
> expose it.
Did you make sure that you marked the bean in the jar
correctly? (The manifest.mf must declare the bean as bean
so that the corresponding bean info can be found in the same jar)
>
> 1) Getter/Setter methods for properties which contain
> additional attributes arent recognised as such.
>
> e.g. for property foo:
>
> public int getFoo() is fine
>
> but
>
> public int getFoo(int extraCriteria) doesn't work.
> .
>
> The packager doesn't recognise it as a valid getter
> and so doesn't bind it to Foo in the typelib.
>
> NB: I've also tried explicitly binding the methods in
> the bean's beanInfo, (using PropertyDescriptors), but
> to no effect.
That might be a COM restriction? IN that prop get and prop put
have to have a certain signature. If your method is public
and part of the bean info, then you should at least have the method.
(That always worked for me...)
>
> 2) Typelib is only generated for the top level bean so
> how do I provide a similar interface for any java
> object that it returns?
Run the packager over all additional beans.
>
> Any java objects that I return from methods in my bean
> cannot be interfaced:
>
> Therefore I have to deal with them all as VB Object
> and I'm also back to square one with my getFoo instead
> of "= Foo" problem.
Once you start with your first bean, all subsequent objects
you receive from your first bean can be analyzed via the
java reflection mechanism on the VB side. Somewhere in the
documentation for the ActiveX Packager, there is sample code
on how to do this (how to get the class, find a method, invoke the
method, create new objects for some other class, pass it to your bean
etc).
>
> 3) The packager arbitrarily listens to, and exposes,
> any events that my class throws. This includes events
> that are fired from any of the classes that I'm
> extending. Therefore I'm getting 20+ events showing
> up from my JPanel on the VB side, NONE of which I'm
> interested in. When the packager finds an event
> firing method it automatically exposes it AND
> registers the activex bridge as a listener of it.
> Again this is a case of the packager introspecting
> instead of asking the programmer what they want to
> expose...
The reason is that VB only knows one event interface (
marked as dispinterface). This interface has to contain all
events for the bean. I suppose the packager just goes and
collects all events it finds for the bean, including all the
inherited ones. The bridge has to be registered for all of them,
otherwise no event could pass through.
>
> Basically I need help in either a) solving these
> specific problems, or b) coming at it from the
> opposite end and finding a way of getting control over
> what is exposed to VB. (Although this doesn't help me
> with problem 2)
>
> Any suggestions?
>
> Cheers
>
> Paul James
>
>
>
Well I'm replying to something that's six months old.
I'm pretty new to the ActiveX Bridge, but one of your
questions looked like it had an obvious answer to me:
-1) Getter/Setter methods for properties which contain
-additional attributes arent recognised as such.
-e.g. for property foo:
-public int getFoo() is fine
-but
-public int getFoo(int extraCriteria) doesn't work.
-The packager doesn't recognise it as a valid getter and
-so doesn't bind it to Foo in the typelib.
...
As far as I know from the JavaBean signature patterns,
you're matching an indexed property signature, so
you are telling it that you're trying to get an element
from the Foo array of ints at index "extraCriteria".