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;
19
20 import org.springframework.beans.factory.InitializingBean;
21 import org.springframework.util.StringUtils;
22
23 import ch.elca.el4j.services.monitoring.notification.CoreNotificationHelper;
24
25 /**
26 * This class is used to manage the given remote protocol.
27 *
28 * @svnLink $Revision: 3873 $;$Date: 2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$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/AbstractRemotingBase.java $
29 *
30 * @author Martin Zeltner (MZE)
31 */
32 public abstract class AbstractRemotingBase implements InitializingBean {
33 /**
34 * Suffix of service name if it is generated. This is needed to be able to
35 * filter incomming requests, i.e. in the web.xml.
36 */
37 public static final String SERVICE_NAME_SUFFIX = ".remoteservice";
38
39 /**
40 * This is the used remote protocol.
41 */
42 private AbstractRemotingProtocol m_remoteProtocol;
43
44 /**
45 * Interface to show to the outside.
46 */
47 private Class m_serviceInterface;
48
49 /**
50 * Optional property. It is possible to set the name of the used service
51 * manually, otherwise it will be generated automatically.
52 */
53 private String m_serviceName;
54
55 /**
56 * This member contains protocol specific configuration. This will only be
57 * used if it is really necessary.
58 */
59 private ProtocolSpecificConfiguration m_protocolSpecificConfiguration;
60
61 /**
62 * @return Returns the remoteProtocol.
63 */
64 public AbstractRemotingProtocol getRemoteProtocol() {
65 return m_remoteProtocol;
66 }
67
68 /**
69 * @param remoteProtocol
70 * The remoteProtocol to set.
71 */
72 public void setRemoteProtocol(AbstractRemotingProtocol remoteProtocol) {
73 m_remoteProtocol = remoteProtocol;
74 }
75
76 /**
77 * @return Returns the serviceInterface.
78 */
79 public Class getServiceInterface() {
80 return m_serviceInterface;
81 }
82
83 /**
84 * @param serviceInterface
85 * The serviceInterface to set.
86 */
87 public void setServiceInterface(Class serviceInterface) {
88 m_serviceInterface = serviceInterface;
89 }
90
91 /**
92 * @return Returns the serviceName.
93 */
94 public String getServiceName() {
95 if (!StringUtils.hasText(m_serviceName)) {
96 m_serviceName = m_serviceInterface.getName() + SERVICE_NAME_SUFFIX;
97 }
98 return m_serviceName;
99 }
100
101 /**
102 * @param serviceName
103 * The serviceName to set.
104 */
105 public void setServiceName(String serviceName) {
106 m_serviceName = serviceName;
107 }
108
109 /**
110 * @return Returns the protocolSpecificConfiguration.
111 */
112 public ProtocolSpecificConfiguration getProtocolSpecificConfiguration() {
113 return m_protocolSpecificConfiguration;
114 }
115
116 /**
117 * @param protocolSpecificConfiguration
118 * The protocolSpecificConfiguration to set.
119 */
120 public void setProtocolSpecificConfiguration(
121 ProtocolSpecificConfiguration protocolSpecificConfiguration) {
122 m_protocolSpecificConfiguration = protocolSpecificConfiguration;
123 }
124
125 /**
126 * {@inheritDoc}
127 */
128 public void afterPropertiesSet() throws Exception {
129 CoreNotificationHelper.notifyIfEssentialPropertyIsEmpty(
130 getRemoteProtocol(), "remoteProtocol", this);
131 CoreNotificationHelper.notifyIfEssentialPropertyIsEmpty(
132 getServiceInterface(), "serviceInterface", this);
133 }
134 }