Exemplo n.º 1
0
  private Response doRequest(final Request<?> request, final HttpRequestBase fetcher) {
    if (fetcher == null) {
      return null;
    }

    List<Parameter> headers = request.getHeaders();
    if (checkListOfParams(headers)) {
      for (Parameter parameter : headers) {
        Header header = new BasicHeader(parameter.getName(), parameter.getValue());
        fetcher.addHeader(header);
      }
    }

    final DefaultHttpClient httpClient = getHttpClient();
    List<Parameter> cookies = request.getCookies();
    if (checkListOfParams(cookies)) {
      CookieStore cookieStore = httpClient.getCookieStore();
      for (Parameter cookie : cookies) {
        cookieStore.addCookie(new BasicClientCookie(cookie.getName(), cookie.getValue()));
      }
      httpClient.setCookieStore(cookieStore);
    }

    return doRequest(fetcher, httpClient);
  }
Exemplo n.º 2
0
 private void writeParam(Parameter param, DataOutputStream out, String boundary)
     throws IOException {
   String name = param.getName();
   out.writeBytes("\r\n");
   if (param instanceof ImageParameter) {
     ImageParameter imageParam = (ImageParameter) param;
     Object value = param.getValue();
     out.writeBytes(
         String.format(
             Locale.US,
             "Content-Disposition: form-data; name=\"%s\"; filename=\"%s\";\r\n",
             name,
             imageParam.getImageName()));
     out.writeBytes(
         String.format(Locale.US, "Content-Type: image/%s\r\n\r\n", imageParam.getImageType()));
     if (value instanceof InputStream) {
       InputStream in = (InputStream) value;
       byte[] buf = new byte[512];
       int res = -1;
       while ((res = in.read(buf)) != -1) {
         out.write(buf, 0, res);
       }
     } else if (value instanceof byte[]) {
       out.write((byte[]) value);
     }
   } else {
     out.writeBytes("Content-Disposition: form-data; name=\"" + name + "\"\r\n");
     out.writeBytes("Content-Type: text/plain; charset=UTF-8\r\n\r\n");
     out.write(((String) param.getValue()).getBytes("UTF-8"));
   }
   out.writeBytes("\r\n");
   out.writeBytes(boundary);
 }
Exemplo n.º 3
0
  /**
   * DOC ggu Comment method "getFunctionMethod".
   *
   * @param f
   */
  public static String getFunctionMethod(Function f) {
    String newValue = ""; // $NON-NLS-1$
    if (f != null) {

      final List<Parameter> parameters = f.getParameters();
      if (isJavaProject()) {
        String fullName = f.getClassName() + JAVA_METHOD_SEPARATED + f.getName();
        newValue = fullName + FUN_PREFIX;
        for (Parameter pa : parameters) {
          newValue += pa.getValue() + FUN_PARAM_SEPARATED;
        }
        if (!parameters.isEmpty()) {
          newValue = newValue.substring(0, newValue.length() - 1);
        }
        newValue += FUN_SUFFIX;

      } else {
        newValue = f.getName() + FUN_PREFIX;
        for (Parameter pa : parameters) {
          newValue += pa.getValue() + FUN_PARAM_SEPARATED;
        }
        if (!parameters.isEmpty()) {
          newValue = newValue.substring(0, newValue.length() - 1);
        }
        newValue += FUN_SUFFIX;
      }
    }
    return newValue;
  }
Exemplo n.º 4
0
 public void testParameterEdit() throws Exception {
   ConfigurationContext configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
   AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
   Parameter parameter = new Parameter();
   parameter.setValue("true");
   parameter.setName("enableMTOM");
   axisConfig.addParameter(parameter);
   parameter.setValue("true");
   AxisServiceGroup serviceGroup = new AxisServiceGroupImpl();
   serviceGroup.setName("testServiceGroup");
   AxisService service = new AxisService();
   service.setName("service");
   serviceGroup.addService(service);
   axisConfig.addServiceGroup(serviceGroup);
   parameter = serviceGroup.getParameter("enableMTOM");
   parameter.setValue("true");
   Parameter para2 = serviceGroup.getParameter("enableMTOM");
   assertEquals(para2.getValue(), "true");
   Parameter test = new Parameter();
   test.setName("test");
   test.setValue("test");
   serviceGroup.addParameter(test);
   Parameter para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "test");
   para.setValue("newValue");
   para = serviceGroup.getParameter("test");
   assertNotNull(para);
   assertEquals(para.getValue(), "newValue");
 }
  public void renderElement(LookupElementPresentation presentation) {

    presentation.setItemText(getLookupString());
    presentation.setTypeText(parameter.getType().toString());

    if (!parameter.getValue().isEmpty())
      presentation.appendTailText("(" + parameter.getValue() + ")", true);

    presentation.setIcon(SilexIcons.Parameter);
  }
