KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > PluginID


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.plugins;
10
11 import org.jboss.portal.server.kernel.ServiceID;
12
13 /**
14  * Plugin key within a given container.
15  *
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.1.1.1 $
18  */

19 public class PluginID
20    implements ServiceID
21 {
22
23    private ServiceID containerID;
24    private String JavaDoc name;
25
26    public PluginID(ServiceID containerID, String JavaDoc name)
27    {
28       if (containerID == null)
29       {
30          throw new IllegalArgumentException JavaDoc("No null container ID");
31       }
32       if (name == null)
33       {
34          throw new IllegalArgumentException JavaDoc("No null name");
35       }
36       this.containerID = containerID;
37       this.name = name;
38    }
39
40    public int hashCode()
41    {
42       return name.hashCode() & containerID.hashCode();
43    }
44
45    public boolean equals(Object JavaDoc obj)
46    {
47       if (obj == this)
48       {
49          return true;
50       }
51       if (obj instanceof PluginID)
52       {
53          PluginID other = (PluginID)obj;
54          return name.equals(other.name) && containerID.equals(other.containerID);
55       }
56       return false;
57    }
58
59    public ServiceID getContainerID()
60    {
61       return containerID;
62    }
63
64    public String JavaDoc getName()
65    {
66       return name;
67    }
68
69    public String JavaDoc toString()
70    {
71       return "(" + containerID + "-" + name + ")";
72    }
73 }
74
Popular Tags