01: package com.sun.portal.wsrp.producer;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05: import com.sun.portal.wsrp.producer.context.WSRPSessionContext;
06: import com.sun.portal.admin.common.util.AdminUtil;
07:
08: public class ISMultiPortalConstants implements ISConstants {
09:
10: public String MP_ATTR_PREFIX = "sunPortalWSRPProducer";
11:
12: public String MP_SUN_WSRP_PRODUCER_SERVICE = MP_ATTR_PREFIX
13: + "Service";
14:
15: public String MP_RDN_PRODUCER = "WSRPProducers";
16:
17: private static Map instances = new HashMap(2);
18: private static String staticId = null;
19: private String portalId = null;
20:
21: private ISMultiPortalConstants(String id) {
22: validateId(id);
23: if (!id.equals(AdminUtil.UPGRADED_PORTAL)) {
24: id = id.trim();
25: portalId = id;
26: MP_ATTR_PREFIX = "sunPortal" + id + "WSRPProducer";
27: MP_SUN_WSRP_PRODUCER_SERVICE = MP_ATTR_PREFIX + "Service";
28: MP_RDN_PRODUCER = MP_RDN_PRODUCER + id;
29: }
30: }
31:
32: public static synchronized void createInstance(String id) {
33: if (!instances.containsKey(id)) {
34: instances.put(id, new ISMultiPortalConstants(id));
35: }
36: }
37:
38: public static ISMultiPortalConstants getInstance() {
39: /*Current assumption - only webapps use this method
40: cli's or anything outside the container should not use
41: this method*/
42:
43: if (staticId == null) {
44: staticId = WSRPSessionContext.getStaticPortalId();
45: }
46: createInstance(staticId);
47: return (ISMultiPortalConstants) instances.get(staticId);
48: }
49:
50: public static ISMultiPortalConstants getInstance(String id) {
51: createInstance(id);
52: return (ISMultiPortalConstants) instances.get(id);
53: }
54:
55: private void validateId(String id) {
56: if (id == null || id.length() == 0) {
57: throw new IllegalArgumentException(
58: "Invalid portal identifier :" + id);
59: } else if (id.matches(".*[^a-zA-Z0-9-].*")) {
60: throw new IllegalArgumentException(
61: "Invalid portal identifier :" + id);
62: }
63: }
64:
65: public String getPortalId() {
66: return portalId;
67: }
68: }
|