Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/opencms/flex/CmsEvent.java


1   /*
2    * File   : $Source: /usr/local/cvs/opencms/src/com/opencms/flex/Attic/CmsEvent.java,v $
3    * Date   : $Date: 2003/02/26 15:19:24 $
4    * Version: $Revision: 1.5 $
5    *
6    * This library is part of OpenCms -
7    * the Open Source Content Mananagement System
8    *
9    * Copyright (C) 2002 - 2003 Alkacon Software (http://www.alkacon.com)
10   *
11   * This library is free software; you can redistribute it and/or
12   * modify it under the terms of the GNU Lesser General Public
13   * License as published by the Free Software Foundation; either
14   * version 2.1 of the License, or (at your option) any later version.
15   *
16   * This library is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   * Lesser General Public License for more details.
20   *
21   * For further information about Alkacon Software, please see the
22   * company website: http://www.alkacon.com
23   *
24   * For further information about OpenCms, please see the
25   * project website: http://www.opencms.org
26   * 
27   * You should have received a copy of the GNU Lesser General Public
28   * License along with this library; if not, write to the Free Software
29   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
30   */
31  
32  package com.opencms.flex;
33  
34  import com.opencms.file.CmsObject;
35  
36  /**
37   * Event class for OpenCms for system wide events that are thrown by various 
38   * operations (e.g. publishing) and can be catched and processed by 
39   * classes that implement the {@link I_CmsEventListener} interface.<p>
40   *
41   * @author  Alexander Kandzior (a.kandzior@alkacon.com)
42   *
43   * @version $Revision: 1.5 $
44   * @since FLEX alpha 1
45   * 
46   * @see I_CmsEventListener
47   */
48  public class CmsEvent extends java.util.EventObject {
49      
50      /** The CmsObject on which this event occurred */
51      private CmsObject m_cms = null;
52  
53      /** The event data associated with this event */
54      private java.util.Map m_data = null;
55  
56      /** The event type this instance represents */
57      private int m_type = -1;
58      
59      /** Boolean whether this event should be clustered */
60      private boolean m_isClusterEvent;
61  
62      /**
63       * Construct a new CmsEvent with the specified parameters, 
64       * this constructor just calls <code>this(cms, type, data, false)</code>.<p>
65       *
66       * @param cms CmsObject on which this event occurred
67       * @param type event type
68       * @param data event data
69       */
70      public CmsEvent(CmsObject cms, int type, java.util.Map data) {
71          this( cms, type, data, false );
72      }
73      
74      /**
75       * Construct a new CmsEvent with the specified parameters.<p>
76       * 
77       * The event data <code>Map</code> provides a facility to 
78       * pass objects with the event that contain information about 
79       * the event environment. For example, if the event is of type
80       * {@link I_CmsEventListener#EVENT_LOGIN_USER} the Map contains 
81       * a single object with the key <code>"data"</code> and a value 
82       * that is the OpenCms user object that represents the user that just logged in.<p>
83       * 
84       * If <code>isClusterEvent</code> is <code>true</code>,
85       * the event should be forwarded to all servers in the OpenCms cluster.
86       * If it is <code>false</code>, is is important only for server
87       * running this instance of OpenCms. 
88       *
89       * @param cms CmsObject on which this event occurred
90       * @param type event type
91       * @param data event data
92       * @param isClusterEvent must be <code>true</code> if this event should be forwarded 
93       *         to the other servers in the cluster
94       * 
95       * @see I_CmsEventListener
96       */    
97      public CmsEvent(CmsObject cms, int type, java.util.Map data, boolean isClusterEvent ) {
98          super(cms);
99          
100         this.m_cms = cms;
101         this.m_type = type;
102         this.m_data = data;
103         this.m_isClusterEvent = isClusterEvent;
104     }
105 
106     /**
107      * Provides access to the event data that was passed with this event.<p>
108      * 
109      * @return the event data of this event
110      */
111     public java.util.Map getData() {
112         return (m_data);
113     }
114 
115     /**
116      * Provides access to the CmsObject that was passed with this event.<p>
117      *
118      * @return the CmsObject on which this event occurred
119      */
120     public CmsObject getCmsObject() {
121         return (m_cms);
122     }
123 
124     /**
125      * Provides access to the event type that was passed with this event.<p>
126      * 
127      * Event types of the core OpenCms classes are defined in {@link I_CmsEventListener}.
128      * For your extensions, you should define them in a central class 
129      * or interface as public member variables. Make sure the integer values 
130      * do not confict with the values from the core classes.<p>
131      * 
132      * @return the event type of this event
133      * 
134      * @see I_CmsEventListener
135      */
136     public int getType() {
137         return (m_type);
138     }
139 
140     /**
141      * Return a String representation of this CmsEvent.<p>
142      *
143      * @return a String representation of this event
144      */
145     public String toString() {
146         return ("CmsEvent['" + m_cms + "','" + m_type + "']");
147     }
148 
149     /**
150      * Set the boolean flag whether this event should be forwarded 
151      * to the other servers in the cluster.<p>
152      *
153      * @param value <code>true</code> if this event should be forwarded to the other 
154      *         servers in the cluster, <code>false</code> otherwise
155      */
156     public void setClusterEvent( boolean value ) {
157         this.m_isClusterEvent = value;
158     }
159     
160     /**
161      * Check whether this event should be forwarded to the other servers 
162      * in the cluster or not.<p>
163      *
164      * @return <code>true</code> if this event should be forwarded to the other servers 
165      *          in the cluster, <code>false</code> otherwise
166      */
167     public boolean isClusterEvent() {
168         return this.m_isClusterEvent;
169     }
170 }