Source Code Cross Referenced for PolicyManager.java in  » Collaboration » JacORB » org » jacorb » orb » policies » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » JacORB » org.jacorb.orb.policies 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jacorb.orb.policies;
002:
003:        /*
004:         *        JacORB - a free Java ORB
005:         *
006:         *   Copyright (C) 1997-2004 Gerald Brose.
007:         *
008:         *   This library is free software; you can redistribute it and/or
009:         *   modify it under the terms of the GNU Library General Public
010:         *   License as published by the Free Software Foundation; either
011:         *   version 2 of the License, or (at your option) any later version.
012:         *
013:         *   This library is distributed in the hope that it will be useful,
014:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         *   Library General Public License for more details.
017:         *
018:         *   You should have received a copy of the GNU Library General Public
019:         *   License along with this library; if not, write to the Free
020:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         */
022:
023:        import org.jacorb.config.Configuration;
024:        import org.jacorb.util.ObjectUtil;
025:        import org.omg.CORBA._PolicyManagerLocalBase;
026:
027:        import org.apache.avalon.framework.logger.*;
028:
029:        import java.util.*;
030:
031:        /**
032:         * Implementation of the ORB-level policy management interface as per
033:         * CORBA 2.6, p. 4-43 to 4-45:
034:         *
035:         * This PolicyManager has operations through which a set of Policies
036:         * can be applied and the current overriding Policy settings can be
037:         * obtained.  Policies applied at the ORB level override any system
038:         * defaults. The ORB's PolicyManager is obtained through an invocation
039:         * of ORB::resolve_initial_references, specifying an identifier of
040:         * "ORBPolicyManager."
041:         *
042:         * @author Gerald Brose
043:         * @version $Id: PolicyManager.java,v 1.8 2006/07/07 10:55:41 alphonse.bendt Exp $
044:         */
045:
046:        public class PolicyManager extends _PolicyManagerLocalBase {
047:            private final Map policy_overrides;
048:            private final Logger logger;
049:
050:            /**
051:             * public c'tor
052:             */
053:
054:            public PolicyManager(Configuration config) {
055:                super ();
056:
057:                policy_overrides = new HashMap();
058:                this .logger = config.getNamedLogger("jacorb.orb.policies");
059:            }
060:
061:            /**
062:             * Returns a PolicyList containing the overridden Polices for the
063:             * requested PolicyTypes.  If the specified sequence is empty, all
064:             * Policy overrides at this scope will be returned.  If none of
065:             * the requested PolicyTypes are overridden at the target
066:             * PolicyManager, an empty sequence is returned. This accessor
067:             * returns only those Policy overrides that have been set at the
068:             * specific scope corresponding to the target PolicyManager (no
069:             * evaluation is done with respect to overrides at other scopes).
070:             *
071:             * @param ts a sequence of overridden policy types identifying the
072:             *           policies that are to be retrieved.
073:             * @return the list of overridden policies of the types specified by ts
074:             */
075:
076:            public synchronized org.omg.CORBA.Policy[] get_policy_overrides(
077:                    int[] ts) {
078:                if (ts == null) {
079:                    throw new IllegalArgumentException(
080:                            "Argument may not be null");
081:                }
082:
083:                if (ts.length == 0) {
084:                    return (org.omg.CORBA.Policy[]) policy_overrides.values()
085:                            .toArray(new org.omg.CORBA.Policy[] {});
086:                }
087:
088:                List policyList = new ArrayList();
089:
090:                for (int i = 0; i < ts.length; i++) {
091:                    org.omg.CORBA.Policy policy = (org.omg.CORBA.Policy) policy_overrides
092:                            .get(ObjectUtil.newInteger(ts[i]));
093:                    if (policy != null) {
094:                        policyList.add(policy);
095:                    }
096:                }
097:
098:                org.omg.CORBA.Policy[] result = (org.omg.CORBA.Policy[]) policyList
099:                        .toArray(new org.omg.CORBA.Policy[] {});
100:
101:                if (logger.isDebugEnabled() && result.length > 0) {
102:                    logger.debug("get_policy_overrides returns "
103:                            + result.length + " policies");
104:                }
105:
106:                return result;
107:            }
108:
109:            /**
110:             *
111:             * Modifies the current set of overrides with the requested list
112:             * of Policy overrides. The first parameter policies is a sequence
113:             * of references to Policy objects. The second parameter set_add
114:             * of type SetOverrideType indicates whether these policies should
115:             * be added onto any other overrides that already exist
116:             * (ADD_OVERRIDE) in the PolicyManager, or they should be added to
117:             * a clean PolicyManager free of any other overrides
118:             * (SET_OVERRIDE).
119:             * <p>
120:             * Invoking set_policy_overrides with an empty sequence of
121:             * policies and a mode of SET_OVERRIDE removes all overrides from
122:             * a PolicyManager. Only certain policies that pertain to the
123:             * invocation of an operation at the client end can be overridden
124:             * using this operation. Attempts to override any other policy
125:             * will result in the raising of the CORBA::NO_PERMISSION
126:             * exception. If the request would put the set of overriding
127:             * policies for the target PolicyManager in an inconsistent state,
128:             * no policies are changed or added, and the exception
129:             * InvalidPolicies is raised. There is no evaluation of
130:             * compatibility with policies set within other PolicyManagers.
131:             *
132:             * @param policies a sequence of Policy objects that are to be
133:             * associated with the PolicyManager object.
134:             *
135:             * @param set_add whether the association is in addition to
136:             * (ADD_OVERRIDE) or as a replacement of (SET_OVERRIDE) any
137:             * existing overrides already associated with the PolicyManager
138:             * object. If the value of this parameter is SET_OVERRIDE, the
139:             * supplied policies completely replace all existing overrides
140:             * associated with the PolicyManager object. If the value of this
141:             * parameter is ADD_OVERRIDE, the supplied policies are added to
142:             * the existing overrides associated with the PolicyManager
143:             * object, except that if a supplied Policy object has the same
144:             * PolicyType value as an existing override, the supplied Policy
145:             * object replaces the existing override.
146:             *
147:             * @throws org.omg.CORBA.InvalidPolicies a list of indices identifying the
148:             * position in the input policies list that are occupied by
149:             * invalid policies
150:             *
151:             * @throws org.omg.CORBA.BAD_PARAM if the sequence contains two or more Policy
152:             * objects with the same PolicyType value, the operation raises
153:             * the standard sytem exception BAD_PARAM with standard minor code
154:             * 30.
155:             */
156:
157:            public synchronized void set_policy_overrides(
158:                    org.omg.CORBA.Policy[] policies,
159:                    org.omg.CORBA.SetOverrideType set_add)
160:                    throws org.omg.CORBA.InvalidPolicies {
161:                if (policies == null) {
162:                    throw new IllegalArgumentException(
163:                            "Argument may not be null");
164:                }
165:
166:                Map newPolicies = new HashMap();
167:                StringBuffer sb = new StringBuffer();
168:
169:                // check that the policies argument does not contain multiple
170:                // policies of the same type while (copying the list of policies)
171:                // and does not override policies that cannot be overriden
172:                for (int i = 0; i < policies.length; i++) {
173:                    if (!PolicyUtil.isInvocationPolicy(policies[i]
174:                            .policy_type())) {
175:                        throw new org.omg.CORBA.NO_PERMISSION(
176:                                "Not an invocation policy, type "
177:                                        + policies[i].policy_type());
178:                    }
179:                    // else:
180:                    Integer key = ObjectUtil.newInteger(policies[i]
181:                            .policy_type());
182:                    if (newPolicies.put(key, policies[i]) != null) {
183:                        throw new org.omg.CORBA.BAD_PARAM(
184:                                "Multiple policies of type "
185:                                        + policies[i].policy_type(), 30,
186:                                org.omg.CORBA.CompletionStatus.COMPLETED_NO);
187:                    }
188:                    sb.append(" " + policies[i].policy_type());
189:                }
190:
191:                if (set_add == org.omg.CORBA.SetOverrideType.SET_OVERRIDE) {
192:                    PolicyUtil.checkValidity(newPolicies);
193:                    if (logger.isDebugEnabled()) {
194:                        logger.debug("SET_OVERRIDE, types: " + sb.toString());
195:                    }
196:                    policy_overrides.clear();
197:                    policy_overrides.putAll(newPolicies);
198:                } else if (set_add == org.omg.CORBA.SetOverrideType.ADD_OVERRIDE) {
199:                    // adds policies (and replaces any existing policies)
200:                    Map test = new HashMap(policy_overrides);
201:                    test.putAll(policy_overrides);
202:                    test.putAll(newPolicies);
203:                    PolicyUtil.checkValidity(test);
204:
205:                    if (logger.isDebugEnabled()) {
206:                        logger.debug("ADD_OVERRIDE, types: " + sb.toString());
207:                    }
208:                    policy_overrides.clear();
209:                    policy_overrides.putAll(test);
210:                }
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.