View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  package com.eviware.soapui.integration.impl;
13  
14  import gnu.cajo.invoke.Remote;
15  import gnu.cajo.utils.ItemServer;
16  
17  import java.io.IOException;
18  
19  import com.eviware.soapui.SoapUI;
20  import com.eviware.soapui.integration.loadui.IntegrationUtils;
21  import com.eviware.soapui.settings.LoadUISettings;
22  
23  public class CajoServer
24  {
25  
26  	public static final String DEFAULT_SOAPUI_CAJO_PORT = "1198";
27  	
28  	private String server = null;
29  	private String port = DEFAULT_SOAPUI_CAJO_PORT;
30  	private String itemName = "soapuiIntegration";
31  	private static CajoServer instance;
32  	
33  	public static CajoServer getInstance()
34  	{
35  		if( instance == null )
36  		{
37  			return instance = new CajoServer();
38  		}
39  		return instance;
40  	}
41  
42  	private CajoServer()
43  	{
44  	}
45  
46  	public void start()
47  	{
48  		String cajoPort = IntegrationUtils.getIntegrationPort( "soapUI", LoadUISettings.SOAPUI_CAJO_PORT,
49  				DEFAULT_SOAPUI_CAJO_PORT );
50  		Remote.config( server, Integer.valueOf( cajoPort ), null, 0 );
51  		try
52  		{
53  			ItemServer.bind( new TestCaseEditIntegrationImpl(), itemName );
54  			SoapUI.log( "The cajo server is running on localhost:" + cajoPort + "/" + itemName );
55  		}
56  		catch( IOException e )
57  		{
58  			SoapUI.log( e.getMessage() );
59  		}
60  
61  		CajoClient.getInstance().testConnection();
62  	}
63  
64  
65  
66  	public String getServer()
67  	{
68  		return server;
69  	}
70  
71  	public String getPort()
72  	{
73  		return port;
74  	}
75  
76  	public String getItemName()
77  	{
78  		return itemName;
79  	}
80  
81  	public void setServer( String server )
82  	{
83  		this.server = server;
84  	}
85  
86  	public void setPort( String port )
87  	{
88  		this.port = port;
89  	}
90  
91  	public void setItemName( String itemName )
92  	{
93  		this.itemName = itemName;
94  	}
95  }