Examples of RuntimeComponent


Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

            long now = System.currentTimeMillis();
            for (Map.Entry<RuntimeComponent, Map<String, Record>> entries : store.entrySet()) {
                for (Map.Entry<String, Record> entry : entries.getValue().entrySet()) {
                    final long expiration = entry.getValue().expiration;
                    if (expiration != NEVER && now >= expiration) {
                        RuntimeComponent owner = entries.getKey();
                        Object instance = entry.getValue().getData();
                        // notify listeners of the expiration
                        StoreExpirationEvent event = new StoreExpirationEvent(this, owner, instance);
                        publish(event);
                        entries.getValue().remove(entry.getKey());
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

        try {
         
            AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
            Composite composite = assemblyFactory.createComposite();
            composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
            RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
            component.setName("default");
            component.setURI("default");
            runtime.getCompositeActivator().configureComponentContext(component);
            composite.getComponents().add(component);
            RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
            reference.setName("default");
            ModelFactoryExtensionPoint factories =
                runtime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
            InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
            reference.setInterfaceContract(interfaceContract);
            component.getReferences().add(reference);
            reference.setComponent(component);
            SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
            SCABinding binding = scaBindingFactory.createSCABinding();
           
            // find the service endpoint somewhere else in the domain
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

            List<InvocationChain> chains = endpointReference.getInvocationChains();
            for (InvocationChain chain : chains) {
                configure(chain, chain.getSourceOperation());
            }
        } else if (subject instanceof RuntimeComponent) {
            RuntimeComponent component = (RuntimeComponent)subject;
            for (ComponentService s : component.getServices()) {
                RuntimeComponentService service = (RuntimeComponentService)s;
                for (Endpoint ep : service.getEndpoints()) {
                    List<InvocationChain> chains = ((RuntimeEndpoint)ep).getInvocationChains();
                    for (InvocationChain chain : chains) {
                        configure(chain, chain.getTargetOperation());
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

    public void start(CompositeContext compositeContext, Component component) {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Starting component: " + component.getURI());
        }
        RuntimeComponent runtimeComponent = ((RuntimeComponent)component);
        if(runtimeComponent.isStarted()) {
            return;
        }

        compositeContext.bindComponent(runtimeComponent);
        Implementation implementation = component.getImplementation();
       
        List<RuntimeProvider> providers = new ArrayList<RuntimeProvider>();
        try {

            if (implementation instanceof Composite) {
                try {
                    start(compositeContext, (Composite)implementation);
                } catch (Throwable e) {
                    try {
                        stop(compositeContext, (Composite) implementation);
                    } catch (Throwable e1) {
                        Monitor.error(monitor, this, "core-messages", "StopException", e1);
                    }
                    rethrow(e);
                }
            } else {
                for (PolicyProvider policyProvider : runtimeComponent.getPolicyProviders()) {
                    policyProvider.start();
                    providers.add(policyProvider);
                }
                ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
                if (implementationProvider != null) {
                    implementationProvider.start();
                    providers.add(implementationProvider);
                }
            }

            for (ComponentService service : component.getServices()) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
                }
                for (Endpoint endpoint : service.getEndpoints()) {
                    RuntimeEndpoint ep = (RuntimeEndpoint)endpoint;
                    startEndpoint(compositeContext, ep, providers);
                }
            }
           
            // Reference start is done after all components have been started to make sure everything
            // is up and running before we try and connect references to services
           
        } catch (Throwable e) {
            // any providers (binding, implementation, policy) that were started
            // before the error occured are stopped here
            for (int i = providers.size() - 1; i >= 0; i--) {
                try {
                    providers.get(i).stop();
                } catch (Throwable e1) {
                    Monitor.error(monitor, this, "core-messages", "StopException", e1);
                }
            }
            rethrow(e);
        } finally {
            providers.clear();
        }

        // mark a successful start
        runtimeComponent.setStarted(true);
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

            // spun up a new thread inside their component implementation
            return null;
        }
        // FIXME: [rfeng] Is this the service reference matching the caller side?
        RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo();
        RuntimeComponent component = (RuntimeComponent) to.getComponent();
       
        ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to);
       
        return callableReference;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

        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 {
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseService.class));
        } catch (InvalidInterfaceException e1) {
            // Nothing to do here - will not happen
        } // end try
        service.setInterfaceContract(interfaceContract);
        String serviceName = epr.getReference().getName() + "_asyncCallback";
        service.setName(serviceName);
        // MJE 06/12/2010 - fixup for JMS binding code which looks at the implementation service
        // as well as the component service...
        // Create a pseudo implementation service...
        Service implService = assemblyFactory.createService();
        implService.setName(serviceName);
        implService.setInterfaceContract(interfaceContract);
        service.setService(implService);
        //
        endpoint.setService(service);
        // Set pseudo-service onto the pseudo-component
        List<ComponentService> services = fakeComponent.getServices();
        services.clear();
        services.add(service);

        // Create a binding
        Binding binding = createMatchingBinding(epr.getBinding(), fakeComponent, service, registry);
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

    public void start(Component component) {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Starting component: " + component.getURI());
        }
        RuntimeComponent runtimeComponent = ((RuntimeComponent)component);
        if(runtimeComponent.isStarted()) {
          return;
        }
       
        configureComponentContext(runtimeComponent);

        for (ComponentReference reference : component.getReferences()) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Starting component reference: " + component.getURI() + "#" + reference.getName());
            }
            RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
            runtimeRef.setComponent(runtimeComponent);
           
            for (Endpoint endpoint : reference.getEndpoints()) {
                final EndpointResolver endpointResolver = runtimeRef.getEndpointResolver(endpoint);
                if (endpointResolver != null) {
                    // Allow endpoint resolvers to do any startup reference manipulation
                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
                        public Object run() {
                            endpointResolver.start();
                            return null;
                          }
                    });                      
                }
            }
           
            for (Binding binding : reference.getBindings()) {
                final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(binding);
                if (bindingProvider != null) {
                    // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
                        public Object run() {
                            bindingProvider.start();
                            return null;
                          }
                    });                      
                }
            }
        }

        for (ComponentService service : component.getServices()) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
            }
            RuntimeComponentService runtimeService = (RuntimeComponentService)service;
            for (Binding binding : service.getBindings()) {
                final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(binding);
                if (bindingProvider != null) {
                    // bindingProvider.start();
                    // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
                        public Object run() {
                            bindingProvider.start();
                            return null;
                          }
                    });                      
                }
            }
        }

        Implementation implementation = component.getImplementation();
        if (implementation instanceof Composite) {
            start((Composite)implementation);
        } else {
            ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
            if (implementationProvider != null) {
                implementationProvider.start();
            }
        }

        if (component instanceof ScopedRuntimeComponent) {
            ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component;
            if (scopedRuntimeComponent.getScopeContainer() != null) {
                scopedRuntimeComponent.getScopeContainer().start();
            }
        }

        runtimeComponent.setStarted(true);
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

    }

    private ScopeContainer<Object> getConversationalScopeContainer(RuntimeWire wire) {
        ScopeContainer<Object> scopeContainer = null;

        RuntimeComponent runtimeComponent = wire.getSource().getComponent();

        if (runtimeComponent instanceof ScopedRuntimeComponent) {
            ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)runtimeComponent;
            ScopeContainer<Object> tmpScopeContainer = scopedRuntimeComponent.getScopeContainer();
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

    public RuntimeComponent read(XMLStreamReader streamReader) throws IOException {
        try {
            StAXArtifactProcessor<Composite> processor = staxProcessors.getProcessor(Composite.class);
            Composite composite = processor.read(streamReader);
            RuntimeComponent component = (RuntimeComponent)composite.getComponents().get(0);
            return component;
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeComponent

        if (message != null) {
            EndpointReference to = message.getTo();
            if (to == null) {
                return null;
            }
            RuntimeComponent component = message.getTo().getComponent();
            return component;
        }
        return null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.