Exemplo n.º 6
0
  @Test
  public void testGettersAndSetters() {
    Parameter p = new Parameter();
    assertTrue(p.getName() == null);
    assertTrue(p.getValue() == null);

    p.setName("bob");
    p.setValue("val");
    assertTrue(p.getName().equals("bob"));
    assertTrue(p.getValue().equals("val"));
  }
Exemplo n.º 7
0
 /**
  * Creates a new instance indexed on the parameters with the specified name.
  *
  * @param list a list of properties
  * @param parameterName the name of parameters on which to index
  */
 public IndexedPropertyList(final PropertyList list, final String parameterName) {
   final Map<String, PropertyList> indexedProperties = new HashMap<String, PropertyList>();
   for (final Property property : list) {
     for (final Iterator<Parameter> j = property.getParameters(parameterName).iterator();
         j.hasNext(); ) {
       final Parameter parameter = (Parameter) j.next();
       PropertyList properties = indexedProperties.get(parameter.getValue());
       if (properties == null) {
         properties = new PropertyList();
         indexedProperties.put(parameter.getValue(), properties);
       }
       properties.add(property);
     }
   }
   this.index = Collections.unmodifiableMap(indexedProperties);
 }
Exemplo n.º 8
0
  /** Calculates the actual rates corresponding to the category indices. */
  protected void setupRates() {

    // System.out.println("BRRRTTZZZ " + distributionIndexParameter.getValue(0));
    for (int i = 0; i < tree.getNodeCount(); i++) {
      // rates[i] = distributionModel.quantile(rateCategoryQuantiles.getNodeValue(
      // rateCategoryQuantiles.getTreeModel(), rateCategoryQuantiles.getTreeModel().getNode(i) ));
      if (!tree.isRoot(tree.getNode(i))) {

        if (useQuantilesForRates) {
            /* Using quantiles to represent rates */
          rates[tree.getNode(i).getNumber()] =
              distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))].quantile(
                  rateCategoryQuantiles.getNodeValue(tree, tree.getNode(i)));
        } else {
            /* Not using quantiles to represent rates. This is practically useless for anything else other than simulation */
          rates[tree.getNode(i).getNumber()] =
              rateCategoryQuantiles.getNodeValue(tree, tree.getNode(i));
        }
      }
    }
    /*System.out.print(distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))].getClass().getName() + "\t" + (int) Math.round(distributionIndexParameter.getValue(0)) + "\t" + rates[1] + "\t" + rateCategoryQuantiles.getNodeValue(tree, tree.getNode(1)));// + "\t" + distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))].);
    if(distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))].getClass().getName().equals("dr.inference.distribution.LogNormalDistributionModel")) {
        LogNormalDistributionModel lndm = (LogNormalDistributionModel) distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))];
        System.out.println("\t" + lndm.getS());
    }
    else if (distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))].getClass().getName().equals("dr.inference.distribution.InverseGaussianDistributionModel")) {
        InverseGaussianDistributionModel lndm = (InverseGaussianDistributionModel) distributionModels[(int) Math.round(distributionIndexParameter.getValue(0))];
        System.out.println("\t" + lndm.getS());
    }*/
    if (normalize) computeFactor();
  }
