Package org.apache.tuscany.core.context

Examples of org.apache.tuscany.core.context.ScopeContext


    }

    public void registerJavaObject(String componentName, Class<?> service, Object instance) throws ConfigurationException {
        SystemObjectContextFactory configuration = new SystemObjectContextFactory(componentName, instance);
        registerConfiguration(configuration);
        ScopeContext scope = scopeContexts.get(configuration.getScope());
        registerAutowireInternal(service, componentName, scope);
    }
View Full Code Here


        cci.start();

        Map<String, Context> ics = new HashMap<String, Context>();
        ics.put(entryPointName, new MockEntryPointContext(instance));

        ScopeContext sc = new MockScopeContext(ics);
        sc.start();

        Map<String, ScopeContext> scopeIndex = cci.getScopeIndex();
        scopeIndex.put(entryPointName, sc);

        return cci;
View Full Code Here

    public SystemScopeStrategy() {
    }

    public Map<Scope, ScopeContext> getScopeContexts(EventContext eventContext) {
        ScopeContext aggregrateScope = new CompositeScopeContext(eventContext);
        ScopeContext moduleScoper = new ModuleScopeContext(eventContext);
        ScopeContext statelessScope = new StatelessScopeContext(eventContext);
        Map<Scope, ScopeContext> scopes = new HashMap<Scope, ScopeContext>();
        scopes.put(Scope.AGGREGATE, aggregrateScope);
        scopes.put(Scope.MODULE, moduleScoper);
        scopes.put(Scope.INSTANCE, statelessScope);
        return scopes;
View Full Code Here

                    registerAutowire(es);
                }
                for (Map.Entry<Scope, List<ContextFactory<Context>>> entries : configurationsByScope.entrySet())
                {
                    // register configurations with scope contexts
                    ScopeContext scope = scopeContexts.get(entries.getKey());
                    scope.registerFactories(entries.getValue());
                }
                initializeWireFactories();
                for (ScopeContext scope : scopeContexts.values()) {
                    // register scope contexts as a listeners for events in the composite context
                    addListener(scope);
                    scope.start();
                }
                lifecycleState = RUNNING;
            } catch (WireFactoryInitException e) {
                lifecycleState = ERROR;
                ContextInitException cie = new ContextInitException(e);
View Full Code Here

        if (lifecycleState == RUNNING) {
            if (scopeIndex.get(factory.getName()) != null) {
                throw new DuplicateNameException(factory.getName());
            }
            try {
                ScopeContext scope = scopeContexts.get(factory.getScope());
                if (scope == null) {
                    ConfigurationException e = new MissingScopeException("Component has an unknown scope");
                    e.addContextName(factory.getName());
                    e.addContextName(getName());
                    throw e;
                }
                scope.registerFactory(factory);
                scopeIndex.put(factory.getName(), scope);
            } catch (TuscanyRuntimeException e) {
                e.addContextName(getName());
                throw e;
            }
View Full Code Here

    }

    public Context getContext(String componentName) {
        checkInit();
        assert (componentName != null) : "Name was null";
        ScopeContext scope = scopeIndex.get(componentName);
        if (scope == null) {
            return null;
        }
        return scope.getContext(componentName);

    }
View Full Code Here

    }

    public Object getInstance(QualifiedName qName) throws TargetException {
        assert (qName != null) : "Name was null ";
        // use the port name to get the context since entry points ports
        ScopeContext scope = scopeIndex.get(qName.getPortName());
        if (scope == null) {
            return null;
        }
        Context ctx = scope.getContext(qName.getPortName());
        if (!(ctx instanceof EntryPointContext)) {
            TargetException e = new TargetException("Target not an entry point");
            e.setIdentifier(qName.getQualifiedName());
            e.addContextName(name);
            throw e;
View Full Code Here

    private void registerAutowire(ModuleComponent component) {
        for (EntryPoint ep : component.getImplementation().getEntryPoints()) {
            for (Binding binding : ep.getBindings()) {
                if (binding instanceof SystemBinding) {
                    Class interfaze = ep.getConfiguredService().getPort().getServiceContract().getInterface();
                    ScopeContext scope = scopeContexts.get(Scope.AGGREGATE);
                    String qname = component.getName() + QualifiedName.NAME_SEPARATOR + ep.getName();
                    registerAutowireInternal(interfaze, qname, scope);
                }
            }
        }
View Full Code Here

    }

    private void registerAutowire(Component component) {
        for (Service service : component.getImplementation().getComponentType().getServices()) {
            Class interfaze = service.getServiceContract().getInterface();
            ScopeContext scopeCtx = scopeContexts.get(service.getServiceContract().getScope());
            registerAutowireInternal(interfaze, component.getName(), scopeCtx);
        }
    }
View Full Code Here

    private void registerAutowire(EntryPoint ep) {
        for (Binding binding : ep.getBindings()) {
            if (binding instanceof SystemBinding) {
                Class interfaze = ep.getConfiguredService().getPort().getServiceContract().getInterface();
                ScopeContext scope = scopeContexts.get(((ContextFactory) ep.getContextFactory()).getScope());
                registerAutowireExternal(interfaze, ep.getName(), scope);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.ScopeContext

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.