Referencing an External Spring Application

Procedure

  1. Import the external Spring application into the workspace as a plug-in project.
    1. Create a new plug-in project using the Plug-in Development > Plug-in from existing JAR archives.
    2. In the JAR selection screen, click Add External... and select the external Spring application JAR file.
    3. Enter the plug-in properties and uncheck the Unzip the JAR archives into the project checkbox.
  2. Edit the external Spring application to export the packages referenced by the Spring component implementation.
    1. Expand the META-INF directory of the external Spring application plug-in project.
    2. Double-click MANIFEST.MF.
    3. In the Manifest editor, click the Runtime tab.
    4. In the Exported Packages area, click the Add... button and check the Show non Java Packages checkbox.
    5. Select the library JAR file and click OK to add it.
  3. Configure dependencies as described in Configuring Dependencies on External Java Classes.
  4. Edit the Spring Bean configuration file:
    1. Add the import statement to the bean definition that points to the location of the external Spring application configuration file:
      <import resource="classpath:/location_of_external_springbean.xml">
    2. Add the property tags from the external Spring application to the bean definition:
      <property name="propertyName" ref="BeanId_External">
  5. Edit the Spring component's implementation class to delegate calls to the external Spring application's classes. The following example illustrates how to delegate calls from class HelloWorldPTImpl to the external Spring class MyLegacyJavaClass:
    public class HelloWorldPTImpl extends AbstractHelloWorldPTImpl {
      /**
      * Initialization of ReuseLegacySpringComponent component.
      */
      private MyLegacyJavaClass legacyBean;
      public void init() {
      // Component initialization code.
      // All properties are initialized and references are injected.
      if(this.legacyBean !=null){
        System.out.println( "Legacy Bean Initilized...");
        System.out.println( this.legacyBean.sayHello("World"));
      } else {
        throw new IllegalStateException("Injected bean is null");
        }
      }
      /**
      * Disposal of ReuseLegacySpringComponent component.
      */
      @Destroy
      public void destroy() {
        // Component disposal code.
        // All properties are disposed.
      }
      /**
      * Implementation of the WSDL operation: sayHello	 */
      public HelloResponseDocument sayHello(HelloRequestDocument firstName) {
        HelloResponseDocument hrd=HelloResponseDocument.Factory.newInstance();
        hrd.setHelloResponse(getLegacyBean().sayHello(
    		firstName.getHelloRequest()).toString());
        return hrd;
      }
      public MyLegacyJavaClass getLegacyBean() {
        return legacyBean;
      }
      public void setLegacyBean(MyLegacyJavaClass legacyBean) {
        this.legacyBean = legacyBean;
      }
    }