Author: veithen Date: Sun Jun 14 11:31:37 2009 New Revision: 784542 URL: http://svn.apache.org/viewvc?rev=784542&view=rev Log: Some refactorings to unify some of the aspects common to all AbstractTransportListener based transports.
Added: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java (with props) webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java (with props) Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java (original) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollTableEntry.java Sun Jun 14 11:31:37 2009 @@ -21,18 +21,13 @@ import java.util.TimerTask; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.description.AxisService; - -public abstract class AbstractPollTableEntry { +public abstract class AbstractPollTableEntry extends ProtocolEndpoint { // status of last scan public static final int SUCCSESSFUL = 0; public static final int WITH_ERRORS = 1; public static final int FAILED = 2; public static final int NONE = 3; - /** Axis2 service */ - private AxisService service; /** next poll time */ private long nextPollTime; /** last poll performed at */ @@ -48,16 +43,6 @@ /** Flag indicating whether polling has been canceled. */ boolean canceled; - public AxisService getService() { - return service; - } - - void setService(AxisService service) { - this.service = service; - } - - public abstract EndpointReference getEndpointReference(); - public long getNextPollTime() { return nextPollTime; } Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java (original) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractPollingTransportListener.java Sun Jun 14 11:31:37 2009 @@ -212,7 +212,7 @@ String candidateName = service.getName(); if (candidateName.equals(serviceName) || serviceName.startsWith(candidateName + ".")) { - return new EndpointReference[]{ entry.getEndpointReference() }; + return entry.getEndpointReferences(ip); } } } Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java (original) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListener.java Sun Jun 14 11:31:37 2009 @@ -337,6 +337,10 @@ return transportIn.getName(); } + public ConfigurationContext getConfigurationContext() { + return cfgCtx; + } + public MetricsCollector getMetricsCollector() { return metrics; } Added: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java?rev=784542&view=auto ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java (added) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java Sun Jun 14 11:31:37 2009 @@ -0,0 +1,93 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.axis2.transport.base; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.description.AxisService; + +/** + * Partial implementation of {...@link AbstractTransportListener} with a higher level + * of abstraction. It maintains the mapping between services and protocol specific + * endpoints. + * <p> + * Note: the intention is to eventually merge the code in this class into + * {...@link AbstractTransportListener} + * + * @param <E> the type of protocol endpoint for this transport + */ +public abstract class AbstractTransportListenerEx<E extends ProtocolEndpoint> + extends AbstractTransportListener { + + /** A Map of service name to the protocol endpoints */ + private Map<String,E> endpoints = new HashMap<String,E>(); + + @Override + public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault { + //Strip out the operation name + if (serviceName.indexOf('/') != -1) { + serviceName = serviceName.substring(0, serviceName.indexOf('/')); + } + // strip out the endpoint name if present + if (serviceName.indexOf('.') != -1) { + serviceName = serviceName.substring(0, serviceName.indexOf('.')); + } + E endpoint = endpoints.get(serviceName); + if (endpoint != null) { + return endpoint.getEndpointReferences(ip); + } else { + return null; + } + } + + public final Collection<E> getEndpoints() { + return Collections.unmodifiableCollection(endpoints.values()); + } + + protected abstract E createEndpoint(); + + @Override + protected final void startListeningForService(AxisService service) throws AxisFault { + E endpoint = createEndpoint(); + endpoint.setService(service); + configureAndStartEndpoint(endpoint, service); + endpoints.put(service.getName(), endpoint); + } + + protected abstract void configureAndStartEndpoint(E endpoint, AxisService service) throws AxisFault; + + @Override + protected final void stopListeningForService(AxisService service) { + E endpoint = endpoints.get(service.getName()); + if (endpoint != null) { + stopEndpoint(endpoint); + endpoints.remove(service.getName()); + } else { + log.error("Unable to stop service : " + service.getName() + + " - unable to find the corresponding protocol endpoint"); + } + } + + protected abstract void stopEndpoint(E endpoint); +} Propchange: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/AbstractTransportListenerEx.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java?rev=784542&view=auto ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java (added) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java Sun Jun 14 11:31:37 2009 @@ -0,0 +1,61 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.axis2.transport.base; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.description.AxisService; + +/** + * Describes a protocol specific endpoint. This might be a TCP/UDP port, a mail account, + * a JMS destination, etc. Typically, a protocol specific endpoint is mapped to a + * service. + */ +public abstract class ProtocolEndpoint { + /** Axis2 service */ + private AxisService service; + + public final AxisService getService() { + return service; + } + + // TODO: this should only be called by AbstractTransportListener and declared with package access + public final void setService(AxisService service) { + this.service = service; + } + + public final String getServiceName() { + return service.getName(); + } + + /** + * Get the endpoint references for this protocol endpoint. + * + * @param ip The host name or IP address of the local host. The implementation should use + * this information instead of {...@link java.net.InetAddress#getLocalHost()}. + * The value of this parameter may be <code>null</code>, in which case the + * implementation should use {...@link org.apache.axis2.util.Utils#getIpAddress( + * org.apache.axis2.engine.AxisConfiguration)}. + * @return an array of endpoint references + * @throws AxisFault + * + * @see org.apache.axis2.transport.TransportListener#getEPRsForService(String, String) + */ + public abstract EndpointReference[] getEndpointReferences(String ip) throws AxisFault; +} Propchange: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java (original) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java Sun Jun 14 11:31:37 2009 @@ -20,21 +20,17 @@ import java.io.IOException; import java.net.SocketException; -import java.util.HashMap; -import java.util.Map; import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.TransportInDescription; -import org.apache.axis2.transport.base.AbstractTransportListener; +import org.apache.axis2.transport.base.AbstractTransportListenerEx; import org.apache.axis2.transport.base.ParamUtils; public abstract class AbstractDatagramTransportListener<E extends DatagramEndpoint> - extends AbstractTransportListener { + extends AbstractTransportListenerEx<E> { - private final Map<String,E> endpoints = new HashMap<String,E>(); private DatagramDispatcher<E> dispatcher; private String defaultIp; @@ -61,10 +57,8 @@ } @Override - protected void startListeningForService(AxisService service) throws AxisFault { - E endpoint = createEndpoint(service); + protected void configureAndStartEndpoint(E endpoint, AxisService service) throws AxisFault { endpoint.setListener(this); - endpoint.setService(service); endpoint.setContentType(ParamUtils.getRequiredParam( service, "transport." + getTransportName() + ".contentType")); endpoint.setMetrics(metrics); @@ -73,24 +67,22 @@ dispatcher.addEndpoint(endpoint); } catch (IOException ex) { throw new AxisFault("Unable to listen on endpoint " - + endpoint.getEndpointReference(defaultIp), ex); + + endpoint.getEndpointReferences(defaultIp)[0], ex); } if (log.isDebugEnabled()) { - log.debug("Started listening on endpoint " + endpoint.getEndpointReference(defaultIp) + log.debug("Started listening on endpoint " + endpoint.getEndpointReferences(defaultIp)[0] + " [contentType=" + endpoint.getContentType() + "; service=" + service.getName() + "]"); } - endpoints.put(service.getName(), endpoint); } @Override - protected void stopListeningForService(AxisService service) { + protected void stopEndpoint(E endpoint) { try { - dispatcher.removeEndpoint(endpoints.get(service.getName())); + dispatcher.removeEndpoint(endpoint); } catch (IOException ex) { - log.error("I/O exception while stopping listener for service " + service.getName(), ex); + log.error("I/O exception while stopping listener for service " + endpoint.getServiceName(), ex); } - endpoints.remove(service.getName()); } @Override @@ -103,24 +95,6 @@ } } - public EndpointReference[] getEPRsForService(String serviceName, String ip) throws AxisFault { - - // strip out the endpoint name if present - if (serviceName.indexOf('.') != -1) { - serviceName = serviceName.substring(0, serviceName.indexOf('.')); - } - - E endpoint = endpoints.get(serviceName); - if (endpoint == null) { - return null; - } else { - return new EndpointReference[] { - endpoint.getEndpointReference(ip == null ? defaultIp : ip) }; - } - } - protected abstract DatagramDispatcher<E> createDispatcher(DatagramDispatcherCallback callback) throws IOException; - - protected abstract E createEndpoint(AxisService service) throws AxisFault; } Modified: webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java (original) +++ webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/DatagramEndpoint.java Sun Jun 14 11:31:37 2009 @@ -18,9 +18,8 @@ */ package org.apache.axis2.transport.base.datagram; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.description.AxisService; import org.apache.axis2.transport.base.MetricsCollector; +import org.apache.axis2.transport.base.ProtocolEndpoint; /** * Endpoint description. @@ -30,10 +29,9 @@ * transport specific information, such as the port number * the transport listens on. */ -public abstract class DatagramEndpoint { +public abstract class DatagramEndpoint extends ProtocolEndpoint { private AbstractDatagramTransportListener listener; private String contentType; - private AxisService service; private MetricsCollector metrics; public AbstractDatagramTransportListener getListener() { @@ -52,14 +50,6 @@ this.contentType = contentType; } - public AxisService getService() { - return service; - } - - public void setService(AxisService service) { - this.service = service; - } - public MetricsCollector getMetrics() { return metrics; } @@ -67,6 +57,4 @@ public void setMetrics(MetricsCollector metrics) { this.metrics = metrics; } - - public abstract EndpointReference getEndpointReference(String ip); } Modified: webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java (original) +++ webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSEndpoint.java Sun Jun 14 11:31:37 2009 @@ -15,8 +15,8 @@ */ package org.apache.axis2.transport.jms; -import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; +import org.apache.axis2.transport.base.ProtocolEndpoint; import org.apache.axis2.transport.jms.ctype.ContentTypeRuleSet; import org.apache.axis2.addressing.EndpointReference; @@ -33,27 +33,14 @@ * all the required information to process incoming JMS messages and to inject them * into Axis2. */ -public class JMSEndpoint { +public class JMSEndpoint extends ProtocolEndpoint { private JMSConnectionFactory cf; - private AxisService service; private String jndiDestinationName; private int destinationType = JMSConstants.GENERIC; private Set<EndpointReference> endpointReferences = new HashSet<EndpointReference>(); private ContentTypeRuleSet contentTypeRuleSet; private ServiceTaskManager serviceTaskManager; - public AxisService getService() { - return service; - } - - public void setService(AxisService service) { - this.service = service; - } - - public String getServiceName() { - return service.getName(); - } - public String getJndiDestinationName() { return jndiDestinationName; } @@ -72,7 +59,8 @@ } } - public EndpointReference[] getEndpointReferences() { + @Override + public EndpointReference[] getEndpointReferences(String ip) { return endpointReferences.toArray(new EndpointReference[endpointReferences.size()]); } Modified: webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java (original) +++ webservices/commons/trunk/modules/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSListener.java Sun Jun 14 11:31:37 2009 @@ -17,12 +17,11 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; -import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; import org.apache.axis2.description.TransportInDescription; -import org.apache.axis2.transport.base.AbstractTransportListener; +import org.apache.axis2.transport.base.AbstractTransportListenerEx; import org.apache.axis2.transport.base.BaseConstants; import org.apache.axis2.transport.base.ManagementSupport; import org.apache.axis2.transport.base.event.TransportErrorListener; @@ -33,9 +32,6 @@ import org.apache.axis2.transport.jms.ctype.MessageTypeRule; import org.apache.axis2.transport.jms.ctype.PropertyRule; -import java.util.HashMap; -import java.util.Map; - import javax.jms.BytesMessage; import javax.jms.TextMessage; @@ -56,15 +52,13 @@ * <p> * All Destinations / JMS Administered objects used MUST be pre-created or already available */ -public class JMSListener extends AbstractTransportListener implements ManagementSupport, +public class JMSListener extends AbstractTransportListenerEx<JMSEndpoint> implements ManagementSupport, TransportErrorSource { public static final String TRANSPORT_NAME = Constants.TRANSPORT_JMS; /** The JMSConnectionFactoryManager which centralizes the management of defined factories */ private JMSConnectionFactoryManager connFacManager; - /** A Map of service name to the JMS endpoints */ - private Map<String,JMSEndpoint> serviceNameToEndpointMap = new HashMap<String,JMSEndpoint>(); private final TransportErrorSourceSupport tess = new TransportErrorSourceSupport(this); @@ -82,27 +76,9 @@ log.info("JMS Transport Receiver/Listener initialized..."); } - /** - * Returns EPRs for the given service over the JMS transport - * - * @param serviceName service name - * @return the JMS EPRs for the service - */ - public EndpointReference[] getEPRsForService(String serviceName) { - //Strip out the operation name - if (serviceName.indexOf('/') != -1) { - serviceName = serviceName.substring(0, serviceName.indexOf('/')); - } - // strip out the endpoint name if present - if (serviceName.indexOf('.') != -1) { - serviceName = serviceName.substring(0, serviceName.indexOf('.')); - } - JMSEndpoint endpoint = serviceNameToEndpointMap.get(serviceName); - if (endpoint != null) { - return endpoint.getEndpointReferences(); - } else { - return null; - } + @Override + protected JMSEndpoint createEndpoint() { + return new JMSEndpoint(); } /** @@ -110,15 +86,14 @@ * * @param service the Axis service for which to listen for messages */ - protected void startListeningForService(AxisService service) throws AxisFault { + @Override + protected void configureAndStartEndpoint(JMSEndpoint endpoint, AxisService service) throws AxisFault { JMSConnectionFactory cf = getConnectionFactory(service); if (cf == null) { throw new AxisFault("The service doesn't specify a JMS connection factory or refers " + "to an invalid factory."); } - JMSEndpoint endpoint = new JMSEndpoint(); - endpoint.setService(service); endpoint.setCf(cf); Parameter destParam = service.getParameter(JMSConstants.PARAM_DESTINATION); @@ -161,8 +136,6 @@ stm.start(); endpoint.setServiceTaskManager(stm); - serviceNameToEndpointMap.put(service.getName(), endpoint); - for (int i=0; i<3; i++) { if (stm.getActiveTaskCount() > 0) { log.info("Started to listen on destination : " + stm.getDestinationJNDIName() + @@ -185,26 +158,19 @@ * * @param service the service that was undeployed or stopped */ - protected void stopListeningForService(AxisService service) { - - JMSEndpoint endpoint = serviceNameToEndpointMap.get(service.getName()); - if (endpoint != null) { - ServiceTaskManager stm = endpoint.getServiceTaskManager(); - if (log.isDebugEnabled()) { - log.debug("Stopping listening on destination : " + stm.getDestinationJNDIName() + - " for service : " + stm.getServiceName()); - } - - stm.stop(); + @Override + protected void stopEndpoint(JMSEndpoint endpoint) { + ServiceTaskManager stm = endpoint.getServiceTaskManager(); + if (log.isDebugEnabled()) { + log.debug("Stopping listening on destination : " + stm.getDestinationJNDIName() + + " for service : " + stm.getServiceName()); + } - serviceNameToEndpointMap.remove(service.getName()); - log.info("Stopped listening for JMS messages to service : " + service.getName()); + stm.stop(); - } else { - log.error("Unable to stop service : " + service.getName() + - " - unable to find its ServiceTaskManager"); - } + log.info("Stopped listening for JMS messages to service : " + endpoint.getServiceName()); } + /** * Return the connection factory name for this service. If this service * refers to an invalid factory or defaults to a non-existent default @@ -233,7 +199,7 @@ public void pause() throws AxisFault { if (state != BaseConstants.STARTED) return; try { - for (JMSEndpoint endpoint : serviceNameToEndpointMap.values()) { + for (JMSEndpoint endpoint : getEndpoints()) { endpoint.getServiceTaskManager().pause(); } state = BaseConstants.PAUSED; @@ -250,7 +216,7 @@ public void resume() throws AxisFault { if (state != BaseConstants.PAUSED) return; try { - for (JMSEndpoint endpoint : serviceNameToEndpointMap.values()) { + for (JMSEndpoint endpoint : getEndpoints()) { endpoint.getServiceTaskManager().resume(); } state = BaseConstants.STARTED; Modified: webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java (original) +++ webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java Sun Jun 14 11:31:37 2009 @@ -86,8 +86,9 @@ private long reconnectTimeout; @Override - public EndpointReference getEndpointReference() { - return new EndpointReference(MailConstants.TRANSPORT_PREFIX + emailAddress); + public EndpointReference[] getEndpointReferences(String ip) { + return new EndpointReference[] { new EndpointReference(MailConstants.TRANSPORT_PREFIX + + emailAddress) }; } public InternetAddress getEmailAddress() { Modified: webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java (original) +++ webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java Sun Jun 14 11:31:37 2009 @@ -18,8 +18,12 @@ */ package org.apache.axis2.transport.udp; +import java.net.SocketException; + +import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.transport.base.datagram.DatagramEndpoint; +import org.apache.axis2.util.Utils; /** * UDP endpoint description. @@ -44,7 +48,16 @@ this.maxPacketSize = maxPacketSize; } - public EndpointReference getEndpointReference(String ip) { - return new EndpointReference("udp://" + ip + ":" + getPort() + "?contentType=" + getContentType()); + @Override + public EndpointReference[] getEndpointReferences(String ip) throws AxisFault { + if (ip == null) { + try { + ip = Utils.getIpAddress(getListener().getConfigurationContext().getAxisConfiguration()); + } catch (SocketException ex) { + throw new AxisFault("Unable to determine the host's IP address", ex); + } + } + return new EndpointReference[] { new EndpointReference("udp://" + ip + ":" + getPort() + + "?contentType=" + getContentType()) }; } } Modified: webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java?rev=784542&r1=784541&r2=784542&view=diff ============================================================================== --- webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java (original) +++ webservices/commons/trunk/modules/transport/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPListener.java Sun Jun 14 11:31:37 2009 @@ -54,10 +54,14 @@ } @Override - protected Endpoint createEndpoint(AxisService service) throws AxisFault { - Endpoint endpoint = new Endpoint(); - endpoint.setPort(ParamUtils.getRequiredParamInt(service, UDPConstants.PORT_KEY)); - endpoint.setMaxPacketSize(ParamUtils.getOptionalParamInt(service, UDPConstants.MAX_PACKET_SIZE_KEY, UDPConstants.DEFAULT_MAX_PACKET_SIZE)); - return endpoint; + protected Endpoint createEndpoint() { + return new Endpoint(); + } + + @Override + protected void configureAndStartEndpoint(Endpoint endpoint, AxisService service) throws AxisFault { + endpoint.setPort(ParamUtils.getRequiredParamInt(service, UDPConstants.PORT_KEY)); + endpoint.setMaxPacketSize(ParamUtils.getOptionalParamInt(service, UDPConstants.MAX_PACKET_SIZE_KEY, UDPConstants.DEFAULT_MAX_PACKET_SIZE)); + super.configureAndStartEndpoint(endpoint, service); } }