org.apache.activemq.web
Class WebClient

java.lang.Object
  extended by org.apache.activemq.web.WebClient
All Implemented Interfaces:
Externalizable, Serializable, EventListener, HttpSessionActivationListener, HttpSessionBindingListener
Direct Known Subclasses:
AjaxWebClient

public class WebClient
extends Object
implements HttpSessionActivationListener, 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.

See Also:
Serialized Form

Field Summary
static String BROKER_URL_INIT_PARAM
           
static String CONNECTION_FACTORY_ATTRIBUTE
           
static String CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM
           
static String CONNECTION_FACTORY_PREFETCH_PARAM
           
static String SELECTOR_NAME
           
static String selectorName
           
static String WEB_CLIENT_ATTRIBUTE
           
 
Constructor Summary
WebClient()
           
 
Method Summary
 void close()
           
 void closeConsumer(Destination destination)
           
 void closeConsumers()
           
protected  Session createSession()
           
protected static WebClient createWebClient(HttpServletRequest request)
           
 Connection getConnection()
           
 MessageConsumer getConsumer(Destination destination, String selector)
           
 MessageConsumer getConsumer(Destination destination, String selector, boolean create)
           
 List<MessageConsumer> getConsumers()
           
 int getDeliveryMode()
           
 String getPassword()
           
 MessageProducer getProducer()
           
 Semaphore getSemaphore()
           
 Session getSession()
           
 String getUsername()
           
static WebClient getWebClient(HttpServletRequest request)
          Helper method to get the client for the current session, lazily creating a client if there is none currently
static WebClient getWebClient(HttpSession session)
           
protected static void initConnectionFactory(ServletContext servletContext)
           
static void initContext(ServletContext context)
           
 boolean isClosed()
           
 void readExternal(ObjectInput in)
           
 void send(Destination destination, Message message)
           
 void send(Destination destination, Message message, boolean persistent, int priority, long timeToLive)
           
 void sessionDidActivate(HttpSessionEvent event)
           
 void sessionWillPassivate(HttpSessionEvent event)
           
 void setDeliveryMode(int deliveryMode)
           
 void setPassword(String password)
           
 void setProducer(MessageProducer producer)
           
 void setUsername(String username)
           
 void valueBound(HttpSessionBindingEvent event)
           
 void valueUnbound(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

WEB_CLIENT_ATTRIBUTE

public static final String WEB_CLIENT_ATTRIBUTE
See Also:
Constant Field Values

CONNECTION_FACTORY_ATTRIBUTE

public static final String CONNECTION_FACTORY_ATTRIBUTE
See Also:
Constant Field Values

CONNECTION_FACTORY_PREFETCH_PARAM

public static final String CONNECTION_FACTORY_PREFETCH_PARAM
See Also:
Constant Field Values

CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM

public static final String CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM
See Also:
Constant Field Values

BROKER_URL_INIT_PARAM

public static final String BROKER_URL_INIT_PARAM
See Also:
Constant Field Values

SELECTOR_NAME

public static final String SELECTOR_NAME
See Also:
Constant Field Values

selectorName

public static String selectorName
Constructor Detail

WebClient

public WebClient()
Method Detail

getWebClient

public static WebClient getWebClient(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(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(ServletContext context)

getDeliveryMode

public int getDeliveryMode()

setDeliveryMode

public void setDeliveryMode(int deliveryMode)

getUsername

public String getUsername()

setUsername

public void setUsername(String username)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

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(Destination destination,
                 Message message)
          throws JMSException
Throws:
JMSException

send

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

getSession

public Session getSession()
                   throws JMSException
Throws:
JMSException

getConnection

public Connection getConnection()
                         throws JMSException
Throws:
JMSException

initConnectionFactory

protected static void initConnectionFactory(ServletContext servletContext)

getProducer

public MessageProducer getProducer()
                            throws JMSException
Throws:
JMSException

setProducer

public void setProducer(MessageProducer producer)

getConsumer

public MessageConsumer getConsumer(Destination destination,
                                   String selector)
                            throws JMSException
Throws:
JMSException

getConsumer

public MessageConsumer getConsumer(Destination destination,
                                   String selector,
                                   boolean create)
                            throws JMSException
Throws:
JMSException

closeConsumer

public void closeConsumer(Destination destination)
                   throws JMSException
Throws:
JMSException

getConsumers

public List<MessageConsumer> getConsumers()

createSession

protected Session createSession()
                         throws JMSException
Throws:
JMSException

getSemaphore

public Semaphore getSemaphore()

sessionWillPassivate

public void sessionWillPassivate(HttpSessionEvent event)
Specified by:
sessionWillPassivate in interface HttpSessionActivationListener

sessionDidActivate

public void sessionDidActivate(HttpSessionEvent event)
Specified by:
sessionDidActivate in interface HttpSessionActivationListener

valueBound

public void valueBound(HttpSessionBindingEvent event)
Specified by:
valueBound in interface HttpSessionBindingListener

valueUnbound

public void valueUnbound(HttpSessionBindingEvent event)
Specified by:
valueUnbound in interface HttpSessionBindingListener

createWebClient

protected static WebClient createWebClient(HttpServletRequest request)


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.