WebLogic Integration


com.bea.wlai.client
Class EventContext

java.lang.Object
  |
  +--com.bea.wlai.client.EventContext

public class EventContext
extends java.lang.Object
implements java.io.Serializable

A frame of reference for generating/receiving events. This class is used by ApplicationView to manage the event delivery mechanics in methods such as postEvent, addEventListener, etc.

Author:
Copyright © 2000, 2001 BEA Systems, Inc. All Rights Reserved.
See Also:
ApplicationView, Serialized Form

Field Summary
static int JMS_QUEUE
           
static int JMS_TOPIC
           
 
Constructor Summary
protected EventContext()
          Constructor for use by Java serialization framework.
  EventContext(java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName, int jmsDestType)
          Get an EventContext object using the given JNDI context.
  EventContext(java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName, int jmsDestType, boolean bTransaction)
          Get an EventContext object using the given JNDI context.
  EventContext(java.lang.String sourceKey, java.lang.String sourceType, java.util.Hashtable jndiEnv, java.lang.String jmsDestName, int jmsDestType)
          Get an EventContext object using the given JNDI context.
  EventContext(java.lang.String durableClientID, java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName)
          Get an EventContext object using the given JNDI context.
protected EventContext(java.lang.String durableClientID, java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName, int jmsDestType)
           
  EventContext(java.lang.String durableClientID, java.lang.String sourceKey, java.lang.String sourceType, java.util.Hashtable jndiEnv, java.lang.String jmsDestName)
          Get an EventContext object using the given JNDI context.
  EventContext(javax.security.auth.Subject authUser, java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName, int jmsDestType)
          constructor for internal use
 
Method Summary
 void addListener(java.lang.String eventTypeName, EventListener eventListener)
          Register a listener for all events of type eventTypeName.
 void addListener(java.lang.String eventTypeName, EventListener eventListener, java.lang.String subscriberName)
          Register a listener for all events of type eventTypeName.
protected  void checkClosed()
           
 void close()
          Close JMS resources.
protected  boolean compare(java.lang.Object obj1, java.lang.Object obj2)
          Helper method for comparing member variables, safe to pass null for either of the parameters.
 boolean containsListener(java.lang.String eventTypeName, EventListener listener)
          Has this EventContext already had EventListener given by listener register interest in events of type eventTypeName.
 boolean equals(java.lang.Object obj)
           
 javax.naming.Context getContext()
          Get the JNDI context being used.
 javax.jms.Queue getJMSQueue()
          Deprecated. This method is no longer used due to internal refactoring.
 javax.jms.Topic getJMSTopic()
          Deprecated. This method is no longer used due to internal refactoring.
 java.lang.String getSourceKey()
           
 java.lang.String getSourceType()
           
protected  void init(java.lang.String durableClientID, java.lang.String sourceKey, java.lang.String sourceType, javax.naming.Context context, java.lang.String jmsDestName, int jmsDestType)
          initialize the Object
protected  void initialize()
          Initialize JMS.
 void postEvent(java.lang.String eventType, IEvent event)
          Post an event with the given type and represented by the given event to this EventContext.
 void reinitialize()
          Reinitialize JMS resources using stored environment properties, and JMS topic name.
 boolean removeListener(java.lang.String eventTypeName, EventListener listener)
          Remove this listener from the list of listeners on events of type eventTypeName.
protected  void setContext(javax.naming.Context context)
          Set the JNDI context to use.
protected  void setJMSQueue(javax.jms.Queue queue)
          Deprecated. This method is no longer used due to internal refactoring.
protected  void setJMSTopic(javax.jms.Topic topic)
          Deprecated. This method is no longer used due to internal refactoring.
 java.lang.String toString()
           
static void validateDurableClientID(java.lang.String strDurableClientID)
          Convenience method for validating if the argument is a valid durable client ID for an EventContext.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JMS_TOPIC

public static final int JMS_TOPIC

JMS_QUEUE

public static final int JMS_QUEUE
Constructor Detail

EventContext

protected EventContext()
Constructor for use by Java serialization framework.

EventContext

public EventContext(java.lang.String sourceKey,
                    java.lang.String sourceType,
                    java.util.Hashtable jndiEnv,
                    java.lang.String jmsDestName,
                    int jmsDestType)
             throws javax.naming.NamingException,
                    EventContextException
Get an EventContext object using the given JNDI context. This context will send messages to the JMS destination (queue or topic) given by the jmsDestName parameter. An instance constructed with this constructor does not support durable subscriptions.

