001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.transport.amqp.message; 018 019import javax.jms.BytesMessage; 020import javax.jms.Destination; 021import javax.jms.MapMessage; 022import javax.jms.Message; 023import javax.jms.ObjectMessage; 024import javax.jms.StreamMessage; 025import javax.jms.TextMessage; 026 027import org.apache.activemq.command.ActiveMQBytesMessage; 028import org.apache.activemq.command.ActiveMQDestination; 029import org.apache.activemq.command.ActiveMQMapMessage; 030import org.apache.activemq.command.ActiveMQMessage; 031import org.apache.activemq.command.ActiveMQObjectMessage; 032import org.apache.activemq.command.ActiveMQStreamMessage; 033import org.apache.activemq.command.ActiveMQTextMessage; 034 035public class ActiveMQJMSVendor implements JMSVendor { 036 037 final public static ActiveMQJMSVendor INSTANCE = new ActiveMQJMSVendor(); 038 039 private ActiveMQJMSVendor() { 040 } 041 042 @Override 043 public BytesMessage createBytesMessage() { 044 return new ActiveMQBytesMessage(); 045 } 046 047 @Override 048 public StreamMessage createStreamMessage() { 049 return new ActiveMQStreamMessage(); 050 } 051 052 @Override 053 public Message createMessage() { 054 return new ActiveMQMessage(); 055 } 056 057 @Override 058 public TextMessage createTextMessage() { 059 return new ActiveMQTextMessage(); 060 } 061 062 @Override 063 public ObjectMessage createObjectMessage() { 064 return new ActiveMQObjectMessage(); 065 } 066 067 @Override 068 public MapMessage createMapMessage() { 069 return new ActiveMQMapMessage(); 070 } 071 072 @Override 073 public Destination createDestination(String name) { 074 return ActiveMQDestination.createDestination(name, ActiveMQDestination.QUEUE_TYPE); 075 } 076 077 @Override 078 public void setJMSXUserID(Message msg, String value) { 079 ((ActiveMQMessage) msg).setUserID(value); 080 } 081 082 @Override 083 public void setJMSXGroupID(Message msg, String value) { 084 ((ActiveMQMessage) msg).setGroupID(value); 085 } 086 087 @Override 088 public void setJMSXGroupSequence(Message msg, int value) { 089 ((ActiveMQMessage) msg).setGroupSequence(value); 090 } 091 092 @Override 093 public void setJMSXDeliveryCount(Message msg, long value) { 094 ((ActiveMQMessage) msg).setRedeliveryCounter((int) value); 095 } 096 097 @Override 098 public String toAddress(Destination dest) { 099 return ((ActiveMQDestination) dest).getQualifiedName(); 100 } 101}