Exemplo n.º 9
0
 /**
  * merge parameters from other table
  *
  * @param adds Parameters
  */
 public void addAll(final ParameterTable adds) {
   synchronized (adds.table) {
     for (final Parameter p : adds.table) {
       add(p.getName(), p.getValue());
     }
   }
 }
  private void addServerIPAndHostEntries() {
    String hostName = serverConfigurationInformation.getHostName();
    String ipAddress = serverConfigurationInformation.getIpAddress();
    if (hostName != null && !"".equals(hostName)) {
      Entry entry = new Entry(SynapseConstants.SERVER_HOST);
      entry.setValue(hostName);
      synapseConfiguration.addEntry(SynapseConstants.SERVER_HOST, entry);
    }

    if (ipAddress != null && !"".equals(ipAddress)) {
      Entry entry = new Entry(SynapseConstants.SERVER_IP);
      entry.setValue(ipAddress);
      if (synapseConfiguration.getAxisConfiguration().getTransportsIn() != null) {
        Map<String, TransportInDescription> transportInConfigMap =
            synapseConfiguration.getAxisConfiguration().getTransportsIn();
        if (transportInConfigMap != null) {
          TransportInDescription transportInDescription = transportInConfigMap.get("http");
          if (transportInDescription != null) {
            Parameter bindAddressParam = transportInDescription.getParameter("bind-address");
            if (bindAddressParam != null) {
              entry.setValue(bindAddressParam.getValue());
            }
          }
        }
      }
      synapseConfiguration.addEntry(SynapseConstants.SERVER_IP, entry);
    }
  }
Exemplo n.º 11
0
  public void doCall(String method, Object value) throws Exception {
    Call call = new Call();
    call.setTargetObjectURI("http://soapinterop.org/");
    call.setMethodName(method);
    call.setEncodingStyleURI(encodingStyleURI);

    Vector params = new Vector();
    params.addElement(new Parameter("in", value.getClass(), value, null));
    call.setParams(params);

    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp = call.invoke(url, "");

    // Check the response.
    if (resp.generatedFault()) {
      Fault fault = resp.getFault();
      System.out.println("Ouch, the call failed: ");
      System.out.println("  Fault Code   = " + fault.getFaultCode());
      System.out.println("  Fault String = " + fault.getFaultString());
    } else {
      Parameter result = resp.getReturnValue();
      System.out.println("Call succeeded: ");
      System.out.println("Result = " + result.getValue());
    }
  }
Exemplo n.º 12
0
 public int getInt(String name, int def) {
   Parameter p = get(name);
   try {
     return p == null ? def : Integer.valueOf(p.getValue());
   } catch (NumberFormatException e) {
     return def;
   }
 }
Exemplo n.º 13
0
  public String getParameterValue(String name) {
    if (parameters == null) return null;

    for (int ix = 0; ix < parameters.size(); ix++) {
      Parameter param = (Parameter) parameters.elementAt(ix);
      if (param.getName().equals(name)) return param.getValue();
    }
    return null;
  }
Exemplo n.º 14
0
  /**
   * Returns an List of String objects containing the names of the parameters contained in this
   * request.
   *
   * @param name
   * @return
   */
  public List<String> getValues(String name) {
    List<String> result = new ArrayList<String>();

    for (Parameter parameter : parameters) {
      if (parameter.name.equals(name)) result.add(parameter.getValue());
    }

    return result;
  }
Exemplo n.º 15
0
 /**
  * 把Parameter类型集合转换成NameValuePair类型集合
  *
  * @param params 参数集合
  * @return
  */
 @SuppressWarnings("unused")
 private List<BasicNameValuePair> buildNameValuePair(List<Parameter> params) {
   List<BasicNameValuePair> result = new ArrayList<BasicNameValuePair>();
   for (Parameter param : params) {
     BasicNameValuePair pair = new BasicNameValuePair(param.getName(), param.getValue());
     result.add(pair);
   }
   return result;
 }
Exemplo n.º 16
0
  private void repaintContent() {
    if (content != null) {
      remove(content);
    }
    content = new JPanel();

    content.setLayout(new GridBagLayout());
    content.setBackground(Colors.TEMPLATE);
    int gridY = 0;
    GridBagConstraints c;
    for (Parameter p : shownParams.getParamList()) {
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = gridY;
      c.anchor = GridBagConstraints.WEST;
      c.fill = GridBagConstraints.NONE;
      c.insets = new Insets(0, 0, 0, 8);
      content.add(new JLabel(p.getName()), c);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = gridY++;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1;
      final Parameter pFinal = p;
      final JTextField jTextField = new DJTextField();
      jTextField.setText(p.getValue());
      jTextField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent keyEvent) {
              // TODO
            }

            public void keyPressed(KeyEvent keyEvent) {
              // TODO
            }

            public void keyReleased(KeyEvent keyEvent) {
              pFinal.setValue(jTextField.getText());
            }
          });
      content.add(jTextField, c);
    }

    GridBagConstraints nc = new GridBagConstraints();
    nc.gridx = 0;
    nc.gridy = 0;
    nc.weightx = 1;
    nc.fill = GridBagConstraints.HORIZONTAL;

    add(content, nc);

    content.updateUI();
    content.repaint();
    this.repaint();
  }
