Examples of WsResourceClient


Examples of org.apache.muse.ws.resource.remote.WsResourceClient

    public void setMemberEPR(EndpointReference memberEPR)
    {
        if (memberEPR == null)
            throw new NullPointerException(_MESSAGES.get("NullResource"));
       
        _member = new WsResourceClient(memberEPR, getServiceGroupEPR(), getEnvironment());
    }
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

        return _currentTime;
    }
   
    public WsResourceClient getEntryClient()
    {
        return new WsResourceClient(_entryEPR);
    }
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

                System.exit(0);

            //
            // test first WsResource we find
            //
            WsResourceClient client = null;
           
            for (int n = 0; n < members.length && client == null; ++n)
                if (members[n].getEndpointReference().getAddress().toString().endsWith("WsResource"))
                    client = members[n];
           
            client.setTrace(true);
           
            //
            // test WSRL operations
            //
            //destroy(client);
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

     
      resourceEndpointReference.addParameter(
          Names.RESOURCE_ID_QNAME,
          wsresourceid);
     
      WsResourceClient resourceClient = new WsResourceClient(resourceEndpointReference);
      Element wsdl = ((Element[])resourceClient.invoke(proxyHandler,WSDL_DIALECT))[0];
           
          NodeList nodelist = wsdl.getChildNodes();
          Element definitions = null;
          for (int i = 0; i < nodelist.getLength(); i++)
          {
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

   */
  void executeExample(String host, int port, String qpidHost, int qpidPort, String virtualHost, String username, String password, int initPoolCapacity, int maxPoolCapacity, long maxWaitTimeout) throws Exception
  {   
    // 1) Creates an endpoint reference of the adapter service...
    EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
    WsResourceClient adapterClient = new WsResourceClient(adapterEndpointReference);
    adapterClient.setTrace(true);
   
    // 2) Creates the Adapter service client...
    adapterClient.invoke(
        getProxyHandler(),
        new Object[]{
          qpidHost,
          qpidPort,
          username,
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

     
      resourceEndpointReference.addParameter(
          Names.RESOURCE_ID_QNAME,
          wsresourceid);
     
      WsResourceClient resourceClient = new WsResourceClient(resourceEndpointReference);
      Element rmd = ((Element[])resourceClient.invoke(proxyHandler,RMD_DIALECT))[0];
           
//          NodeList nodelist = wsdl.getChildNodes();
//          Element definitions = null;
//          for (int i = 0; i < nodelist.getLength(); i++)
//          {
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

   
    // 4) Creates a proxy handler for service invocation.
    ProxyHandler metadataProxyHandler = createProxyHandler();
   
    // 5) ..and invokes the GetMetadata on the first member.
    WsResourceClient firstMember = resources[0];
    firstMember.setTrace(true);
   
    // Dialect is RDM for this example
    String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
    Object [] inputParameters = {dialect};
   
    // WSDL is the first element of the returned array. We don't need to print out it here
    // because at this point it should have been already printed out (line 96 : firstMember.setTrace(true))
    @SuppressWarnings("unused")
    Element [] metadata = (Element[]) firstMember.invoke(metadataProxyHandler, inputParameters);
  }
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

      System.out.println("-------------------------------------------------------------------");
      System.exit(0);
    }
   
    // 4) ..and invokes the GetMetadata on the first member.
    WsResourceClient wsResourceClient = resources[0];
    wsResourceClient.setTrace(true);
   
    @SuppressWarnings("unused")
    Element resourcePropertyDocument = wsResourceClient.getResourcePropertyDocument();
  }
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

   
    // 4) Creates a proxy handler for service invocation.
    ProxyHandler metadataProxyHandler = createProxyHandler();
   
    // 5) ..and invokes the GetMetadata on the first member.
    WsResourceClient wsResourceClient = resources[0];
    wsResourceClient.setTrace(true);
   
    // Dialect is RDM for this example
    String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
    Object [] inputParameters = {dialect};
   
    // RDM is the first element of the returned array.
    // The first element is a wsx:Metadata containing all resource properties.
    Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
    Element resourceMetadataDescriptor   = metadata[0];
   
    // 6) using XPath navigates xml in order to get the list of all properties.
    Element [] properties = XmlUtils.findInSubTree(
        resourceMetadataDescriptor,
        new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));

    for (Element property : properties)
    {
     
      String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>
     
      // For this example we are only interested on qman namespace related properties...
      if (attributeName.startsWith("qman"))
      {
        String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); //  = <Attribute Name>
       
        // 7) Send a GetResourcePropertyRequest for the given attribute.
        // We do nothing with the returned value(s) because it / they
        // has / have already printed out (wsResourceClient.setTrace(true))
        @SuppressWarnings("unused")
        Element [] values = wsResourceClient.getResourceProperty(
            new QName(
                "http://amqp.apache.org/qpid/management/qman",
                attributeNameWithoutPrefix,
                "qman"));
      }
