View Javadoc

1   /*
2    * Copyright (c) 1998-2005 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  package jgroup.util.log;
19  
20  import jgroup.relacs.config.Domain;
21  
22  /**
23   * A partition or merge event to be logged.
24   * 
25   * @author Hein Meling
26   */
27  public class DomainEvent
28    extends Event
29  {
30  
31    ////////////////////////////////////////////////////////////////////////////////////////////
32    // Constants
33    ////////////////////////////////////////////////////////////////////////////////////////////
34  
35    private static final long serialVersionUID = 227099539664502309L;
36  
37    /**
38     * Supported domain event types.
39     */
40    public enum Type implements EventType { Partition, Merge }
41  
42  
43    ////////////////////////////////////////////////////////////////////////////////////////////
44    // Fields
45    ////////////////////////////////////////////////////////////////////////////////////////////
46  
47    /**
48     * The domain name for this DomainEvent
49     */
50    private String domain;
51  
52  
53    ////////////////////////////////////////////////////////////////////////////////////////////
54    // Constructor
55    ////////////////////////////////////////////////////////////////////////////////////////////
56  
57    public DomainEvent(EventType type, String description, Domain domain)
58    {
59      super(type, description);
60      this.domain = domain.getName();
61    }
62  
63  
64    ////////////////////////////////////////////////////////////////////////////////////////////
65    // Access Methods
66    ////////////////////////////////////////////////////////////////////////////////////////////
67  
68    /**
69     * @return Returns the domain.
70     */
71    public String getDomain()
72    {
73      return domain;
74    }
75  
76  
77    ////////////////////////////////////////////////////////////////////////////////////////////
78    // Methods from Object
79    ////////////////////////////////////////////////////////////////////////////////////////////
80  
81    public String toString()
82    {
83      StringBuilder buf = commonToString(true);
84      buf.append(" domain=");
85      buf.append(domain);
86      return buf.toString();
87    }
88  
89  } // END DomainEvent