Exemplo n.º 17
0
  public T getValue() {
    if (currentUser == users) {
      cachedValue = baseParam.getValue();
      currentUser = 0;
    }

    currentUser++;

    return cachedValue;
  }
Exemplo n.º 18
0
  @Override
  protected void fillVoiceXmlDocument(
      Document document, Element formElement, VoiceXmlDialogueContext dialogueContext)
      throws VoiceXmlDocumentRenderingException {

    List<String> submitNameList = new ArrayList<String>();
    VariableList submitVariableList = mSubmitParameters;
    if (submitVariableList != null) {
      addVariables(formElement, submitVariableList);

      for (Entry<String, String> entry : mSubmitParameters) {
        submitNameList.add(entry.getKey());
      }
    }

    Element subdialogueElement = DomUtils.appendNewElement(formElement, SUBDIALOG_ELEMENT);
    subdialogueElement.setAttribute(NAME_ATTRIBUTE, SUBDIALOGUE_FORM_ITEM_NAME);
    subdialogueElement.setAttribute(SRC_ATTRIBUTE, mUri);

    if (!submitNameList.isEmpty()) {
      subdialogueElement.setAttribute(NAME_LIST_ATTRIBUTE, StringUtils.join(submitNameList, " "));
    }

    for (Parameter parameter : mParameters) {
      Element paramElement = DomUtils.appendNewElement(subdialogueElement, PARAM_ELEMENT);
      paramElement.setAttribute(NAME_ATTRIBUTE, parameter.getName());
      setAttribute(paramElement, VALUE_ATTRIBUTE, parameter.getValue());
      setAttribute(paramElement, EXPR_ATTRIBUTE, parameter.getExpression());
    }

    SubmitMethod submitMethod = mMethod;
    if (submitMethod != null) {
      subdialogueElement.setAttribute(METHOD_ATTRIBUTE, submitMethod.name());
    }

    DocumentFetchConfiguration fetchConfiguration = mFetchConfiguration;
    if (fetchConfiguration != null) {
      applyFetchAudio(subdialogueElement, fetchConfiguration.getFetchAudio());
      applyRessourceFetchConfiguration(subdialogueElement, fetchConfiguration);
    }

    Element filledElement = DomUtils.appendNewElement(subdialogueElement, FILLED_ELEMENT);

    createVarElement(
        filledElement, SUBDIALOGUE_RESULT_VARIABLE_NAME, "dialog." + SUBDIALOGUE_FORM_ITEM_NAME);

    if (mPostDialogueScript != null) {
      createScript(filledElement, mPostDialogueScript);
    }

    createScript(
        filledElement,
        RIVR_SCOPE_OBJECT + ".addValueResult(" + SUBDIALOGUE_RESULT_VARIABLE_NAME + ");");
    createGotoSubmit(filledElement);
  }
Exemplo n.º 19
0
 /**
  * Sets the mass. Overrides PointMass method.
  *
  * @param mass the mass
  */
 public void setMass(double mass) {
   super.setMass(mass);
   mass = super.getMass();
   massField.setValue(mass);
   // refresh mass parameter in paramPanel if changed
   Parameter massParam = (Parameter) getParamEditor().getObject("m"); // $NON-NLS-1$
   if (massParam != null && massParam.getValue() != mass) {
     functionPanel.getParamEditor().setExpression("m", String.valueOf(mass), false); // $NON-NLS-1$
     refreshSteps();
   }
 }
Exemplo n.º 20
0
  public ParameterTable copy() {
    ParameterTable ptable = new ParameterTable();
    ptable.setParent(parent);

    synchronized (table) {
      for (Parameter p : table) {
        ptable.add(p.getName(), p.getValue());
      }
    }

    return ptable;
  }
