ProducerManagerImplpublic class ProducerManagerImpl extends Object implements ProducerManager, Externalizable, org.jboss.aop.advice.Interceptor
Fields Summary |
---|
private static final long | serialVersionUID | private static final Logger | log | private static final int | PERSISTENT | private static final int | NON_PERSISTENT | protected org.jboss.annotation.ejb.Producer | producer | protected javax.jms.Destination | destination | protected String | factoryLookup | protected int | deliveryMode | protected int | timeToLive | protected int | priority | protected HashMap | methodMap | protected transient javax.jms.ConnectionFactory | factory | protected transient javax.jms.Connection | connection | protected transient javax.jms.Session | session | protected transient javax.jms.MessageProducer | msgProducer | protected transient String | username | protected transient String | password | protected transient InitialContext | initialContext | protected Hashtable | initialContextProperties |
Constructors Summary |
---|
public ProducerManagerImpl(org.jboss.annotation.ejb.Producer producer, javax.jms.Destination destination, javax.jms.ConnectionFactory factory, org.jboss.annotation.ejb.DeliveryMode deliveryMode, int timeToLive, int priority, HashMap methodMap, Hashtable initialContextProperties)
this.initialContextProperties = initialContextProperties;
try
{
this.initialContext = EJB3Util.getInitialContext(initialContextProperties);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
this.producer = producer;
this.destination = destination;
this.factory = factory;
int mode = deliveryMode.ordinal();
switch (mode)
{
case PERSISTENT:
this.deliveryMode = javax.jms.DeliveryMode.PERSISTENT;
break;
case NON_PERSISTENT:
this.deliveryMode = javax.jms.DeliveryMode.NON_PERSISTENT;
break;
}
this.timeToLive = timeToLive;
this.priority = priority;
this.methodMap = methodMap;
| public ProducerManagerImpl(org.jboss.annotation.ejb.Producer producer, javax.jms.Destination destination, String factory, org.jboss.annotation.ejb.DeliveryMode deliveryMode, int timeToLive, int priority, HashMap methodMap, Hashtable initialContextProperties)
this.initialContextProperties = initialContextProperties;
try
{
this.initialContext = EJB3Util.getInitialContext(initialContextProperties);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
this.producer = producer;
this.destination = destination;
this.factoryLookup = factory;
int mode = deliveryMode.ordinal();
switch (mode)
{
case PERSISTENT:
this.deliveryMode = javax.jms.DeliveryMode.PERSISTENT;
break;
case NON_PERSISTENT:
this.deliveryMode = javax.jms.DeliveryMode.NON_PERSISTENT;
break;
}
this.timeToLive = timeToLive;
this.priority = priority;
this.methodMap = methodMap;
| public ProducerManagerImpl()
|
Methods Summary |
---|
public void | close()
msgProducer.close();
msgProducer = null;
session.close();
session = null;
connection.close();
connection = null;
| public void | commit()
session.commit();
| public void | connect()
if (factory == null)
{
try
{
factory = (ConnectionFactory) initialContext.lookup(factoryLookup);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
}
if (connection != null) return;
if (username != null)
{
connection = factory.createConnection(username, password);
}
else
{
connection = factory.createConnection();
}
session = connection.createSession(producer.transacted(), producer.acknowledgeMode());
msgProducer = session.createProducer(destination);
msgProducer.setDeliveryMode(deliveryMode);
msgProducer.setTimeToLive(timeToLive);
msgProducer.setPriority(priority);
| public java.lang.String | getName()
return ProducerManager.class.getName();
| public java.lang.Object | invoke(org.jboss.aop.joinpoint.Invocation invocation)
if (session == null)
{
throw new RuntimeException("You must call connect() on the producer. The JMS session has not been set");
}
ObjectMessage msg = session.createObjectMessage((Serializable) invocation);
MethodInvocation mi = (MethodInvocation) invocation;
MessageProperties props = (MessageProperties)methodMap.get(new Long(mi.getMethodHash()));
if (props != null)
{
int del = (props.delivery() == DeliveryMode.PERSISTENT) ? javax.jms.DeliveryMode.PERSISTENT : javax.jms.DeliveryMode.NON_PERSISTENT;
msgProducer.send(msg, del, props.priority(), props.timeToLive());
}
else
{
msgProducer.send(msg);
}
return null;
| public void | readExternal(java.io.ObjectInput in)
producer = (Producer) in.readObject();
destination = (Destination) in.readObject();
factoryLookup = (String) in.readObject();
deliveryMode = in.readInt();
timeToLive = in.readInt();
priority = in.readInt();
methodMap = (HashMap) in.readObject();
initialContextProperties = (Hashtable)in.readObject();
try
{
initialContext = EJB3Util.getInitialContext(initialContextProperties);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
if (factoryLookup != null)
{
try
{
factory = (ConnectionFactory) initialContext.lookup(factoryLookup);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
}
else
{
factory = (ConnectionFactory) in.readObject();
}
| public void | rollback()
session.rollback();
| public void | setPassword(java.lang.String passwd)
this.password = passwd;
| public void | setUsername(java.lang.String user)
this.username = user;
| public void | writeExternal(java.io.ObjectOutput out)
out.writeObject(producer);
out.writeObject(destination);
out.writeObject(factoryLookup);
out.writeInt(deliveryMode);
out.writeInt(timeToLive);
out.writeInt(priority);
out.writeObject(methodMap);
out.writeObject(initialContextProperties);
if (factoryLookup == null)
{
out.writeObject(factory);
}
|
|