Parameters:
sourceKey - - identifies the source of the events; cannot be null
sourceType - - identifies the type of source; e.g. ApplicationView; cannot be null
jndiEnv - - contains properties needed to establish an initial JNDI context to a J2EE application server.
jmsDestName - - the JNDI context for the JMS destination for events
jmsDestType - - destination type: JMS_TOPIC or JMS_QUEUE
Throws:
javax.naming.NamingException - if an error occurs trying to connect to the J2EE application server using the supplied JNDI properties.
EventContextException - if an error occurs while initializing the members of this instance.

EventContext

public EventContext(java.lang.String sourceKey,
                    java.lang.String sourceType,
                    javax.naming.Context context,
                    java.lang.String jmsDestName,
                    int jmsDestType)
             throws javax.naming.NamingException,
                    EventContextException
Get an EventContext object using the given JNDI context. This context will send messages to the JMS destination (queue or topic) given by the jmsDestName parameter. An instance constructed with this constructor does not support durable subscriptions.

Parameters:
sourceKey - - identifies the source of the events; cannot be null
sourceType - - identifies the type of source; e.g. ApplicationView; cannot be null
context - - a JNDI context to a J2EE application server.
jmsDestName - - the JNDI context for the JMS destination for events
jmsDestType - - destination type: JMS_TOPIC or JMS_QUEUE
Throws:
javax.naming.NamingException - if an error occurs trying to connect to the J2EE application server using the supplied JNDI properties.
EventContextException - if an error occurs while initializing the members of this instance.

EventContext

public EventContext(javax.security.auth.Subject authUser,
                    java.lang.String sourceKey,
                    java.lang.String sourceType,
                    javax.naming.Context context,
                    java.lang.String jmsDestName,
                    int jmsDestType)
             throws javax.naming.NamingException,
                    EventContextException
constructor for internal use

EventContext

public EventContext(java.lang.String sourceKey,
                    java.lang.String sourceType,
                    javax.naming.Context context,
                    java.lang.String jmsDestName,
                    int jmsDestType,
                    boolean bTransaction)
             throws javax.naming.NamingException,
                    EventContextException
Get an EventContext object using the given JNDI context. This context will send messages to the JMS destination (queue or topic) given by the jmsDestName parameter. An instance constructed with this constructor does not support durable subscriptions.

Parameters:
sourceKey - - identifies the source of the events; cannot be null
sourceType - - identifies the type of source; e.g. ApplicationView; cannot be null
context - - a JNDI context to a J2EE application server.
jmsDestName - - the JNDI context for the JMS destination for events
jmsDestType - - destination type: JMS_TOPIC or JMS_QUEUE
bTransaction - - not used
Throws:
javax.naming.NamingException - if an error occurs trying to connect to the J2EE application server using the supplied JNDI properties.
EventContextException - if an error occurs while initializing the members of this instance.

EventContext

public EventContext(java.lang.String durableClientID,
                    java.lang.String sourceKey,
                    java.lang.String sourceType,
                    java.util.Hashtable jndiEnv,
                    java.lang.String jmsDestName)
             throws javax.naming.NamingException,
                    EventContextException
Get an EventContext object using the given JNDI context. This context will send/receive messages to/from the JMS topic given by the jmsDestName parameter.

Parameters:
durableClientID - - an identifier of the client of this instance; this ID is used to obtain durable subscriptions for this JMS topic. The ID must be a valid Java identifier.
sourceKey - - identifies the source of the events; cannot be null
sourceType - - identifies the type of source; e.g. ApplicationView; cannot be null
jndiEnv - - contains properties needed to establish an initial JNDI context to a J2EE application server.
jmsDestName - - the JNDI context for the JMS topic for events this parameter is currently not used by this implementation.
Throws:
javax.naming.NamingException - if an error occurs trying to connect to the J2EE application server using the supplied JNDI properties.
EventContextException - if an error occurs while initializing the members of this instance.

EventContext

public EventContext(java.lang.String durableClientID,
                    java.lang.String sourceKey,
                    java.lang.String sourceType,
                    javax.naming.Context context,
                    java.lang.String jmsDestName)
             throws javax.naming.NamingException,
                    EventContextException
Get an EventContext object using the given JNDI context. This context will send/receive messages to/from the JMS topic given by the jmsDestName parameter.

