/**
 * Copyright (c) 2005-2006 Intalio inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Intalio inc. - initial API and implementation
 *
 * $Id: TaskManagementServicesFacade.java 5440 2006-06-09 08:58:15Z imemruk $
 * $Log:$
 */

package org.intalio.tempo.workflow;

import java.io.IOException;

import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.ServiceLifeCycle;
import org.apache.log4j.Logger;
import org.intalio.tempo.web.SysPropApplicationContextLoader;

public class SpringInit implements ServiceLifeCycle {

	private static final Logger LOG = Logger.getLogger(SpringInit.class);

    public static SysPropApplicationContextLoader CONTEXT;
    
	/**
	 * Called by Axis2 during deployment
	 */
	public void startUp(ConfigurationContext ignore, AxisService service) {
        String configFile = "#unspecified#";
		try {
	        Parameter p = service.getParameter("SpringContextFile");
	        if (p != null) configFile = (String) p.getValue();
	        LOG.debug("Loading configuration: "+configFile);
	        try {
	        	Thread.currentThread().setContextClassLoader(service.getClassLoader());
	            CONTEXT = new SysPropApplicationContextLoader(configFile);
	        } catch (IOException except) {
	            throw new RuntimeException(except);
	        }
		} catch (Exception except) {
			LOG.error("Error while loading Spring context file: "+configFile, except);
		}
	}

	/**
	 * Called by Axis2 during undeployment 
	 */
	public void shutDown(ConfigurationContext ctxIgnore, AxisService ignore) {
		CONTEXT = null;
	}
}

@@ -866,17 +866,20 @@
 ycle %7B%0A%0A
-%09
+    
 private 
@@ -1005,22 +1005,28 @@
 T;%0A    %0A
-%09/**%0A%09
+    /**%0A    
  * Calle
@@ -1054,22 +1054,28 @@
 loyment%0A
-%09 */%0A%09
+     */%0A    
 public v
@@ -1187,17 +1187,26 @@
 #%22;%0A
-%09%09
+        
 try %7B%0A
-%09
+    
     
@@ -1266,17 +1266,20 @@
 File%22);%0A
-%09
+    
         
@@ -1329,17 +1329,20 @@
 alue();%0A
-%09
+    
         
@@ -1390,25 +1390,26 @@
 gFile);%0A
-%09
+  
         
 try %7B%0A%09 
@@ -1404,23 +1404,24 @@
     
+  
 try %7B%0A
-%09
         
 %09Thr
@@ -1416,17 +1416,24 @@
         
-%09
+        
 Thread.c
@@ -1496,17 +1496,20 @@
 der());%0A
-%09
+    
         
@@ -1571,17 +1571,704 @@
 gFile);%0A
-%09
+                Parameter load = service.getParameter(%22LoadOnStartup%22);%0A                if (load != null && ((String) load.getValue()).equalsIgnoreCase(%22true%22)) %7B%0A                    Parameter bean = service.getParameter(%22SpringBeanName%22);%0A                    if (bean == null) throw new IllegalArgumentException(%22Missing 'SpringBeanName' parameter%22);%0A                    String beanName = (String) bean.getValue();%0A                    try %7B%0A                        CONTEXT.getBean(beanName);%0A                    %7D catch (Exception e) %7B%0A                        throw new IllegalArgumentException(%22Unable to initialize bean '%22+beanName+%22'%22, e);%0A                    %7D%0A                %7D%0A    
         
@@ -2298,17 +2298,20 @@
 cept) %7B%0A
-%09
+    
         
@@ -2350,17 +2350,20 @@
 xcept);%0A
-%09
+    
         
@@ -2364,18 +2364,24 @@
       %7D%0A
-%09%09
+        
 %7D catch 
@@ -2405,11 +2405,20 @@
 ) %7B%0A
-%09%09%09
+            
 LOG.
@@ -2492,22 +2492,37 @@
 t);%0A
-%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09
+        %7D%0A    %7D%0A%0A    /**%0A    
  * C
@@ -2561,14 +2561,20 @@
 nt %0A
-%09 */%0A%09
+     */%0A    
 publ
@@ -2648,10 +2648,16 @@
 ) %7B%0A
-%09%09
+        
 CONT
@@ -2672,9 +2672,12 @@
 ll;%0A
-%09
+    
 %7D%0A%7D%0A

Add 'LoadOnStartup' option