Source Code Cross Referenced for PolicyInclude.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » description » 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 » Web Services AXIS2 » kernal » org.apache.axis2.description 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        package org.apache.axis2.description;
021:
022:        import org.apache.axiom.om.util.UUIDGenerator;
023:        import org.apache.axis2.util.AxisPolicyLocator;
024:        import org.apache.neethi.Policy;
025:        import org.apache.neethi.PolicyReference;
026:        import org.apache.neethi.PolicyRegistry;
027:        import org.apache.neethi.PolicyRegistryImpl;
028:
029:        import java.util.ArrayList;
030:        import java.util.Hashtable;
031:        import java.util.Iterator;
032:        import java.util.List;
033:
034:        public class PolicyInclude {
035:
036:            public static final int ANON_POLICY = 100;
037:
038:            public static final int AXIS_POLICY = 1;
039:
040:            public static final int AXIS_MODULE_POLICY = 2;
041:
042:            public static final int AXIS_MODULE_OPERATION_POLICY = 17;
043:
044:            public static final int AXIS_SERVICE_POLICY = 3;
045:
046:            public static final int AXIS_OPERATION_POLICY = 4;
047:
048:            public static final int AXIS_MESSAGE_POLICY = 5;
049:
050:            public static final int SERVICE_POLICY = 6;
051:
052:            public static final int PORT_POLICY = 7;
053:
054:            public static final int PORT_TYPE_POLICY = 8;
055:
056:            public static final int BINDING_POLICY = 9;
057:
058:            public static final int OPERATION_POLICY = 10;
059:
060:            public static final int BINDING_OPERATION_POLICY = 11;
061:
062:            public static final int INPUT_POLICY = 12;
063:
064:            public static final int OUTPUT_POLICY = 13;
065:
066:            public static final int BINDING_INPUT_POLICY = 14;
067:
068:            public static final int BINDING_OUTPUT_POLICY = 15;
069:
070:            public static final int MESSAGE_POLICY = 16;
071:
072:            private Policy policy = null;
073:
074:            private Policy effectivePolicy = null;
075:
076:            private PolicyRegistry reg;
077:
078:            private AxisDescription description;
079:
080:            private Hashtable wrapperElements = new Hashtable();
081:
082:            public PolicyInclude() {
083:                reg = new PolicyRegistryImpl();
084:            }
085:
086:            public PolicyInclude(AxisDescription axisDescription) {
087:
088:                if (axisDescription.getParent() != null) {
089:                    PolicyInclude parentPolicyInclude = axisDescription
090:                            .getParent().getPolicyInclude();
091:                    reg = new PolicyRegistryImpl(parentPolicyInclude
092:                            .getPolicyRegistry());
093:                } else {
094:                    reg = new PolicyRegistryImpl();
095:                }
096:                setDescription(axisDescription);
097:            }
098:
099:            public void setPolicyRegistry(PolicyRegistry reg) {
100:                this .reg = reg;
101:            }
102:
103:            public PolicyRegistry getPolicyRegistry() {
104:                return reg;
105:            }
106:
107:            public void setPolicy(Policy policy) {
108:                wrapperElements.clear();
109:
110:                if (policy.getName() == null && policy.getId() == null) {
111:                    policy.setId(UUIDGenerator.getUUID());
112:                }
113:
114:                Wrapper wrapper = new Wrapper(PolicyInclude.ANON_POLICY, policy);
115:                if (policy.getName() != null) {
116:                    wrapperElements.put(policy.getName(), wrapper);
117:                } else {
118:                    wrapperElements.put(policy.getId(), wrapper);
119:                }
120:            }
121:
122:            public void updatePolicy(Policy policy) {
123:                String key;
124:
125:                if ((key = policy.getName()) == null
126:                        && (key = policy.getId()) == null) {
127:                    // TODO throw more meaningful exception ..
128:                    throw new RuntimeException(
129:                            "policy doesn't have a name or an id ");
130:                }
131:
132:                Wrapper wrapper = (Wrapper) wrapperElements.get(key);
133:                wrapper.value = policy;
134:            }
135:
136:            public void setEffectivePolicy(Policy effectivePolicy) {
137:                this .effectivePolicy = effectivePolicy;
138:            }
139:
140:            public void setDescription(AxisDescription description) {
141:                this .description = description;
142:            }
143:
144:            public AxisDescription getDescription() {
145:                return description;
146:            }
147:
148:            private PolicyInclude getParent() {
149:
150:                if (description != null && description.getParent() != null) {
151:                    return description.getParent().getPolicyInclude();
152:                }
153:                return null;
154:            }
155:
156:            private void calculatePolicy() {
157:
158:                Policy result = null;
159:                Iterator iterator = wrapperElements.values().iterator();
160:
161:                while (iterator.hasNext()) {
162:                    Object policyElement = ((Wrapper) iterator.next())
163:                            .getValue();
164:                    Policy p;
165:
166:                    if (policyElement instanceof  PolicyReference) {
167:                        AxisPolicyLocator locator = new AxisPolicyLocator(
168:                                description);
169:                        p = (Policy) ((PolicyReference) policyElement)
170:                                .normalize(locator, false);
171:
172:                    } else if (policyElement instanceof  Policy) {
173:                        p = (Policy) policyElement;
174:
175:                    } else {
176:                        // TODO AxisFault?
177:                        throw new RuntimeException();
178:                    }
179:
180:                    result = (result == null) ? (Policy) p : (Policy) result
181:                            .merge(p);
182:                }
183:
184:                this .policy = result;
185:            }
186:
187:            private void calculateEffectivePolicy() {
188:                Policy result;
189:
190:                if (getParent() != null) {
191:                    Policy parentPolicy = getParent().getEffectivePolicy();
192:
193:                    if (parentPolicy == null) {
194:                        result = getPolicy();
195:
196:                    } else {
197:
198:                        if (getPolicy() != null) {
199:                            result = (Policy) parentPolicy.merge(getPolicy());
200:
201:                        } else {
202:                            result = parentPolicy;
203:                        }
204:                    }
205:
206:                } else {
207:                    result = getPolicy();
208:                }
209:                setEffectivePolicy(result);
210:            }
211:
212:            public Policy getPolicy() {
213:                calculatePolicy();
214:                return policy;
215:            }
216:
217:            public Policy getEffectivePolicy() {
218:                calculateEffectivePolicy();
219:                return effectivePolicy;
220:            }
221:
222:            public ArrayList getPolicyElements() {
223:                ArrayList policyElementsList = new ArrayList();
224:                Iterator policyElementIterator = wrapperElements.values()
225:                        .iterator();
226:
227:                while (policyElementIterator.hasNext()) {
228:                    policyElementsList.add(((Wrapper) policyElementIterator
229:                            .next()).getValue());
230:                }
231:                return policyElementsList;
232:            }
233:
234:            public ArrayList getPolicyElements(int type) {
235:                ArrayList policyElementList = new ArrayList();
236:                Iterator wrapperElementIterator = wrapperElements.values()
237:                        .iterator();
238:                Wrapper wrapper;
239:
240:                while (wrapperElementIterator.hasNext()) {
241:                    wrapper = (Wrapper) wrapperElementIterator.next();
242:
243:                    if (wrapper.getType() == type) {
244:                        policyElementList.add(wrapper.getValue());
245:                    }
246:                }
247:                return policyElementList;
248:            }
249:
250:            public void registerPolicy(String key, Policy policy) {
251:                reg.register(key, policy);
252:            }
253:
254:            public Policy getPolicy(String key) {
255:                return reg.lookup(key);
256:            }
257:
258:            public void addPolicyElement(int type, Policy policy) {
259:
260:                String key;
261:
262:                if ((key = policy.getName()) == null
263:                        && (key = policy.getId()) == null) {
264:                    policy.setId(UUIDGenerator.getUUID());
265:                }
266:
267:                key = (policy.getName() != null) ? policy.getName() : policy
268:                        .getId();
269:
270:                Wrapper wrapper = new Wrapper(type, policy);
271:                wrapperElements.put(key, wrapper);
272:                reg.register(key, policy);
273:            }
274:
275:            public void addPolicyRefElement(int type,
276:                    PolicyReference policyReference) {
277:                Wrapper wrapper = new Wrapper(type, policyReference);
278:                wrapperElements.put(policyReference.getURI(), wrapper);
279:            }
280:
281:            class Wrapper {
282:                private int type;
283:                private Object value;
284:
285:                Wrapper(int type, Object value) {
286:                    setType(type);
287:                    setValue(value);
288:                }
289:
290:                void setType(int type) {
291:                    this .type = type;
292:                }
293:
294:                int getType() {
295:                    return type;
296:                }
297:
298:                void setValue(Object value) {
299:                    this .value = value;
300:                }
301:
302:                Object getValue() {
303:                    return value;
304:                }
305:            }
306:
307:            public void removePolicyElement(String policyURI) {
308:                wrapperElements.remove(policyURI);
309:                reg.remove(policyURI);
310:            }
311:
312:            public void removeAllPolicyElements() {
313:                wrapperElements.clear();
314:            }
315:
316:            public List getAttachedPolicies() {
317:
318:                ArrayList arrayList = new ArrayList();
319:
320:                for (Iterator iterator = wrapperElements.values().iterator(); iterator
321:                        .hasNext();) {
322:                    arrayList.add(((Wrapper) iterator.next()).value);
323:                }
324:
325:                return arrayList;
326:            }
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.