Examples of ScopeContext


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

    }

    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

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

    }

    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

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

    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

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

    }

    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

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

    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

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

    }


    public void removeContext(String name){
       configurations.remove(name);
       ScopeContext ctx = scopeIndex.remove(name);
        if (ctx != null){
            ctx.removeContext(name);
        }

    }
View Full Code Here

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

        ScopeStrategy strategy = new DefaultScopeStrategy();
        DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
        wireBuilder.addWireBuilder(javaWireBuilder);
        Module module = MockFactory.createModule();
        EventContext eCtx = new EventContextImpl();
        ScopeContext scopeContext = new ModuleScopeContext(eCtx);
        scopeContext.start();
        scopeContext.onEvent(new ModuleStart(this));
        List<Component> components = module.getComponents();
        Map<String, Component> compMap = new HashMap<String, Component>(components.size());

        for (Component component : components) {
            compMap.put(component.getName(), component);
            builder.build(component);
            ContextFactory contextFactory = (ContextFactory) component.getContextFactory();
            Assert.assertNotNull(contextFactory);
        }
        for (Component component : components) {
            ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
            Assert.assertNotNull(source);
            for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
                WireConfiguration pConfig = pFactory.getConfiguration();
                Component target = compMap.get(pConfig.getTargetName().getPartName());

                if (target != null) {
                    ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
                    boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
                    wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
                            .getPortName()), targetConfig.getClass(), downScope, scopeContext);
                }
                pFactory.initialize();
            }
            scopeContext.registerFactory(source);
        }
        for (Component component : components) {
            ContextFactory config = (ContextFactory) component.getContextFactory();
            Context context = config.createContext();
            if ("source".equals(component.getName())) {
View Full Code Here

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

        echoMethod = SimpleTarget.class.getDeclaredMethod("echo", String.class);
        Assert.assertNotNull(echoMethod);
    }

    public void testScopedInvoke() throws Exception {
        ScopeContext container = new MockScopeContext();
        ScopedJavaComponentInvoker invoker = new ScopedJavaComponentInvoker(new QualifiedName("foo"), echoMethod, container,false);
        Object ret = invoker.invokeTarget("foo");
        Assert.assertEquals("foo", ret);
    }
View Full Code Here

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

        TargetInvocationConfiguration barInvocation = new TargetInvocationConfiguration(m);
        barConfigs.put(m, barInvocation);
        targetFooFactory.setConfiguration(new WireTargetConfiguration(null, fooConfigs, null, null));
        TargetWireFactory targetBarFactory = new JDKTargetWireFactory();
        targetBarFactory.setConfiguration(new WireTargetConfiguration(null, barConfigs, null, null));
        ScopeContext ctx = new MockScopeContext();
        defaultBuilder.completeTargetChain(targetFooFactory, FooContextFactory.class, ctx);
        defaultBuilder.completeTargetChain(targetBarFactory, BarContextFactory.class, ctx);
        assertEquals(FooInvoker.class, targetFooFactory.getConfiguration().getInvocationConfigurations().get(m).getTargetInvoker().getClass());
        assertEquals(BarInvoker.class, targetBarFactory.getConfiguration().getInvocationConfigurations().get(m).getTargetInvoker().getClass());
View Full Code Here

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

    public RuntimeScopeStrategy() {
    }

    public Map<Scope, ScopeContext> getScopeContexts(EventContext eventContext) {
        ScopeContext aggregrateScope = new CompositeScopeContext(eventContext);
        Map<Scope, ScopeContext> scopes = new HashMap<Scope, ScopeContext>();
        scopes.put(Scope.AGGREGATE, aggregrateScope);
        return scopes;
    }
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.