Dear Felix users,
Is there a way to register a service object whose class has static
methods? (In such a way that those methods become available to other
bundles in the framework?)
Let's consider as an example a Java implementation of numerical
routines, which are often implemented as static functions. Say we have,
for instance, a class foo.Log:
package foo;
public class Log {
public static double log(double x) {
...
}
}
I'd like to bundleize my library and naively start writing the
following:
package foo.osgi.Log;
public interface Log {
public double log(double x);
}
With the hope of later registering my service with:
context.registerService("foo.osgi.Log", new foo.Log(), null);
But this will, of course, not work for 2 reasons:
1) foo.Log does not implement foo.osgi.Log because the static methods
will hide, and not implement, the non-static methods.
2) It sounds awfully sinful to register an instance of the foo.Log class
instead of being able to register the class itself. But the object
passed back to the client after a call to getService() is always an
instance object, never the class itself. The client is thus doomed to
always use static methods in a non-static way.
Is there any way that a class (especially a class's static methods) can
be registered with framework instead of an instance of that class?
And if yes, what will the semantics be on the client's side?
If anyone has ever come across this problem I'd love to hear from you.
Kind regards,
--
--------------------------------------------------
David Lindelöf
Product Developer
Adhoco AG
Technopark
Jagerstrasse 2
8406 Winterthur
tel +41-52-203.2903
mob +41-79-415.6641
fax +41-52-203.2904
e-mail [EMAIL PROTECTED]
url http://www.adhoco.com
weblog http://www.visnet.ch/smartbuildings/
--------------------------------------------------
Since we have to speak well of the dead, let's knock them while they're alive.
-- John Sloan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]