Hello Michael, On Wednesday 30 September 2009, 10:43, Michael Strobel wrote: > Hi Ariel and Frank, > > @Frank: Again, thanks for your help and your explanations. > > @Ariel: > >> public final class MyObjectFactory extends WeakBase { > >> > >> private final XComponentContext m_xContext; > >> > >> public MyObjectFactory(XComponentContext context) { > >> m_xContext = context; > >> } > >> } > > Just to be sure, by css.uno.XComponentContext, you mean > com.sun.star.uno.XComponentContext, right?
yes, css is a shortcut for lazy people like me not wanting to type com.sun.star (it has no sense in Java, but the common use comes from C++, where you can shorten a namespace) > Then this exactly what I have > here for the driver class, but when the constructor is called the context > that is passed is always null. then this is quite strange. Java UNO component are quite easy and straight forward to develop (even more with the NB OOo plug-in). I assume everything is fine in OOo Base/Java UNO framework side. May be something is wrong somewhere in your code (or something is horribly broken in OOo side)... hard to guess without seeing your code. > I have no idea why we don't get a valid > context here. As far as I understand is should be passed to the > constructor, when createInstanceWithContext(XComponentContext context) of > the XComponentSingleFactory for the driver class, which is returned by > __getComponentFactory, is called from OOo side. If you are using the factory helper from the javaunohelper, then all you have simply have to do is write the proper constructor, see http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Create_Instance_with_Arguments "Alternatively, a component may also receive these arguments in its constructor. ... When using the FactoryHelper, implement the constructors with the following arguments: [see table] The FactoryHelper *automatically* passes the array of arguments it received from the createInstanceWithArguments[AndContext]() call to the appropriate constructor." As you see, this should be rather straight forward. > There is also a class named CentralRegistrationClass (generated by > NetBeans) that seems to get all the __getComponentFactory and > __getComponentFactory calls from OOo side and then delegates them to the > __getComponentFactory and __getComponentFactory methods of actual > implementation classes. This class only has a private constructor that > takes no parameters, but this is probably okay. yes, this is a helper class, useful when you have several UNO components in a same JAR file; in the nbproject/project-uno.properties you will have the central registration class, the entry point for all components in your JAR: central.registration.class=<org.openoffice.examples>.CentralRegistrationClass All UNO components classes are listed, separated by a space in registration.classname=<org.openoffice.examples.>MyObjectFactory1 <org.openoffice.examples.>MyObjectFactory2 <org.openoffice.examples.>MyObjectFactory3 As you can have several UNO component per JAR file, you could try adding another, but dummy, component, using the same CentralRegistrationClass and the com.sun.star.lib.uno.helper.Factory helper, and then debug to see if the constructor with the XComponentContext works with it. Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@dba.openoffice.org For additional commands, e-mail: dev-h...@dba.openoffice.org