All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.webcohesion.enunciate.modules.jaxws.api.impl.JaxwsServiceApi Maven / Gradle / Ivy

There is a newer version: 2.18.1
Show newest version
package com.webcohesion.enunciate.modules.jaxws.api.impl;

import com.webcohesion.enunciate.api.ApiRegistrationContext;
import com.webcohesion.enunciate.api.services.Operation;
import com.webcohesion.enunciate.api.services.Service;
import com.webcohesion.enunciate.api.services.ServiceApi;
import com.webcohesion.enunciate.api.services.ServiceGroup;
import com.webcohesion.enunciate.modules.jaxws.EnunciateJaxwsContext;
import com.webcohesion.enunciate.modules.jaxws.WsdlInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Ryan Heaton
 */
public class JaxwsServiceApi implements ServiceApi {

  private final EnunciateJaxwsContext context;
  private ApiRegistrationContext registrationContext;

  public JaxwsServiceApi(EnunciateJaxwsContext context, ApiRegistrationContext registrationContext) {
    this.context = context;
    this.registrationContext = registrationContext;
  }

  @Override
  public String getContextPath() {
    return this.context.getContextPath();
  }

  @Override
  public List getServiceGroups() {
    Map wsdls = this.context.getWsdls();
    ArrayList serviceGroups = new ArrayList();
    for (WsdlInfo wsdlInfo : wsdls.values()) {
      serviceGroups.add(new ServiceGroupImpl(wsdlInfo, registrationContext));
    }
    return serviceGroups;
  }

  @Override
  public Operation findOperationFor(String classname, String method) {
    if (method.isEmpty() || classname.isEmpty()) {
      return null;
    }

    for (ServiceGroup serviceGroup : getServiceGroups()) {
      for (Service service : serviceGroup.getServices()) {
        for (Operation operation : service.getOperations()) {
          if (operation instanceof OperationImpl) {
            if (method.startsWith(((OperationImpl)operation).getWebMethod().getSimpleName().toString()) && ((OperationImpl)operation).getWebMethod().getDeclaringEndpointInterface().getQualifiedName().contentEquals(classname)) {
              return operation;
            }
          }
        }
      }
    }

    return null;
  }

  @Override
  public Service findServiceFor(String classname) {
    if (classname.isEmpty()) {
      return null;
    }
    for (ServiceGroup serviceGroup : getServiceGroups()) {
      for (Service service : serviceGroup.getServices()) {
        for (Operation operation : service.getOperations()) {
          if (operation instanceof OperationImpl) {
            if (((OperationImpl)operation).getWebMethod().getDeclaringEndpointInterface().getQualifiedName().contentEquals(classname)) {
              return service;
            }
          }
        }
      }
    }

    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy