Source Code Cross Referenced for ClusterBuilder.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » deployment » 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.deployment 
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.deployment;
021:
022:        import org.apache.axiom.om.OMAttribute;
023:        import org.apache.axiom.om.OMElement;
024:        import org.apache.axis2.clustering.ClusterManager;
025:        import org.apache.axis2.clustering.configuration.ConfigurationManager;
026:        import org.apache.axis2.clustering.configuration.ConfigurationManagerListener;
027:        import org.apache.axis2.clustering.context.ContextManager;
028:        import org.apache.axis2.clustering.context.ContextManagerListener;
029:        import org.apache.axis2.engine.AxisConfiguration;
030:        import org.apache.axis2.i18n.Messages;
031:
032:        import javax.xml.namespace.QName;
033:        import java.io.InputStream;
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:        import java.util.List;
037:
038:        /**
039:         * Builds a service description from OM
040:         */
041:        public class ClusterBuilder extends DescriptionBuilder {
042:
043:            //	private static final Log log = LogFactory.getLog(ClusterBuilder.class);
044:
045:            public ClusterBuilder(AxisConfiguration axisConfig) {
046:                this .axisConfig = axisConfig;
047:            }
048:
049:            public ClusterBuilder(InputStream serviceInputStream,
050:                    AxisConfiguration axisConfig) {
051:                super (serviceInputStream, axisConfig);
052:            }
053:
054:            /**
055:             * Populates service from corresponding OM.
056:             */
057:            public void buildCluster(OMElement clusterElement)
058:                    throws DeploymentException {
059:
060:                OMAttribute classNameAttr = clusterElement
061:                        .getAttribute(new QName(TAG_CLASS_NAME));
062:                if (classNameAttr == null) {
063:                    throw new DeploymentException(Messages.getMessage(
064:                            "classAttributeNotFound", TAG_CLUSTER));
065:                }
066:
067:                String className = classNameAttr.getAttributeValue();
068:                ClusterManager clusterManager;
069:                try {
070:                    Class clazz;
071:                    try {
072:                        clazz = Class.forName(className);
073:                    } catch (ClassNotFoundException e) {
074:                        throw new DeploymentException(Messages.getMessage(
075:                                "clusterImplNotFound", className));
076:                    }
077:                    clusterManager = (ClusterManager) clazz.newInstance();
078:
079:                    clusterManager.setConfigurationContext(configCtx);
080:
081:                    //loading the parameters.
082:                    processParameters(clusterElement
083:                            .getChildrenWithName(new QName(TAG_PARAMETER)),
084:                            clusterManager, null);
085:
086:                    //loading the ConfigurationManager
087:                    loadConfigManager(clusterElement, clusterManager);
088:
089:                    // loading the ContextManager
090:                    loadContextManager(clusterElement, clusterManager);
091:
092:                    axisConfig.setClusterManager(clusterManager);
093:                } catch (InstantiationException e) {
094:                    throw new DeploymentException(Messages
095:                            .getMessage("cannotLoadClusterImpl"));
096:                } catch (IllegalAccessException e) {
097:                    throw new DeploymentException(e);
098:                }
099:            }
100:
101:            private void loadContextManager(OMElement clusterElement,
102:                    ClusterManager clusterManager) throws DeploymentException,
103:                    InstantiationException, IllegalAccessException {
104:                OMElement contextManagerEle = clusterElement
105:                        .getFirstChildWithName(new QName(TAG_CONTEXT_MANAGER));
106:                if (contextManagerEle != null) {
107:
108:                    // Load & set the ContextManager class
109:                    OMAttribute classNameAttr = contextManagerEle
110:                            .getAttribute(new QName(ATTRIBUTE_CLASS));
111:                    if (classNameAttr == null) {
112:                        throw new DeploymentException(Messages.getMessage(
113:                                "classAttributeNotFound", TAG_CONTEXT_MANAGER));
114:                    }
115:
116:                    String className = classNameAttr.getAttributeValue();
117:
118:                    Class clazz;
119:                    try {
120:                        clazz = Class.forName(className);
121:                    } catch (ClassNotFoundException e) {
122:                        throw new DeploymentException(Messages.getMessage(
123:                                "clusterImplNotFound", className));
124:                    }
125:                    ContextManager contextManager = (ContextManager) clazz
126:                            .newInstance();
127:                    clusterManager.setContextManager(contextManager);
128:
129:                    // Load & set the ContextManagerListener
130:                    OMElement listenerEle = contextManagerEle
131:                            .getFirstChildWithName(new QName(TAG_LISTENER));
132:                    if (listenerEle != null) {
133:                        classNameAttr = listenerEle.getAttribute(new QName(
134:                                TAG_CLASS_NAME));
135:                        if (classNameAttr == null) {
136:                            throw new DeploymentException(Messages.getMessage(
137:                                    "classAttributeNotFound", TAG_LISTENER));
138:                        }
139:                        className = classNameAttr.getAttributeValue();
140:                        try {
141:                            clazz = Class.forName(className);
142:                        } catch (ClassNotFoundException e) {
143:                            throw new DeploymentException(Messages.getMessage(
144:                                    "clusterImplNotFound", className));
145:                        }
146:                        ContextManagerListener listener = (ContextManagerListener) clazz
147:                                .newInstance();
148:                        contextManager.setContextManagerListener(listener);
149:                    } else {
150:                        throw new DeploymentException(Messages
151:                                .getMessage("contextManagerListenerIsNull"));
152:                    }
153:
154:                    //loading the parameters.
155:                    processParameters(contextManagerEle
156:                            .getChildrenWithName(new QName(TAG_PARAMETER)),
157:                            contextManager, null);
158:
159:                    // Load the replication patterns to be excluded. We load the following structure.
160:                    /*<replication>
161:                        <defaults>
162:                            <exclude name="foo.bar.*"/>
163:                        </defaults>
164:                        <context class="org.apache.axis2.context.ConfigurationContext">
165:                            <exclude name="my.sandesha.*"/>
166:                        </context>
167:                        <context class="org.apache.axis2.context.ServiceGroupContext">
168:                            <exclude name="my.sandesha.*"/>
169:                        </context>
170:                        <context class="org.apache.axis2.context.ServiceContext">
171:                            <exclude name="my.sandesha.*"/>
172:                        </context>
173:                    </replication>*/
174:                    OMElement replicationEle = contextManagerEle
175:                            .getFirstChildWithName(new QName(TAG_REPLICATION));
176:                    if (replicationEle != null) {
177:                        // Process defaults
178:                        OMElement defaultsEle = replicationEle
179:                                .getFirstChildWithName(new QName(TAG_DEFAULTS));
180:                        if (defaultsEle != null) {
181:                            List defaults = new ArrayList();
182:                            for (Iterator iter = defaultsEle
183:                                    .getChildrenWithName(new QName(TAG_EXCLUDE)); iter
184:                                    .hasNext();) {
185:                                OMElement excludeEle = (OMElement) iter.next();
186:                                OMAttribute nameAtt = excludeEle
187:                                        .getAttribute(new QName(ATTRIBUTE_NAME));
188:                                defaults.add(nameAtt.getAttributeValue());
189:                            }
190:                            contextManager.setReplicationExcludePatterns(
191:                                    TAG_DEFAULTS, defaults);
192:                        }
193:
194:                        // Process specifics
195:                        for (Iterator iter = replicationEle
196:                                .getChildrenWithName(new QName(TAG_CONTEXT)); iter
197:                                .hasNext();) {
198:                            OMElement contextEle = (OMElement) iter.next();
199:                            String ctxClassName = contextEle.getAttribute(
200:                                    new QName(ATTRIBUTE_CLASS))
201:                                    .getAttributeValue();
202:                            List excludes = new ArrayList();
203:                            for (Iterator iter2 = contextEle
204:                                    .getChildrenWithName(new QName(TAG_EXCLUDE)); iter2
205:                                    .hasNext();) {
206:                                OMElement excludeEle = (OMElement) iter2.next();
207:                                OMAttribute nameAtt = excludeEle
208:                                        .getAttribute(new QName(ATTRIBUTE_NAME));
209:                                excludes.add(nameAtt.getAttributeValue());
210:                            }
211:                            contextManager.setReplicationExcludePatterns(
212:                                    ctxClassName, excludes);
213:                        }
214:                    }
215:                }
216:            }
217:
218:            private void loadConfigManager(OMElement clusterElement,
219:                    ClusterManager clusterManager) throws DeploymentException,
220:                    InstantiationException, IllegalAccessException {
221:                OMElement configManagerEle = clusterElement
222:                        .getFirstChildWithName(new QName(
223:                                TAG_CONFIGURATION_MANAGER));
224:                if (configManagerEle != null) {
225:                    OMAttribute classNameAttr = configManagerEle
226:                            .getAttribute(new QName(ATTRIBUTE_CLASS));
227:                    if (classNameAttr == null) {
228:                        throw new DeploymentException(Messages.getMessage(
229:                                "classAttributeNotFound",
230:                                TAG_CONFIGURATION_MANAGER));
231:                    }
232:
233:                    String className = classNameAttr.getAttributeValue();
234:                    Class clazz;
235:                    try {
236:                        clazz = Class.forName(className);
237:                    } catch (ClassNotFoundException e) {
238:                        throw new DeploymentException(Messages.getMessage(
239:                                "clusterImplNotFound", className));
240:                    }
241:
242:                    ConfigurationManager configurationManager = (ConfigurationManager) clazz
243:                            .newInstance();
244:                    clusterManager
245:                            .setConfigurationManager(configurationManager);
246:
247:                    OMElement listenerEle = configManagerEle
248:                            .getFirstChildWithName(new QName(TAG_LISTENER));
249:                    if (listenerEle != null) {
250:                        classNameAttr = listenerEle.getAttribute(new QName(
251:                                TAG_CLASS_NAME));
252:                        if (classNameAttr == null) {
253:                            throw new DeploymentException(Messages.getMessage(
254:                                    "clusterImplNotFound", TAG_LISTENER));
255:                        }
256:
257:                        className = classNameAttr.getAttributeValue();
258:                        try {
259:                            clazz = Class.forName(className);
260:                        } catch (ClassNotFoundException e) {
261:                            throw new DeploymentException(
262:                                    Messages
263:                                            .getMessage("configurationManagerListenerIsNull"));
264:                        }
265:                        ConfigurationManagerListener listener = (ConfigurationManagerListener) clazz
266:                                .newInstance();
267:                        listener.setConfigurationContext(configCtx);
268:                        configurationManager
269:                                .setConfigurationManagerListener(listener);
270:                    } else {
271:                        throw new DeploymentException(
272:                                Messages
273:                                        .getMessage("configurationManagerListenerIsNull"));
274:                    }
275:
276:                    //updating the ConfigurationManager with the new ConfigurationContext
277:                    configurationManager.setConfigurationContext(configCtx);
278:
279:                    //loading the parameters.
280:                    processParameters(configManagerEle
281:                            .getChildrenWithName(new QName(TAG_PARAMETER)),
282:                            configurationManager, null);
283:                }
284:            }
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.