This project has retired. For details please refer to its Attic page.
Spring Integration
Polygene™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

Spring Integration

code

docs

tests

Table 41. Artifact

Group IDArtifact IDVersion

org.apache.polygene.libraries

org.apache.polygene.library.spring

3.0.0


Using Spring Framework in Apache Polygene™

Polygene™ supports that Spring Application Context is imported into the Polygene™ runtime, and the declared Spring beans will be available as Polygene™ services. The most important things to remember are;

  1. Only Spring Singletons are currently supported.
  2. One ApplicationContext per Polygene™ Module.
  3. The Polygene™ service will be given the same name as the Spring Bean name.
  4. Polygene™ Configuration is not reacbable from the Spring bean (kind of obvious).
new SpringImporterAssembler( appContext ).assemble( module );

Using Apache Polygene™ in Spring Framework

It is also possible to run a Polygene™ Application as a Spring Bean and export its Services to Spring.

Steps to export Polygene™ service:

  1. Create spring BeanFactory service of Polygene services to export.
  2. Create a class that extends PolygeneApplicationBootstrap.
  3. Sets the layer and module that register BeanFactory service.
  4. Assemble Polygene application by implementing #assemble method.
  5. Sets the identity of bean factory service. This identity is the spring bean name.
  6. Declare Polygene bootstrap in spring xml application context.

To bootstrap the Polygene™ runtime in Spring, you should have a bootstrap bean that extends the org.apache.polygene.library.spring.bootstrap.PolygeneApplicationBootstrap and implement the org.springframework.context.ApplicationContextAware.

A new bean will appear in the application context, called "polygeneApplication" which is only intended for internal use of this library.

Example application context;

 <?xml version="1.0" encoding="UTF-8"?>

 <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:polygene="http://polygene.apache.org/schema/polygene/spring"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://polygene.apache.org/schema/polygene/spring http://polygene.apache.org/schema/polygene/spring/spring-0.5.xsd">

  <!-- class that implements PolygeneApplicationBootstrap -->

  <polygene:bootstrap class="org.hedhman.niclas.MyPolygeneBootstrapper"/>

  <bean id="someService" class="org.hedhman.niclas.SomeService">

  <constructor-arg ref="someService"/> <!-- Reference polygene comment service -->

 </bean>
public class MyPolygeneBootstrapper extends PolygeneApplicationBootstrap
        implements ApplicationContextAware
{
    private ApplicationContext applicationContext;

    @Override
    public void assemble(ApplicationAssembly assembly) throws AssemblyException
    {
        // Normal assembly of an application.
          [...snip...]

    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
    {
        this.applicationContext = applicationContext;
    }

}