Skip to content
Permalink
Browse files
AXIS2-4722: Introduced an abstract doInit method in AbstractTransport…
…ListenerEx so that derived classes can properly do their initialization stuff before the first endpoint is created.
  • Loading branch information
veithen committed May 23, 2010
1 parent 2907276 commit 1d8233c101d27ddfb414742efe147237170a1189
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 50 deletions.
@@ -18,8 +18,6 @@
*/
package org.apache.axis2.transport.base;

import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.AxisFault;

import java.util.ArrayList;
@@ -36,11 +34,8 @@
private final List<T> endpoints = new ArrayList<T>();

@Override
public void init(ConfigurationContext cfgCtx,
TransportInDescription transportIn) throws AxisFault {

protected void doInit() throws AxisFault {
timer = new Timer("PollTimer");
super.init(cfgCtx, transportIn);
}

@Override
@@ -347,6 +347,10 @@ protected void logException(String msg, Exception e) {
log.error(msg, e);
}

public TransportInDescription getTransportInDescription() {
return transportIn;
}

public String getTransportName() {
return transportIn.getName();
}
@@ -48,11 +48,13 @@
protected boolean useGlobalListener = false;

@Override
public void init(ConfigurationContext cfgCtx,
public final void init(ConfigurationContext cfgCtx,
TransportInDescription transportIn) throws AxisFault {

super.init(cfgCtx, transportIn);

doInit();

// Create endpoint configured at transport level (if available)
E endpoint = createEndpoint();
endpoint.init(this, null);
@@ -62,6 +64,15 @@ public void init(ConfigurationContext cfgCtx,
}
}

/**
* Initialize the transport. This method will be called after the initialization work in
* {@link AbstractTransportListener} and before the first endpoint is created, i.e. before the
* first call to {@link #createEndpoint()}.
*
* @throws AxisFault
*/
protected abstract void doInit() throws AxisFault;

@Override
public void destroy() {
// Explicitly stop all endpoints not predispatched to services. All other endpoints will
@@ -23,8 +23,6 @@
import java.net.SocketAddress;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.transport.base.AbstractTransportListenerEx;

public abstract class AbstractDatagramTransportListener<E extends DatagramEndpoint>
@@ -33,19 +31,8 @@
private DatagramDispatcher<E> dispatcher;
private String defaultIp;

@Override
public void init(ConfigurationContext cfgCtx, TransportInDescription transportIn)
throws AxisFault {

super.init(cfgCtx, transportIn);
initDispatcher();
}

private void initDispatcher() throws AxisFault {
if (dispatcher != null) {
return;
}

@Override
protected void doInit() throws AxisFault {
DatagramDispatcherCallback callback = new DatagramDispatcherCallback() {

public void receive(SocketAddress address,
@@ -80,8 +67,6 @@ protected final E createEndpoint() {

@Override
protected void startEndpoint(E endpoint) throws AxisFault {
initDispatcher();

try {
dispatcher.addEndpoint(endpoint);
} catch (IOException ex) {
@@ -17,10 +17,8 @@

import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
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.AbstractTransportListenerEx;
import org.apache.axis2.transport.base.BaseConstants;
import org.apache.axis2.transport.base.ManagementSupport;
@@ -55,18 +53,9 @@ public class JMSListener extends AbstractTransportListenerEx<JMSEndpoint> implem

private final TransportErrorSourceSupport tess = new TransportErrorSourceSupport(this);

/**
* TransportListener initialization
*
* @param cfgCtx the Axis configuration context
* @param trpInDesc the TransportIn description
*/
@Override
public void init(ConfigurationContext cfgCtx,
TransportInDescription trpInDesc) throws AxisFault {

super.init(cfgCtx, trpInDesc);
connFacManager = new JMSConnectionFactoryManager(trpInDesc);
protected void doInit() throws AxisFault {
connFacManager = new JMSConnectionFactoryManager(getTransportInDescription());
log.info("JMS Transport Receiver/Listener initialized...");
}

@@ -22,9 +22,7 @@
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.context.MessageContext;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.transport.TransportUtils;
import org.apache.axis2.transport.RequestResponseTransport;
@@ -68,18 +66,9 @@ public class MailTransportListener extends AbstractPollingTransportListener<Poll

private final TransportErrorSourceSupport tess = new TransportErrorSourceSupport(this);

/**
* Initializes the Mail transport
*
* @param cfgCtx the Axsi2 configuration context
* @param trpInDesc the POP3 transport in description from the axis2.xml
* @throws AxisFault on error
*/
@Override
public void init(ConfigurationContext cfgCtx, TransportInDescription trpInDesc)
throws AxisFault {
super.init(cfgCtx, trpInDesc);

protected void doInit() throws AxisFault {
super.doInit();
// set the synchronise callback table
if (cfgCtx.getProperty(BaseConstants.CALLBACK_TABLE) == null){
cfgCtx.setProperty(BaseConstants.CALLBACK_TABLE, new ConcurrentHashMap());

0 comments on commit 1d8233c

Please sign in to comment.