Hello Stuart,
I am little bit familiar with Guice and Peaberry and I can say that I am
not happy to them. If you are familiar with Java EE I would like to
compare Guice and Peaberry with EJB 2.x and Java EE 1.4 where most of
routine/repeated works was done from the programmer and the popularity
of EJB 2.x was not so good. Now with EJB 3 the things are changed
because if you don't want to use some specific configurations you use
only few annotations to create EJB 3.x from POJO bean: @Remote, @Local,
@Stateful, @Stateless. Unfortunately this is not the case with Guice and
Peaberry. In my opinion this improvement can be done only if the
dependency injection is part of OSGi Framework implementation and it
will be much better if this is a part of the OSGi Specification.
Regards,
Miro.
Stuart McCulloch wrote:
2008/10/14 Miroslav Nachev <[EMAIL PROTECTED]>
Hi,
This is very interesting and I will try it but this answer is half of my
question. I am interesting how to get some service in my code, not in
another service. For example:
public class SomePOJOBean
{
@Requires
??? how to pass some parameters to the service (passive, dynamics)
private FooService foo;
}
How can be implemented the above scenario?
Well, iPOJO injects components - but these are not necessarily services.
Clement's example happened to provide a service, but this isn't mandatory.
You do need to tell iPOJO about your code somehow, and in iPOJO this is done
by marking them as components which iPOJO injects as necessary. (I'm sure
Clement can explain this better than me!)
There are also alternative ways to inject OSGi services, using (non-OSGi)
dependency injection frameworks:
* Spring has the Spring-DM extension, but I don't know if it fully supports
configuration via annotation.
http://www.springframework.org/osgi/
* Guice has the peaberry extension, which I work on - in this case the
service configuration is done in the binding module, not the annotation (I
did look at doing annotation configuration, but this rapidly becomes a
management nightmare)
http://code.google.com/p/peaberry/
HTH
Regards,
Miro.
clement escoffier wrote:
Hi,
iPOJO provides such annotations as:
@Component
@Provides // Provides a service
public class Foo implements Service {
@Requires // Service dependency
private HelloService hello;
...
}
You can find further info at
http://felix.apache.org/site/how-to-use-ipojo-annotations.html
About parameters, the iPOJO's way is to inject instance property. Those
fields will be set before the execution of your constructor (between the
super constructor invocation and the constructor code), and your
constructor
can use those fields, such as in:
@Component
@Provides // Provides a service
public class Foo implements Service {
@Property
private String myString;
@Requires // Service dependency
private HelloService hello;
public Foo() {
// Can use myString here as well as hello
}
...
}
Regards,
Clement
2008/10/14 Miroslav Nachev <[EMAIL PROTECTED]>
Hi,
I would like to ask you about some way in Felix to export services in
more
easy way only with annotation like in EJB3.x: @Stateful, @Stateless,
@Remote, @Local, @EJB, etc.
In my opinion the best way this to be done is inside of the OSGi
framework.
Then all resources (services) can be exported to the framework just with
annotation. The same for needed services. What about if before to get
some
service we have to pass some parameters to the constructor?
Regards,
Miro.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]