Save This Page
Home » axis2-1.5-src » org.apache » axis2 » deployment » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements. See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership. The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License. You may obtain a copy of the License at
    9    *
   10    * http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied. See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   package org.apache.axis2.deployment;
   21   
   22   import org.apache.axiom.om.OMAttribute;
   23   import org.apache.axiom.om.OMElement;
   24   import org.apache.axis2.AxisFault;
   25   import org.apache.axis2.Constants;
   26   import org.apache.axis2.builder.Builder;
   27   import org.apache.axis2.context.ConfigurationContext;
   28   import org.apache.axis2.description.AxisOperation;
   29   import org.apache.axis2.description.AxisService;
   30   import org.apache.axis2.description.Flow;
   31   import org.apache.axis2.description.HandlerDescription;
   32   import org.apache.axis2.description.Parameter;
   33   import org.apache.axis2.description.ParameterInclude;
   34   import org.apache.axis2.description.PhaseRule;
   35   import org.apache.axis2.description.PolicyInclude;
   36   import org.apache.axis2.description.PolicySubject;
   37   import org.apache.axis2.description.WSDL2Constants;
   38   import org.apache.axis2.engine.AxisConfiguration;
   39   import org.apache.axis2.engine.MessageReceiver;
   40   import org.apache.axis2.i18n.Messages;
   41   import org.apache.axis2.transport.MessageFormatter;
   42   import org.apache.axis2.util.Loader;
   43   import org.apache.axis2.util.XMLUtils;
   44   import org.apache.commons.logging.Log;
   45   import org.apache.commons.logging.LogFactory;
   46   import org.apache.neethi.Policy;
   47   import org.apache.neethi.PolicyEngine;
   48   import org.apache.neethi.PolicyReference;
   49   
   50   import javax.xml.namespace.QName;
   51   import javax.xml.stream.XMLStreamException;
   52   import java.io.InputStream;
   53   import java.security.PrivilegedActionException;
   54   import java.security.PrivilegedExceptionAction;
   55   import java.util.ArrayList;
   56   import java.util.HashMap;
   57   import java.util.Iterator;
   58   
   59   /**
   60    * This class does the common tasks for all *Builder class.
   61    */
   62   public class DescriptionBuilder implements DeploymentConstants {
   63   
   64       private static final Log log = LogFactory.getLog(DescriptionBuilder.class);
   65   
   66       protected ConfigurationContext configCtx;
   67   
   68       protected AxisConfiguration axisConfig;
   69   
   70       protected InputStream descriptionStream;
   71   
   72       public DescriptionBuilder() {
   73       }
   74   
   75       public DescriptionBuilder(InputStream serviceInputStream,
   76                                 ConfigurationContext configCtx) {
   77           this.configCtx = configCtx;
   78           this.descriptionStream = serviceInputStream;
   79           this.axisConfig = this.configCtx.getAxisConfiguration();
   80       }
   81   
   82       public DescriptionBuilder(InputStream serviceInputStream,
   83                                 AxisConfiguration axisConfig) {
   84           this.descriptionStream = serviceInputStream;
   85           this.axisConfig = axisConfig;
   86       }
   87   
   88       /**
   89        * Creates OMElement for a given description document (axis2.xml ,
   90        * services.xml and module.xml).
   91        *
   92        * @return Returns <code>OMElement</code> .
   93        * @throws javax.xml.stream.XMLStreamException
   94        *
   95        */
   96       public OMElement buildOM() throws XMLStreamException {
   97           OMElement element = (OMElement) XMLUtils.toOM(descriptionStream);
   98           element.build();
   99           return element;
  100       }
  101   
  102       /**
  103        * Loads default message receivers. First searches in Axiservice for the
  104        * given mepURL, if not found searches in AxisConfiguration with the given
  105        * mepURL.
  106        *
  107        * @param mepURL  :
  108        *                can be null
  109        * @param service :
  110        *                This can be null <code>AxisService</code>
  111        */
  112       protected MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
  113           MessageReceiver messageReceiver;
  114           if (mepURL == null) {
  115               mepURL = WSDL2Constants.MEP_URI_IN_OUT;
  116           }
  117           if (service != null) {
  118               messageReceiver = service.getMessageReceiver(mepURL);
  119               if (messageReceiver != null) {
  120                   return messageReceiver;
  121               }
  122           }
  123           return axisConfig.getMessageReceiver(mepURL);
  124       }
  125   
  126       /**
  127        * Processes default message receivers specified either in axis2.xml or
  128        * services.xml.
  129        *
  130        */
  131       protected HashMap processMessageReceivers(OMElement messageReceivers)
  132               throws DeploymentException {
  133           HashMap mr_mep = new HashMap();
  134           Iterator msgReceivers = messageReceivers.getChildrenWithName(new QName(
  135                   TAG_MESSAGE_RECEIVER));
  136           while (msgReceivers.hasNext()) {
  137               OMElement msgReceiver = (OMElement) msgReceivers.next();
  138               final OMElement tempMsgReceiver = msgReceiver;
  139               MessageReceiver receiver = null;
  140               try {
  141                   receiver = (MessageReceiver) org.apache.axis2.java.security.AccessController
  142                           .doPrivileged(new PrivilegedExceptionAction() {
  143                               public Object run()
  144                                       throws org.apache.axis2.deployment.DeploymentException {
  145                                   return loadMessageReceiver(
  146                                           Thread.currentThread().getContextClassLoader(),
  147                                           tempMsgReceiver);
  148                               }
  149                           });
  150               } catch (PrivilegedActionException e) {
  151                   throw (DeploymentException) e.getException();
  152               }
  153               OMAttribute mepAtt = msgReceiver.getAttribute(new QName(TAG_MEP));
  154               mr_mep.put(mepAtt.getAttributeValue(), receiver);
  155           }
  156           return mr_mep;
  157       }
  158   
  159       /**
  160        * Processes default message receivers specified either in axis2.xml or
  161        * services.xml.
  162        *
  163        */
  164       protected HashMap processMessageReceivers(ClassLoader loader,
  165                                                 OMElement element) throws DeploymentException {
  166           HashMap meps = new HashMap();
  167           Iterator iterator = element.getChildrenWithName(new QName(
  168                   TAG_MESSAGE_RECEIVER));
  169           while (iterator.hasNext()) {
  170               OMElement receiverElement = (OMElement) iterator.next();
  171               MessageReceiver receiver = loadMessageReceiver(loader,
  172                                                              receiverElement);
  173               OMAttribute mepAtt = receiverElement
  174                       .getAttribute(new QName(TAG_MEP));
  175               meps.put(mepAtt.getAttributeValue(), receiver);
  176           }
  177           return meps;
  178       }
  179   
  180       protected MessageReceiver loadMessageReceiver(ClassLoader loader,
  181                                                     OMElement element) throws DeploymentException {
  182           OMAttribute receiverName = element.getAttribute(new QName(
  183                   TAG_CLASS_NAME));
  184           String className = receiverName.getAttributeValue();
  185           MessageReceiver receiver = null;
  186   
  187           try {
  188               Class messageReceiver;
  189   
  190               if ((className != null) && !"".equals(className)) {
  191                   messageReceiver = Loader.loadClass(loader, className);
  192                   receiver = (MessageReceiver) messageReceiver.newInstance();
  193               }
  194           } catch (ClassNotFoundException e) {
  195               throw new DeploymentException(Messages.getMessage(
  196                       DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
  197                       "ClassNotFoundException", className), e);
  198           } catch (IllegalAccessException e) {
  199               throw new DeploymentException(Messages.getMessage(
  200                       DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
  201                       "IllegalAccessException", className), e);
  202           } catch (InstantiationException e) {
  203               throw new DeploymentException(Messages.getMessage(
  204                       DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
  205                       "InstantiationException", className), e);
  206           }
  207   
  208           return receiver;
  209       }
  210   
  211       /**
  212        * Processes the message builders specified in axis2.xml or services.xml.
  213        *
  214        * @param messageBuildersElement
  215        */
  216       protected HashMap processMessageBuilders(OMElement messageBuildersElement)
  217               throws DeploymentException {
  218           HashMap builderSelector = new HashMap();
  219           Iterator msgBuilders = messageBuildersElement
  220                   .getChildrenWithName(new QName(TAG_MESSAGE_BUILDER));
  221           while (msgBuilders.hasNext()) {
  222               OMElement msgBuilderElement = (OMElement) msgBuilders.next();
  223               OMAttribute builderName = msgBuilderElement.getAttribute(new QName(TAG_CLASS_NAME));
  224               String className = builderName.getAttributeValue();
  225               Class builderClass = null;
  226               Builder builderObject;
  227               try {
  228                   builderClass = findAndValidateSelectorClass(className,
  229                                                               DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_BUILDER);
  230                   builderObject = (Builder) builderClass.newInstance();
  231               } catch (PrivilegedActionException e) {
  232                   throw (DeploymentException) e.getException();
  233               } catch (InstantiationException e) {
  234                   throw new DeploymentException(
  235                           "Cannot instantiate the specified Builder Class  : "
  236                                   + builderClass.getName() + ".", e);
  237               } catch (IllegalAccessException e) {
  238                   throw new DeploymentException(
  239                           "Cannot instantiate the specified Builder Class : "
  240                                   + builderClass.getName() + ".", e);
  241               }
  242               OMAttribute contentTypeAtt = msgBuilderElement
  243                       .getAttribute(new QName(TAG_CONTENT_TYPE));
  244               builderSelector.put(contentTypeAtt.getAttributeValue(),
  245                                   builderObject);
  246           }
  247           return builderSelector;
  248       }
  249   
  250   
  251       /**
  252        * Processes the message builders specified in axis2.xml or services.xml.
  253        */
  254       protected HashMap processMessageFormatters(OMElement messageFormattersElement)
  255               throws DeploymentException {
  256           HashMap messageFormatters = new HashMap();
  257           Iterator msgFormatters = messageFormattersElement
  258                   .getChildrenWithName(new QName(TAG_MESSAGE_FORMATTER));
  259           while (msgFormatters.hasNext()) {
  260               OMElement msgFormatterElement = (OMElement) msgFormatters.next();
  261               OMElement tempMsgFormatter = msgFormatterElement;
  262               OMAttribute formatterName = tempMsgFormatter.getAttribute(new QName(TAG_CLASS_NAME));
  263               String className = formatterName.getAttributeValue();
  264               MessageFormatter formatterObject;
  265               Class formatterClass = null;
  266               try {
  267                   formatterClass = findAndValidateSelectorClass(className,
  268                                                                 DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_FORMATTER);
  269                   formatterObject = (MessageFormatter) formatterClass.newInstance();
  270               } catch (PrivilegedActionException e) {
  271                   throw (DeploymentException) e.getException();
  272               } catch (InstantiationException e) {
  273                   throw new DeploymentException(
  274                           "Cannot instantiate the specified Formatter Class  : "
  275                                   + formatterClass.getName() + ".", e);
  276               } catch (IllegalAccessException e) {
  277                   throw new DeploymentException(
  278                           "Cannot instantiate the specified Formatter Class : "
  279                                   + formatterClass.getName() + ".", e);
  280               }
  281               OMAttribute contentTypeAtt = msgFormatterElement
  282                       .getAttribute(new QName(TAG_CONTENT_TYPE));
  283               messageFormatters.put(contentTypeAtt.getAttributeValue(),
  284                                     formatterObject);
  285           }
  286           return messageFormatters;
  287       }
  288   
  289       protected Class findAndValidateSelectorClass(final String className, final String errorMsg)
  290               throws PrivilegedActionException {
  291           return (Class) org.apache.axis2.java.security.AccessController
  292                   .doPrivileged(new PrivilegedExceptionAction() {
  293                       public Object run()
  294                               throws org.apache.axis2.deployment.DeploymentException {
  295                           Class selectorClass;
  296                           try {
  297                               if ((className != null) && !"".equals(className)) {
  298                                   selectorClass = Loader.loadClass(Thread.currentThread()
  299                                           .getContextClassLoader(), className);
  300                               } else {
  301                                   throw new DeploymentException(Messages.getMessage(errorMsg,
  302                                                                                     "Invalid Class Name",
  303                                                                                     className));
  304                               }
  305                           } catch (ClassNotFoundException e) {
  306                               throw new DeploymentException(Messages.getMessage(errorMsg,
  307                                                                                 "ClassNotFoundException",
  308                                                                                 className), e);
  309                           }
  310                           return selectorClass;
  311                       }
  312                   });
  313       }
  314   
  315       /**
  316        * Processes flow elements in services.xml .
  317        *
  318        * @param flowelement <code>OMElement</code>
  319        * @return Returns Flow.
  320        * @throws DeploymentException <code>DeploymentException</code>
  321        */
  322       protected Flow processFlow(OMElement flowelement, ParameterInclude parent)
  323               throws DeploymentException {
  324           Flow flow = new Flow();
  325   
  326           if (flowelement == null) {
  327               return flow;
  328           }
  329   
  330           Iterator handlers = flowelement.getChildrenWithName(new QName(
  331                   TAG_HANDLER));
  332   
  333           while (handlers.hasNext()) {
  334               OMElement handlerElement = (OMElement) handlers.next();
  335   
  336               flow.addHandler(processHandler(handlerElement, parent));
  337           }
  338   
  339           return flow;
  340       }
  341   
  342       protected String[] processSupportedPolicyNamespaces(
  343               OMElement supportedPolicyElements) {
  344           OMAttribute namespaces = supportedPolicyElements
  345                   .getAttribute(new QName(TAG_NAMESPACES));
  346           if (namespaces != null) {
  347               String value = namespaces.getAttributeValue();
  348               if (value.trim().length() != 0) {
  349                   return value.split(" ");
  350               }
  351           }
  352           return null;
  353       }
  354   
  355       protected QName[] getLocalPolicyAssertionNames(OMElement localPolicyAssertionsElement) {
  356   
  357           Iterator iterator = localPolicyAssertionsElement.getChildElements();
  358           if (! iterator.hasNext()) {
  359               return null;
  360           }
  361   
  362           ArrayList qnames = new ArrayList();
  363           OMElement childElement;
  364   
  365           for (; iterator.hasNext();) {
  366               childElement = (OMElement) iterator.next();
  367               qnames.add(childElement.getQName());
  368           }
  369   
  370           QName[] buffer = new QName[qnames.size()];
  371           System.arraycopy(qnames.toArray(), 0, buffer, 0, qnames.size());
  372           return buffer;
  373   
  374       }
  375   
  376       protected HandlerDescription processHandler(OMElement handler_element, ParameterInclude parent)
  377               throws DeploymentException
  378       {
  379           return processHandler(handler_element, parent, null);
  380       }
  381       /**
  382        * Processes Handler element.
  383        *
  384        * @param handler_element <code>OMElement</code>
  385        * @return Returns HandlerDescription.
  386        * @throws DeploymentException <code>DeploymentException</code>
  387        */
  388       protected HandlerDescription processHandler(OMElement handler_element,
  389                                                   ParameterInclude parent,
  390                                                   String containingPhase)
  391               throws DeploymentException {
  392   
  393           // Setting handler name
  394           OMAttribute name_attribute = handler_element.getAttribute(new QName(
  395                   ATTRIBUTE_NAME));
  396   
  397           if (name_attribute == null || name_attribute.getAttributeValue().equals("")) {
  398               throw new DeploymentException(Messages.getMessage(
  399                       DeploymentErrorMsgs.INVALID_HANDLER, "Unknown", "Name missing"));
  400           }
  401   
  402           HandlerDescription handler = new HandlerDescription(name_attribute.getAttributeValue());
  403   
  404           // Setting handler class name
  405           OMAttribute class_attribute = handler_element.getAttribute(new QName(
  406                   TAG_CLASS_NAME));
  407   
  408           if (class_attribute == null) {
  409               throw new DeploymentException((Messages.getMessage(
  410                       DeploymentErrorMsgs.INVALID_HANDLER, name_attribute.getAttributeValue(),
  411                       "class name is missing")));
  412           } else {
  413               handler.setClassName(class_attribute.getAttributeValue());
  414           }
  415   
  416           // processing phase rules (order)
  417           OMElement order_element = handler_element
  418                   .getFirstChildWithName(new QName(TAG_ORDER));
  419   
  420           PhaseRule rules = handler.getRules();
  421           if (order_element == null) {
  422               if (containingPhase == null) {
  423                   // TODO : Include more information (which handler?) in message!
  424                   throw new DeploymentException((Messages.getMessage(
  425                           DeploymentErrorMsgs.INVALID_HANDLER, name_attribute.getAttributeValue(),
  426                           "phase rule has not been specified")));
  427               }
  428               rules.setPhaseName(containingPhase);
  429           } else {
  430               Iterator order_itr = order_element.getAllAttributes();
  431   
  432               while (order_itr.hasNext()) {
  433                   OMAttribute orderAttribute = (OMAttribute) order_itr.next();
  434                   String name = orderAttribute.getQName().getLocalPart();
  435                   String value = orderAttribute.getAttributeValue();
  436   
  437                   if (TAG_AFTER.equals(name)) {
  438                       rules.setAfter(value);
  439                   } else if (TAG_BEFORE.equals(name)) {
  440                       rules.setBefore(value);
  441                   } else if (TAG_PHASE.equals(name)) {
  442                       rules.setPhaseName(value);
  443                   } else if (TAG_PHASE_FIRST.equals(name)) {
  444                       String boolval = getValue(value);
  445   
  446                       if (boolval.equals(BOOLEAN_TRUE)) {
  447                           rules.setPhaseFirst(true);
  448                       } else if (boolval.equals(BOOLEAN_FALSE)) {
  449                           rules.setPhaseFirst(false);
  450                       }
  451                   } else if (TAG_PHASE_LAST.equals(name)) {
  452                       String boolval = getValue(value);
  453   
  454                       if (boolval.equals(BOOLEAN_TRUE)) {
  455                           rules.setPhaseLast(true);
  456                       } else if (boolval.equals(BOOLEAN_FALSE)) {
  457                           rules.setPhaseLast(false);
  458                       }
  459                   }
  460               }
  461   
  462               Iterator parameters = handler_element
  463                       .getChildrenWithName(new QName(TAG_PARAMETER));
  464   
  465               try {
  466                   processParameters(parameters, handler, parent);
  467               } catch (AxisFault axisFault) {
  468                   throw new DeploymentException(axisFault);
  469               }
  470           }
  471   
  472           handler.setParent(parent);
  473   
  474           return handler;
  475       }
  476   
  477       protected void processOperationModuleRefs(Iterator moduleRefs,
  478                                                 AxisOperation operation) throws DeploymentException {
  479           try {
  480               while (moduleRefs.hasNext()) {
  481                   OMElement moduleref = (OMElement) moduleRefs.next();
  482                   OMAttribute moduleRefAttribute = moduleref
  483                           .getAttribute(new QName(TAG_REFERENCE));
  484   
  485                   if (moduleRefAttribute != null) {
  486                       String refName = moduleRefAttribute.getAttributeValue();
  487   
  488                       if (axisConfig.getModule(refName) == null) {
  489                           throw new DeploymentException(Messages.getMessage(
  490                                   DeploymentErrorMsgs.MODULE_NOT_FOUND, refName));
  491                       } else {
  492                           operation.addModule(refName);
  493                       }
  494                   }
  495               }
  496           } catch (AxisFault axisFault) {
  497               throw new DeploymentException(Messages.getMessage(
  498                       DeploymentErrorMsgs.MODULE_NOT_FOUND, axisFault
  499                       .getMessage()), axisFault);
  500           }
  501       }
  502   
  503       /**
  504        * Gets the Parameter object from the OM.
  505        *
  506        * @param parameters       <code>Parameter</code>
  507        * @param parameterInclude <code>ParameterInclude</code>
  508        * @param parent           <code>ParameterInclude</code>
  509        */
  510       protected void processParameters(Iterator parameters,
  511                                        ParameterInclude parameterInclude,
  512                                        ParameterInclude parent)
  513               throws DeploymentException {
  514           while (parameters.hasNext()) {
  515               // this is to check whether some one has locked the parmeter at the
  516               // top level
  517               OMElement parameterElement = (OMElement) parameters.next();
  518               Parameter parameter = new Parameter();
  519               // setting parameterElement
  520               parameter.setParameterElement(parameterElement);
  521               // setting parameter Name
  522               OMAttribute paramName = parameterElement.getAttribute(new QName(ATTRIBUTE_NAME));
  523               if (paramName == null) {
  524                   throw new DeploymentException(Messages.getMessage(
  525                           DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT,
  526                           parameterElement.toString()));
  527               }
  528               parameter.setName(paramName.getAttributeValue());
  529               // setting parameter Value (the child element of the parameter)
  530               OMElement paramValue = parameterElement.getFirstElement();
  531               if (paramValue != null) {
  532                   parameter.setValue(parameterElement);
  533                   parameter.setParameterType(Parameter.OM_PARAMETER);
  534               } else {
  535                   String paratextValue = parameterElement.getText();
  536   
  537                   parameter.setValue(paratextValue);
  538                   parameter.setParameterType(Parameter.TEXT_PARAMETER);
  539               }
  540               // setting locking attribute
  541               OMAttribute paramLocked = parameterElement.getAttribute(new QName(
  542                       ATTRIBUTE_LOCKED));
  543               Parameter parentParam = null;
  544               if (parent != null) {
  545                   parentParam = parent.getParameter(parameter.getName());
  546               }
  547               if (paramLocked != null) {
  548                   String lockedValue = paramLocked.getAttributeValue();
  549                   if (BOOLEAN_TRUE.equals(lockedValue)) {
  550                       // if the parameter is locked at some level parameter value
  551                       // replace by that
  552                       if ((parent != null)
  553                               && parent.isParameterLocked(parameter.getName())) {
  554                           throw new DeploymentException(Messages.getMessage(
  555                                   DeploymentErrorMsgs.CONFIG_NOT_FOUND, parameter
  556                                   .getName()));
  557                       } else {
  558                           parameter.setLocked(true);
  559                       }
  560                   } else {
  561                       parameter.setLocked(false);
  562                   }
  563               }
  564               try {
  565                   if (parent != null) {
  566                       if ((parentParam == null)
  567                               || !parent.isParameterLocked(parameter.getName())) {
  568                           parameterInclude.addParameter(parameter);
  569                       }
  570                   } else {
  571                       parameterInclude.addParameter(parameter);
  572                   }
  573               } catch (AxisFault axisFault) {
  574                   throw new DeploymentException(axisFault);
  575               }
  576           }
  577       }
  578   
  579       /**
  580        * Populate the AxisOperation with details from the actionMapping,
  581        * outputActionMapping and faultActionMapping elements from the operation
  582        * element.
  583        *
  584        * @param operation
  585        * @param op_descrip
  586        */
  587       protected void processActionMappings(OMElement operation,
  588                                            AxisOperation op_descrip) {
  589           Iterator mappingIterator = operation.getChildrenWithName(new QName(
  590                   Constants.ACTION_MAPPING));
  591           ArrayList mappingList = new ArrayList();
  592           while (mappingIterator.hasNext()) {
  593               OMElement mappingElement = (OMElement) mappingIterator.next();
  594               String inputActionString = mappingElement.getText().trim();
  595               if (log.isTraceEnabled()) {
  596                   log.trace("Input Action Mapping found: " + inputActionString);
  597               }
  598               if (!"".equals(inputActionString)) {
  599                   mappingList.add(inputActionString);
  600               } else {
  601                   if (log.isTraceEnabled()) {
  602                       log.trace("Zero length input action string found. Not added to mapping");
  603                   }
  604               }
  605           }
  606           op_descrip.setWsamappingList(mappingList);
  607   
  608           OMElement outputAction = operation.getFirstChildWithName(new QName(
  609                   Constants.OUTPUT_ACTION_MAPPING));
  610           if ((outputAction != null) && (outputAction.getText() != null)) {
  611               String outputActionString = outputAction.getText().trim();
  612               if (log.isTraceEnabled()) {
  613                   log.trace("Output Action Mapping found: " + outputActionString);
  614               }
  615               op_descrip.setOutputAction(outputActionString);
  616           }
  617           Iterator faultActionsIterator = operation
  618                   .getChildrenWithName(new QName(Constants.FAULT_ACTION_MAPPING));
  619           while (faultActionsIterator.hasNext()) {
  620               OMElement faultMappingElement = (OMElement) faultActionsIterator
  621                       .next();
  622               String faultActionString = faultMappingElement.getText().trim();
  623               String faultActionName = faultMappingElement
  624                       .getAttributeValue(new QName(Constants.FAULT_ACTION_NAME));
  625               if (faultActionName != null && faultActionString != null) {
  626                   if (log.isTraceEnabled()) {
  627                       log.trace("Fault Action Mapping found: " + faultActionName
  628                               + ", " + faultActionString);
  629                   }
  630                   op_descrip.addFaultAction(faultActionName, faultActionString);
  631               }
  632           }
  633       }
  634   
  635       protected void processPolicyElements(Iterator policyElements,
  636                                            PolicySubject policySubject) {
  637           while (policyElements.hasNext()) {
  638               Policy p = PolicyEngine
  639                       .getPolicy((OMElement) policyElements.next());
  640               policySubject.attachPolicy(p);
  641           }
  642       }
  643   
  644       protected void processPolicyRefElements(Iterator policyRefElements,
  645                                               PolicySubject policySubject) {
  646           while (policyRefElements.hasNext()) {
  647               PolicyReference policyReference = PolicyEngine
  648                       .getPolicyReference((OMElement) policyRefElements.next());
  649               policySubject.attachPolicyReference(policyReference);
  650           }
  651       }
  652   
  653       /**
  654        * Gets the short file name. Short file name is the name before the dot.
  655        *
  656        * @param fileName
  657        * @return Returns String.
  658        */
  659       public static String getShortFileName(String fileName) {
  660           char seperator = SEPARATOR_DOT;
  661           String value;
  662           int index = fileName.lastIndexOf(seperator);
  663   
  664           if (index > 0) {
  665               value = fileName.substring(0, index);
  666   
  667               return value;
  668           }
  669   
  670           return fileName;
  671       }
  672   
  673       /**
  674        * Gets the value of an attribute. eg xsd:anyVal --> anyVal
  675        *
  676        * @return Returns String.
  677        */
  678       protected String getValue(String in) {
  679           char seperator = SEPARATOR_COLON;
  680           String value;
  681           int index = in.indexOf(seperator);
  682   
  683           if (index > 0) {
  684               value = in.substring(index + 1, in.length());
  685   
  686               return value;
  687           }
  688   
  689           return in;
  690       }
  691   }

Save This Page
Home » axis2-1.5-src » org.apache » axis2 » deployment » [javadoc | source]