KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > ServerObjectID


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;
10
11 import org.jboss.portal.common.FQN;
12 import org.jboss.portal.server.kernel.ServiceID;
13
14 /**
15  * Uniquely identify a portal object.
16  *
17  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
18  * @version $Revision: 1.2 $
19  */

20 public class ServerObjectID
21    extends FQN
22    implements ServiceID
23 {
24
25    private String JavaDoc desc = null;
26
27    public ServerObjectID(String JavaDoc[] names) throws IllegalArgumentException JavaDoc
28    {
29       super(names);
30    }
31
32    public String JavaDoc toString()
33    {
34       if (desc == null)
35       {
36          StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
37          buffer.append(names[0]);
38          for (int i = 1;i < names.length;i++)
39          {
40             buffer.append('.').append(names[i]);
41          }
42          desc = buffer.toString();
43       }
44       return desc;
45    }
46
47    /**
48     *
49     */

50    public static ServerObjectID createPortalContainerID() throws IllegalArgumentException JavaDoc
51    {
52
53       return new ServerObjectID(new String JavaDoc[]{"container"});
54    }
55
56    /**
57     *
58     */

59    public static ServerObjectID createPortalID(String JavaDoc name) throws IllegalArgumentException JavaDoc
60    {
61       return new ServerObjectID(new String JavaDoc[]{"portal", name});
62    }
63
64    /**
65     *
66     */

67    public static ServerObjectID createPortalID(ServerObjectID id, String JavaDoc portalName) throws IllegalArgumentException JavaDoc
68    {
69       return createPortalID(portalName);
70    }
71
72    /**
73     *
74     */

75    public static ServerObjectID createInstanceID(String JavaDoc applicationName, String JavaDoc componentName, String JavaDoc instanceName) throws IllegalArgumentException JavaDoc
76    {
77       return new ServerObjectID(new String JavaDoc[]{"instance", applicationName, componentName, instanceName});
78    }
79
80    /**
81     *
82     */

83    public static ServerObjectID createInstanceID(ServerObjectID id, String JavaDoc name) throws IllegalArgumentException JavaDoc
84    {
85       return createInstanceID((String JavaDoc)id.getName(1), (String JavaDoc)id.getName(2), name);
86    }
87
88    /**
89     *
90     */

91    public static ServerObjectID createWindowID(String JavaDoc portalName, String JavaDoc windowName) throws IllegalArgumentException JavaDoc
92    {
93       return new ServerObjectID(new String JavaDoc[]{"window", portalName, windowName});
94    }
95
96    /**
97     *
98     */

99    public static ServerObjectID createWindowID(ServerObjectID id, String JavaDoc name) throws IllegalArgumentException JavaDoc
100    {
101       return createWindowID((String JavaDoc)id.getName(1), name);
102    }
103
104    /**
105     *
106     */

107    public static ServerObjectID createApplicationID(String JavaDoc applicationName) throws IllegalArgumentException JavaDoc
108    {
109       return new ServerObjectID(new String JavaDoc[]{"application", applicationName});
110    }
111
112    /**
113     *
114     */

115    public static ServerObjectID createApplicationID(ServerObjectID id, String JavaDoc name) throws IllegalArgumentException JavaDoc
116    {
117       return createApplicationID(name);
118    }
119
120    /**
121     *
122     */

123    public static ServerObjectID createComponentID(String JavaDoc applicationName, String JavaDoc componentName) throws IllegalArgumentException JavaDoc
124    {
125       return new ServerObjectID(new String JavaDoc[]{"component", applicationName, componentName});
126    }
127
128    /**
129     *
130     */

131    public static ServerObjectID createComponentID(ServerObjectID id, String JavaDoc name) throws IllegalArgumentException JavaDoc
132    {
133       return createComponentID((String JavaDoc)id.getName(1), name);
134    }
135 }
136
Popular Tags