Package org.apache.tuscany.sca.domain

Examples of org.apache.tuscany.sca.domain.SCADomainSPI


                                                   messageFactory);
       

        if (node != null){
           
            SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();
           
            if (domainProxy != null) {

                // work out what the component service name is that will be registered
                // it should be the path element of the binding uri
                String componentServiceName = this.binding.getURI();
               
          try {
              URI servicePath = new URI(this.binding.getURI());
                    componentServiceName = servicePath.getPath();
                   
                    // strip any leading slash
                    if (componentServiceName.charAt(0) == '/'){
                        componentServiceName = componentServiceName.substring(1, componentServiceName.length());
                    }
                } catch(Exception ex) {
                    // do nothing, the binding uri string will be used
                }
               
                // work out what the endpoint address is that the component service name will be registered
                // against. Be default this is the url calculated by the web services binding but
                // we have to adjust that to:
                // 1. correct the host and port in the case that this is a web app as the container controlls the port
                // 2. correct the host name in the case that it's localhost           
                String componentServiceUrlString = wsBinding.getURI();
                URL componentServiceUrl;
               
                try {
                    componentServiceUrl = new URL(componentServiceUrlString);
                } catch (MalformedURLException ex) {
                  throw new IllegalStateException("Unable to conver url " +
                                                  componentServiceUrlString +
                                                  " as generated by the web service binding into a URL");
                }
               
                String originalHost = componentServiceUrl.getHost();
                String newHost = originalHost;
                int originalPort = componentServiceUrl.getPort();
                int newPort = originalPort;
               
                // TODO - could do with a change to the ServletHost API so that we can just ask the servlet
                //        host if it is controlling the URL
                if (servletHost.getClass().getName().equals("WebbAppServletHost")){
                    // the service URL will likely be completely different to that
                    // calculated by the ws binding so replace it with the node url
                    // The node url will have been set via init parameters in the web app
                    URL nodeUrl;
                    try {
                        URI tmpURI = new URI(node.getURI());
                        nodeUrl = tmpURI.toURL();
                    } catch (Exception ex) {
                        throw new IllegalStateException("Node running inside a webapp and node was not created with a valid node url");
                    }
                    
                    if (nodeUrl != null){
                        newHost = nodeUrl.getHost();
                        newPort = nodeUrl.getPort();
                    } else {
                        throw new IllegalStateException("Node running inside a webapp and node was not created with a valid node url");
                    }
                }
               
                // no good registering localhost as a host name when nodes are spread across
                // machines
                if ( newHost.equals("localhost")){
                    try {
                        newHost = InetAddress.getLocalHost().getHostName();
                    } catch(UnknownHostException ex) {
                        throw new IllegalStateException("Got unknown host while trying to get the local host name in order to regsiter service with the domain");
                    }           
                }
                   
                // replace the old with the new
                componentServiceUrlString = componentServiceUrlString.replace(String.valueOf(originalPort), String.valueOf(newPort));         
                componentServiceUrlString = componentServiceUrlString.replace(originalHost, newHost);           
                   
                try {
                    domainProxy.registerServiceEndpoint(node.getDomain().getURI(),
                                                        node.getURI(),
                                                        componentServiceName,
                                                        SCABinding.class.getName(),
                                                        componentServiceUrlString);
                } catch(Exception ex) {
View Full Code Here


            // if no target is found then this could be a completely dynamic
            // reference, e.g. a callback, so check the domain to see if the service is available
            // at this node. The binding uri might be null here if the dynamic reference has been
            // fully configured yet. It won't have all of the information until invocation time
            if ((node != null) && (binding.getURI() != null)) {
                SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();

                String serviceUrl =
                    domainProxy.findServiceEndpoint(node.getDomain().getURI(),
                                                         binding.getURI(),
                                                         SCABinding.class.getName());
                if ((serviceUrl == null) || serviceUrl.equals("")) {
                    targetIsRemote = false;
                } else {
View Full Code Here

     */
    public EndpointReference getServiceEndpoint(){
       
        if ( serviceEPR == null && node != null ){
            // try to resolve the service endpoint with the registry
            SCADomainSPI domainProxy = (SCADomainSPI)node.getDomain();
           
            if (domainProxy != null){
           
              // The binding URI might be null in the case where this reference is completely
              // dynamic, for example, in the case of callbacks
              if (binding.getURI() != null) {
                  String serviceUrl = domainProxy.findServiceEndpoint(node.getDomain().getURI(),
                                                                           binding.getURI(),
                                                                           SCABinding.class.getName());
                 
                  if ( (serviceUrl != null ) &&
                       (!serviceUrl.equals(""))){
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.domain.SCADomainSPI

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.