3 Replies Latest reply on Jan 13, 2011 3:00 PM by Keith Babo

    Service Metadata

    Keith Babo Master

      I took a quick first stab at a service metadata API for SwitchYard.  It's really basic at this point and only concerns itself with the interface details.  At some point, other metadata such as policy details will need to be factored in as well.  The initial code can be found in the metadata branch of my repository.  Please note that this is a temporary branch and you should not do other core-related work off of this branch since we will almost certainly re-write the commit history when merging it into upstream.

       

      I have added a org.switchyard.metadata package which contains the basic interface information.  There is also a JavaService class which can be used to create a ServiceInterface instance from any Java class.  We need to add a WsdlService class as well, which parses a WSDL definition and creates a ServiceInterface instance.

       

      A new method has been added to ServiceDomain that accepts a ServiceInterface instance when registering a service.  You can still use the method which does not accept a ServiceInterface, but keep in mind that a default ServiceInterface (single operation, in-out) is registered for you in that case.

       

      Feedback welcome.

        • 1. Re: Service Metadata
          Keith Babo Master

          I updated the branch with a slight refactoring of how Exchange instances are created.  Instead of passing a service QName and the exchange pattern, I changed the API to take a Service reference and an operation name.  The exchange pattern can be derived from the operation details on the ServiceInterface.  There is an option to omit the operation name in one of the createExchange() methods, which results in the use of ServiceInterface.DEFAULT_OPERATION underneath the covers.  The idea is that this would be used by services that don't care about operation-level granularity - e.g. a service that accepts one type of message.

           

          Old Way

           

          ServiceDomain domain = ServiceDomains.getDomain();
          QName serviceName = new QName("blah");
          Exchange exchange = domain.createExchange(serviceName, ExchangePattern.IN_OUT, new MyHandler());
          

           

          New Way

           

          ServiceDomain domain = ServiceDomains.getDomain();
          QName serviceName = new QName("blah");
          Service service = domain.getService(serviceName);
          Exchange exchange = domain.createExchange(service, new MyHandler());
          

           

          The real change here is that the creator of the exchange selects the registered service before creating the exchange.  It removes the requirement to set the exchange pattern, since we already know this from the registered service's metadata.  Tends to tighten things up a bit, I think.  I briefly considered moving the createExchange() methods to the Service class, but that got funky with the internals and I wasn't sure it felt right.  Might be worth revisiting.  Thoughts?

          • 2. Re: Service Metadata
            Tom Cunningham Master

            Probably want a way of specifying the service-choosing policy that we talked about for AddressingHandler.java here too :

             

            ServiceDomain domain = ServiceDomains.getDomain();
            QName serviceName = new QName("blah");
            ServicePolicy policy = new SimpleServicePolicy();
            Service service = domain.getService(serviceName, policy);
            Exchange exchange = domain.createExchange(service, new MyHandler());
            
            
            • 3. Re: Service Metadata
              Keith Babo Master

              Agreed.  In my mind, I was thinking that the client of the API would grab a list of all services (say for a particular interface) and then make the policy choice on its own.  This way we don't have to mess with allowing extensions in AddressingHandler and we can do away with the service-choosing logic in there altogether.  e.g.

               

               

              List<Service> services = getServices(ServiceInterface serviceInterface);
              for (Service s : services) {
                 if (matchesPolicy(s.getPolicy)) {
                    // use this service
                    break;
                 }
              }