mirror of https://github.com/apache/activemq.git
Refactorings of the transport/service base classes
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@384222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
436fe42778
commit
1ccd7bdbf0
|
@ -21,6 +21,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
|
|||
|
||||
import org.apache.activemq.command.Command;
|
||||
import org.apache.activemq.transport.TransportSupport;
|
||||
import org.apache.activemq.util.ServiceStopper;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
|
@ -44,13 +45,13 @@ public class BlockingQueueTransport extends TransportSupport {
|
|||
return queue;
|
||||
}
|
||||
|
||||
public void start() throws JMSException {
|
||||
}
|
||||
|
||||
public void oneway(Command command) throws IOException {
|
||||
queue.add(command);
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
protected void doStart() throws Exception {
|
||||
}
|
||||
|
||||
protected void doStop(ServiceStopper stopper) throws Exception {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class HttpClientTransport extends HttpTransportSupport {
|
|||
log.trace("HTTP GET consumer thread starting: " + this);
|
||||
HttpClient httpClient = getReceiveHttpClient();
|
||||
URI remoteUrl = getRemoteUrl();
|
||||
while (!isClosed()) {
|
||||
while (!isStopped()) {
|
||||
|
||||
GetMethod httpMethod = new GetMethod(remoteUrl.toString());
|
||||
configureMethod(httpMethod);
|
||||
|
|
|
@ -75,7 +75,7 @@ public class HttpTransport extends HttpTransportSupport {
|
|||
public void run() {
|
||||
log.trace("HTTP GET consumer thread starting for transport: " + this);
|
||||
URI remoteUrl = getRemoteUrl();
|
||||
while (!isClosed()) {
|
||||
while (!isStopped()) {
|
||||
try {
|
||||
HttpURLConnection connection = getReceiveConnection();
|
||||
int answer = connection.getResponseCode();
|
||||
|
@ -100,7 +100,7 @@ public class HttpTransport extends HttpTransportSupport {
|
|||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (!isClosed()) {
|
||||
if (!isStopped()) {
|
||||
log.warn("Failed to perform GET on: " + remoteUrl + " due to: " + e, e);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.activemq.command.BrokerInfo;
|
|||
import org.apache.activemq.transport.TransportServerSupport;
|
||||
import org.apache.activemq.transport.util.TextWireFormat;
|
||||
import org.apache.activemq.transport.xstream.XStreamWireFormat;
|
||||
import org.apache.activemq.util.ServiceStopper;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.bio.SocketConnector;
|
||||
|
@ -46,7 +47,33 @@ public class HttpTransportServer extends TransportServerSupport {
|
|||
this.bindAddress = uri;
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
public void setBrokerInfo(BrokerInfo brokerInfo) {
|
||||
}
|
||||
|
||||
// Properties
|
||||
// -------------------------------------------------------------------------
|
||||
public TextWireFormat getWireFormat() {
|
||||
if (wireFormat == null) {
|
||||
wireFormat = createWireFormat();
|
||||
}
|
||||
return wireFormat;
|
||||
}
|
||||
|
||||
public void setWireFormat(TextWireFormat wireFormat) {
|
||||
this.wireFormat = wireFormat;
|
||||
}
|
||||
|
||||
// Implementation methods
|
||||
// -------------------------------------------------------------------------
|
||||
protected TextWireFormat createWireFormat() {
|
||||
return new XStreamWireFormat();
|
||||
}
|
||||
|
||||
protected void setConnector(Connector connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
protected void doStart() throws Exception {
|
||||
server = new Server();
|
||||
if (connector==null)
|
||||
connector = new SocketConnector();
|
||||
|
@ -81,7 +108,7 @@ public class HttpTransportServer extends TransportServerSupport {
|
|||
server.start();
|
||||
}
|
||||
|
||||
public synchronized void stop() throws Exception {
|
||||
protected void doStop(ServiceStopper stopper) throws Exception {
|
||||
Server temp = server;
|
||||
server = null;
|
||||
if (temp != null) {
|
||||
|
@ -89,29 +116,4 @@ public class HttpTransportServer extends TransportServerSupport {
|
|||
}
|
||||
}
|
||||
|
||||
// Properties
|
||||
// -------------------------------------------------------------------------
|
||||
public TextWireFormat getWireFormat() {
|
||||
if (wireFormat == null) {
|
||||
wireFormat = createWireFormat();
|
||||
}
|
||||
return wireFormat;
|
||||
}
|
||||
|
||||
public void setWireFormat(TextWireFormat wireFormat) {
|
||||
this.wireFormat = wireFormat;
|
||||
}
|
||||
|
||||
// Implementation methods
|
||||
// -------------------------------------------------------------------------
|
||||
protected TextWireFormat createWireFormat() {
|
||||
return new XStreamWireFormat();
|
||||
}
|
||||
|
||||
protected void setConnector(Connector connector) {
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
public void setBrokerInfo(BrokerInfo brokerInfo) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue