Skip to content
Permalink
Browse files
https://issues.apache.org/jira/browse/OPENWIRE-11
Initial work to remove JMS dependency.
  • Loading branch information
tabish121 committed Dec 4, 2015
1 parent 0c90d2e commit 71efcd78abba5994df861eb93386623b1fa8683b
Showing 24 changed files with 281 additions and 687 deletions.
@@ -48,10 +48,6 @@
<groupId>org.fusesource.hawtbuf</groupId>
<artifactId>hawtbuf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
</dependency>

<!-- =================================== -->
<!-- Testing Dependencies -->
@@ -28,13 +28,11 @@
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;

import javax.jms.JMSException;

import org.apache.activemq.openwire.annotations.OpenWireExtension;
import org.apache.activemq.openwire.annotations.OpenWireProperty;
import org.apache.activemq.openwire.annotations.OpenWireType;
import org.apache.activemq.openwire.codec.OpenWireFormat;
import org.apache.activemq.openwire.utils.ExceptionSupport;
import org.apache.activemq.openwire.utils.IOExceptionSupport;
import org.apache.activemq.openwire.utils.OpenWireMarshallingSupport;
import org.fusesource.hawtbuf.Buffer;
import org.fusesource.hawtbuf.ByteArrayInputStream;
@@ -43,8 +41,6 @@

