Source Code Cross Referenced for DescriptionBuilder.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.AxisFault;
025:        import org.apache.axis2.Constants;
026:        import org.apache.axis2.builder.Builder;
027:        import org.apache.axis2.context.ConfigurationContext;
028:        import org.apache.axis2.description.AxisOperation;
029:        import org.apache.axis2.description.AxisService;
030:        import org.apache.axis2.description.Flow;
031:        import org.apache.axis2.description.HandlerDescription;
032:        import org.apache.axis2.description.Parameter;
033:        import org.apache.axis2.description.ParameterInclude;
034:        import org.apache.axis2.description.PolicyInclude;
035:        import org.apache.axis2.description.WSDL2Constants;
036:        import org.apache.axis2.description.PhaseRule;
037:        import org.apache.axis2.engine.AxisConfiguration;
038:        import org.apache.axis2.engine.MessageReceiver;
039:        import org.apache.axis2.i18n.Messages;
040:        import org.apache.axis2.transport.MessageFormatter;
041:        import org.apache.axis2.util.Loader;
042:        import org.apache.axis2.util.XMLUtils;
043:        import org.apache.commons.logging.Log;
044:        import org.apache.commons.logging.LogFactory;
045:        import org.apache.neethi.Policy;
046:        import org.apache.neethi.PolicyEngine;
047:        import org.apache.neethi.PolicyReference;
048:
049:        import javax.xml.namespace.QName;
050:        import javax.xml.stream.XMLStreamException;
051:        import java.io.InputStream;
052:        import java.security.PrivilegedActionException;
053:        import java.security.PrivilegedExceptionAction;
054:        import java.util.ArrayList;
055:        import java.util.HashMap;
056:        import java.util.Iterator;
057:
058:        /**
059:         * This class does the common tasks for all *Builder class.
060:         */
061:        public class DescriptionBuilder implements  DeploymentConstants {
062:
063:            private static final Log log = LogFactory
064:                    .getLog(DescriptionBuilder.class);
065:
066:            protected ConfigurationContext configCtx;
067:
068:            protected AxisConfiguration axisConfig;
069:
070:            protected InputStream descriptionStream;
071:
072:            public DescriptionBuilder() {
073:            }
074:
075:            public DescriptionBuilder(InputStream serviceInputStream,
076:                    ConfigurationContext configCtx) {
077:                this .configCtx = configCtx;
078:                this .descriptionStream = serviceInputStream;
079:                this .axisConfig = this .configCtx.getAxisConfiguration();
080:            }
081:
082:            public DescriptionBuilder(InputStream serviceInputStream,
083:                    AxisConfiguration axisConfig) {
084:                this .descriptionStream = serviceInputStream;
085:                this .axisConfig = axisConfig;
086:            }
087:
088:            /**
089:             * Creates OMElement for a given description document (axis2.xml ,
090:             * services.xml and module.xml).
091:             *
092:             * @return Returns <code>OMElement</code> .
093:             * @throws javax.xml.stream.XMLStreamException
094:             *
095:             */
096:            public OMElement buildOM() throws XMLStreamException {
097:                OMElement element = (OMElement) XMLUtils
098:                        .toOM(descriptionStream);
099:                element.build();
100:                return element;
101:            }
102:
103:            /**
104:             * Loads default message receivers. First searches in Axiservice for the
105:             * given mepURL, if not found searches in AxisConfiguration with the given
106:             * mepURL.
107:             *
108:             * @param mepURL  :
109:             *                can be null
110:             * @param service :
111:             *                This can be null <code>AxisService</code>
112:             */
113:            protected MessageReceiver loadDefaultMessageReceiver(String mepURL,
114:                    AxisService service) {
115:                MessageReceiver messageReceiver;
116:                if (mepURL == null) {
117:                    mepURL = WSDL2Constants.MEP_URI_IN_OUT;
118:                }
119:                if (service != null) {
120:                    messageReceiver = service.getMessageReceiver(mepURL);
121:                    if (messageReceiver != null) {
122:                        return messageReceiver;
123:                    }
124:                }
125:                return axisConfig.getMessageReceiver(mepURL);
126:            }
127:
128:            /**
129:             * Processes default message receivers specified either in axis2.xml or
130:             * services.xml.
131:             *
132:             */
133:            protected HashMap processMessageReceivers(OMElement messageReceivers)
134:                    throws DeploymentException {
135:                HashMap mr_mep = new HashMap();
136:                Iterator msgReceivers = messageReceivers
137:                        .getChildrenWithName(new QName(TAG_MESSAGE_RECEIVER));
138:                while (msgReceivers.hasNext()) {
139:                    OMElement msgReceiver = (OMElement) msgReceivers.next();
140:                    final OMElement tempMsgReceiver = msgReceiver;
141:                    MessageReceiver receiver = null;
142:                    try {
143:                        receiver = (MessageReceiver) org.apache.axis2.java.security.AccessController
144:                                .doPrivileged(new PrivilegedExceptionAction() {
145:                                    public Object run()
146:                                            throws org.apache.axis2.deployment.DeploymentException {
147:                                        return loadMessageReceiver(Thread
148:                                                .currentThread()
149:                                                .getContextClassLoader(),
150:                                                tempMsgReceiver);
151:                                    }
152:                                });
153:                    } catch (PrivilegedActionException e) {
154:                        throw (DeploymentException) e.getException();
155:                    }
156:                    OMAttribute mepAtt = msgReceiver.getAttribute(new QName(
157:                            TAG_MEP));
158:                    mr_mep.put(mepAtt.getAttributeValue(), receiver);
159:                }
160:                return mr_mep;
161:            }
162:
163:            /**
164:             * Processes default message receivers specified either in axis2.xml or
165:             * services.xml.
166:             *
167:             */
168:            protected HashMap processMessageReceivers(ClassLoader loader,
169:                    OMElement element) throws DeploymentException {
170:                HashMap meps = new HashMap();
171:                Iterator iterator = element.getChildrenWithName(new QName(
172:                        TAG_MESSAGE_RECEIVER));
173:                while (iterator.hasNext()) {
174:                    OMElement receiverElement = (OMElement) iterator.next();
175:                    MessageReceiver receiver = loadMessageReceiver(loader,
176:                            receiverElement);
177:                    OMAttribute mepAtt = receiverElement
178:                            .getAttribute(new QName(TAG_MEP));
179:                    meps.put(mepAtt.getAttributeValue(), receiver);
180:                }
181:                return meps;
182:            }
183:
184:            protected MessageReceiver loadMessageReceiver(ClassLoader loader,
185:                    OMElement element) throws DeploymentException {
186:                OMAttribute receiverName = element.getAttribute(new QName(
187:                        TAG_CLASS_NAME));
188:                String className = receiverName.getAttributeValue();
189:                MessageReceiver receiver = null;
190:
191:                try {
192:                    Class messageReceiver;
193:
194:                    if ((className != null) && !"".equals(className)) {
195:                        messageReceiver = Loader.loadClass(loader, className);
196:                        receiver = (MessageReceiver) messageReceiver
197:                                .newInstance();
198:                    }
199:                } catch (ClassNotFoundException e) {
200:                    throw new DeploymentException(
201:                            Messages
202:                                    .getMessage(
203:                                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
204:                                            "ClassNotFoundException", className),
205:                            e);
206:                } catch (IllegalAccessException e) {
207:                    throw new DeploymentException(
208:                            Messages
209:                                    .getMessage(
210:                                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
211:                                            "IllegalAccessException", className),
212:                            e);
213:                } catch (InstantiationException e) {
214:                    throw new DeploymentException(
215:                            Messages
216:                                    .getMessage(
217:                                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
218:                                            "InstantiationException", className),
219:                            e);
220:                }
221:
222:                return receiver;
223:            }
224:
225:            /**
226:             * Processes the message builders specified in axis2.xml or services.xml.
227:             *
228:             * @param messageBuildersElement
229:             */
230:            protected HashMap processMessageBuilders(
231:                    OMElement messageBuildersElement)
232:                    throws DeploymentException {
233:                HashMap builderSelector = new HashMap();
234:                Iterator msgBuilders = messageBuildersElement
235:                        .getChildrenWithName(new QName(TAG_MESSAGE_BUILDER));
236:                while (msgBuilders.hasNext()) {
237:                    OMElement msgBuilderElement = (OMElement) msgBuilders
238:                            .next();
239:                    OMAttribute builderName = msgBuilderElement
240:                            .getAttribute(new QName(TAG_CLASS_NAME));
241:                    String className = builderName.getAttributeValue();
242:                    Class builderClass = null;
243:                    Builder builderObject;
244:                    try {
245:                        builderClass = findAndValidateSelectorClass(
246:                                className,
247:                                DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_BUILDER);
248:                        builderObject = (Builder) builderClass.newInstance();
249:                    } catch (PrivilegedActionException e) {
250:                        throw (DeploymentException) e.getException();
251:                    } catch (InstantiationException e) {
252:                        throw new DeploymentException(
253:                                "Cannot instantiate the specified Builder Class  : "
254:                                        + builderClass.getName() + ".", e);
255:                    } catch (IllegalAccessException e) {
256:                        throw new DeploymentException(
257:                                "Cannot instantiate the specified Builder Class : "
258:                                        + builderClass.getName() + ".", e);
259:                    }
260:                    OMAttribute contentTypeAtt = msgBuilderElement
261:                            .getAttribute(new QName(TAG_CONTENT_TYPE));
262:                    builderSelector.put(contentTypeAtt.getAttributeValue(),
263:                            builderObject);
264:                }
265:                return builderSelector;
266:            }
267:
268:            /**
269:             * Processes the message builders specified in axis2.xml or services.xml.
270:             */
271:            protected HashMap processMessageFormatters(
272:                    OMElement messageFormattersElement)
273:                    throws DeploymentException {
274:                HashMap messageFormatters = new HashMap();
275:                Iterator msgFormatters = messageFormattersElement
276:                        .getChildrenWithName(new QName(TAG_MESSAGE_FORMATTER));
277:                while (msgFormatters.hasNext()) {
278:                    OMElement msgFormatterElement = (OMElement) msgFormatters
279:                            .next();
280:                    OMElement tempMsgFormatter = msgFormatterElement;
281:                    OMAttribute formatterName = tempMsgFormatter
282:                            .getAttribute(new QName(TAG_CLASS_NAME));
283:                    String className = formatterName.getAttributeValue();
284:                    MessageFormatter formatterObject;
285:                    Class formatterClass = null;
286:                    try {
287:                        formatterClass = findAndValidateSelectorClass(
288:                                className,
289:                                DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_FORMATTER);
290:                        formatterObject = (MessageFormatter) formatterClass
291:                                .newInstance();
292:                    } catch (PrivilegedActionException e) {
293:                        throw (DeploymentException) e.getException();
294:                    } catch (InstantiationException e) {
295:                        throw new DeploymentException(
296:                                "Cannot instantiate the specified Formatter Class  : "
297:                                        + formatterClass.getName() + ".", e);
298:                    } catch (IllegalAccessException e) {
299:                        throw new DeploymentException(
300:                                "Cannot instantiate the specified Formatter Class : "
301:                                        + formatterClass.getName() + ".", e);
302:                    }
303:                    OMAttribute contentTypeAtt = msgFormatterElement
304:                            .getAttribute(new QName(TAG_CONTENT_TYPE));
305:                    messageFormatters.put(contentTypeAtt.getAttributeValue(),
306:                            formatterObject);
307:                }
308:                return messageFormatters;
309:            }
310:
311:            protected Class findAndValidateSelectorClass(
312:                    final String className, final String errorMsg)
313:                    throws PrivilegedActionException {
314:                return (Class) org.apache.axis2.java.security.AccessController
315:                        .doPrivileged(new PrivilegedExceptionAction() {
316:                            public Object run()
317:                                    throws org.apache.axis2.deployment.DeploymentException {
318:                                Class selectorClass;
319:                                try {
320:                                    if ((className != null)
321:                                            && !"".equals(className)) {
322:                                        selectorClass = Loader.loadClass(Thread
323:                                                .currentThread()
324:                                                .getContextClassLoader(),
325:                                                className);
326:                                    } else {
327:                                        throw new DeploymentException(Messages
328:                                                .getMessage(errorMsg,
329:                                                        "Invalid Class Name",
330:                                                        className));
331:                                    }
332:                                } catch (ClassNotFoundException e) {
333:                                    throw new DeploymentException(Messages
334:                                            .getMessage(errorMsg,
335:                                                    "ClassNotFoundException",
336:                                                    className), e);
337:                                }
338:                                return selectorClass;
339:                            }
340:                        });
341:            }
342:
343:            /**
344:             * Processes flow elements in services.xml .
345:             *
346:             * @param flowelement <code>OMElement</code>
347:             * @return Returns Flow.
348:             * @throws DeploymentException <code>DeploymentException</code>
349:             */
350:            protected Flow processFlow(OMElement flowelement,
351:                    ParameterInclude parent) throws DeploymentException {
352:                Flow flow = new Flow();
353:
354:                if (flowelement == null) {
355:                    return flow;
356:                }
357:
358:                Iterator handlers = flowelement.getChildrenWithName(new QName(
359:                        TAG_HANDLER));
360:
361:                while (handlers.hasNext()) {
362:                    OMElement handlerElement = (OMElement) handlers.next();
363:
364:                    flow.addHandler(processHandler(handlerElement, parent));
365:                }
366:
367:                return flow;
368:            }
369:
370:            protected String[] processSupportedPolicyNamespaces(
371:                    OMElement supportedPolicyElements) {
372:                OMAttribute namespaces = supportedPolicyElements
373:                        .getAttribute(new QName(TAG_NAMESPACES));
374:                if (namespaces != null) {
375:                    String value = namespaces.getAttributeValue();
376:                    if (value.trim().length() != 0) {
377:                        return value.split(" ");
378:                    }
379:                }
380:                return null;
381:            }
382:
383:            protected QName[] getLocalPolicyAssertionNames(
384:                    OMElement localPolicyAssertionsElement) {
385:
386:                Iterator iterator = localPolicyAssertionsElement
387:                        .getChildElements();
388:                if (!iterator.hasNext()) {
389:                    return null;
390:                }
391:
392:                ArrayList qnames = new ArrayList();
393:                OMElement childElement;
394:
395:                for (; iterator.hasNext();) {
396:                    childElement = (OMElement) iterator.next();
397:                    qnames.add(childElement.getQName());
398:                }
399:
400:                QName[] buffer = new QName[qnames.size()];
401:                System.arraycopy(qnames.toArray(), 0, buffer, 0, qnames.size());
402:                return buffer;
403:
404:            }
405:
406:            protected HandlerDescription processHandler(
407:                    OMElement handler_element, ParameterInclude parent)
408:                    throws DeploymentException {
409:                return processHandler(handler_element, parent, null);
410:            }
411:
412:            /**
413:             * Processes Handler element.
414:             *
415:             * @param handler_element <code>OMElement</code>
416:             * @return Returns HandlerDescription.
417:             * @throws DeploymentException <code>DeploymentException</code>
418:             */
419:            protected HandlerDescription processHandler(
420:                    OMElement handler_element, ParameterInclude parent,
421:                    String containingPhase) throws DeploymentException {
422:
423:                // Setting handler name
424:                OMAttribute name_attribute = handler_element
425:                        .getAttribute(new QName(ATTRIBUTE_NAME));
426:
427:                if (name_attribute == null
428:                        || name_attribute.getAttributeValue().equals("")) {
429:                    throw new DeploymentException(Messages.getMessage(
430:                            DeploymentErrorMsgs.INVALID_HANDLER, "Unknown",
431:                            "Name missing"));
432:                }
433:
434:                HandlerDescription handler = new HandlerDescription(
435:                        name_attribute.getAttributeValue());
436:
437:                // Setting handler class name
438:                OMAttribute class_attribute = handler_element
439:                        .getAttribute(new QName(TAG_CLASS_NAME));
440:
441:                if (class_attribute == null) {
442:                    throw new DeploymentException((Messages.getMessage(
443:                            DeploymentErrorMsgs.INVALID_HANDLER, name_attribute
444:                                    .getAttributeValue(),
445:                            "class name is missing")));
446:                } else {
447:                    handler.setClassName(class_attribute.getAttributeValue());
448:                }
449:
450:                // processing phase rules (order)
451:                OMElement order_element = handler_element
452:                        .getFirstChildWithName(new QName(TAG_ORDER));
453:
454:                PhaseRule rules = handler.getRules();
455:                if (order_element == null) {
456:                    if (containingPhase == null) {
457:                        // TODO : Include more information (which handler?) in message!
458:                        throw new DeploymentException((Messages.getMessage(
459:                                DeploymentErrorMsgs.INVALID_HANDLER,
460:                                name_attribute.getAttributeValue(),
461:                                "phase rule has not been specified")));
462:                    }
463:                    rules.setPhaseName(containingPhase);
464:                } else {
465:                    Iterator order_itr = order_element.getAllAttributes();
466:
467:                    while (order_itr.hasNext()) {
468:                        OMAttribute orderAttribute = (OMAttribute) order_itr
469:                                .next();
470:                        String name = orderAttribute.getQName().getLocalPart();
471:                        String value = orderAttribute.getAttributeValue();
472:
473:                        if (TAG_AFTER.equals(name)) {
474:                            rules.setAfter(value);
475:                        } else if (TAG_BEFORE.equals(name)) {
476:                            rules.setBefore(value);
477:                        } else if (TAG_PHASE.equals(name)) {
478:                            rules.setPhaseName(value);
479:                        } else if (TAG_PHASE_FIRST.equals(name)) {
480:                            String boolval = getValue(value);
481:
482:                            if (boolval.equals(BOOLEAN_TRUE)) {
483:                                rules.setPhaseFirst(true);
484:                            } else if (boolval.equals(BOOLEAN_FALSE)) {
485:                                rules.setPhaseFirst(false);
486:                            }
487:                        } else if (TAG_PHASE_LAST.equals(name)) {
488:                            String boolval = getValue(value);
489:
490:                            if (boolval.equals(BOOLEAN_TRUE)) {
491:                                rules.setPhaseLast(true);
492:                            } else if (boolval.equals(BOOLEAN_FALSE)) {
493:                                rules.setPhaseLast(false);
494:                            }
495:                        }
496:                    }
497:
498:                    Iterator parameters = handler_element
499:                            .getChildrenWithName(new QName(TAG_PARAMETER));
500:
501:                    try {
502:                        processParameters(parameters, handler, parent);
503:                    } catch (AxisFault axisFault) {
504:                        throw new DeploymentException(axisFault);
505:                    }
506:                }
507:
508:                handler.setParent(parent);
509:
510:                return handler;
511:            }
512:
513:            protected void processOperationModuleRefs(Iterator moduleRefs,
514:                    AxisOperation operation) throws DeploymentException {
515:                try {
516:                    while (moduleRefs.hasNext()) {
517:                        OMElement moduleref = (OMElement) moduleRefs.next();
518:                        OMAttribute moduleRefAttribute = moduleref
519:                                .getAttribute(new QName(TAG_REFERENCE));
520:
521:                        if (moduleRefAttribute != null) {
522:                            String refName = moduleRefAttribute
523:                                    .getAttributeValue();
524:
525:                            if (axisConfig.getModule(refName) == null) {
526:                                throw new DeploymentException(
527:                                        Messages
528:                                                .getMessage(
529:                                                        DeploymentErrorMsgs.MODULE_NOT_FOUND,
530:                                                        refName));
531:                            } else {
532:                                operation.addModule(refName);
533:                            }
534:                        }
535:                    }
536:                } catch (AxisFault axisFault) {
537:                    throw new DeploymentException(Messages.getMessage(
538:                            DeploymentErrorMsgs.MODULE_NOT_FOUND, axisFault
539:                                    .getMessage()), axisFault);
540:                }
541:            }
542:
543:            /**
544:             * Gets the Parameter object from the OM.
545:             *
546:             * @param parameters       <code>Parameter</code>
547:             * @param parameterInclude <code>ParameterInclude</code>
548:             * @param parent           <code>ParameterInclude</code>
549:             */
550:            protected void processParameters(Iterator parameters,
551:                    ParameterInclude parameterInclude, ParameterInclude parent)
552:                    throws DeploymentException {
553:                while (parameters.hasNext()) {
554:                    // this is to check whether some one has locked the parmeter at the
555:                    // top level
556:                    OMElement parameterElement = (OMElement) parameters.next();
557:                    Parameter parameter = new Parameter();
558:                    // setting parameterElement
559:                    parameter.setParameterElement(parameterElement);
560:                    // setting parameter Name
561:                    OMAttribute paramName = parameterElement
562:                            .getAttribute(new QName(ATTRIBUTE_NAME));
563:                    if (paramName == null) {
564:                        throw new DeploymentException(Messages.getMessage(
565:                                DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT,
566:                                parameterElement.toString()));
567:                    }
568:                    parameter.setName(paramName.getAttributeValue());
569:                    // setting parameter Value (the child element of the parameter)
570:                    OMElement paramValue = parameterElement.getFirstElement();
571:                    if (paramValue != null) {
572:                        parameter.setValue(parameterElement);
573:                        parameter.setParameterType(Parameter.OM_PARAMETER);
574:                    } else {
575:                        String paratextValue = parameterElement.getText();
576:
577:                        parameter.setValue(paratextValue);
578:                        parameter.setParameterType(Parameter.TEXT_PARAMETER);
579:                    }
580:                    // setting locking attribute
581:                    OMAttribute paramLocked = parameterElement
582:                            .getAttribute(new QName(ATTRIBUTE_LOCKED));
583:                    Parameter parentParam = null;
584:                    if (parent != null) {
585:                        parentParam = parent.getParameter(parameter.getName());
586:                    }
587:                    if (paramLocked != null) {
588:                        String lockedValue = paramLocked.getAttributeValue();
589:                        if (BOOLEAN_TRUE.equals(lockedValue)) {
590:                            // if the parameter is locked at some level parameter value
591:                            // replace by that
592:                            if ((parent != null)
593:                                    && parent.isParameterLocked(parameter
594:                                            .getName())) {
595:                                throw new DeploymentException(
596:                                        Messages
597:                                                .getMessage(
598:                                                        DeploymentErrorMsgs.CONFIG_NOT_FOUND,
599:                                                        parameter.getName()));
600:                            } else {
601:                                parameter.setLocked(true);
602:                            }
603:                        } else {
604:                            parameter.setLocked(false);
605:                        }
606:                    }
607:                    try {
608:                        if (parent != null) {
609:                            if ((parentParam == null)
610:                                    || !parent.isParameterLocked(parameter
611:                                            .getName())) {
612:                                parameterInclude.addParameter(parameter);
613:                            }
614:                        } else {
615:                            parameterInclude.addParameter(parameter);
616:                        }
617:                    } catch (AxisFault axisFault) {
618:                        throw new DeploymentException(axisFault);
619:                    }
620:                }
621:            }
622:
623:            /**
624:             * Populate the AxisOperation with details from the actionMapping,
625:             * outputActionMapping and faultActionMapping elements from the operation
626:             * element.
627:             *
628:             * @param operation
629:             * @param op_descrip
630:             */
631:            protected void processActionMappings(OMElement operation,
632:                    AxisOperation op_descrip) {
633:                Iterator mappingIterator = operation
634:                        .getChildrenWithName(new QName(Constants.ACTION_MAPPING));
635:                ArrayList mappingList = new ArrayList();
636:                while (mappingIterator.hasNext()) {
637:                    OMElement mappingElement = (OMElement) mappingIterator
638:                            .next();
639:                    String inputActionString = mappingElement.getText().trim();
640:                    if (log.isTraceEnabled()) {
641:                        log.trace("Input Action Mapping found: "
642:                                + inputActionString);
643:                    }
644:                    if (!"".equals(inputActionString)) {
645:                        mappingList.add(inputActionString);
646:                    } else {
647:                        if (log.isTraceEnabled()) {
648:                            log
649:                                    .trace("Zero length input action string found. Not added to mapping");
650:                        }
651:                    }
652:                }
653:                op_descrip.setWsamappingList(mappingList);
654:
655:                OMElement outputAction = operation
656:                        .getFirstChildWithName(new QName(
657:                                Constants.OUTPUT_ACTION_MAPPING));
658:                if ((outputAction != null) && (outputAction.getText() != null)) {
659:                    String outputActionString = outputAction.getText().trim();
660:                    if (log.isTraceEnabled()) {
661:                        log.trace("Output Action Mapping found: "
662:                                + outputActionString);
663:                    }
664:                    op_descrip.setOutputAction(outputActionString);
665:                }
666:                Iterator faultActionsIterator = operation
667:                        .getChildrenWithName(new QName(
668:                                Constants.FAULT_ACTION_MAPPING));
669:                while (faultActionsIterator.hasNext()) {
670:                    OMElement faultMappingElement = (OMElement) faultActionsIterator
671:                            .next();
672:                    String faultActionString = faultMappingElement.getText()
673:                            .trim();
674:                    String faultActionName = faultMappingElement
675:                            .getAttributeValue(new QName(
676:                                    Constants.FAULT_ACTION_NAME));
677:                    if (faultActionName != null && faultActionString != null) {
678:                        if (log.isTraceEnabled()) {
679:                            log.trace("Fault Action Mapping found: "
680:                                    + faultActionName + ", "
681:                                    + faultActionString);
682:                        }
683:                        op_descrip.addFaultAction(faultActionName,
684:                                faultActionString);
685:                    }
686:                }
687:            }
688:
689:            protected void processPolicyElements(int type,
690:                    Iterator policyElements, PolicyInclude policyInclude) {
691:                while (policyElements.hasNext()) {
692:                    Policy p = PolicyEngine
693:                            .getPolicy((OMElement) policyElements.next());
694:                    policyInclude.addPolicyElement(type, p);
695:                }
696:            }
697:
698:            protected void processPolicyRefElements(int type,
699:                    Iterator policyRefElements, PolicyInclude policyInclude) {
700:
701:                while (policyRefElements.hasNext()) {
702:                    PolicyReference policyReference = PolicyEngine
703:                            .getPolicyReference((OMElement) policyRefElements
704:                                    .next());
705:                    policyInclude.addPolicyRefElement(type, policyReference);
706:                }
707:            }
708:
709:            /**
710:             * Gets the short file name. Short file name is the name before the dot.
711:             *
712:             * @param fileName
713:             * @return Returns String.
714:             */
715:            public static String getShortFileName(String fileName) {
716:                char seperator = SEPARATOR_DOT;
717:                String value;
718:                int index = fileName.lastIndexOf(seperator);
719:
720:                if (index > 0) {
721:                    value = fileName.substring(0, index);
722:
723:                    return value;
724:                }
725:
726:                return fileName;
727:            }
728:
729:            /**
730:             * Gets the value of an attribute. eg xsd:anyVal --> anyVal
731:             *
732:             * @return Returns String.
733:             */
734:            protected String getValue(String in) {
735:                char seperator = SEPARATOR_COLON;
736:                String value;
737:                int index = in.indexOf(seperator);
738:
739:                if (index > 0) {
740:                    value = in.substring(index + 1, in.length());
741:
742:                    return value;
743:                }
744:
745:                return in;
746:            }
747:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.