org.apache.activemq.web
Class WebClient

java.lang.Object
  extended by org.apache.activemq.web.WebClient
All Implemented Interfaces:
Externalizable, Serializable, EventListener, javax.servlet.http.HttpSessionActivationListener, javax.servlet.http.HttpSessionBindingListener

public class WebClient
extends Object
implements javax.servlet.http.HttpSessionActivationListener, javax.servlet.http.HttpSessionBindingListener, Externalizable

Represents a messaging client used from inside a web container typically stored inside a HttpSession TODO controls to prevent DOS attacks with users requesting many consumers TODO configure consumers with small prefetch.

Version:
$Revision: 1.1.1.1 $
See Also:
Serialized Form

Field Summary
static String brokerUrlInitParam
           
static String connectionFactoryAttribute
           
static String connectionFactoryOptimizeAckParam
           
static String connectionFactoryPrefetchParam
           
static String webClientAttribute
           
 
Constructor Summary
WebClient()
           
 
Method Summary
 void close()
           
 void closeConsumer(javax.jms.Destination destination)
           
 void closeConsumers()
           
protected  ActiveMQSession createSession()
           
protected static WebClient createWebClient(javax.servlet.http.HttpServletRequest request)
           
 ActiveMQConnection getConnection()
           
 javax.jms.MessageConsumer getConsumer(javax.jms.Destination destination)
           
 javax.jms.MessageConsumer getConsumer(javax.jms.Destination destination, boolean create)
           
 List getConsumers()
           
 int getDeliveryMode()
           
 javax.jms.MessageProducer getProducer()
           
 edu.emory.mathcs.backport.java.util.concurrent.Semaphore getSemaphore()
           
 javax.jms.Session getSession()
           
static WebClient getWebClient(javax.servlet.http.HttpServletRequest request)
          Helper method to get the client for the current session, lazily creating a client if there is none currently
static WebClient getWebClient(javax.servlet.http.HttpSession session)
           
static void initConnectionFactory(javax.servlet.ServletContext servletContext)
           
static void initContext(javax.servlet.ServletContext context)
           
 boolean isClosed()
           
 void readExternal(ObjectInput in)
           
 void send(javax.jms.Destination destination, javax.jms.Message message)
           
 void send(javax.jms.Destination destination, javax.jms.Message message, boolean persistent, int priority, int timeToLive)
           
 void sessionDidActivate(javax.servlet.http.HttpSessionEvent event)
           
 void sessionWillPassivate(javax.servlet.http.HttpSessionEvent event)
           
 void setDeliveryMode(int deliveryMode)
           
 void setProducer(javax.jms.MessageProducer producer)
           
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
           
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

webClientAttribute

public static final String webClientAttribute
See Also:
Constant Field Values

connectionFactoryAttribute

public static final String connectionFactoryAttribute
See Also:
Constant Field Values

connectionFactoryPrefetchParam

public static final String connectionFactoryPrefetchParam
See Also:
Constant Field Values

connectionFactoryOptimizeAckParam

public static final String connectionFactoryOptimizeAckParam
See Also:
Constant Field Values

brokerUrlInitParam

public static final String brokerUrlInitParam
See Also:
Constant Field Values
Constructor Detail

WebClient

public WebClient()
Method Detail

getWebClient

public static WebClient getWebClient(javax.servlet.http.HttpServletRequest request)
Helper method to get the client for the current session, lazily creating a client if there is none currently

Parameters:
request - is the current HTTP request
Returns:
the current client or a newly creates

getWebClient

public static WebClient getWebClient(javax.servlet.http.HttpSession session)
Returns:
the web client for the current HTTP session or null if there is not a web client created yet

initContext

public static void initContext(javax.servlet.ServletContext context)

getDeliveryMode

public int getDeliveryMode()

setDeliveryMode

public void setDeliveryMode(int deliveryMode)

closeConsumers

public void closeConsumers()

close

public void close()

isClosed

public boolean isClosed()

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message)
          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 boolean persistent,
                 int priority,
                 int timeToLive)
          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getSession

public javax.jms.Session getSession()
                             throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getConnection

public ActiveMQConnection getConnection()
                                 throws javax.jms.JMSException
Throws:
javax.jms.JMSException

initConnectionFactory

public static void initConnectionFactory(javax.servlet.ServletContext servletContext)

getProducer

public javax.jms.MessageProducer getProducer()
                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setProducer

public void setProducer(javax.jms.MessageProducer producer)

getConsumer

public javax.jms.MessageConsumer getConsumer(javax.jms.Destination destination)
                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getConsumer

public javax.jms.MessageConsumer getConsumer(javax.jms.Destination destination,
                                             boolean create)
                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

closeConsumer

public void closeConsumer(javax.jms.Destination destination)
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getConsumers

public List getConsumers()

createSession

protected ActiveMQSession createSession()
                                 throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getSemaphore

public edu.emory.mathcs.backport.java.util.concurrent.Semaphore getSemaphore()

sessionWillPassivate

public void sessionWillPassivate(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionWillPassivate in interface javax.servlet.http.HttpSessionActivationListener

sessionDidActivate

public void sessionDidActivate(javax.servlet.http.HttpSessionEvent event)
Specified by:
sessionDidActivate in interface javax.servlet.http.HttpSessionActivationListener

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener

createWebClient

protected static WebClient createWebClient(javax.servlet.http.HttpServletRequest request)


Copyright © 2011 Apache Software Foundation. All Rights Reserved.