Package org.apache.ws.scout.model.uddi.v2

Examples of org.apache.ws.scout.model.uddi.v2.BusinessService


 
  private Topology lookupEndpointInUDDI(String serviceKey) {
    Topology topology = null;
    try {
     
      BusinessService service = clerk.findService(serviceKey);
      if (service==null) {
        log.debug("No Service with key " + serviceKey + " was found in the registry.");
        //TODO find service by tModel
      }
      if (service!=null && service.getBindingTemplates()!=null && service.getBindingTemplates().getBindingTemplate() != null)
      {
        ArrayList<String> eprs = new ArrayList<String>();
        BindingTemplates bindingTemplates = service.getBindingTemplates();
        if (bindingTemplates==null) {
          log.warn("Found service " + service.getName().get(0).getValue()
                + " with serviceKey '" + serviceKey + "'"
                + " but no EPRs");
        } else {
          log.debug("Found service " + service.getName().get(0).getValue()
                + " with serviceKey '" + serviceKey + "'"
                + " and " + bindingTemplates.getBindingTemplate().size() + " EPRs");
          //Loop over all bindingTemplates found and get the endpoints.
          for (BindingTemplate bindingTemplate : bindingTemplates.getBindingTemplate()) {
            AccessPoint accessPoint = bindingTemplate.getAccessPoint();
View Full Code Here


        BusinessServices businessServices = new BusinessServices();

        for (Object serviceName : wsdlDefinition.getAllServices().keySet()) {
            QName serviceQName = (QName) serviceName;
            Service service = wsdlDefinition.getService(serviceQName);
            BusinessService businessService = null;
            //add service
            URL serviceUrl = null;
            if (service.getPorts() != null && service.getPorts().size() > 0) {
                for (Object portName : service.getPorts().keySet()) {
                    businessService = registerBusinessService(serviceQName, (String) portName, serviceUrl, wsdlDefinition).getBusinessService();
View Full Code Here

    public ServiceRegistrationResponse registerBusinessService(QName serviceQName, String portName, URL serviceUrl, Definition wsdlDefinition) throws RemoteException, ConfigurationException, TransportException, WSDLException {

        String genericWSDLURL = wsdlDefinition.getDocumentBaseURI();   //TODO maybe point to repository version
        ServiceRegistrationResponse response = new ServiceRegistrationResponse();
        String serviceKey = UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart());
        BusinessService businessService = lookupService(serviceKey);
        if (businessService == null) {
            List<TModel> tModels = new ArrayList<TModel>();
            // Create the PortType tModels
            Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
            tModels.addAll(createWSDLPortTypeTModels(genericWSDLURL, portTypes));
            // Create the Binding tModels
            Map<QName, Binding> bindings = (Map<QName, Binding>) wsdlDefinition.getAllBindings();
            tModels.addAll(createWSDLBindingTModels(genericWSDLURL, bindings));
            // Register these tModels
            for (TModel tModel : tModels) {
                clerk.register(tModel);
            }
            // Service
            businessService = createBusinessService(serviceQName, wsdlDefinition);
            // Register this Service
            clerk.register(businessService);
        }
        //Add the BindingTemplate to this Service
        BindingTemplate binding = createWSDLBinding(serviceQName, portName, serviceUrl, wsdlDefinition);
        // Register BindingTemplate
        if (binding.getAccessPoint()!=null) {
          clerk.register(binding);
          if (businessService.getBindingTemplates() == null) {
              businessService.setBindingTemplates(new BindingTemplates());
          }
          businessService.getBindingTemplates().getBindingTemplate().add(binding);
          response.setBindingKey(binding.getBindingKey());
        }
        response.setBusinessService(businessService);
        return response;
    }
View Full Code Here

    }

    public String unRegisterBusinessService(QName serviceName, String portName, URL serviceUrl) throws RemoteException, ConfigurationException, TransportException {

        String serviceKey = UDDIKeyConvention.getServiceKey(properties, serviceName.getLocalPart());
        BusinessService service = lookupService(serviceKey);
        boolean isRemoveServiceIfNoTemplates = true;
        String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceName, portName, serviceUrl);
        //check if this bindingKey is in the service's binding templates
        for (BindingTemplate bindingTemplate : service.getBindingTemplates().getBindingTemplate()) {
            if (bindingKey.equals(bindingTemplate.getBindingKey())) {
                clerk.unRegisterBinding(bindingKey);
                //if this is the last binding for this service, and
                if (service.getBindingTemplates().getBindingTemplate().size() == 1 && isRemoveServiceIfNoTemplates) {
                    clerk.unRegisterService(serviceKey);
                    if (bindingTemplate.getTModelInstanceDetails() != null
                            && bindingTemplate.getTModelInstanceDetails().getTModelInstanceInfo() != null) {
                        for (TModelInstanceInfo tModelInstanceInfo : bindingTemplate.getTModelInstanceDetails().getTModelInstanceInfo()) {
                            String tModelKey = tModelInstanceInfo.getTModelKey();
View Full Code Here

     * @throws TransportException
     */
    private BusinessService lookupService(String serviceKey) throws RemoteException, ConfigurationException, TransportException {

        //Checking if this serviceKey already exist
        BusinessService service = clerk.findService(serviceKey);
        return service;
    }
View Full Code Here

        }
        BusinessServices businessServices = new BusinessServices();
        for (Object serviceName : wsdlDefinition.getAllServices().keySet()) {
            QName serviceQName = (QName) serviceName;
            Service service = wsdlDefinition.getService(serviceQName);
            BusinessService businessService = createBusinessService(serviceQName, wsdlDefinition);
            //service.getExtensibilityElements().
            //add the bindingTemplates
            URL serviceUrl = null;
            if (service.getPorts() != null && service.getPorts().size() > 0) {
                businessService.setBindingTemplates(new BindingTemplates());
                for (Object portName : service.getPorts().keySet()) {
                    BindingTemplate bindingTemplate = createWSDLBinding(serviceQName, (String) portName, serviceUrl, wsdlDefinition);
                    businessService.getBindingTemplates().getBindingTemplate().add(bindingTemplate);
                }
            }
            businessServices.getBusinessService().add(businessService);
        }
View Full Code Here

     * @return
     */
    protected BusinessService createBusinessService(QName serviceQName, Definition wsdlDefinition) {

        log.debug("Constructing Service UDDI Information for " + serviceQName);
        BusinessService service = new BusinessService();
        // BusinessKey
        service.setBusinessKey(businessKey);
        // ServiceKey
        service.setServiceKey(UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));
        // Description
        String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
        // Override with the service description from the WSDL if present
        if (wsdlDefinition.getService(serviceQName) != null) {
            Element docElement = wsdlDefinition.getService(serviceQName).getDocumentationElement();
            if (docElement != null && docElement.getTextContent() != null) {
                serviceDescription = docElement.getTextContent();
            }
        }
        Description description = new Description();
        description.setLang(lang);
        description.setValue(serviceDescription);
        service.getDescription().add(description);
        // Service name
        Name sName = new Name();
        sName.setLang(lang);
        sName.setValue(serviceQName.getLocalPart());
        service.getName().add(sName);

        CategoryBag categoryBag = new CategoryBag();

        String namespace = serviceQName.getNamespaceURI();
        if (namespace != null && namespace != "") {
            KeyedReference namespaceReference = newKeyedReference(
                    "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", namespace);
            categoryBag.getKeyedReference().add(namespaceReference);
        }

        KeyedReference serviceReference = newKeyedReference(
                "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "service");
        categoryBag.getKeyedReference().add(serviceReference);

        KeyedReference localNameReference = newKeyedReference(
                "uddi:uddi.org:xml:localname", "uddi-org:xml:localName", serviceQName.getLocalPart());
        categoryBag.getKeyedReference().add(localNameReference);

        service.setCategoryBag(categoryBag);

        return service;
    }
View Full Code Here

   * Register a service.
   *
   */
  public BusinessService register(BusinessService service, Node node) {
   
    BusinessService businessService=null;
    log.info("Registering service " + service.getName().get(0).getValue()
        + " with key " + service.getServiceKey());
    try {
      String authToken = getAuthToken(node.getSecurityUrl());
      SaveService saveService = new SaveService();
View Full Code Here

 
  public Collection<BusinessService> readServiceAnnotations(String[] classesWithAnnotations, Properties properties) {
    Collection<BusinessService> services = new ArrayList<BusinessService>();
    for (String className : classesWithAnnotations) {
      try {   
        BusinessService service = readServiceAnnotations(className, properties);
        services.add(service);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

    return services;
  }
 
  public BusinessService readServiceAnnotations(String classWithAnnotations, Properties properties) throws ClassNotFoundException {
   
    BusinessService service = new BusinessService();
    Class<?> clazz = ClassUtil.forName(classWithAnnotations, this.getClass());
    UDDIService uddiService= (UDDIService) clazz.getAnnotation(UDDIService.class);
    WebService webServiceAnnotation = (WebService) clazz.getAnnotation(WebService.class);
   
    if (uddiService!=null) {
      //service
      String lang = "en"; //default to english
      if (uddiService.lang()!=null) {
        lang = uddiService.lang();
      }
      Name name = new Name();
      name.setLang(lang);
      service.setBusinessKey(TokenResolver.replaceTokens(uddiService.businessKey(),properties));
      service.setServiceKey(TokenResolver.replaceTokens(uddiService.serviceKey(),properties));
      if (!"".equals(uddiService.serviceName())) {
        name.setValue(TokenResolver.replaceTokens(uddiService.serviceName(),properties));
      } else if (webServiceAnnotation!=null && !"".equals(webServiceAnnotation.serviceName())) {
        name.setValue(webServiceAnnotation.serviceName());
      } else {
        name.setValue(clazz.getSimpleName());
      }
      service.getName().add(name);
      Description description = new Description();
      description.setLang(lang);
      description.setValue(TokenResolver.replaceTokens(uddiService.description(),properties));
      service.getDescription().add(description);
     
      //categoryBag on the service
      if (!"".equals(uddiService.categoryBag())) {
        CategoryBag categoryBag = parseCategoryBag(uddiService.categoryBag());
            service.setCategoryBag(categoryBag);
      }
     
      //bindingTemplate on service
      BindingTemplate bindingTemplate = parseServiceBinding(clazz, lang, webServiceAnnotation, properties);
      if (bindingTemplate!=null) {
        bindingTemplate.setServiceKey(service.getServiceKey());
        if (service.getBindingTemplates()==null) {
          service.setBindingTemplates(new BindingTemplates());
        }
        service.getBindingTemplates().getBindingTemplate().add(bindingTemplate);
      }
     
     
    } else {
      log.error("Missing UDDIService annotation in class " + classWithAnnotations);
View Full Code Here

TOP

Related Classes of org.apache.ws.scout.model.uddi.v2.BusinessService

Copyright © 2018 www.massapicom. 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.