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) 2005 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  
18  package ch.elca.el4j.services.remoting.protocol;
19  
20  import ch.elca.el4j.services.monitoring.notification.CoreNotificationHelper;
21  import ch.elca.el4j.services.remoting.AbstractRemotingBase;
22  import ch.elca.el4j.services.remoting.AbstractRemotingProtocol;
23  
24  
25  /**
26   * This is an abstract <code>InetSocketAddress</code> protocol.
27   * HTTP is used as default service protocol.
28   *
29   * @svnLink $Revision: 4204 $;$Date: 2010-11-02 11:44:37 +0100 (Di, 02. Nov 2010) $;$Author: swisswheel $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/remoting_core/src/main/java/ch/elca/el4j/services/remoting/protocol/AbstractInetSocketAddressProtocol.java $
30   *
31   * @author Martin Zeltner (MZE)
32   */
33  public abstract class AbstractInetSocketAddressProtocol
34  	extends AbstractRemotingProtocol {
35  	/**
36  	 * This is the host where the service is installed.
37  	 */
38  	private String m_serviceHost;
39  
40  	/**
41  	 * This is the port where the service is installed.
42  	 */
43  	private int m_servicePort;
44  
45  	/**
46  	 * The service protocol. Default is "http".
47  	 */
48  	private String m_serviceProtocol = "http";
49  
50  	/**
51  	 * @return Returns the serviceHost.
52  	 */
53  	public String getServiceHost() {
54  		return m_serviceHost;
55  	}
56  
57  	/**
58  	 * @param serviceHost
59  	 *            The serviceHost to set.
60  	 */
61  	public void setServiceHost(String serviceHost) {
62  		m_serviceHost = serviceHost;
63  	}
64  
65  	/**
66  	 * @return Returns the servicePort.
67  	 */
68  	public int getServicePort() {
69  		return m_servicePort;
70  	}
71  
72  	/**
73  	 * @param servicePort
74  	 *            The servicePort to set.
75  	 */
76  	public void setServicePort(int servicePort) {
77  		m_servicePort = servicePort;
78  	}
79  
80  	/**
81  	 * @return Returns the m_serviceProtocol.
82  	 */
83  	public String getServiceProtocol() {
84  		return m_serviceProtocol;
85  	}
86  
87  	/**
88  	 * @param serviceProtocol Is the serviceProtocol to set.
89  	 */
90  	public void setServiceProtocol(String serviceProtocol) {
91  		m_serviceProtocol = serviceProtocol;
92  	}
93  
94  	/**
95  	 * {@inheritDoc}
96  	 */
97  	public void afterPropertiesSet() throws Exception {
98  		CoreNotificationHelper.notifyIfEssentialPropertyIsEmpty(
99  				getServiceHost(), "serviceHost", this);
100 		if (getServicePort() <= 0) {
101 			CoreNotificationHelper.notifyMisconfiguration(
102 					"The property 'servicePort' is required.");
103 		}
104 	}
105 	
106 	/**
107 	 * Method to generate the url to be able to access the service.
108 	 *
109 	 * @param remotingBase
110 	 *            Is the reference to get information about the service.
111 	 * @return Returns the generated service url.
112 	 */
113 	public abstract String generateUrl(AbstractRemotingBase remotingBase);
114 }