View Full Code Here

Examples of org.apache.muse.ws.resource.remote.WsResourceClient

   
    // 4) Creates a proxy handler for service invocation.
    ProxyHandler metadataProxyHandler = createProxyHandler();
   
    // 5) ..and invokes the GetMetadata on the first member.
    WsResourceClient wsResourceClient = resources[0];
    wsResourceClient.setTrace(true);
   
    // Resource Metadata Descriptor
    String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
    Object [] inputParameters = {dialect};
   
    // RDM is the first element of the returned array.
    // The first element is a wsx:Metadata containing all resource properties.
    Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
    Element resourceMetadataDescriptor   = metadata[0];
   
    // 6) Now we need WSDL in order to catch datatypes
    dialect = "http://schemas.xmlsoap.org/wsdl/";
    inputParameters = new Object[]{dialect};
    metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
    Element wsdl = metadata[0];
   
    //7) Defines sample values used for update property.
    Map<String, Object> sampleValues = new HashMap<String, Object>();
    sampleValues.put("xsd:string","This is a string.");
    sampleValues.put("xsd:integer",new Integer(12345));
    sampleValues.put("xsd:int",new Integer(54321));
    sampleValues.put("xsd:long",new Integer(12345));
    sampleValues.put("xsd:double",new Double(12345.6d));
    sampleValues.put("xsd:float",new Float(123.4f));
    sampleValues.put("xsd:short",new Short((short)12));
   
    // 8) using XPath navigates xml in order to get the list of all properties.
    Element [] properties = XmlUtils.findInSubTree(
        resourceMetadataDescriptor,
        new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));
   
    Element [] wsdlElements = XmlUtils.findInSubTree(
        wsdl,
        new QName("http://www.w3.org/2001/XMLSchema","element","xsd"));
   
    // Did we find at least one writable property?
    boolean atLeastOnePropertyHasBeenFound = false;
   
    for (Element property : properties)
    { 
      // Sanity check : if the property is read-only then proceed with next
      // property.
      if (!"read-write".equals(property.getAttribute("modifiability")))
      {
        continue;
      }
     
      String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>

      // For this example we are only interested on qman namespace related properties...
      if (attributeName.startsWith("qman"))
      {
        String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); //  = <Attribute Name>

        for (Element wsdlElement : wsdlElements)
        {
          String name = wsdlElement.getAttribute("name");
          String type = wsdlElement.getAttribute("type");
          if ((name != null) && (attributeNameWithoutPrefix.equals(name)) && (type != null))
          {
            Object newValue = sampleValues.get(type);
            if (newValue != null)
            {
              atLeastOnePropertyHasBeenFound = true;
             
              inputParameters = new Object[] {newValue};
             
              // 9) Makes a GetResourcePropertiesRequest in order to get the current value.
              QName propertyQName = new QName(
                  "http://amqp.apache.org/qpid/management/qman",
                  name,
                  "qman");
             
              // The returned value is really an array because property shoudl be a multi-value property.
              // So in order to get its value we need to extract the first value.
              Object currentValue = wsResourceClient.getPropertyAsObject(propertyQName,newValue.getClass());
             
              // 10a) If the property is not set (value is null) then an "Insert" request must be sent.
              if (currentValue == null || Array.getLength(currentValue) == 0)
              {
                wsResourceClient.insertResourceProperty(propertyQName,inputParameters);
              }
              // 10b) If the property is not null then an "Update" request must be sent.
              else
              {
                wsResourceClient.updateResourceProperty(propertyQName,inputParameters);               
              }
             
              // 11) Let's query again the resource using GetResourceProperties in order to ensure the
              // previous property has been properly updated.
              currentValue = wsResourceClient.getPropertyAsObject(propertyQName,newValue.getClass());
             
              String resultMessage = (newValue.equals(Array.get(currentValue, 0)))
                ? "Resource has been correctly updated."
                : "Something was wrong : resource seems not to be properly updated.";
             
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.