Exemplo n.º 21
0
 /** Refreshes initial time parameter for this model. */
 protected void refreshInitialTime() {
   if (trackerPanel == null) return;
   double t0 = trackerPanel.getPlayer().getFrameTime(getStartFrame()) / 1000;
   String t = timeFormat.format(t0);
   Parameter param = (Parameter) getInitEditor().getObject("t"); // $NON-NLS-1$
   if (param.getValue() != t0) {
     boolean prev = refreshing;
     refreshing = true;
     getInitEditor().setExpression("t", t, false); // $NON-NLS-1$
     refreshing = prev;
   }
 }
  private Object translate(Response resp) {
    Object rtnValue = null;

    if (!resp.generatedFault()) {
      Parameter ret = resp.getReturnValue();
      rtnValue = SoapUtils.fromByteArray((byte[]) ret.getValue());
    } else {
      outputFault(d_methodName, resp);
    }

    return rtnValue;
  }
Exemplo n.º 23
0
  private String createUrlWithParams(final Request<?> request) {
    if (request == null || TextUtils.isEmpty(request.getUrl())) {
      return null;
    }
    Uri.Builder uriBuilder = Uri.parse(request.getUrl()).buildUpon();

    List<Parameter> params = request.getUrlParams();
    if (checkListOfParams(params)) {
      for (Parameter parameter : params) {
        uriBuilder.appendQueryParameter(parameter.getName(), parameter.getValue());
      }
    }
    return uriBuilder.build().toString();
  }
 /** Refreshes the functions. */
 protected void refreshFunctions() {
   // put the parameter values into the data properties map
   Map map = getData().getProperties();
   map.clear();
   Iterator it = paramEditor.getObjects().iterator();
   while (it.hasNext()) {
     Parameter p = (Parameter) it.next();
     String name = p.getName();
     double val = p.getValue();
     map.put(name, new Double(val));
   }
   // evaluate the functions
   functionEditor.evaluateAll();
 }
Exemplo n.º 25
0
 private Directive parseDirective(final StringBuilder buffer, final ParserCursor cursor) {
   Parameter parameter = parseParameter(buffer, cursor, ALL_DELIMITERS);
   List<Parameter> params = Collections.emptyList();
   if (!cursor.atEnd()) {
     char ch = buffer.charAt(cursor.getPos() - 1);
     if (ch != ELEM_DELIMITER) {
       params = parseParameters(buffer, cursor);
     }
   }
   if (parameter instanceof QuotedParameter) {
     return createDirective(
         parameter.getName(), ((QuotedParameter) parameter).getQuotedValue(), params);
   }
   return createDirective(parameter.getName(), parameter.getValue(), params);
 }
Exemplo n.º 26
0
 public static String encodeParameters(List<Parameter> parameters) {
   if (parameters == null || parameters.isEmpty()) {
     return "";
   }
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < parameters.size(); i++) {
     if (i != 0) {
       buf.append("&");
     }
     Parameter param = parameters.get(i);
     buf.append(UrlUtilities.encode(param.getName()))
         .append("=")
         .append(UrlUtilities.encode(String.valueOf(param.getValue())));
   }
   return buf.toString();
 }
Exemplo n.º 27
0
  private Response doPost(final Request<?> request) {
    if (checkRequest(request)) {
      return null;
    }
    final HttpPost post = new HttpPost(createUrlWithParams(request));

    List<Parameter> postEntities = request.getPostEntities();
    if (checkListOfParams(postEntities)) {
      final LinkedList<BasicNameValuePair> postParams = new LinkedList<BasicNameValuePair>();
      for (Parameter parameter : postEntities) {
        postParams.add(new BasicNameValuePair(parameter.getName(), parameter.getValue()));
      }
      try {
        // Encoding parameter
        post.setEntity(new UrlEncodedFormEntity(postParams, "UTF-8"));
      } catch (final UnsupportedEncodingException ex) {
        return buildErrorResponse(ex.getMessage(), ResponseStatus.FAILED);
      }
    }

    return doRequest(request, post);
  }
