Rony G. Flatscher wrote:
Hi Daniel,

* Or maybe rephrased: if reflecting an UNO object, does one need to
use an instance of "com.sun.star.reflection.CoreReflection" from
the same context as the reflected UNO object?


No, you need not use the same component context, but it may be more
performant to choose one within your process. Please use the singleton
entry

"com.sun.star.reflection.theCoreReflection"

for the sole reason that it internally caches created IdlClass objects.

When will that object be registered? Is there anything I could do that it gets registered and available at bootstrap time?

What follows is a small Java program that shows that "theServiceManager" is registred with the context, but "theCoreReflection" object is not yet.

In your example you bootstrap a new fresh Java UNO env. I assume that the singleton is not registered in this env but when you use the native bootstrap mechanism or use the context from an office this singleton should be registered. This can maybe considered as bug and you can submit one or an request for enhancement if you want.

Juergen


---------------- cut here --------------
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

public final class RgfUnoAnalyzeTest2 {

    public static XComponentContext defaultContext=null;

    /** Static block to initialize static fields. */
    static {
        try
        {
XComponentContext ctxt0=Bootstrap.createInitialComponentContext(null) ;
            System.err.println("ctxt0="+pp(ctxt0));

String key="/singletons/com.sun.star.reflection.theCoreReflection";
            Object tcr2=ctxt0.getValueByName(key);
            System.err.println(key+"\t=\t"+pp(tcr2));

            key="/singletons/com.sun.star.lang.theServiceManager";
            tcr2=ctxt0.getValueByName(key);
            System.err.println(key+"\t=\t"+pp(tcr2)+"\n");
        }
        catch (Exception e)
        {
            System.err.println("Exception:" + pp(e) + "has occurred!");
        }
    }

    public static void main(String[] arguments) throws Exception {

        System.out.println("In main()...");
        System.exit(0);
    }

    private RgfUnoAnalyzeTest2 () {}

    public static String pp(Object o)
    {
        if (o==null) return "<null>  <=== <=== <===";
        return "<"+o.toString()+">";
    }
}
---------------- cut here --------------


Output:
---------------- cut here --------------
F:\work\tmp\ooo\tst>java RgfUnoAnalyzeTest2
ctxt0=<[EMAIL PROTECTED]>
/singletons/com.sun.star.reflection.theCoreReflection = <Any[Type[void], null]> /singletons/com.sun.star.lang.theServiceManager = <[EMAIL PROTECTED]>

In main()...
---------------- cut here --------------

Any hints, insights?

TIA,

---rony


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

Reply via email to