View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.tests.services.remoting.loadbalancing.server;
18  
19  import org.slf4j.Logger;
20  import org.slf4j.LoggerFactory;
21  import org.springframework.context.ApplicationContext;
22  import org.springframework.context.support.ClassPathXmlApplicationContext ;
23  
24  import ch.elca.el4j.tests.services.remoting.loadbalancing.common.BusinessObject;
25  import ch.elca.el4j.core.context.ModuleApplicationContext;
26  
27  
28  /**
29   * Defines the server used to test the idempotent invocation module. Launches a
30   * business object whose unique purpose is to illustrate the behavior of the
31   * module.
32   *
33   * @svnLink $Revision: 3880 $;$Date: 2009-08-04 15:17:52 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/tests/remoting/apps/server/src/test/java/ch/elca/el4j/tests/services/remoting/loadbalancing/server/LbTestServerNoContextPassing.java $
34   *
35   * @author Stefan Pleisch (SPL)
36   */
37  public class LbTestServerNoContextPassing {
38  
39  	/**
40  	 * Private logger.
41  	 */
42  	private static Logger s_logger = LoggerFactory.getLogger(LbTestServerNoContextPassing.class);
43  
44  	/** {@inheritDoc} */
45  	public static void main(String args[]) {
46  
47  /**
48  		// This is a hack, because the ModuleApplicationContext does not work
49  		// with the antrun plugin.
50  		ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath*:mandatory/*.xml",
51  			"classpath:loadbalancing/server/startup-nocontextpassing.xml",
52  		"classpath*:loadbalancing/remoting/rmi-nocontext-protocol-config.xml"});
53  */
54  		ApplicationContext applicationContext = new ModuleApplicationContext(
55  			new String[] {"classpath*:mandatory/*.xml",
56  				"classpath:loadbalancing/server/startup-nocontextpassing.xml",
57  				"classpath*:loadbalancing/remoting/rmi-nocontext-protocol-config.xml"},
58  			(String[]) null,
59  			false,
60  			(ApplicationContext) null);
61  
62  		s_logger.debug("Starting up ....");
63  
64  //        BusinessObject obj = (BusinessObject)applicationContext.getBean("rmiTestObjExporter");
65  		BusinessObject obj = (BusinessObject)applicationContext.getBean("rmiTestObjImpl");
66  
67  
68  		int iterations = 1;
69  		while (iterations < LbServerConstants.NBR_ITERATIONS) {
70  
71  			try {
72  				// 100s
73  				Thread.sleep(LbServerConstants.SLEEPING_TIME);
74  			} catch (Exception e) {
75  				System.err.println("Problem:");
76  				e.printStackTrace();
77  				System.exit(-1);
78  			}
79  
80  			iterations += 1;
81  			s_logger.debug("Looping around, iteration: " + iterations);
82  
83  		} // while
84  
85  		s_logger.debug("Done.");
86  		System.exit(0);
87  	} // main()
88  }