I've just created a new discussion group jEmbedded Discussion Group so you are free to join and post your questions, requests etc...
After holidays want I'm going to do it's to write down a full documentation and upload more examples.
In the meantime here it's more Q/A:
* What's the difference between the @Include and @Repository annotations?
With these two annotations resources can be added to the container but in a different manner as @Repository will create a new container for the resources and @Include will just add them to the current container (default container in case you haven't provided the @Repository ann).
Use @Include if you only want to add some extra resources to the container and not to create a new one.
* Spring Integration, how to do it?
There are many different ways to do this. I've provided a spring-support-module that will help you, but in this stage it's not very comprehensive as I've focused to provide a stand alone IoC container.
In this module a FactoryBean class is provided so an instance of the embedded container can be stored into the spring-context. Then you can inject the container in any bean you want, get the container from Spring or just use ContainerHolder.getCurrentThreadContainer().
Please have a look at the spring-integration-module and the embedded-database example for more information.
You may ignore the integration module and write your own FactoryBean:
@Container(instanceType=
ContainerInstanceType.xxxx)
@Repository(id="database-service-layer", resources={EmbeddedDatabaseImpl.class})
public class EmbeddedDatabaseFactory implements FactoryBean {
public Object getObject() throws Exception {
return EmbeddedHandlerFactory.getInstance(getClass());
}
public Class getObjectType() {
return EmbeddedHandler.class;
}
public boolean isSingleton() {
return false;
}
}
Then you can retrieve the container like this:
ApplicationContex appContex; //SpringContext
@Repository(id="database-
public class EmbeddedDatabaseFactory implements FactoryBean {
public Object getObject() throws Exception {
return EmbeddedHandlerFactory.
}
public Class getObjectType() {
return EmbeddedHandler.class;
}
public boolean isSingleton() {
return false;
}
}
Then you can retrieve the container like this:
ApplicationContex appContex; //SpringContext
EmbeddedHandler handler = (EmbeddedHandler)appContext.getBean("factory-bean-id");
Finally, you can create the container in any spring bean you'd like. Of course watch out what kind of bean it is (singleton, prototype etc...)
* Can the annotation @Inject be used to reference a Spring bean?
No at this moment, but you can inject the container to any spring bean or just accessing the container with ContainerHolder. I will add this feature in the near future.
No at this moment, but you can inject the container to any spring bean or just accessing the container with ContainerHolder. I will add this feature in the near future.