Package org.apache.tuscany.sca.context

Examples of org.apache.tuscany.sca.context.CompositeContext


        bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
    }

    public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
        if (compositeContext == null) {
            compositeContext = new CompositeContext(registry, endpointRegistry);
        }
        this.registry = registry;
        this.endpointRegistry = endpointRegistry;
        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
        this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
View Full Code Here


        }
    }

    public void stop(RuntimeEndpointReference epr) {
        if (epr.isStarted()) {
            CompositeContext compositeContext = epr.getCompositeContext();
            if (compositeContext == null) {
                throw new IllegalStateException("The endpoint reference is not bound");
            }
            compositeContext.getEndpointRegistry().removeEndpointReference(epr);
            ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
            if (bindingProvider != null) {
                bindingProvider.stop();
            }
            for (PolicyProvider policyProvider : epr.getPolicyProviders()) {
View Full Code Here

     * Create the async callback endpoint for a reference that is going to invoke an asyncInvocation service
     * @param epr - the RuntimeEndpointReference for which the callback is created
     * @return - a RuntimeEndpoint representing the callback endpoint
     */
    private RuntimeEndpoint createAsyncCallbackEndpoint(RuntimeEndpointReference epr) {
        CompositeContext compositeContext = epr.getCompositeContext();
        RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory(compositeContext);
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);

        // Create a pseudo-component and pseudo-service
        // - need to end with a chain with an invoker into the AsyncCallbackHandler class
        RuntimeComponent fakeComponent = null;
        try {
            fakeComponent = (RuntimeComponent)epr.getComponent().clone();
            applyImplementation(fakeComponent);
        } catch (CloneNotSupportedException e2) {
            // will not happen
        } // end try
        endpoint.setComponent(fakeComponent);

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        JavaInterfaceFactory javaInterfaceFactory =
            (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        try {
View Full Code Here

            if (o instanceof ClassLoader) {
                contribution.setClassLoader((ClassLoader)o);       
            }
        }

        compositeContext = new CompositeContext(extensionPointRegistry,
                                                domainRegistry,
                                                builtComposite,
                                                null, // nothing appears to use the domain name in CompositeContext
                                                null, // don't need node uri
                                                deployer.getSystemDefinitions());
View Full Code Here

            throw new ServiceRuntimeException(e);
        }
    }
   
    public void resolveEndpoint(Endpoint endpoint) {
        CompositeContext compositeContext = ((RuntimeEndpoint)endpoint).getCompositeContext();
       
        if (compositeContext == null){
            // will be null if this is the SCAClient
            return;
        }
       
        Definitions systemDefinitions = compositeContext.getSystemDefinitions();
        if (systemDefinitions != null){
            // Find pre-resolved intents from the system definition
            List<Intent> intents = new ArrayList<Intent>();
           
            for (Intent intent : endpoint.getRequiredIntents()){
                Intent resolvedIntent = PolicyHelper.getIntent(systemDefinitions, intent.getName());
             
                if (resolvedIntent != null){
                    intents.add(resolvedIntent);
                } else {
                    // look to see if this intent is provided by the binding
                    BindingType bindingType = systemDefinitions.getBindingType(endpoint.getBinding().getType());

                    if (bindingType != null){
                        for (Intent apIntent : bindingType.getAlwaysProvidedIntents()){
                            if (apIntent.getName().equals(intent.getName())){
                                resolvedIntent = apIntent;
                                break;
                            }
                        }
                       
                        if (resolvedIntent == null){
                            for (Intent mpIntent : bindingType.getMayProvidedIntents()){
                                if (mpIntent.getName().equals(intent.getName())){
                                    resolvedIntent = mpIntent;
                                    break;
                                }
                            }
                        }
                    }
                   
                    if (resolvedIntent != null){
                        intents.add(resolvedIntent);
                    } else {
                        throw new ServiceRuntimeException("Remote endpoint " +
                                                          endpoint +
                                                          " has intent " +
                                                          intent +
                                                          " that can't be found in the local system definitions in node " +
                                                          compositeContext.getNodeURI());
                    }
                }
            }
           
            endpoint.getRequiredIntents().clear();
            endpoint.getRequiredIntents().addAll(intents);
           
            // Find pre-resolved policy sets from the system definition
            List<PolicySet> policySets = new ArrayList<PolicySet>();
           
            for (PolicySet policySet : endpoint.getPolicySets()){
                PolicySet resolvedPolicySet = PolicyHelper.getPolicySet(systemDefinitions, policySet.getName());
                if (resolvedPolicySet != null){
                    policySets.add(resolvedPolicySet);
                } else {
                    throw new ServiceRuntimeException("Remote endpoint " +
                                                      endpoint +
                                                      " has policy set " +
                                                      policySet +
                                                      " that can't be found in the local system definitions in node " +
                                                      compositeContext.getNodeURI());
                }
            }
           
            endpoint.getPolicySets().clear();
            endpoint.getPolicySets().addAll(policySets);
View Full Code Here

        bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
    }

    public void bind(ExtensionPointRegistry registry, DomainRegistry domainRegistry) {
        if (compositeContext == null) {
            compositeContext = new CompositeContext(registry, domainRegistry);
        }
        this.registry = registry;
        this.domainRegistry = domainRegistry;
        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
        this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
View Full Code Here

       
        return interfaceContract.getNormalizedWSDLContract();     
    }  
   
    public void createAsyncCallbackEndpoint(){
        CompositeContext compositeContext = getCompositeContext();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        RuntimeAssemblyFactory assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
       
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);
View Full Code Here

  @SuppressWarnings("unchecked")
  private ServiceReference<AsyncResponseHandler<?>> getAsyncCallbackRef( Message msg ) {
      RuntimeEndpointReference callbackEPR = (RuntimeEndpointReference) msg.getHeaders().get(Constants.ASYNC_CALLBACK);
      if( callbackEPR == null ) return null;
     
      CompositeContext compositeContext = callbackEPR.getCompositeContext();
        registry = compositeContext.getExtensionPointRegistry();
      ProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
      msgFactory = getMessageFactory();
      List<EndpointReference> eprList = new ArrayList<EndpointReference>();
      eprList.add(callbackEPR);
      ObjectFactory<?> factory = new CallbackReferenceObjectFactory(AsyncResponseHandler.class, proxyFactory, eprList);
View Full Code Here

        endpointReference.getInvocationChains();
    }

    public void stop(RuntimeEndpointReference epr) {
        if (epr.isStarted()) {
            CompositeContext compositeContext = epr.getCompositeContext();
            if (compositeContext == null) {
                throw new IllegalStateException("The endpoint reference is not bound");
            }
            compositeContext.getEndpointRegistry().removeEndpointReference(epr);
            ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
            if (bindingProvider != null) {
                try {
                    bindingProvider.stop();
                } catch (Throwable ex){
View Full Code Here

     * Create the async callback endpoint for a reference that is going to invoke an asyncInvocation service
     * @param epr - the RuntimeEndpointReference for which the callback is created
     * @return - a RuntimeEndpoint representing the callback endpoint
     */
    private RuntimeEndpoint createAsyncCallbackEndpoint(RuntimeEndpointReference epr) {
        CompositeContext compositeContext = epr.getCompositeContext();
        RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory(compositeContext);
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);

        // Create a pseudo-component and pseudo-service
        // - need to end with a chain with an invoker into the AsyncCallbackHandler class
        RuntimeComponent fakeComponent = null;
        try {
            fakeComponent = (RuntimeComponent)epr.getComponent().clone();
            applyImplementation(fakeComponent);
        } catch (CloneNotSupportedException e2) {
            // will not happen
        } // end try
        endpoint.setComponent(fakeComponent);

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        JavaInterfaceFactory javaInterfaceFactory =
            (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        try {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.context.CompositeContext

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.