activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r476194 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands: ActiveMQMessage.cpp ActiveMQMessage.h
Date Fri, 17 Nov 2006 16:23:16 GMT
Author: tabish
Date: Fri Nov 17 08:23:16 2006
New Revision: 476194

URL: http://svn.apache.org/viewvc?view=rev&rev=476194
Log:
Changes to support new Openwire Functionality

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.cpp?view=diff&rev=476194&r1=476193&r2=476194
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.cpp
Fri Nov 17 08:23:16 2006
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 #include <activemq/connector/openwire/commands/ActiveMQMessage.h>
+#include <activemq/connector/openwire/OpenWireFormat.h>
 
 using namespace std;
 using namespace activemq;
@@ -35,3 +36,12 @@
     return ActiveMQMessage::ID_ACTIVEMQMESSAGE; 
 }
 
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQMessage::beforeMarshall( OpenWireFormat* wireFormat )
+{
+//    marshalledProperties.clear();
+//    if( !properties.empty() )
+//    {
+//        properties.Marshal( marshalledProperties );
+//    }
+}

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h?view=diff&rev=476194&r1=476193&r2=476194
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMessage.h
Fri Nov 17 08:23:16 2006
@@ -51,6 +51,23 @@
             ActiveMQMessage::copyDataStructure( src );
         }
 
+        /**
+         * Indicates that this command is aware of Marshalling, and needs
+         * to have its Marshalling methods invoked.
+         * @returns boolean indicating desire to be in marshalling stages
+         */
+        virtual bool IsMarshallAware() {
+            return true;
+        }
+        
+        /**
+         * Handles the marshalling of the objects properties into the 
+         * internal byte array before the object is marshalled to the
+         * wire
+         * @param wireFormat - the wireformatting controller
+         */
+        virtual void beforeMarshall( OpenWireFormat* wireFormat );
+
     public:   // core::ActiveMQMessage
     
         /**
@@ -89,540 +106,3 @@
 }}}}
 
 #endif /*_ACTIVEMQ_CONNECTOR_OPENWIRE_COMMANDS_ACTIVEMQMESSAGE_H_*/
