KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > server > ServerObjectInstance


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.mx.server;
23
24 import java.io.ObjectStreamException JavaDoc;
25
26 import javax.management.ObjectInstance JavaDoc;
27 import javax.management.ObjectName JavaDoc;
28
29 /**
30  * An Object Instance that differentiates between MBeanServers.
31  *
32  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
33  * @version $Revision: 37459 $
34  */

35 public class ServerObjectInstance
36    extends ObjectInstance JavaDoc
37 {
38    // Attributes --------------------------------------------------
39

40    /**
41     * The agent id
42     */

43    String JavaDoc agentID;
44
45
46    // Constructors ------------------------------------------------
47

48    /**
49     * Create a new Server Object Instance
50     *
51     * @param name the object name
52     * @param className the class name
53     * @param agentID the agentID
54     */

55    public ServerObjectInstance(ObjectName JavaDoc name, String JavaDoc className, String JavaDoc agentID)
56    {
57       super(name, className);
58       this.agentID = agentID;
59    }
60
61    // Public ------------------------------------------------------
62

63    /**
64     * Retrieve the agent id of the object instance
65     *
66     * @return the agent id
67     */

68    String JavaDoc getAgentID()
69    {
70       return agentID;
71    }
72
73  
74    // ObjectInstance overrides ------------------------------------
75

76    public boolean equals(Object JavaDoc object)
77    {
78      if (object instanceof ServerObjectInstance)
79        return (super.equals(object) == true
80                && this.agentID.equals(((ServerObjectInstance)object).agentID));
81      else
82        return super.equals(object);
83    }
84
85  
86    // Serialization implementation ----------------------------------
87

88    /**
89     * We replace ourself with an ObjectInstance in the stream.
90     * This loses the agentId which isn't part of the spec.
91     *
92     * @return an ObjectInstance version of ourself
93     * @exception ObjectStreamException for a serialization error
94     */

95    private Object JavaDoc writeReplace()
96       throws ObjectStreamException JavaDoc
97    {
98       return new ObjectInstance JavaDoc(getObjectName(), getClassName());
99    }
100
101 }
102
Popular Tags