Package org.apache.tuscany.core.context

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


            CompositeContext ctx = resolver.getCurrentContext();
            do {
                if (ctx == null) {
                    break; // reached top of context hierarchy
                }
                Context compContext = ctx.getContext(targetQualifiedName.getPartName());
                if (compContext != null) {
                    o = compContext.getInstance(targetQualifiedName);
                    if (o != null) {
                        return (T) o;
                    }
                }
                ctx = ctx.getParent();
View Full Code Here


        this.container = cont;
    }

    public Object invokeTarget(Object payload) throws InvocationTargetException {
        if (context == null) {
            Context iContext = container.getContext(esName);
            if (!(iContext instanceof ExternalServiceContext)) {
                TargetException te = new TargetException("Unexpected target context type");
                te.setIdentifier(iContext.getClass().getName());
                te.addContextName(iContext.getName());
                throw te;
            }
            context = (ExternalServiceContext)iContext;
        }
        ExternalWebServiceClient client = (ExternalWebServiceClient)context.getHandler();
View Full Code Here

    }

    public Object getInstance(QualifiedName qName) throws TargetException {
        try {
            if (cachedInstance == null) {
                Context ctx = resolver.getCurrentContext().getContext(targetName.getPartName());
                if (ctx == null){
                    return null;
                }
                cachedInstance = ctx.getInstance(targetName);
            }
            return cachedInstance;
        } catch (TargetException e) {
            e.addContextName(getName());
            throw e;
View Full Code Here

            }
            scopeContext.registerFactory(source);
        }
        for (Component component : components) {
            ContextFactory config = (ContextFactory) component.getContextFactory();
            Context context = config.createContext();
            if ("source".equals(component.getName())) {
                ModuleScopeComponent source = (ModuleScopeComponent) context.getInstance(null);
                Assert.assertNotNull(source);
                GenericComponent gComp = source.getGenericComponent();
                gComp.getString();
            }
        }
View Full Code Here

        this.container = container;
    }

    public Object invokeTarget(Object payload) throws InvocationTargetException {
        if (context == null) {
            Context iContext = container.getContext(esName);
            if (!(iContext instanceof AtomicContext)) {
                TargetException te = new TargetException("Unexpected target context type");
                te.setIdentifier(iContext.getClass().getName());
                te.addContextName(iContext.getName());
                throw te;
            }
            context = (AtomicContext) iContext;
        }
View Full Code Here

        this.container = container;
    }

    public Object invokeTarget(Object payload) throws InvocationTargetException {
        if (context == null) {
            Context iContext = container.getContext(esName);
            if (!(iContext instanceof ExternalServiceContext)) {
                TargetException te = new TargetException("Unexpected target context type");
                te.setIdentifier(iContext.getClass().getName());
                te.addContextName(iContext.getName());
                throw te;
            }
            context = (ExternalServiceContext) iContext;
        }
View Full Code Here

    public void testMonitorInjection() {
        builder.build(component);
        ContextFactory<?> contextFactory = (ContextFactory<?>) component.getContextFactory();
        Assert.assertNotNull(contextFactory);
        contextFactory.prepare(createContext());
        Context ctx = contextFactory.createContext();

        ctx.start();
        TestComponent instance = (TestComponent) ctx.getInstance(null);
        assertSame(MONITOR1, instance.monitor1);
        assertSame(MONITOR2, instance.monitor2);
    }
View Full Code Here

        } else if (event instanceof ModuleStop) {
            shutdownContexts();
        } else if (event instanceof InstanceCreated) {
            checkInit();
            if (event.getSource() instanceof Context) {
                Context context = (Context) event.getSource();
                // Queue the context to have its implementation instance released if destroyable
                destroyQueue.add(context);
            }
        }
    }
View Full Code Here

    public void removeContext(String ctxName) {
        checkInit();
        if (contexts == null){
            return;
        }
        Context context = contexts.remove(ctxName);
        if (context != null) {
            destroyQueue.remove(context);
        }
    }
View Full Code Here

    private synchronized void initComponentContexts() throws CoreRuntimeException {
        if (contexts == null) {
            contexts = new ConcurrentHashMap<String, Context>();
            destroyQueue = new ArrayList<Context>();
            for (ContextFactory<Context> config : contextFactories.values()) {
                Context context = config.createContext();
                context.start();
                contexts.put(context.getName(), context);
            }
            // Initialize eager contexts. Note this cannot be done when we initially create each context since a component may
            // contain a forward reference to a component which has not been instantiated
            for (Context context : contexts.values()) {
                if (context instanceof AtomicContext) {
                    AtomicContext atomic = (AtomicContext) context;
                    if (atomic.isEagerInit()) {
                        // perform silent creation and manual shutdown registration
                        atomic.init();
                        destroyQueue.add(context);
                    }
                }
                context.addListener(this);
            }
        }
    }
View Full Code Here

TOP

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

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.