Exemplo n.º 28
0
  /**
   * Populates service from corresponding OM.
   *
   * @param service_element an OMElement for the &lt;service&gt; tag
   * @return a filled-in AxisService, configured from the passed XML
   * @throws DeploymentException if there is a problem
   */
  public AxisService populateService(OMElement service_element) throws DeploymentException {
    try {
      // Determine whether service should be activated.
      String serviceActivate = service_element.getAttributeValue(new QName(ATTRIBUTE_ACTIVATE));
      if (serviceActivate != null) {
        if ("true".equals(serviceActivate)) {
          service.setActive(true);
        } else if ("false".equals(serviceActivate)) {
          service.setActive(false);
        }
      }

      // Processing service level parameters
      OMAttribute serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));

      // If the service name is explicitly specified in the services.xml
      // then use that as the service name
      if (serviceNameatt != null) {
        if (!"".equals(serviceNameatt.getAttributeValue().trim())) {
          AxisService wsdlService = wsdlServiceMap.get(serviceNameatt.getAttributeValue());
          if (wsdlService != null) {
            wsdlService.setClassLoader(service.getClassLoader());
            wsdlService.setParent(service.getAxisServiceGroup());
            service = wsdlService;
            service.setWsdlFound(true);
            service.setCustomWsdl(true);
          }
          service.setName(serviceNameatt.getAttributeValue());
          // To be on the safe side
          if (service.getDocumentation() == null) {
            service.setDocumentation(serviceNameatt.getAttributeValue());
          }
        }
      }

      Iterator itr = service_element.getChildrenWithName(new QName(TAG_PARAMETER));
      processParameters(itr, service, service.getParent());

      Parameter childFirstClassLoading =
          service.getParameter(Constants.Configuration.ENABLE_CHILD_FIRST_CLASS_LOADING);
      if (childFirstClassLoading != null) {
        ClassLoader cl = service.getClassLoader();
        if (cl instanceof DeploymentClassLoader) {
          DeploymentClassLoader deploymentClassLoader = (DeploymentClassLoader) cl;
          if (JavaUtils.isTrueExplicitly(childFirstClassLoading.getValue())) {
            deploymentClassLoader.setChildFirstClassLoading(true);
          } else if (JavaUtils.isFalseExplicitly(childFirstClassLoading.getValue())) {
            deploymentClassLoader.setChildFirstClassLoading(false);
          }
        }
      }

      // If multiple services in one service group have different values
      // for the PARENT_FIRST
      // parameter then the final value become the value specified by the
      // last service in the group
      // Parameter parameter =
      // service.getParameter(DeploymentClassLoader.PARENT_FIRST);
      // if (parameter !=null && "false".equals(parameter.getValue())) {
      // ClassLoader serviceClassLoader = service.getClassLoader();
      // ((DeploymentClassLoader)serviceClassLoader).setParentFirst(false);
      // }
      // process service description
      OMElement descriptionElement =
          service_element.getFirstChildWithName(new QName(TAG_DESCRIPTION));
      if (descriptionElement != null) {
        OMElement descriptionValue = descriptionElement.getFirstElement();
        if (descriptionValue != null) {
          service.setDocumentation(descriptionValue);
        } else {
          service.setDocumentation(descriptionElement.getText());
        }
      } else {
        serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));

        if (serviceNameatt != null) {
          if (!"".equals(serviceNameatt.getAttributeValue().trim())
              && service.getDocumentation() == null) {
            service.setDocumentation(serviceNameatt.getAttributeValue());
          }
        }
      }

      if (service.getParameter("ServiceClass") == null) {
        log.debug("The Service " + service.getName() + " does not specify a Service Class");
      }

      // Process WS-Addressing flag attribute
      OMAttribute addressingRequiredatt =
          service_element.getAttribute(new QName(ATTRIBUTE_WSADDRESSING));
      if (addressingRequiredatt != null) {
        String addressingRequiredString = addressingRequiredatt.getAttributeValue();
        AddressingHelper.setAddressingRequirementParemeterValue(service, addressingRequiredString);
      }

      // Setting service target namespace if any
      OMAttribute targetNameSpace = service_element.getAttribute(new QName(TARGET_NAME_SPACE));

      if (targetNameSpace != null) {
        String nameSpeceVale = targetNameSpace.getAttributeValue();
        if (nameSpeceVale != null && !"".equals(nameSpeceVale)) {
          service.setTargetNamespace(nameSpeceVale);
        }
      } else {
        if (service.getTargetNamespace() == null || "".equals(service.getTargetNamespace())) {
          service.setTargetNamespace(Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE);
        }
      }

      // Processing service lifecycle attribute
      OMAttribute serviceLifeCycleClass = service_element.getAttribute(new QName(TAG_CLASS_NAME));
      if (serviceLifeCycleClass != null) {
        String className = serviceLifeCycleClass.getAttributeValue();
        loadServiceLifeCycleClass(className);
      }
      // Setting schema namespece if any
      OMElement schemaElement = service_element.getFirstChildWithName(new QName(SCHEMA));
      if (schemaElement != null) {
        OMAttribute schemaNameSpace = schemaElement.getAttribute(new QName(SCHEMA_NAME_SPACE));
        if (schemaNameSpace != null) {
          String nameSpeceVale = schemaNameSpace.getAttributeValue();
          if (nameSpeceVale != null && !"".equals(nameSpeceVale)) {
            service.setSchemaTargetNamespace(nameSpeceVale);
          }
        }
        OMAttribute elementFormDefault =
            schemaElement.getAttribute(new QName(SCHEMA_ELEMENT_QUALIFIED));
        if (elementFormDefault != null) {
          String value = elementFormDefault.getAttributeValue();
          if ("true".equals(value)) {
            service.setElementFormDefault(true);
          } else if ("false".equals(value)) {
            service.setElementFormDefault(false);
          }
        }

        // package to namespace mapping. This will be an element that
        // maps pkg names to a namespace
        // when this is doing AxisService.getSchemaTargetNamespace will
        // be overridden
        // This will be <mapping/> with @namespace and @package
        Iterator mappingIterator = schemaElement.getChildrenWithName(new QName(MAPPING));
        if (mappingIterator != null) {
          Map<String, String> pkg2nsMap = new Hashtable<String, String>();
          while (mappingIterator.hasNext()) {
            OMElement mappingElement = (OMElement) mappingIterator.next();
            OMAttribute namespaceAttribute =
                mappingElement.getAttribute(new QName(ATTRIBUTE_NAMESPACE));
            OMAttribute packageAttribute =
                mappingElement.getAttribute(new QName(ATTRIBUTE_PACKAGE));
            if (namespaceAttribute != null && packageAttribute != null) {
              String namespaceAttributeValue = namespaceAttribute.getAttributeValue();
              String packageAttributeValue = packageAttribute.getAttributeValue();
              if (namespaceAttributeValue != null && packageAttributeValue != null) {
                pkg2nsMap.put(packageAttributeValue.trim(), namespaceAttributeValue.trim());
              } else {
                log.warn(
                    "Either value of @namespce or @packagename not available. Thus, generated will be selected.");
              }
            } else {
              log.warn(
                  "Either @namespce or @packagename not available. Thus, generated will be selected.");
            }
          }
          service.setP2nMap(pkg2nsMap);
        }
      }

      // processing Default Message receivers
      OMElement messageReceiver =
          service_element.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVERS));
      if (messageReceiver != null) {
        HashMap<String, MessageReceiver> mrs =
            processMessageReceivers(service.getClassLoader(), messageReceiver);
        for (Map.Entry<String, MessageReceiver> entry : mrs.entrySet()) {
          service.addMessageReceiver(entry.getKey(), entry.getValue());
        }
      }

      // Removing exclude operations
      OMElement excludeOperations =
          service_element.getFirstChildWithName(new QName(TAG_EXCLUDE_OPERATIONS));
      ArrayList<String> excludeops = null;
      if (excludeOperations != null) {
        excludeops = processExcludeOperations(excludeOperations);
      }
      if (excludeops == null) {
        excludeops = new ArrayList<String>();
      }
      Utils.addExcludeMethods(excludeops);

      // <schema targetNamespace="http://x.y.z"/>
      // setting the PolicyInclude
      // processing <wsp:Policy> .. </..> elements
      Iterator policyElements =
          service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));

      if (policyElements != null && policyElements.hasNext()) {
        processPolicyElements(policyElements, service.getPolicySubject());
      }

      // processing <wsp:PolicyReference> .. </..> elements
      Iterator policyRefElements =
          service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));

      if (policyRefElements != null && policyRefElements.hasNext()) {
        processPolicyRefElements(policyRefElements, service.getPolicySubject());
      }

      // processing service scope
      String sessionScope = service_element.getAttributeValue(new QName(ATTRIBUTE_SCOPE));
      if (sessionScope != null) {
        service.setScope(sessionScope);
      }

      // processing service-wide modules which required to engage globally
      Iterator moduleRefs = service_element.getChildrenWithName(new QName(TAG_MODULE));

      processModuleRefs(moduleRefs);

      // processing transports
      OMElement transports = service_element.getFirstChildWithName(new QName(TAG_TRANSPORTS));
      if (transports != null) {
        Iterator transport_itr = transports.getChildrenWithName(new QName(TAG_TRANSPORT));
        ArrayList<String> trs = new ArrayList<String>();
        while (transport_itr.hasNext()) {
          OMElement trsEle = (OMElement) transport_itr.next();
          String transportName = trsEle.getText().trim();
          if (axisConfig.getTransportIn(transportName) == null) {
            log.warn(
                "Service [ "
                    + service.getName()
                    + "] is trying to expose in a transport : "
                    + transportName
                    + " and which is not available in Axis2");
          } else {
            trs.add(transportName);
          }
        }

        if (trs.isEmpty()) {
          throw new AxisFault(
              "Service ["
                  + service.getName()
                  + "] is trying expose in tranpsorts: "
                  + transports
                  + " and which is/are not available in Axis2");
        }
        service.setExposedTransports(trs);
      }
      // processing operations
      Iterator operationsIterator = service_element.getChildrenWithName(new QName(TAG_OPERATION));
      ArrayList ops = processOperations(operationsIterator);

      for (int i = 0; i < ops.size(); i++) {
        AxisOperation operationDesc = (AxisOperation) ops.get(i);
        ArrayList wsamappings = operationDesc.getWSAMappingList();
        if (wsamappings == null) {
          continue;
        }
        if (service.getOperation(operationDesc.getName()) == null) {
          service.addOperation(operationDesc);
        }
        for (int j = 0; j < wsamappings.size(); j++) {
          String mapping = (String) wsamappings.get(j);
          if (mapping.length() > 0) {
            service.mapActionToOperation(mapping, operationDesc);
          }
        }
      }
      String objectSupplierValue = (String) service.getParameterValue(TAG_OBJECT_SUPPLIER);
      if (objectSupplierValue != null) {
        loadObjectSupplierClass(objectSupplierValue);
      }
      // Set the default message receiver for the operations that were
      // not listed in the services.xml
      setDefaultMessageReceivers();
      Utils.processBeanPropertyExclude(service);
      if (!service.isUseUserWSDL()) {
        // Generating schema for the service if the impl class is Java
        if (!service.isWsdlFound()) {
          // trying to generate WSDL for the service using JAM and
          // Java reflection
          try {
            if (generateWsdl(service)) {
              Utils.fillAxisService(service, axisConfig, excludeops, null);
            } else {
              ArrayList nonRpcOperations = getNonRPCMethods(service);
              Utils.fillAxisService(service, axisConfig, excludeops, nonRpcOperations);
            }
          } catch (Exception e) {
            throw new DeploymentException(
                Messages.getMessage("errorinschemagen", e.getMessage()), e);
          }
        }
      }
      if (service.isCustomWsdl()) {
        OMElement mappingElement =
            service_element.getFirstChildWithName(new QName(TAG_PACKAGE2QNAME));
        if (mappingElement != null) {
          processTypeMappings(mappingElement);
        }
      }

      for (String opName : excludeops) {
        service.removeOperation(new QName(opName));
      }

      // Need to call the same logic towice
      setDefaultMessageReceivers();
      Iterator moduleConfigs = service_element.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
      processServiceModuleConfig(moduleConfigs, service, service);

      // Loading Data Locator(s) configured
      OMElement dataLocatorElement =
          service_element.getFirstChildWithName(new QName(DRConstants.DATA_LOCATOR_ELEMENT));
      if (dataLocatorElement != null) {
        processDataLocatorConfig(dataLocatorElement, service);
      }

      processEndpoints(service);
      processPolicyAttachments(service_element, service);

    } catch (AxisFault axisFault) {
      throw new DeploymentException(axisFault);
    }

    startupServiceLifecycle();
    return service;
  }
Exemplo n.º 29
0
 public String getPara(String name, String def) {
   Parameter p = get(name);
   return p == null ? def : p.getValue();
 }
Exemplo n.º 30
0
 /**
  * Gets the mass. Overrides PointMass method.
  *
  * @return the mass
  */
 public double getMass() {
   Parameter massParam = (Parameter) getParamEditor().getObject("m"); // $NON-NLS-1$
   if (massParam != null) return massParam.getValue();
   return super.getMass();
 }