/**
* Represents an ActiveMQ message
*
* @openwire:marshaller
*/
@OpenWireType(typeCode = 0, marshalAware = true)
public abstract class Message extends BaseCommand implements MarshallAware {
@@ -153,12 +149,12 @@ public abstract class Message extends BaseCommand implements MarshallAware {
protected Map<String, Object> properties;

public abstract Message copy();
public abstract void clearBody() throws JMSException;
public abstract void clearBody() throws IOException;
public abstract void storeContent();
public abstract void storeContentAndClear();

// useful to reduce the memory footprint of a persisted message
public void clearMarshalledState() throws JMSException {
public void clearMarshalledState() throws IOException {
properties = null;
}

@@ -216,20 +212,20 @@ public Map<String, Object> getProperties() throws IOException {
return Collections.unmodifiableMap(properties);
}

public void clearProperties() throws JMSException {
public void clearProperties() throws IOException {
marshalledProperties = null;
properties = null;
}

public Object getProperty(String name) throws JMSException {
public Object getProperty(String name) throws IOException {
if (properties == null) {
if (marshalledProperties == null) {
return null;
}
try {
properties = unmarsallProperties(marshalledProperties);
} catch (IOException e) {
throw ExceptionSupport.create("Error during properties unmarshal, reason: " + e.getMessage(), e);
} catch (Exception e) {
throw IOExceptionSupport.create("Error during properties unmarshal, reason: " + e.getMessage(), e);
}
}
Object result = properties.get(name);
@@ -240,25 +236,25 @@ public Object getProperty(String name) throws JMSException {
return result;
}

public void setProperty(String name, Object value) throws JMSException {
public void setProperty(String name, Object value) throws IOException {
lazyCreateProperties();
properties.put(name, value);
}

public void removeProperty(String name) throws JMSException {
public void removeProperty(String name) throws IOException {
lazyCreateProperties();
properties.remove(name);
}

protected void lazyCreateProperties() throws JMSException {
protected void lazyCreateProperties() throws IOException {
if (properties == null) {
if (marshalledProperties == null) {
properties = new HashMap<String, Object>();
} else {
try {
properties = unmarsallProperties(marshalledProperties);
} catch (IOException e) {
throw ExceptionSupport.create(
} catch (Exception e) {
throw IOExceptionSupport.create(
"Error during properties unmarshal, reason: " + e.getMessage(), e);
}
marshalledProperties = null;
@@ -17,20 +17,15 @@
package org.apache.activemq.openwire.commands;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import javax.jms.JMSException;

import org.apache.activemq.openwire.annotations.OpenWireType;
import org.apache.activemq.openwire.annotations.OpenWireExtension;
import org.apache.activemq.openwire.annotations.OpenWireProperty;
import org.apache.activemq.openwire.annotations.OpenWireType;

/**
* An implementation of ActiveMQ's BlobMessage for out of band BLOB transfer
*
* openwire:marshaller code="29"
*/
@OpenWireType(typeCode = 29, version = 3)
public class OpenWireBlobMessage extends OpenWireMessage {
@@ -126,16 +121,12 @@ public void setDeletedByBroker(boolean deletedByBroker) {
this.deletedByBroker = deletedByBroker;
}

public InputStream getInputStream() throws IOException, JMSException {
return null;
}

public URL getURL() throws JMSException {
public URL getURL() throws IOException {
if (url == null && remoteBlobUrl != null) {
try {
url = new URL(remoteBlobUrl);
} catch (MalformedURLException e) {
throw new JMSException(e.getMessage());
throw new IOException(e.getMessage());
}
}
return url;
@@ -145,16 +136,4 @@ public void setURL(URL url) {
this.url = url;
remoteBlobUrl = url != null ? url.toExternalForm() : null;
}

@Override
public void onSend() throws JMSException {
super.onSend();

// lets ensure we upload the BLOB first out of band before we send the
// message
// TODO - Lets support this later.
}

public void deleteFile() throws IOException, JMSException {
}
}
@@ -21,9 +21,6 @@
import java.util.zip.Deflater;
import java.util.zip.Inflater;

import javax.jms.JMSException;
import javax.jms.MessageNotReadableException;

import org.apache.activemq.openwire.annotations.OpenWireType;
import org.fusesource.hawtbuf.Buffer;
import org.fusesource.hawtbuf.BufferEditor;
@@ -70,12 +67,10 @@ public String getMimeType() {
* of where the pointer for reading the message is currently located.
*
* @return number of bytes in the message
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageNotReadableException if the message is in write-only mode.
* @since 1.1
*
* @throws IOException if there is an error in retrieving the body length value.
*/
public long getBodyLength() throws JMSException {
public long getBodyLength() throws IOException {
if (compressed) {
return getBodyBytes().length;
} else if (content != null) {
@@ -96,9 +91,9 @@ public long getBodyLength() throws JMSException {
*
* @return a copy of the message contents, uncompressed as needed.
*
* @throws JMSException if an error occurs while accessing the message payload.
* @throws IOException if an error occurs while accessing the message payload.
*/
public byte[] getBodyBytes() throws JMSException {
public byte[] getBodyBytes() throws IOException {
Buffer data = getPayload();
if (data == null) {
data = new Buffer(new byte[] {}, 0, 0);
@@ -26,27 +26,16 @@
import java.util.Set;
import java.util.StringTokenizer;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.TemporaryQueue;
import javax.jms.TemporaryTopic;
import javax.jms.Topic;

import org.apache.activemq.openwire.annotations.OpenWireType;
import org.apache.activemq.openwire.annotations.OpenWireExtension;
import org.apache.activemq.openwire.annotations.OpenWireProperty;
import org.apache.activemq.openwire.utils.DefaultUnresolvedDestinationTransformer;
import org.apache.activemq.openwire.utils.UnresolvedDestinationTransformer;
import org.apache.activemq.openwire.annotations.OpenWireType;

/**
* Base Destination class used to provide most of the utilities necessary to deal
* with incoming and outgoing destination processing.
*
* @openwire:marshaller
*/
@OpenWireType(typeCode = 0)
public abstract class OpenWireDestination implements Destination, DataStructure, Comparable<OpenWireDestination> {
public abstract class OpenWireDestination implements DataStructure, Comparable<OpenWireDestination> {

public static final String PATH_SEPERATOR = ".";
public static final char COMPOSITE_SEPERATOR = ',';
@@ -82,8 +71,6 @@ public abstract class OpenWireDestination implements Destination, DataStructure,
@OpenWireExtension(serialized = true)
protected Map<String, String> options;

protected static UnresolvedDestinationTransformer unresolvableDestinationTransformer = new DefaultUnresolvedDestinationTransformer();

public OpenWireDestination() {
}

@@ -122,40 +109,6 @@ public static OpenWireDestination createDestination(String name, byte defaultTyp
}
}

public static OpenWireDestination transform(Destination dest) throws JMSException {
if (dest == null) {
return null;
}
if (dest instanceof OpenWireDestination) {
return (OpenWireDestination)dest;
}

if (dest instanceof Queue && dest instanceof Topic) {
String queueName = ((Queue) dest).getQueueName();
String topicName = ((Topic) dest).getTopicName();
if (queueName != null && topicName == null) {
return new OpenWireQueue(queueName);
} else if (queueName == null && topicName != null) {
return new OpenWireTopic(topicName);
} else {
return unresolvableDestinationTransformer.transform(dest);
}
}
if (dest instanceof TemporaryQueue) {
return new OpenWireTempQueue(((TemporaryQueue)dest).getQueueName());
}
if (dest instanceof TemporaryTopic) {
return new OpenWireTempTopic(((TemporaryTopic)dest).getTopicName());
}
if (dest instanceof Queue) {
return new OpenWireQueue(((Queue)dest).getQueueName());
}
if (dest instanceof Topic) {
return new OpenWireTopic(((Topic)dest).getTopicName());
}
throw new JMSException("Could not transform the destination into a ActiveMQ destination: " + dest);
}

public static int compare(OpenWireDestination destination, OpenWireDestination destination2) {
if (destination == destination2) {
return 0;
@@ -379,14 +332,6 @@ public boolean isPattern() {
return isPattern;
}

public static UnresolvedDestinationTransformer getUnresolvableDestinationTransformer() {
return unresolvableDestinationTransformer;
}

public static void setUnresolvableDestinationTransformer(UnresolvedDestinationTransformer unresolvableDestinationTransformer) {
OpenWireDestination.unresolvableDestinationTransformer = unresolvableDestinationTransformer;
}

private static Map<String, String> parseQuery(String uri) throws Exception {
if (uri != null) {
Map<String, String> rc = new HashMap<String, String>();

0 comments on commit 71efcd7

Please sign in to comment.