/*
* Created on May 9, 2004
*
* TODO To change the template for this generated file go to Window -
* Preferences - Java - Code Generation - Code and Comments
*/
package org.activemq.itests;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.codehaus.activemq.ActiveMQConnectionFactory;
/**
* @version $Revision: 1.1 $
*/
public class JmsResourceProvider {
private String serverUri = "tcp://localhost:61616";
private boolean transacted = false;
private int ackMode = Session.AUTO_ACKNOWLEDGE;
private boolean isTopic;
/**
* @see org.codehaus.activemq.JmsResourceProvider#createConnectionFactory()
*/
public ConnectionFactory createConnectionFactory() throws JMSException {
return new ActiveMQConnectionFactory(serverUri);
}
/**
* @see org.codehaus.activemq.JmsResourceProvider#createConnection(javax.jms.ConnectionFactory)
*/
public Connection createConnection(ConnectionFactory cf) throws JMSException {
return cf.createConnection();
}
/**
* @see org.codehaus.activemq.JmsResourceProvider#createSession(javax.jms.Connection)
*/
public Session createSession(Connection conn) throws JMSException {
return conn.createSession(transacted, ackMode);
}
/**
* @see org.codehaus.activemq.JmsResourceProvider#createConsumer(javax.jms.Session,
* javax.jms.Destination)
*/
public MessageConsumer createConsumer(Session session,
Destination destination) throws JMSException {
return session.createConsumer(destination);
}
/**
* @see org.codehaus.activemq.JmsResourceProvider#createProducer(javax.jms.Session,
* javax.jms.Destination)
*/
public MessageProducer createProducer(Session session,
Destination destination) throws JMSException {
return session.createProducer(destination);
}
/**
* @see org.codehaus.activemq.JmsResourceProvider#createDestination(javax.jms.Session,
* java.lang.String)
*/
public Destination createDestination(Session session, String name)
throws JMSException {
if( isTopic )
return session.createTopic(name);
else
return session.createQueue(name);
}
/**
* @return Returns the ackMode.
*/
public int getAckMode() {
return ackMode;
}
/**
* @param ackMode The ackMode to set.
*/
public void setAckMode(int ackMode) {
this.ackMode = ackMode;
}
/**
* @return Returns the isTopic.
*/
public boolean isTopic() {
return isTopic;
}
/**
* @param isTopic The isTopic to set.
*/
public void setTopic(boolean isTopic) {
this.isTopic = isTopic;
}
/**
* @return Returns the serverUri.
*/
public String getServerUri() {
return serverUri;
}
/**
* @param serverUri The serverUri to set.
*/
public void setServerUri(String serverUri) {
this.serverUri = serverUri;
}
/**
* @return Returns the transacted.
*/
public boolean isTransacted() {
return transacted;
}
/**
* @param transacted The transacted to set.
*/
public void setTransacted(boolean transacted) {
this.transacted = transacted;
}
}