Re: [dev] Howto get the actual interface type of an UNO service object (via Java) ?

2008-09-10 Thread Stephan Bergmann

On 09/09/08 19:24, Rony G. Flatscher wrote:

Hi there,

while poking around a little bit I was wondering, how one could get at
the Type[...] information via Java that the Java proxy object reveals,
if asking it to render to a string.

E.g. in the following (interactive) session Java is used as the bridge
for the scripting language ooRexx; first a Desktop service object is
created and assigned to a variable a, then its
com.sun.star.frame.XDesktop interface is assigned to variabel b and
from it the com.sun.star.beans.XPropertySet interface is assigned to
variable c. Sending the toString message to all three proxy objects
displays them allowing to distinguish which interface type they represent.

In the example session below (please watch out for line-wraps) that
interface type is the last comma separated token in the form of
Type[...interface_name...].

Now the question: how can one get at exactly that piece of information
via Java at runtime?


You can't, easily.  (Maybe you can via reflection).  As of DEV300m31, 
every Java proxy object must implement interface 
com.sun.star.lib.uno.Proxy (see 
jurt/com/sun/star/lib/uno/Proxy.java:1.4), and the two cases that do are 
defined in 
jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java:1.8 (for 
the remote URP bridge), storing the relevant data as private final Type 
type;, and in 
bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java 
(for the in-process JNI bridge), storing the relevant data as protected 
Type m_type;.


Besides, that a proxy handles only a single interface (plus parent 
interfaces) of a UNO object is, of course, an implementation detail that 
can always change.


-Stephan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [dev] Howto get the actual interface type of an UNO service object (via Java) ?

2008-09-10 Thread Rony G. Flatscher
Hi Stephan,

 while poking around a little bit I was wondering, how one could get at
 the Type[...] information via Java that the Java proxy object reveals,
 if asking it to render to a string.

 E.g. in the following (interactive) session Java is used as the bridge
 for the scripting language ooRexx; first a Desktop service object is
 created and assigned to a variable a, then its
 com.sun.star.frame.XDesktop interface is assigned to variabel b and
 from it the com.sun.star.beans.XPropertySet interface is assigned to
 variable c. Sending the toString message to all three proxy objects
 displays them allowing to distinguish which interface type they
 represent.

 In the example session below (please watch out for line-wraps) that
 interface type is the last comma separated token in the form of
 Type[...interface_name...].

 Now the question: how can one get at exactly that piece of information
 via Java at runtime?

 You can't, easily.  (Maybe you can via reflection).  As of DEV300m31,
 every Java proxy object must implement interface
 com.sun.star.lib.uno.Proxy (see
 jurt/com/sun/star/lib/uno/Proxy.java:1.4), and the two cases that do
 are defined in
 jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java:1.8
 (for the remote URP bridge), storing the relevant data as private
 final Type type;, and in
 bridges/source/jni_uno/java/com/sun/star/bridges/jni_uno/JNI_proxy.java
 (for the in-process JNI bridge), storing the relevant data as
 protected Type m_type;.
Thank you very much for these interesting pointers!

Just another question: how about if I were to run the toString()
method against a service object proxy and parse the type information.
This way it's the proxy's toString()-method problem to figure out and
supply the interface type. (Performance in the context of the thought
for use-cases is not an issue at all, given those warped PCs people have
come to use today.)

 Besides, that a proxy handles only a single interface (plus parent
 interfaces) of a UNO object is, of course, an implementation detail
 that can always change.
Sure.

Actually, what I am after is to determine at runtime whether the service
object in hand got a queryInterface for a specific interface carried out
already or not. Currently, it would be important to find out whether the
com.sun.star.beans.XPropertySet interface was queried already (i.e.
whether its methods would be available already, or whether one needs to
query that interface). However, this may be interesting in other
contexts, where a service object is returned and it may be interesting
to know which interfaces got queried for already.

---rony








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[dev] Howto get the actual interface type of an UNO service object (via Java) ?

2008-09-09 Thread Rony G. Flatscher
Hi there,

while poking around a little bit I was wondering, how one could get at
the Type[...] information via Java that the Java proxy object reveals,
if asking it to render to a string.

E.g. in the following (interactive) session Java is used as the bridge
for the scripting language ooRexx; first a Desktop service object is
created and assigned to a variable a, then its
com.sun.star.frame.XDesktop interface is assigned to variabel b and
from it the com.sun.star.beans.XPropertySet interface is assigned to
variable c. Sending the toString message to all three proxy objects
displays them allowing to distinguish which interface type they represent.

In the example session below (please watch out for line-wraps) that
interface type is the last comma separated token in the form of
Type[...interface_name...].

Now the question: how can one get at exactly that piece of information
via Java at runtime?

E:\rony\dev\bsf\src\binrexxtry
REXX-ooRexx_3.2.0(MT) 6.02 16 Jun 2008
  rexxtry.rex lets you interactively try REXX statements.
Each string is executed when you hit Enter.
Enter 'call tell' for a description of the features.
  Go on - try a few...Enter 'exit' to end.
call uno.cls
  ... rexxtry.rex on WindowsNT
a=uno.createDesktop()  /* creates and returns a desktop service object */
  ... rexxtry.rex on WindowsNT
b=a~XDesktop   /* queries the com.sun.star.frame.XDestkop 
interface */
  ... rexxtry.rex on WindowsNT
c=b~XPropertySet   /* queries the com.sun.star.beans.XPropertySet 
interface */
  ... rexxtry.rex on WindowsNT
say a~toString /* ask the proxy for its string representation */

[Proxy:9938272,4c801ac;msci[0];71a4c62fd6a4ea18dca702d3c4a726d,Type[com.sun.star.uno.XInterface]]
  ... rexxtry.rex on WindowsNT
say b~toString /* ask the proxy for its string representation */

[Proxy:32134769,4c801ac;msci[0];71a4c62fd6a4ea18dca702d3c4a726d,Type[com.sun.star.frame.XDesktop]]
  ... rexxtry.rex on WindowsNT
say c~toString /* ask the proxy for its string representation */

[Proxy:30495813,4c801ac;msci[0];71a4c62fd6a4ea18dca702d3c4a726d,Type[com.sun.star.beans.XPropertySet]]
  ... rexxtry.rex on WindowsNT
say a~uno.getTypeName b~uno.getTypeName c~uno.getTypeName  /* get the IDL 
type name via reflection */
UNO_SERVICE UNO_SERVICE UNO_SERVICE
  ... rexxtry.rex on WindowsNT
say uno.areSame(a,b) uno.areSame(b,c) uno.areSame(a,c) /* test whether 
all three are the same object */
1 1 1
  ... rexxtry.rex on WindowsNT
  


TIA for any pointers/hints,

---rony