Fabric3 can host Spring applications, expose bean as remote endpoints, and wire beans remotely.
Spring application contexts are configured as SCA components using the implementation.spring element in a composite:
The location attribute of the implementation.spring element refers to the application context file that declares the Spring bean.
To expose a bean as an SCA endpoint, and SCA service must be declared in the application context and the service must then be configured on the implementation.spring entry. In the Spring application context, the SCA service should be declared using the SCA namespace:
The service is then configured with a binding as follows:
To use an SCA reference in your Spring bean, use the sca:reference element in the application context:
The reference can then be bound or wired in the composite containing the application context:
|SCA schema file referenced in Spring configuration (http://docs.oasis-open.org/opencsa/sca-assembly/sca-1.1.xsd) does not actually exist at all. This may give XML validation errors in your IDE and it also makes Fabric3 to start really slow with seemingly random warnings or even errors from Xerces XML validator validating Spring configuration files.
Currently this can be bypassed by disabling XML validation in IDE and adding the following configuration element into conf/systemConfig.xml:
Fabric3 integrates its it transaction and JPA/Hibernate infrastructure with Spring. Fabric3 provides a Spring Bean org.fabric3.implementation.spring.api.Fabric3EntityManagerFactoryBean, that extends the standard Spring LocalContainerEntityManagerFactoryBean. This gives the ability to have pooled datasources and it makes it unnecessary to specify a persistence provider in persistence.xml. With this approach, vendor-specific configurations can be avoided in application artifacts.
Alternatively, the standard Spring LocalContainerEntityManagerFactoryBean can be used instead of the Fabric3EntityManager. In that case, the naming of the datasource needed, should be placed in the persistence.xml:
Fabric3 supports Spring JDK Proxy-based AOP and transactions. (Use the Spring @Transactional annotation to use transactional behavior).
Fabric3 JTA transaction manager and pooled datasources are automatically aliased in each Spring application context. This provides full transactional support (including XA and pooled datasources) to Spring persistence (JPA, Hibernate, JDBC) and makes it also possible to automatically propagate transactions from other SCA components and bindings to Spring Beans.
There are two extensions to enable Spring support in Fabric3: the Spring implementation type extension and an extension that supplies the Spring library classes. By separating these two extensions, it is possible to use custom versions of the Spring library extension. Under the covers, the Spring implementation extension will use the Fabric3 extension point mechanism to resolve the Spring library extension. To create a custom library extension, a jar containing other jars in META-INF/lib/ and an SCA manifest needs to be produced.
To install Spring support into the Fabric3 runtime, download the Spring profile from the Fabric3 web site and copy the appropriate jars into the correct directory. To find out in which directory these jars should be copied, read the runtime layout description. After restarting the runtime, Spring support will be activated.