All the feedback are highly appreciated so I can improve it in the next versions.
I reckon that the documentation now is quite scarce but I wanted to release before I went on holidays (I will improved it a lot though) so I did that compromise. Also there are some features that are not explained in the provided documentation (many actually)
So I will try to answer here some of the questions I have received.
* What is this framework good for?
Well first of all it's just an IoC container with all that implies, but more importantly it allows you to manage your application elements (definition, creation, composing, starting, stopping, releasing) in a easy and fast way (using annotations, no need of XML or other additional configuration).
It provides the semantics or annotations needed to promote a bean or a POJO to a service, to a component, or to a entity managing their life cycle (if you choose that). For example, the container will start and stop the services for you.
These additional semantics provide not only a life cycle to the POJOS, or a contract but also additional features as accessing to the executing environment and a chance to be externally managed (through JMX, I'm already working on a console).
I would say that the provided embedded services and the feature of easy composition (creating a new service using other services) it's quite useful. In fact, it's how this framework was born.
For example, you can get the jetty-service and create and web server of your own using just composition. Or a rules-server for your application using the rules-service provided, executing a set of business rules for the rest of the services.
Finally, jEmbedded is an implementation of another framework of mine, jRepository that allows you to create your own IoC customized container (included in the distribution).
* Can jEmbedded be used in a web application?
Of course you can, in the same way you would use it in a standalone application. (I designed it with the 2 environments in mind). You have to be careful though, in the way that the container are created or disposed. This is managed by the annotation :
@Container(ContainerInstanceType instanceType)
public enum ContainerInstanceType {
SINGLETON_VM, PROTOTYPE_VM, PROTOTYPE_BY_THREAD;
}
If you don't provide this annotation by default the way of creating instances it's PROTOTYPE_BY_THREAD (a new instance per thread) so if you are creating an instance of jEmbedded inside a MVC Controller, there is a good chance that you are creating a new container with each request. In this case use the SINGLETON_VM property to have one container per VM.
Another way of getting the handler to the container is using the following static method:
EmbededHandler handler = ContainerHolder.getCurrentThreadContainer();
No comments:
Post a Comment