[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Bundle services

In Java 1.6 (and to some extent earlier versions) there is a mechanism
to allow a jar file to declare that it contains an implementation of
some standard service interface, and to discover and load service
implementations.  The basic mechanism is that the jar file contains a
folder named META-INF/services, within which there are text files named
after interfaces; within each text file are the qualified names of
classes that implement the interface.  There is then a utility
java.util.ServiceLoader, which takes a classloader and the Class object
of an interface, and returns an iterator of implementations.

In Eclipse, the way that I know to publish services is that one plug-in
declares an extension point and an interface, and other plug-ins extend
the extension point and declare the names of the implementation classes;
IConfigurationElement.createExecutableExtension() is then used to load
the implementations.  But this mechanism has the disadvantage that it is
not standardized across different services - that is, I can't easily
write an arbitrary "ServiceLoader" for plug-ins, because the extension
points corresponding to different services do not share the same schema.

I have just discovered the org.osgi.framework.ServiceFactory,
ServiceRegistration, etc. interfaces.  Are these intended to provide a
standardized service-provider system for OSGi?  If so, is there
somewhere I can read more about these, beyond the javadoc for the
classes themselves?  Or if the javadoc is all that exists, is there a
particular class I should start with?

Or, are these interfaces meant for lower-level functionality, or some
such, so I should continue to use extension points?

  ***

My application, in case anyone's interested, is Java 6 annotation
processing.  Annotation processors are third-party components that
execute at compile time to report errors and generate additional
resources.  They plug into Sun's javac by using the Java service
provider mechanism; I'm trying to perform the equivalent for processors
written as Eclipse plug-ins as well as jar files.

Thanks,
  -Walter Harley
   JDT APT team
_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.