-
-//
-//import java.io.IOException;
-//import java.io.UnsupportedEncodingException;
-//import java.util.Enumeration;
-//import java.util.HashMap;
-//import java.util.Iterator;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.Vector;
-//
-//import javax.jms.DeliveryMode;
-//import javax.jms.Destination;
-//import javax.jms.JMSException;
-//import javax.jms.MessageFormatException;
-//import javax.jms.MessageNotWriteableException;
-//
-//import org.apache.activemq.ActiveMQConnection;
-//import org.apache.activemq.filter.PropertyExpression;
-//import org.apache.activemq.state.CommandVisitor;
-//import org.apache.activemq.util.Callback;
-//import org.apache.activemq.util.JMSExceptionSupport;
-//import org.apache.activemq.util.TypeConversionSupport;
-//
-///**
-// * @openwire:marshaller code="23"
-// * 
-// * @version $Revision:$
-// */
-//public class ActiveMQMessage extends Message implements javax.jms.Message {
-//
-//
-//
-//    public Message copy() {
-//        ActiveMQMessage copy = new ActiveMQMessage();
-//        copy(copy);
-//        return copy;
-//    }
-//
-//
-//    protected void copy(ActiveMQMessage copy) {
-//        super.copy(copy);
-//        copy.acknowledgeCallback = acknowledgeCallback;
-//    }
-//
-//    public void clearBody() throws JMSException {
-//        setContent(null);
-//        readOnlyBody = false;
-//    }
-//
-//    public String getJMSMessageID() {
-//        MessageId messageId = this.getMessageId();
-//        if (messageId == null) {
-//            return null;
-//        }
-//        return messageId.toString();
-//    }
-//
-//    /**
-//     * Seems to be invalid because the parameter doesn't initialize MessageId instance
variables ProducerId and
-//     * ProducerSequenceId
-//     *
-//     * @param value
-//     * @throws JMSException
-//     */
-//    public void setJMSMessageID(String value) throws JMSException {
-//        if( value !=null ) {
-//            try {
-//                MessageId id = new MessageId(value);
-//                this.setMessageId(id);
-//            }
-//            catch (NumberFormatException e) {
-//                // we must be some foreign JMS provider or strange user-supplied String
-//                // so lets set the IDs to be 1
-//                MessageId id = new MessageId();
-//                id.setTextView(value);
-//                this.setMessageId(messageId);
-//            }
-//        } else {
-//            this.setMessageId(null);
-//        }
-//    }
-//
-//    /**
-//     * This will create an object of MessageId. For it to be valid, the instance variable
ProducerId and
-//     * producerSequenceId must be initialized.
-//     *
-//     * @param producerId
-//     * @param producerSequenceId
-//     * @throws JMSException
-//     */
-//    public void setJMSMessageID(ProducerId producerId, long producerSequenceId) throws
JMSException {
-//        MessageId id = null;
-//        try {
-//            id = new MessageId(producerId, producerSequenceId);
-//            this.setMessageId(id);
-//        } catch (Throwable e) {
-//            throw JMSExceptionSupport.create("Invalid message id '" + id + "', reason:
" + e.getMessage(), e);
-//        }
-//    }
-//
-//    public long getJMSTimestamp() {
-//        return this.getTimestamp();
-//    }
-//
-//    public void setJMSTimestamp(long timestamp) {
-//        this.setTimestamp(timestamp);
-//    }
-//
-//    public String getJMSCorrelationID() {
-//        return this.getCorrelationId();
-//    }
-//
-//    public void setJMSCorrelationID(String correlationId) {
-//        this.setCorrelationId(correlationId);
-//    }
-//
-//    public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
-//        return encodeString(this.getCorrelationId());
-//    }
-//
-//    public void setJMSCorrelationIDAsBytes(byte[] correlationId) throws JMSException {
-//        this.setCorrelationId(decodeString(correlationId));
-//    }
-//    
-//    static protected String decodeString(byte[] data) throws JMSException {
-//        try {
-//            if (data == null) {
-//                return null;
-//            }
-//            return new String(data, "UTF-8");
-//        } catch (UnsupportedEncodingException e) {
-//            throw new JMSException("Invalid UTF-8 encoding: " + e.getMessage());
-//        }
-//    }
-//
-//    static protected byte[] encodeString(String data) throws JMSException {
-//        try {
-//            if (data == null) {
-//                return null;
-//            }
-//            return data.getBytes("UTF-8");
-//        } catch (UnsupportedEncodingException e) {
-//            throw new JMSException("Invalid UTF-8 encoding: " + e.getMessage());
-//        }
-//    }
-//
-//    public Destination getJMSReplyTo() {
-//        return this.getReplyTo();
-//    }
-//
-//    public void setJMSReplyTo(Destination destination) throws JMSException {
-//        this.setReplyTo(ActiveMQDestination.transform(destination));
-//    }
-//
-//    public Destination getJMSDestination() {
-//        return this.getDestination();
-//    }
-//
-//    public void setJMSDestination(Destination destination) throws JMSException {
-//        this.setDestination(ActiveMQDestination.transform(destination));
-//    }
-//
-//    public int getJMSDeliveryMode() {
-//        return this.isPersistent() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
-//    }
-//
-//    public void setJMSDeliveryMode(int mode) {
-//        this.setPersistent(mode==DeliveryMode.PERSISTENT);
-//    }
-//
-//    public boolean getJMSRedelivered() {
-//        return this.isRedelivered();
-//    }
-//
-//    public void setJMSRedelivered(boolean redelivered) {
-//        this.setRedelivered(redelivered);
-//    }
-//
-//    public String getJMSType() {
-//        return this.getType();
-//    }
-//
-//    public void setJMSType(String type) {
-//        this.setType(type);
-//    }
-//
-//    public long getJMSExpiration() {
-//        return this.getExpiration();
-//    }
-//
-//    public void setJMSExpiration(long expiration) {
-//        this.setExpiration(expiration);
-//    }
-//
-//    public int getJMSPriority() {
-//        return this.getPriority();
-//    }
-//
-//    public void setJMSPriority(int priority) {
-//        this.setPriority((byte) priority);
-//    }
-//
-//    public void clearProperties() {
-//        super.clearProperties();
-//        readOnlyProperties = false;
-//    }
-//
-//    public boolean propertyExists(String name) throws JMSException {
-//        try {
-//            return this.getProperties().containsKey(name);
-//        } catch (IOException e) {
-//            throw JMSExceptionSupport.create(e);
-//        }
-//    }
-//
-//    public Enumeration getPropertyNames() throws JMSException {
-//        try {
-//            return new Vector(this.getProperties().keySet()).elements();
-//        } catch (IOException e) {
-//            throw JMSExceptionSupport.create(e);
-//        }
-//    }
-//
-//    interface PropertySetter {
-//        public void set(Message message, Object value) throws MessageFormatException;
-//    }
-//    
-//    static final private HashMap JMS_PROPERTY_SETERS = new HashMap();  
-//    static {
-//        JMS_PROPERTY_SETERS.put("JMSXDeliveryCount", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSXDeliveryCount cannot
be set from a "+value.getClass().getName()+".");
-//                }
-//                message.setRedeliveryCounter(rc.intValue()-1);
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSXGroupID", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                String rc = (String)TypeConversionSupport.convert(value, String.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSXGroupID cannot be set
from a "+value.getClass().getName()+".");
-//                }
-//                message.setGroupID(rc);
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSXGroupSeq", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSXGroupSeq cannot be set
from a "+value.getClass().getName()+".");
-//                }
-//                message.setGroupSequence(rc.intValue());
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSCorrelationID", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                String rc = (String)TypeConversionSupport.convert(value, String.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSCorrelationID cannot
be set from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSCorrelationID(rc);
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSExpiration", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Long rc = (Long)TypeConversionSupport.convert(value, Long.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSExpiration cannot be
set from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSExpiration(rc.longValue());
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSPriority", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSPriority cannot be set
from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSPriority(rc.intValue());
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSRedelivered", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Boolean rc = (Boolean)TypeConversionSupport.convert(value, Boolean.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSRedelivered cannot be
set from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSRedelivered(rc.booleanValue());
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSReplyTo", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                ActiveMQDestination rc = (ActiveMQDestination)TypeConversionSupport.convert(value,
ActiveMQDestination.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSReplyTo cannot be set
from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setReplyTo(rc);
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSTimestamp", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                Long rc = (Long)TypeConversionSupport.convert(value, Long.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSTimestamp cannot be set
from a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSTimestamp(rc.longValue());
-//            }
-//        });
-//        JMS_PROPERTY_SETERS.put("JMSType", new PropertySetter() {
-//            public void set(Message message, Object value) throws MessageFormatException
{
-//                String rc = (String)TypeConversionSupport.convert(value, String.class);
-//                if( rc == null ) {
-//                    throw new MessageFormatException("Property JMSType cannot be set from
a "+value.getClass().getName()+".");
-//                }
-//                ((ActiveMQMessage)message).setJMSType(rc);
-//            }
-//        });
-//    }
-//
-//    public void setObjectProperty(String name, Object value) throws JMSException {
-//        checkReadOnlyProperties();
-//        if (name == null || name.equals("")) {
-//            throw new IllegalArgumentException("Property name cannot be empty or null");
-//        }
-//        
-//        checkValidObject(value);
-//        PropertySetter setter = (PropertySetter) JMS_PROPERTY_SETERS.get(name);
-//        
-//        if( setter != null ) {
-//            setter.set(this,value);
-//        } else {
-//            try {
-//                this.setProperty(name, value);
-//            } catch (IOException e) {
-//                throw JMSExceptionSupport.create(e);
-//            }
-//        }
-//    }
-//    
-//    public void setProperties(Map properties) throws JMSException {
-//        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
-//            Map.Entry entry = (Map.Entry) iter.next();
-//            
-//            // Lets use the object property method as we may contain standard extension
headers like JMSXGroupID
-//            setObjectProperty((String) entry.getKey(), entry.getValue());
-//        }
-//    }
-//    
-//
-//    protected void checkValidObject(Object value) throws MessageFormatException {
-//        if (!(value instanceof Boolean || value instanceof Byte || value instanceof Short
|| value instanceof Integer || value instanceof Long
-//                || value instanceof Float || value instanceof Double || value instanceof
Character || value instanceof String || value == null)) {
-//
-//            ActiveMQConnection conn = getConnection();
-//            // conn is null if we are in the broker rather than a JMS client
-//            if (conn == null || conn.isNestedMapAndListEnabled()) {
-//                if (!(value instanceof Map || value instanceof List)) {
-//                    throw new MessageFormatException("Only objectified primitive objects,
String, Map and List types are allowed but was: " + value + " type: "
-//                            + value.getClass());
-//                }
-//            }
-//            else {
-//                throw new MessageFormatException("Only objectified primitive objects and
String types are allowed but was: " + value + " type: "
-//                        + value.getClass());
-//            }
-//        }
-//    }
-//
-//    public Object getObjectProperty(String name) throws JMSException {
-//        if (name == null) {
-//            throw new NullPointerException("Property name cannot be null");
-//        }
-//        
-//        // PropertyExpression handles converting message headers to properties.
-//        PropertyExpression expression = new PropertyExpression(name);
-//        return expression.evaluate(this);
-//    }
-//
-//    public boolean getBooleanProperty(String name) throws JMSException {        
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            return false;        
-//        Boolean rc = (Boolean)TypeConversionSupport.convert(value, Boolean.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a boolean");
-//        }
-//        return rc.booleanValue();
-//    }
-//
-//    public byte getByteProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NumberFormatException("property "+name+" was null");        
-//        Byte rc = (Byte)TypeConversionSupport.convert(value, Byte.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a byte");
-//        }
-//        return rc.byteValue();
-//    }
-//
-//    public short getShortProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NumberFormatException("property "+name+" was null");        
-//        Short rc = (Short)TypeConversionSupport.convert(value, Short.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a short");
-//        }
-//        return rc.shortValue();
-//    }
-//
-//    public int getIntProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NumberFormatException("property "+name+" was null");        
-//        Integer rc = (Integer)TypeConversionSupport.convert(value, Integer.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as an integer");
-//        }
-//        return rc.intValue();
-//    }
-//
-//    public long getLongProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NumberFormatException("property "+name+" was null");        
-//        Long rc = (Long)TypeConversionSupport.convert(value, Long.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a long");
-//        }
-//        return rc.longValue();
-//    }
-//
-//    public float getFloatProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NullPointerException("property "+name+" was null");        
-//        Float rc = (Float)TypeConversionSupport.convert(value, Float.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a float");
-//        }
-//        return rc.floatValue();
-//    }
-//
-//    public double getDoubleProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null )
-//            throw new NullPointerException("property "+name+" was null");        
-//        Double rc = (Double)TypeConversionSupport.convert(value, Double.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a double");
-//        }
-//        return rc.doubleValue();
-//    }
-//
-//    public String getStringProperty(String name) throws JMSException {
-//        Object value = getObjectProperty(name);
-//        if( value == null ) {
-//            if (name.equals("JMSXUserID")) {
-//                value = getUserID();
-//            }
-//        }
-//        if( value == null )
-//            return null;        
-//        String rc = (String)TypeConversionSupport.convert(value, String.class);
-//        if( rc == null ) {
-//            throw new MessageFormatException("Property "+name+" was a "+value.getClass().getName()+"
and cannot be read as a String");
-//        }
-//        return rc;
-//    }
-//
-//    public void setBooleanProperty(String name, boolean value) throws JMSException {
-//        setObjectProperty(name, value ? Boolean.TRUE : Boolean.FALSE);
-//    }
-//
-//    public void setByteProperty(String name, byte value) throws JMSException {
-//        setObjectProperty(name, new Byte(value));
-//    }
-//
-//    public void setShortProperty(String name, short value) throws JMSException {
-//        setObjectProperty(name, new Short(value));
-//    }
-//
-//    public void setIntProperty(String name, int value) throws JMSException {
-//        setObjectProperty(name, new Integer(value));
-//    }
-//
-//    public void setLongProperty(String name, long value) throws JMSException {
-//        setObjectProperty(name, new Long(value));
-//    }
-//
-//    public void setFloatProperty(String name, float value) throws JMSException {
-//        setObjectProperty(name, new Float(value));
-//    }
-//
-//    public void setDoubleProperty(String name, double value) throws JMSException {
-//        setObjectProperty(name, new Double(value));
-//    }
-//
-//    public void setStringProperty(String name, String value) throws JMSException {
-//        setObjectProperty(name, value);
-//    }
-//
-//
-//    private void checkReadOnlyProperties() throws MessageNotWriteableException {
-//        if (readOnlyProperties) {
-//            throw new MessageNotWriteableException("Message properties are read-only");
-//        }
-//    }
-//
-//    protected void checkReadOnlyBody() throws MessageNotWriteableException {
-//        if (readOnlyBody) {
-//            throw new MessageNotWriteableException("Message body is read-only");
-//        }
-//    }
-//
-//    public boolean isExpired() {
-//        long expireTime = this.getExpiration();
-//        if (expireTime > 0 && System.currentTimeMillis() > expireTime) {
-//            return true;
-//        }
-//        return false;
-//    }
-//
-//    /**
-//     * Send operation event listener.  Used to get the message ready to be sent. 
-//     */
-//    public void onSend() {
-//        setReadOnlyBody(true);
-//        setReadOnlyProperties(true);
-//    }
-//
-//}
-//



Mime
View raw message