New issue 70 by dennie...@gmail.com: Bind concrete service classes
http://code.google.com/p/peaberry/issues/detail?id=70
Using Peaberry 1.2:
When I want to bind a concrete service (without an interface) I am
receiving an Exception:
The array of service names is empty
at jpa.example1.GuiceModule.configure(GuiceModule.java:24)
while locating org.ops4j.peaberry.Export<jpa.example1.ConcreteService>
I am using this code:
public class GuiceModule extends PeaberryActivationModule{
@Override
protected void configure() {
// 1. Does not work
bind(export(ConcreteService.class))
.toProvider(service(ConcreteService.class).export());
// 2. Does not work
bindService(ConcreteService.class).export();
}
The current getInterfaceNames implementation (in OSGiServiceExport.java)
finds interfaces implemented by the service class - if the implementation
has no interfaces then this will be empty, and perhaps in that case it
should also include the implementation class itself as a service interface.
A workaround is to set the OBJECTCLASS property yourself:
bind(export(ConcreteService.class)).toProvider(
service(ConcreteService.class).attributes(objectClass(ConcreteService.class)).export());
Where objectClass is a static utility method from Attributes.java