Parameters:
durableClientID - - an identifier of the client of this instance; this ID is used to obtain durable subscriptions for this JMS topic. The ID must be a valid Java identifier.
sourceKey - - identifies the source of the events; cannot be null
sourceType - - identifies the type of source; e.g. ApplicationView; cannot be null
jndiEnv - - contains properties needed to establish an initial JNDI context to a J2EE application server.
jmsDestName - - the JNDI context for the JMS topic for events this parameter is currently not used by this implementation.
Throws:
javax.naming.NamingException - if an error occurs trying to connect to the J2EE application server using the supplied JNDI properties.
EventContextException - if an error occurs while initializing the members of this instance.

EventContext

protected EventContext(java.lang.String durableClientID,
                       java.lang.String sourceKey,
                       java.lang.String sourceType,
                       javax.naming.Context context,
                       java.lang.String jmsDestName,
                       int jmsDestType)
                throws javax.naming.NamingException,
                       EventContextException
Method Detail

validateDurableClientID

public static final void validateDurableClientID(java.lang.String strDurableClientID)
                                          throws java.lang.IllegalArgumentException
Convenience method for validating if the argument is a valid durable client ID for an EventContext.

Throws:
java.lang.IllegalArgumentException - if the argument is not a valid durable client ID.

init

protected void init(java.lang.String durableClientID,
                    java.lang.String sourceKey,
                    java.lang.String sourceType,
                    javax.naming.Context context,
                    java.lang.String jmsDestName,
                    int jmsDestType)
             throws javax.naming.NamingException,
                    EventContextException
initialize the Object


getSourceKey

public java.lang.String getSourceKey()

Returns:
the source key for this instance; typically ApplicationView name

getSourceType

public java.lang.String getSourceType()

Returns:
the source type for this instance, such as ApplicationView

initialize

protected void initialize()
                   throws javax.naming.NamingException,
                          EventContextException
Initialize JMS. JNDI context, JMS destination JNDI name and type must be set before calling this method.


close

public void close()
Close JMS resources.


checkClosed

protected void checkClosed()
                    throws EventContextException


postEvent

public void postEvent(java.lang.String eventType,
                      IEvent event)
               throws DocumentException,
                      EventContextException
Post an event with the given type and represented by the given event to this EventContext.


addListener

public void addListener(java.lang.String eventTypeName,
                        EventListener eventListener)
                 throws EventContextException
Register a listener for all events of type eventTypeName. Passing eventTypeName=null means you want to be notified about all event types.


addListener

public void addListener(java.lang.String eventTypeName,
                        EventListener eventListener,
                        java.lang.String subscriberName)
                 throws EventContextException
Register a listener for all events of type eventTypeName. Passing eventTypeName=null means you want to be notified about all event types. If subscriberName is specified, the Listener will utilize a Durable Subscriber. If subscriberName is null or empty, a non-Durable Subscriber will be used.

Parameters:
eventTypeName -  
eventListener -  
subscriberName - unique name for a durable subscriber
Throws:
EventContextException -  

containsListener

public boolean containsListener(java.lang.String eventTypeName,
                                EventListener listener)
Has this EventContext already had EventListener given by listener register interest in events of type eventTypeName.


removeListener

public boolean removeListener(java.lang.String eventTypeName,
                              EventListener listener)
Remove this listener from the list of listeners on events of type eventTypeName.


setJMSTopic

protected void setJMSTopic(javax.jms.Topic topic)
Deprecated. This method is no longer used due to internal refactoring.
Set the JMS topic to use.


setJMSQueue

protected void setJMSQueue(javax.jms.Queue queue)
Deprecated. This method is no longer used due to internal refactoring.
Set the JMS queue to use.


setContext

protected void setContext(javax.naming.Context context)
Set the JNDI context to use.


getContext

public javax.naming.Context getContext()
Get the JNDI context being used.


getJMSTopic

public javax.jms.Topic getJMSTopic()
Deprecated. This method is no longer used due to internal refactoring.
Get the JMS topic being used; may be null depending on construction


getJMSQueue

public javax.jms.Queue getJMSQueue()
Deprecated. This method is no longer used due to internal refactoring.
Get the JMS queue being used; may be null depending on construction


reinitialize

public void reinitialize()
                  throws javax.naming.NamingException,
                         EventContextException
Reinitialize JMS resources using stored environment properties, and JMS topic name.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

compare

protected final boolean compare(java.lang.Object obj1,
                                java.lang.Object obj2)
Helper method for comparing member variables, safe to pass null for either of the parameters.


WebLogic Integration

WebLogic Integration (WLI)