User: user57
Date: 02/02/16 22:13:29
Added: src/main/org/jboss/resource/jms JmsConnectionFactory.java
JmsConnectionFactoryImpl.java
JmsConnectionManager.java
JmsConnectionRequestInfo.java JmsCred.java
JmsLocalTransaction.java JmsMCFProperties.java
JmsManagedConnection.java
JmsManagedConnectionFactory.java JmsMetaData.java
JmsSession.java JmsSessionFactory.java
JmsSessionFactoryImpl.java TestClient.java
package.html
Log:
o moved JMSRA to resource module
o repackaged under org.jboss.resource.jms
Revision Changes Path
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsConnectionFactory.java
Index: JmsConnectionFactory.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.jms.TopicConnectionFactory;
import javax.jms.QueueConnectionFactory;
/**
* JmsConnectionFactory.java
*
* <p>Created: Thu Apr 26 17:01:35 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version <pre>$Revision: 1.1 $</pre>
*/
public interface JmsConnectionFactory
extends TopicConnectionFactory, QueueConnectionFactory
{
// empty
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsConnectionFactoryImpl.java
Index: JmsConnectionFactoryImpl.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.io.Serializable;
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ConnectionManager;
import javax.jms.JMSException;
import javax.jms.QueueConnection;
import javax.jms.TopicConnection;
/**
* ???
*
* Created: Thu Apr 26 17:02:50 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsConnectionFactoryImpl
implements JmsConnectionFactory, Serializable, Referenceable
{
private Reference reference;
/**
* JmsRa own factory
*/
private ManagedConnectionFactory mcf;
/**
* Hook to the appserver
*/
private ConnectionManager cm;
public JmsConnectionFactoryImpl(ManagedConnectionFactory mcf,
ConnectionManager cm)
{
this.mcf = mcf;
this.cm = cm;
if (cm == null) {
// This is standalone usage, no appserver
this.cm = new JmsConnectionManager();
} else {
this.cm = cm;
}
}
public void setReference(Reference reference)
{
this.reference = reference;
}
public Reference getReference()
{
return reference;
}
// --- QueueConnectionFactory
public QueueConnection createQueueConnection()
throws JMSException
{
JmsSessionFactoryImpl s = new JmsSessionFactoryImpl(mcf,cm);
s.isTopic(Boolean.FALSE);
return s;
}
public QueueConnection createQueueConnection(String userName,
String password)
throws JMSException
{
JmsSessionFactoryImpl s = new JmsSessionFactoryImpl(mcf,cm);
s.isTopic(Boolean.FALSE);
s.setUserName(userName);
s.setPassword(password);
return s;
}
// --- TopicConnectionFactory
public TopicConnection createTopicConnection()
throws JMSException
{
JmsSessionFactoryImpl s = new JmsSessionFactoryImpl(mcf,cm);
s.isTopic(Boolean.TRUE);
return s;
}
public TopicConnection createTopicConnection(String userName,
String password)
throws JMSException
{
JmsSessionFactoryImpl s = new JmsSessionFactoryImpl(mcf,cm);
s.isTopic(Boolean.TRUE);
s.setUserName(userName);
s.setPassword(password);
return s;
}
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsConnectionManager.java
Index: JmsConnectionManager.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
/**
* The resource adapters own ConnectionManager, used in non-managed
* environments.
*
* <p>Will handle some of the houskeeping an appserver nomaly does.
*
* <p>Created: Thu Mar 29 16:09:26 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsConnectionManager
implements ConnectionManager
{
/**
* Construct a <tt>JmsConnectionManager</tt>.
*/
public JmsConnectionManager() {
super();
}
/**
* Allocate a new connection.
*
* @param mcf
* @param cxRequestInfo
* @return A new connection
*
* @throws ResourceException Failed to create connection.
*/
public Object allocateConnection(ManagedConnectionFactory mcf,
ConnectionRequestInfo cxRequestInfo)
throws ResourceException
{
ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
return mc.getConnection(null, cxRequestInfo);
}
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsConnectionRequestInfo.java
Index: JmsConnectionRequestInfo.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.resource.spi.ConnectionRequestInfo;
import javax.jms.Session;
import org.jboss.util.Strings;
/**
* ???
*
* Created: Thu Mar 29 16:29:55 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsConnectionRequestInfo
implements ConnectionRequestInfo
{
private String userName;
private String password;
private boolean transacted = true;
private int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
private boolean isTopic = true;
/**
* Creats with the MCF configured properties.
*/
public JmsConnectionRequestInfo(JmsMCFProperties prop)
{
this.userName = prop.getUserName();
this.password = prop.getPassword();
this.isTopic = prop.isTopic();
}
/**
* Create with specified properties.
*/
public JmsConnectionRequestInfo(boolean transacted,
int acknowledgeMode,
boolean isTopic)
{
this.transacted = transacted;
this.acknowledgeMode = acknowledgeMode;
this.isTopic = isTopic;
}
/**
* Fill in default values if missing. Only applies to user and password.
*/
public void setDefaults(JmsMCFProperties prop)
{
if (userName == null)
userName = prop.getUserName();//May be null there to
if (password == null)
password = prop.getPassword();//May be null there to
}
public String getUserName()
{
return userName;
}
public void setUserName(String name)
{
userName = name;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public boolean isTransacted()
{
return transacted;
}
public int getAcknowledgeMode()
{
return acknowledgeMode;
}
public boolean isTopic() {
return isTopic;
}
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof JmsConnectionRequestInfo)
{
JmsConnectionRequestInfo you = (JmsConnectionRequestInfo) obj;
return (this.transacted == you.isTransacted() &&
this.acknowledgeMode == you.getAcknowledgeMode() &&
this.isTopic == you.isTopic() &&
Strings.compare(userName, you.getUserName()) &&
Strings.compare(password, you.getPassword()));
}
else {
return false;
}
}
// FIXME !!
public int hashCode() {
String result = "" + userName + password + transacted + acknowledgeMode +
isTopic;
return result.hashCode();
}
/**
* May be used if we fill in username and password later.
*/
private boolean isEqual(Object o1, Object o2) {
if (o1 == null) {
return (o2 == null);
} else {
return o1.equals(o2);
}
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsCred.java
Index: JmsCred.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.util.Set;
import java.util.Iterator;
import javax.security.auth.Subject;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.SecurityException;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.security.PasswordCredential;
/**
* ???
*
* Created: Sat Mar 31 03:23:30 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsCred
{
public String name;
public String pwd;
public JmsCred() {
// empty
}
/**
* Get our own simple cred
*/
public static JmsCred getJmsCred(ManagedConnectionFactory mcf,
Subject subject,
ConnectionRequestInfo info)
throws SecurityException
{
JmsCred jc = new JmsCred();
if (subject == null && info !=null )
{
// Credentials specifyed on connection request
jc.name = ((JmsConnectionRequestInfo)info).getUserName();
jc.pwd = ((JmsConnectionRequestInfo)info).getPassword();
}
else if (subject != null)
{
// Credentials from appserver
Set creds =
subject.getPrivateCredentials(PasswordCredential.class);
PasswordCredential pwdc = null;
Iterator credentials = creds.iterator();
while (credentials.hasNext())
{
PasswordCredential curCred =
(PasswordCredential) credentials.next();
if (curCred.getManagedConnectionFactory().equals(mcf)) {
pwdc = curCred;
break;
}
}
if (pwdc == null) {
// No hit - we do need creds
throw new SecurityException("No Passwdord credentials found");
}
jc.name = pwdc.getUserName();
jc.pwd = new String(pwdc.getPassword());
}
else {
throw new SecurityException("No Subject or ConnectionRequestInfo set, could
not get credentials");
}
return jc;
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsLocalTransaction.java
Index: JmsLocalTransaction.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.jms.JMSException;
import javax.resource.ResourceException;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.EISSystemException;
/**
* ???
*
* Created: Tue Apr 17 23:44:05 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsLocalTransaction
implements LocalTransaction
{
protected JmsManagedConnection mc;
public JmsLocalTransaction(final JmsManagedConnection mc) {
this.mc = mc;
}
public void begin() throws ResourceException {
// NOOP - begin is automatic in JMS
// Should probably send event
ConnectionEvent ev = new ConnectionEvent(mc,
ConnectionEvent.LOCAL_TRANSACTION_STARTED);
mc.sendEvent(ev);
}
public void commit() throws ResourceException {
try {
mc.getSession().commit();
ConnectionEvent ev = new ConnectionEvent(mc,
ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
mc.sendEvent(ev);
}
catch (JMSException ex) {
ResourceException re =
new EISSystemException("Could not commit LocalTransaction : " +
ex.getMessage());
re.setLinkedException(ex);
throw re;
}
}
public void rollback() throws ResourceException {
try {
mc.getSession().rollback();
ConnectionEvent ev = new ConnectionEvent(mc,
ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
mc.sendEvent(ev);
}
catch (JMSException ex) {
ResourceException re =
new EISSystemException("Could not rollback LocalTransaction : " +
ex.getMessage());
re.setLinkedException(ex);
throw re;
}
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsMCFProperties.java
Index: JmsMCFProperties.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.resource.ResourceException;
import org.jboss.util.Strings;
/**
* The MCF default properties, settable in ra.xml or in deployer.
*
* Created: Thu Sep 27 10:01:25 2001
*
* @author Peter Antman
* @version $Revision: 1.1 $
*/
public class JmsMCFProperties
{
final static String QUEUE_TYPE = "javax.jms.Queue";
final static String TOPIC_TYPE = "javax.jms.Topic";
String userName;
String password;
String providerJNDI = "java:DefaultJMSProvider";
boolean isTopic = true;
public JmsMCFProperties() {
// empty
}
/**
* Set userName, null by default.
*/
public void setUserName(final String userName) {
this.userName = userName;
}
/**
* Get userName, may be null.
*/
public String getUserName() {
return userName;
}
/**
* Set password, null by default.
*/
public void setPassword(final String password) {
this.password = password;
}
/**
* Get password, may be null.
*/
public String getPassword() {
return password;
}
/**
* Set providerJNDI, the JMS provider adapter to use.
*
* <p>Defaults to java:DefaultJMSProvider.
*/
public void setProviderJNDI(final String providerJNDI) {
this.providerJNDI = providerJNDI;
}
/**
* Get providerJNDI. May not be null.
*/
public String getProviderJNDI() {
return providerJNDI;
}
/**
* Type of the JMS Session, defaults to true.
*/
public boolean isTopic() {
return isTopic;
}
/**
* Set the default session type.
*/
public void setIsTopic(boolean isTopic) {
this.isTopic = isTopic;
}
/**
* Helper method to set the default session type.
*
* @param type either javax.jms.Topic or javax.jms.Queue
* @exception ResourceException if type was not a valid type.
*/
public void setSessionDefaultType(String type) throws ResourceException
{
if (type.equals(QUEUE_TYPE)) {
isTopic = false;
}
else if(type.equals(TOPIC_TYPE)) {
isTopic = true;
}
else {
throw new ResourceException(type + " is not a recogniced JMS session type");
}
}
public String getSessionDefaultType() {
return (isTopic ? TOPIC_TYPE : QUEUE_TYPE);
}
/**
* Test for equality of all attributes.
*/
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof JmsMCFProperties) {
JmsMCFProperties you = (JmsMCFProperties) obj;
return (Strings.compare(userName, you.getUserName()) &&
Strings.compare(password, you.getPassword()) &&
Strings.compare(providerJNDI, you.getProviderJNDI()) &&
this.isTopic == you.isTopic());
}
return false;
}
/**
* Simple hashCode of all attributes.
*/
public int hashCode() {
// FIXME
String result = "" + userName + password + providerJNDI + isTopic;
return result.hashCode();
}
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsManagedConnection.java
Index: JmsManagedConnection.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.util.Vector;
import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
import java.io.PrintWriter;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.jms.*;
import javax.resource.ResourceException;
import javax.resource.NotSupportedException;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.resource.spi.CommException;
import javax.resource.spi.SecurityException;
import javax.resource.spi.IllegalStateException;
import javax.resource.spi.ConnectionEvent;
import org.jboss.jms.ConnectionFactoryHelper;
import org.jboss.jms.jndi.JMSProviderAdapter;
import org.jboss.logging.Logger;
/**
* Managed Connection, manages one or more JMS sessions.
*
* <p>Every ManagedConnection will have a physical JMSConnection under the
* hood. This may leave out several session, as specifyed in 5.5.4 Multiple
* Connection Handles. Thread safe semantics is provided.
* <p>Hm. If we are to follow the example in 6.11 this will not work. We would
* have to use the SAME session. This means we will have to guard against
* concurrent access. We use a stack, and only allowes the handle at the
* top of the stack to do things.
*
* <p>As to transactions we some fairly hairy alternatives to handle:
* XA - we get an XA. We may now only do transaction through the
* XAResource, since a XASession MUST throw exceptions in commit etc. But
* since XA support implies LocatTransaction support, we will have to use
* the XAResource in the LocalTransaction class.
* LocalTx - we get a normal session. The LocalTransaction will then work
* against the normal session api.
*
* <p>An invokation of JMS MAY BE DONE in none transacted context. What do we
* do then? How much should we leave to the user???
*
* <p>One possible solution is to use transactions any way, but under the hood.
* If not LocalTransaction or XA has been aquired by the container, we have
* to do the commit in send and publish. (CHECK is the container required
* to get a XA every time it uses a managed connection? No its is not, only
* at creation!)
*
* <p>Does this mean that a session one time may be used in a transacted env,
* and another time in a not transacted.
*
* <p>Maybe we could have this simple rule:
*
* <p>If a user is going to use non trans:
* <ul>
* <li>mark that i ra deployment descr
* <li>Use a JmsProviderAdapter with non XA factorys
* <li>Mark session as non transacted (this defeats the purpose of specifying
* <li>trans attrinbutes in deploy descr NOT GOOD
* </ul>
*
* <p>From the JMS tutorial:
* "When you create a session in an enterprise bean, the container ignores
* the arguments you specify, because it manages all transactional
* properties for enterprise beans."
*
* <p>And further:
* "You do not specify a message acknowledgment mode when you create a
* message-driven bean that uses container-managed transactions. The
* container handles acknowledgment automatically."
*
* <p>On Session or Connection:
* <p>From Tutorial:
* "A JMS API resource is a JMS API connection or a JMS API session." But in
* the J2EE spec only connection is considered a resource.
*
* <p>Not resolved: connectionErrorOccurred: it is verry hard to know from the
* exceptions thrown if it is a connection error. Should we register an
* ExceptionListener and mark al handles as errounous? And then let them
* send the event and throw an exception?
*
* <p>Created: Tue Apr 10 13:09:45 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
* @version $Revision: 1.1 $
*/
public class JmsManagedConnection
implements ManagedConnection
{
private static final Logger log = Logger.getLogger(JmsManagedConnection.class);
private JmsManagedConnectionFactory mcf;
private JmsConnectionRequestInfo info;
private String user; // = null;
private String pwd; // = null;
private boolean isDestroyed; // = false;
// Physical JMS connection stuff
private Connection con;
private TopicSession topicSession;
private XATopicSession xaTopicSession;
private QueueSession queueSession;
private XAQueueSession xaQueueSession;
private XAResource xaResource;
private boolean xaTransacted; // = false;
/** Holds all current JmsSession handles. */
private Set handles = new HashSet();
/** The event listeners */
private Vector listeners = new Vector();
/**
* Create a <tt>JmsManagedConnection</tt>.
*
* @param mcf
* @param info
* @param user
* @param pwd
*
* @throws ResourceException
*/
public JmsManagedConnection(final JmsManagedConnectionFactory mcf,
final ConnectionRequestInfo info,
final String user,
final String pwd)
throws ResourceException
{
this.mcf = mcf;
// seem like its asking for trouble here
this.info = (JmsConnectionRequestInfo)info;
this.user = user;
this.pwd = pwd;
setup();
}
//---- ManagedConnection API ----
/**
* Get the physical connection handler.
*
* <p>This bummer will be called in two situations:
* <ol>
* <li>When a new mc has bean created and a connection is needed
* <li>When an mc has been fetched from the pool (returned in match*)
* </ol>
*
* <p>It may also be called multiple time without a cleanup, to support
* connection sharing.
*
* @param subject
* @param info
* @return A new connection object.
*
* @throws ResourceException
*/
public Object getConnection(final Subject subject,
final ConnectionRequestInfo info)
throws ResourceException
{
// Check user first
JmsCred cred = JmsCred.getJmsCred(mcf,subject,info);
// Null users are allowed!
if (user != null && !user.equals(cred.name)) {
throw new SecurityException
("Password credentials not the same, reauthentication not allowed");
}
if (cred.name != null && user == null) {
throw new SecurityException
("Password credentials not the same, reauthentication not allowed");
}
user = cred.name; // Basically meaningless
if (isDestroyed) {
throw new IllegalStateException("ManagedConnection already destroyd");
}
// Create a handle
JmsSession handle = new JmsSession(this);
handles.add(handle);
return handle;
}
/**
* Destroy all handles.
*
* @throws ResourceException Failed to close one or more handles.
*/
private void destroyHandles() throws ResourceException {
Iterator iter = handles.iterator();
while (iter.hasNext()) {
((JmsSession)iter.next()).destroy();
}
// clear the handles map
handles.clear();
}
/**
* Destroy the physical connection.
*
* @throws ResourceException Could not property close the session and
* connection.
*/
public void destroy() throws ResourceException {
if (isDestroyed) return;
isDestroyed = true;
// destory handles
destroyHandles();
try {
// Close session and connection
if (info.isTopic()) {
topicSession.close();
if (xaTransacted) {
xaTopicSession.close();
}
}
else {
queueSession.close();
if (xaTransacted) {
xaQueueSession.close();
}
}
con.close();
}
catch (JMSException ex) {
ResourceException e = new ResourceException
("Could not properly close the session and connection: " + ex);
e.setLinkedException(ex);
throw e;
}
}
/**
* Cleans up the, from the spec
* - The cleanup of ManagedConnection instance resets its client specific
* state.
*
* Does that mean that autentication should be redone. FIXME
*/
public void cleanup() throws ResourceException {
if (isDestroyed) {
throw new IllegalStateException("ManagedConnection already destroyd");
}
// destory handles
destroyHandles();
}
/**
* Move a handler from one mc to this one.
*
* @param obj An object of type JmsSession.
*
* @throws ResourceException Failed to associate connection.
* @throws IllegalStateException ManagedConnection in an illegal state.
*/
public void associateConnection(final Object obj)
throws ResourceException
{
//
// Should we check auth, ie user and pwd? FIXME
//
if (!isDestroyed && obj instanceof JmsSession) {
JmsSession h = (JmsSession)obj;
h.setManagedConnection(this);
handles.add(h);
}
else {
throw new IllegalStateException
("ManagedConnection in an illegal state");
}
}
/**
* Add a connection event listener.
*
* @param l The connection event listener to be added.
*/
public void addConnectionEventListener(final ConnectionEventListener l) {
listeners.addElement(l);
if (log.isDebugEnabled()) {
log.debug("ConnectionEvent listener added: " + l);
}
}
/**
* Remove a connection event listener.
*
* @param l The connection event listener to be removed.
*/
public void removeConnectionEventListener(final ConnectionEventListener l) {
listeners.removeElement(l);
}
/**
* Get the XAResource for the connection.
*
* @return The XAResource for the connection.
*
* @throws ResourceException XA transaction not supported
*/
public XAResource getXAResource() throws ResourceException {
//
// Spec says a mc must allways return the same XA resource,
// so we cache it.
//
if (!xaTransacted) {
throw new NotSupportedException("XA transaction not supported");
}
if (xaResource == null) {
if (info.isTopic()) {
xaResource = xaTopicSession.getXAResource();
}
else {
xaResource = xaQueueSession.getXAResource();
}
}
log.debug("Leaving out XAResource");
return xaResource;
}
/**
* Get the location transaction for the connection.
*
* @return The local transaction for the connection.
*
* @throws ResourceException
*/
public LocalTransaction getLocalTransaction() throws ResourceException {
log.debug("Leaving out LocalTransaction");
return new JmsLocalTransaction(this);
}
/**
* Get the meta data for the connection.
*
* @return The meta data for the connection.
*
* @throws ResourceException
* @throws IllegalStateException ManagedConnection already destroyed.
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException {
if (isDestroyed) {
throw new IllegalStateException("ManagedConnection already destroyd");
}
return new JmsMetaData(this);
}
/**
* Set the log writer for this connection.
*
* @param out The log writer for this connection.
*
* @throws ResourceException
*/
public void setLogWriter(final PrintWriter out) throws ResourceException {
log.debug("Ignoring call to setLogWriter()");
}
/**
* Get the log writer for this connection.
*
* @return Always null
*/
public PrintWriter getLogWriter() throws ResourceException {
return null;
}
// --- Api to JmsSession
/**
* Get the session for this connection.
*
* @return Either a topic or queue connection.
*/
protected Session getSession() {
if (info.isTopic()) {
return topicSession;
}
else {
return queueSession;
}
}
/**
* Send an event.
*
* @param event The event to send.
*/
protected void sendEvent(final ConnectionEvent event) {
log.debug("Sending connection event: " + event.getId());
Vector list = (Vector) listeners.clone();
int size = list.size();
for (int i=0; i<size; i++) {
ConnectionEventListener listener =
(ConnectionEventListener)list.elementAt(i);
int type = event.getId();
switch (type) {
case ConnectionEvent.CONNECTION_CLOSED:
listener.connectionClosed(event);
break;
case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
listener.localTransactionStarted(event);
break;
case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
listener.localTransactionCommitted(event);
break;
case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
listener.localTransactionRolledback(event);
break;
case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
listener.connectionErrorOccurred(event);
break;
default:
throw new IllegalArgumentException("Illegal eventType: " + type);
}
}
}
/**
* Remove a handle from the handle map.
*
* @param handle The handle to remove.
*/
protected void removeHandle(final JmsSession handle) {
handles.remove(handle);
}
// --- Used by MCF
/**
* Get the request info for this connection.
*
* @return The request info for this connection.
*/
protected ConnectionRequestInfo getInfo() {
return info;
}
/**
* Get the connection factory for this connection.
*
* @return The connection factory for this connection.
*/
protected JmsManagedConnectionFactory getManagedConnectionFactory() {
return mcf;
}
// --- Used by MetaData
/**
* Get the user name for this connection.
*
* @return The user name for this connection.
*/
protected String getUserName() {
return user;
}
// --- Private helper methods
/**
* Get the JMS provider adapter that will be used to create JMS
* resources.
*
* @return A JMS provider adapter.
*
* @throws NamingException Failed to lookup provider adapter.
*/
private JMSProviderAdapter getProviderAdapter() throws NamingException {
JMSProviderAdapter adapter;
if (mcf.getJmsProviderAdapterJNDI() != null) {
// lookup the adapter from JNDI
Context ctx = new InitialContext();
try {
adapter = (JMSProviderAdapter)
ctx.lookup(mcf.getJmsProviderAdapterJNDI());
}
finally {
ctx.close();
}
}
else {
adapter = mcf.getJmsProviderAdapter();
}
return adapter;
}
/**
* Setup the connection.
*
* @throws ResourceException
*/
private void setup() throws ResourceException
{
try {
JMSProviderAdapter adapter = getProviderAdapter();
Context context = adapter.getInitialContext();
Object factory;
boolean transacted = true;
int ack = Session.AUTO_ACKNOWLEDGE;
if (info.isTopic()) {
factory = context.lookup(adapter.getTopicFactoryRef());
con = ConnectionFactoryHelper.createTopicConnection(factory,
user,
pwd);
log.debug("created connection: " + con);
if (con instanceof XATopicConnection) {
xaTopicSession = ((XATopicConnection)con).createXATopicSession();
topicSession = xaTopicSession.getTopicSession();
xaTransacted = true;
}
else if (con instanceof TopicConnection) {
topicSession =
((TopicConnection)con).createTopicSession(transacted, ack);
log.debug("Using a non-XA TopicConnection. " +
"It will not be able to participate in a Global UOW");
}
else {
log.error("Error in getting session for con: " + con);
throw new ResourceException
("Connection was not reconizable: " + con);
}
log.debug("xaTopicSession: " + xaTopicSession);
log.debug("topicSession: " + topicSession);
}
else { // isQueue
factory = context.lookup(adapter.getQueueFactoryRef());
con = ConnectionFactoryHelper.createQueueConnection(factory,
user,
pwd);
log.debug("created connection: " + con);
if (con instanceof XAQueueConnection) {
xaQueueSession =
((XAQueueConnection)con).createXAQueueSession();
queueSession = xaQueueSession.getQueueSession();
xaTransacted = true;
}
else if (con instanceof QueueConnection) {
queueSession =
((QueueConnection)con).createQueueSession(transacted, ack);
log.debug("Using a non-XA QueueConnection. " +
"It will not be able to participate in a Global UOW");
}
else {
log.error("Error in getting session for con: " + con);
throw new ResourceException
("Connection was not reconizable: " + con);
}
log.debug("xaQueueSession: " + xaQueueSession);
log.debug("queueSession: " + queueSession);
}
con.start();
log.debug("transacted: " + transacted);
log.debug("ack mode: " + ack);
}
catch (NamingException e) {
CommException ce = new CommException(e.toString());
ce.setLinkedException(e);
throw ce;
}
catch (JMSException e) {
CommException ce = new CommException(e.toString());
ce.setLinkedException(e);
throw ce;
}
}
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsManagedConnectionFactory.java
Index: JmsManagedConnectionFactory.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.util.Set;
import java.util.Iterator;
import java.io.PrintWriter;
import javax.security.auth.Subject;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.SecurityException;
import javax.resource.spi.IllegalStateException;
import javax.resource.spi.security.PasswordCredential;
import org.jboss.jms.jndi.JMSProviderAdapter;
import org.jboss.logging.Logger;
/**
* ???
*
* Created: Sat Mar 31 03:08:35 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsManagedConnectionFactory
implements ManagedConnectionFactory
{
private static final Logger log = Logger.getLogger(JmsManagedConnection.class);
/** Settable attributes in ra.xml */
private JmsMCFProperties mcfProperties = new JmsMCFProperties();
/** For local access. */
private JMSProviderAdapter adapter;
public JmsManagedConnectionFactory() {
// empty
}
/**
* Create a "non managed" connection factory. No appserver involved
*/
public Object createConnectionFactory() throws ResourceException
{
return new JmsConnectionFactoryImpl(this, null);
}
/**
* Create a ConnectionFactory with appserver hook
*/
public Object createConnectionFactory(ConnectionManager cxManager)
throws ResourceException
{
return new JmsConnectionFactoryImpl(this, cxManager);
}
/**
* Create a new connection to manage in pool
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo info)
throws ResourceException
{
info = getInfo(info);
JmsCred cred = JmsCred.getJmsCred(this,subject, info);
// OK we got autentication stuff
JmsManagedConnection mc = new JmsManagedConnection
(this, info,cred.name, cred.pwd);
// Set default logwriter according to spec
// user57: screw the logWriter stuff for now it sucks ass
return mc;
}
/**
* Match a set of connections from the pool
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject,
ConnectionRequestInfo info)
throws ResourceException
{
// Get cred
info = getInfo(info);
JmsCred cred = JmsCred.getJmsCred(this,subject, info);
// Traverse the pooled connections and look for a match, return
// first found
Iterator connections = connectionSet.iterator();
while (connections.hasNext()) {
Object obj = connections.next();
// We only care for connections of our own type
if (obj instanceof JmsManagedConnection) {
// This is one from the pool
JmsManagedConnection mc = (JmsManagedConnection) obj;
// Check if we even created this on
ManagedConnectionFactory mcf =
mc.getManagedConnectionFactory();
// Only admit a connection if it has the same username as our
// asked for creds
// FIXME, Here we have a problem, jms connection
// may be anonymous, have a user name
if ((mc.getUserName() == null ||
(mc.getUserName() != null &&
mc.getUserName().equals(cred.name))) && mcf.equals(this))
{
// Now check if ConnectionInfo equals
if (info.equals( mc.getInfo() )) {
return mc;
}
}
}
}
return null;
}
public void setLogWriter(PrintWriter out)
throws ResourceException
{
log.debug("Ignoring call to setLogWriter()");
}
public PrintWriter getLogWriter() throws ResourceException {
return null;
}
/**
* Checks for equality ower the configured properties.
*/
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof JmsManagedConnectionFactory) {
return mcfProperties.equals(
((JmsManagedConnectionFactory)obj).getProperties());
}
else {
return false;
}
}
public int hashCode() {
return mcfProperties.hashCode();
}
// --- Connfiguration API ---
public void setJmsProviderAdapterJNDI(String jndi) {
mcfProperties.setProviderJNDI(jndi);
}
public String getJmsProviderAdapterJNDI() {
return mcfProperties.getProviderJNDI();
}
/**
* Set userName, null by default.
*/
public void setUserName(String userName) {
mcfProperties.setUserName(userName);
}
/**
* Get userName, may be null.
*/
public String getUserName() {
return mcfProperties.getUserName();
}
/**
* Set password, null by default.
*/
public void setPassword(String password) {
mcfProperties.setPassword(password);
}
/**
* Get password, may be null.
*/
public String getPassword() {
return mcfProperties.getPassword();
}
/**
* Set the default session typ
*
* @param type either javax.jms.Topic or javax.jms.Queue
*
* @exception ResourceException if type was not a valid type.
*/
public void setSessionDefaultType(String type) throws ResourceException {
mcfProperties.setSessionDefaultType(type);
}
public String getSessionDefaultType() {
return mcfProperties.getSessionDefaultType();
}
/**
* For local access
*/
public void setJmsProviderAdapter(final JMSProviderAdapter adapter) {
this.adapter = adapter;
}
public JMSProviderAdapter getJmsProviderAdapter() {
return adapter;
}
private ConnectionRequestInfo getInfo(ConnectionRequestInfo info) {
if (info == null) {
// Create a default one
return new JmsConnectionRequestInfo(mcfProperties);
}
else {
// Fill the one with any defaults
((JmsConnectionRequestInfo)info).setDefaults(mcfProperties);
return info;
}
}
//---- MCF to MCF API
protected JmsMCFProperties getProperties() {
return mcfProperties;
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsMetaData.java
Index: JmsMetaData.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionMetaData;
/**
* ???
*
* Created: Sat Mar 31 03:36:27 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsMetaData
implements ManagedConnectionMetaData
{
private JmsManagedConnection mc;
public JmsMetaData(final JmsManagedConnection mc) {
this.mc = mc;
}
public String getEISProductName() throws ResourceException {
return "JMS CA Resource Adapter";
}
public String getEISProductVersion() throws ResourceException {
return "0.1";//Is this possible to get another way
}
public int getMaxConnections() throws ResourceException {
// Dont know how to get this, from Jms, we
// set it to unlimited
return 0;
}
public String getUserName() throws ResourceException {
return mc.getUserName();
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsSession.java
Index: JmsSession.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.io.Serializable;
import javax.jms.*;
import javax.resource.spi.ConnectionEvent;
import org.jboss.logging.Logger;
// make sure we throw the jmx variety
import javax.jms.IllegalStateException;
/**
* Adapts the JMS QueueSession and TopicSession API to a JmsManagedConnection.
*
* <p>Created: Tue Apr 17 22:39:45 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>.
* @version $Revision: 1.1 $
*/
public class JmsSession
implements QueueSession, TopicSession
{
private static final Logger log = Logger.getLogger(JmsSession.class);
/** The managed connection for this session. */
private JmsManagedConnection mc; // = null;
/**
* Construct a <tt>JmsSession</tt>.
*
* @param mc The managed connection for this session.
*/
public JmsSession(final JmsManagedConnection mc) {
this.mc = mc;
}
/**
* Ensure that the session is opened.
*
* @return The session
*
* @throws IllegalStateException The session is closed
*/
private Session getSession() throws JMSException {
// ensure that the connection is opened
if (mc == null)
throw new IllegalStateException("The session is closed");
return mc.getSession();
}
// ---- Session API
public BytesMessage createBytesMessage() throws JMSException
{
return getSession().createBytesMessage();
}
public MapMessage createMapMessage() throws JMSException
{
return getSession().createMapMessage();
}
public Message createMessage() throws JMSException
{
return getSession().createMessage();
}
public ObjectMessage createObjectMessage() throws JMSException
{
return getSession().createObjectMessage();
}
public ObjectMessage createObjectMessage(Serializable object)
throws JMSException
{
return getSession().createObjectMessage(object);
}
public StreamMessage createStreamMessage() throws JMSException
{
return getSession().createStreamMessage();
}
public TextMessage createTextMessage() throws JMSException
{
return getSession().createTextMessage();
}
public TextMessage createTextMessage(String string) throws JMSException
{
return getSession().createTextMessage(string);
}
public boolean getTransacted() throws JMSException
{
return getSession().getTransacted();
}
/**
* Always throws an Exception.
*
* @throws IllegalStateException Method not allowed.
*/
public MessageListener getMessageListener() throws JMSException
{
throw new IllegalStateException("Method not allowed");
}
/**
* Always throws an Exception.
*
* @throws IllegalStateException Method not allowed.
*/
public void setMessageListener(MessageListener listener)
throws JMSException
{
throw new IllegalStateException("Method not allowed");
}
/**
* Always throws an Error.
*
* @throws Error Method not allowed.
*/
public void run() {
// should this really throw an Error?
throw new Error("Method not allowed");
}
/**
* Closes the session. Sends a ConnectionEvent.CONNECTION_CLOSED to the
* managed connection.
*
* @throws JMSException Failed to close session.
*/
public void close() throws JMSException
{
if (mc != null) {
log.debug("Closing session");
// Special stuff FIXME
mc.removeHandle(this);
ConnectionEvent ev =
new ConnectionEvent(mc, ConnectionEvent.CONNECTION_CLOSED);
ev.setConnectionHandle(this);
mc.sendEvent(ev);
mc = null;
}
}
// FIXME - is this really OK, probably not
public void commit() throws JMSException
{
getSession().commit();
}
public void rollback() throws JMSException
{
getSession().rollback();
}
public void recover() throws JMSException
{
getSession().recover();
}
// --- TopicSession API
public Topic createTopic(String topicName) throws JMSException
{
return ((TopicSession)getSession()).createTopic(topicName);
}
public TopicSubscriber createSubscriber(Topic topic) throws JMSException
{
return ((TopicSession)getSession()).createSubscriber(topic);
}
public TopicSubscriber createSubscriber(Topic topic,
String messageSelector,
boolean noLocal)
throws JMSException
{
return ((TopicSession)getSession()).
createSubscriber(topic,messageSelector, noLocal);
}
public TopicSubscriber createDurableSubscriber(Topic topic,
String name)
throws JMSException
{
return ((TopicSession)getSession()).
createDurableSubscriber(topic, name);
}
public TopicSubscriber createDurableSubscriber(Topic topic,
String name,
String messageSelector,
boolean noLocal)
throws JMSException
{
return ((TopicSession)getSession()).
createDurableSubscriber(topic, name, messageSelector, noLocal);
}
public TopicPublisher createPublisher(Topic topic) throws JMSException
{
return ((TopicSession)getSession()).createPublisher(topic);
}
public TemporaryTopic createTemporaryTopic() throws JMSException
{
return ((TopicSession)getSession()).createTemporaryTopic();
}
public void unsubscribe(String name) throws JMSException
{
((TopicSession)getSession()).unsubscribe(name);
}
//--- QueueSession API
public QueueBrowser createBrowser(Queue queue) throws JMSException
{
return ((QueueSession)getSession()).createBrowser(queue);
}
public QueueBrowser createBrowser(Queue queue,
String messageSelector)
throws JMSException
{
return ((QueueSession)getSession()).
createBrowser(queue,messageSelector);
}
public Queue createQueue(String queueName) throws JMSException
{
return ((QueueSession)getSession()).createQueue(queueName);
}
public QueueReceiver createReceiver(Queue queue) throws JMSException
{
return ((QueueSession)getSession()).createReceiver(queue);
}
public QueueReceiver createReceiver(Queue queue, String messageSelector)
throws JMSException
{
return ((QueueSession)getSession()).
createReceiver(queue, messageSelector);
}
public QueueSender createSender(Queue queue) throws JMSException
{
return ((QueueSession)getSession()).createSender(queue);
}
public TemporaryQueue createTemporaryQueue() throws JMSException
{
return ((QueueSession)getSession()).createTemporaryQueue();
}
// --- JmsManagedConnection api
void setManagedConnection(final JmsManagedConnection mc) {
if (this.mc != null) {
this.mc.removeHandle(this);
}
this.mc = mc;
}
void destroy() {
mc = null;
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/JmsSessionFactory.java
Index: JmsSessionFactory.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.jms.TopicConnection;
import javax.jms.QueueConnection;
/**
* A marker interface to join topics and queues into one factory.
*
* <p>Created: Thu Mar 29 15:37:21 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version <pre>$Revision: 1.1 $</pre>
*/
public interface JmsSessionFactory
extends TopicConnection, QueueConnection
{
// empty
}
1.1
jbosscx/src/main/org/jboss/resource/jms/JmsSessionFactoryImpl.java
Index: JmsSessionFactoryImpl.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import java.io.Serializable;
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.jms.JMSException;
import javax.jms.ConnectionConsumer;
import javax.jms.ServerSessionPool;
import javax.jms.TopicSession;
import javax.jms.Topic;
import javax.jms.QueueSession;
import javax.jms.Queue;
import javax.jms.ExceptionListener;
import javax.jms.ConnectionMetaData;
import org.jboss.logging.Logger;
/**
* Implements the JMS Connection API and produces {@link JmsSession} objects.
*
* <p>Created: Thu Mar 29 15:36:51 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class JmsSessionFactoryImpl
implements JmsSessionFactory, Serializable, Referenceable
{
private static final Logger log = Logger.getLogger(JmsSessionFactoryImpl.class);
private static final String ISE =
"This method is not applicatable in JMS resource adapter";
private Reference reference;
// Used from JmsConnectionFactory
private String userName; // = null;
private String password; // = null;
private Boolean isTopic; // = null;
/** JmsRa own factory */
private ManagedConnectionFactory mcf;
/** Hook to the appserver */
private ConnectionManager cm;
public JmsSessionFactoryImpl(final ManagedConnectionFactory mcf,
final ConnectionManager cm)
{
this.mcf = mcf;
this.cm = cm;
if (cm == null) {
// This is standalone usage, no appserver
this.cm = new JmsConnectionManager();
}
else {
this.cm = cm;
}
}
public void setReference(final Reference reference) {
this.reference = reference;
}
public Reference getReference() {
return reference;
}
// --- API for JmsConnectionFactoryImpl
public void setUserName(final String name)
{
userName = name;
}
public void setPassword(final String password)
{
this.password = password;
}
public void isTopic(final Boolean isTopic) {
this.isTopic = isTopic;
}
//---- QueueConnection ---
public QueueSession createQueueSession(final boolean transacted,
final int acknowledgeMode)
throws JMSException
{
try {
if (isTopic != null && isTopic == Boolean.TRUE) {
throw new IllegalStateException
("Cant get a queue session from a topic connection");
}
JmsConnectionRequestInfo info =
new JmsConnectionRequestInfo(transacted, acknowledgeMode, false);
info.setUserName(userName);
info.setPassword(password);
return (QueueSession)cm.allocateConnection(mcf, info);
}
catch (ResourceException e) {
log.error("could not create session", e);
JMSException je =
new JMSException("Could not create a session: " + e);
je.setLinkedException(e);
throw je;
}
}
public ConnectionConsumer createConnectionConsumer
(Queue queue,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
{
throw new IllegalStateException(ISE);
}
//--- TopicConnection ---
public TopicSession createTopicSession(final boolean transacted,
final int acknowledgeMode)
throws JMSException
{
try {
if (isTopic != null && isTopic == Boolean.FALSE) {
throw new IllegalStateException
("Cant get a topic session from a session connection");
}
JmsConnectionRequestInfo info =
new JmsConnectionRequestInfo(transacted, acknowledgeMode, true);
info.setUserName(userName);
info.setPassword(password);
return (TopicSession)cm.allocateConnection(mcf, info);
}
catch (ResourceException e) {
log.error("could not create session", e);
JMSException je = new JMSException
("Could not create a session: " + e);
je.setLinkedException(e);
throw je;
}
}
public ConnectionConsumer createConnectionConsumer
(Topic topic,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
{
throw new IllegalStateException(ISE);
}
public ConnectionConsumer createDurableConnectionConsumer
(Topic topic,
String subscriptionName,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
{
throw new IllegalStateException(ISE);
}
//--- All the Connection methods
public String getClientID() throws JMSException {
throw new IllegalStateException(ISE);
}
public void setClientID(String cID) throws JMSException {
throw new IllegalStateException(ISE);
}
public ConnectionMetaData getMetaData() throws JMSException {
throw new IllegalStateException(ISE);
}
public ExceptionListener getExceptionListener() throws JMSException {
throw new IllegalStateException(ISE);
}
public void setExceptionListener(ExceptionListener listener)
throws JMSException
{
throw new IllegalStateException(ISE);
}
public void start() throws JMSException {
throw new IllegalStateException(ISE);
}
public void stop() throws JMSException {
throw new IllegalStateException(ISE);
}
public void close() throws JMSException {
//
// TODO: close all sessions, for now just do nothing.
//
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/TestClient.java
Index: TestClient.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.resource.jms;
import javax.jms.*;
import javax.naming.InitialContext;
/**
* TestClient for stand alone use. Basically verry uninteresting.
*
* Created: Sun Apr 22 19:10:27 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>.
* @version $Revision: 1.1 $
*/
public class TestClient
{
public TestClient() {
// empty
}
public static void main(String[] args) {
try {
JmsManagedConnectionFactory f = new JmsManagedConnectionFactory();
f.setJmsProviderAdapter( new org.jboss.jms.jndi.JBossMQProvider());
//f.setLogging("true");
JmsConnectionFactory cf = (JmsConnectionFactory)f.createConnectionFactory();
//FIXME - how to get LocalTransaction for standalone usage?
TopicConnection con = cf.createTopicConnection();
TopicSession ses = con.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic)new InitialContext().lookup("topic/testTopic");
TopicPublisher pub = ses.createPublisher(topic);
TextMessage m = ses.createTextMessage("Hello world!");
pub.publish(m);
ses.commit();
ses.close();
}
catch(Exception ex) {
System.err.println("Error: " + ex);
ex.printStackTrace();
}
}
}
1.1 jbosscx/src/main/org/jboss/resource/jms/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- $Id: package.html,v 1.1 2002/02/17 06:13:29 user57 Exp $ -->
<!--
JBoss: The OpenSource J2EE WebOS
Distributable under LGPL license.
See terms of license at gnu.org.
-->
</head>
<body bgcolor="white">
<p>JMS Resource Adapter
<h2>Package Specification</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Related Documentation</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Package Status</h2>
<ul>
<li><font color="green"><b>STABLE</b></font>
</ul>
<h2>Todo</h2>
<ul>
<li>???
</ul>
<!-- Put @see and @since tags down here. -->
</body>
</html>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development