Examples of EntryPoint


Examples of org.apache.tuscany.model.assembly.EntryPoint

        app1Component.getImplementation().getComponents().add(app1bComponent);

        Component target = MockFactory.createSystemComponent("target", Target.class, TargetImpl.class, Scope.MODULE);
        app1bComponent.getImplementation().getComponents().add(target);

        EntryPoint ep = MockFactory.createEPSystemBinding("target.ep", Target.class, "target", target);
        ep.getBindings().add(systemFactory.createSystemBinding());
        Service service = systemFactory.createService();
        service.setName("target.ep");
        ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
        app1bComponent.getImplementation().getEntryPoints().add(ep);

        CompositeContext root = runtime.getRootContext();
        root.registerModelObject(app1Component);
        return runtime;
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

        ModuleComponent system1aComponent = MockFactory.createSystemCompositeComponent("system1a");
        system1Component.getImplementation().getComponents().add(system1aComponent);

        Component target = MockFactory.createSystemComponent("target", Target.class, TargetImpl.class, Scope.MODULE);
        system2Component.getImplementation().getComponents().add(target);
        EntryPoint ep = MockFactory.createEPSystemBinding("target.ep", Target.class, "target", target);
        system2Component.getImplementation().getEntryPoints().add(ep);
        system.registerModelObject(system2Component);

        Component source = MockFactory.createSystemComponent("source", Source.class, AutowireSourceImpl.class, Scope.MODULE);
        system1aComponent.getImplementation().getComponents().add(source);
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

    public void testRegistration() throws Exception {
        CompositeContext moduleContext = createContext();
        Component component = factory.createSystemComponent("TestService1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        moduleContext.registerModelObject(component);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1", component);
        moduleContext.registerModelObject(ep);
        moduleContext.start();
        moduleContext.publish(new ModuleStart(this));
        GenericSystemComponent test = (GenericSystemComponent) moduleContext.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(test);
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

    public void testRegistrationAfterStart() throws Exception {
        CompositeContext moduleContext = createContext();
        Component component = factory.createSystemComponent("TestService1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        moduleContext.start();
        moduleContext.registerModelObject(component);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1", component);
        moduleContext.registerModelObject(ep);
        moduleContext.publish(new ModuleStart(this));
        GenericSystemComponent test = (GenericSystemComponent) moduleContext.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(test);
        GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.getContext("TestService1EP").getInstance(null);
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

        moduleContext.start();
        moduleContext.registerModelObject(component);
        moduleContext.publish(new ModuleStart(this));
        GenericSystemComponent test = (GenericSystemComponent) moduleContext.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(test);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1", component);
        moduleContext.registerModelObject(ep);
        GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.getContext("TestService1EP").getInstance(null);
        Assert.assertNotNull(testEP);
        moduleContext.publish(new ModuleStop(this));
        moduleContext.stop();
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

    public void testParentContextIsolation() throws Exception {
        CompositeContext parent = createContextHierachy();
        CompositeContext child = (CompositeContext) parent.getContext("test.child");
        Component component = factory.createSystemComponent("TestService1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        parent.registerModelObject(component);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1", component);
        parent.registerModelObject(ep);
        parent.publish(new ModuleStart(this));
        child.publish(new ModuleStart(this));
        Assert.assertNotNull(parent.getContext("TestService1EP").getInstance(null));
        try {
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

        }

        // now expose the service as an entry point
        // FIXME hack to get around initialization of component - just create another one ;-)
        component = factory.createSystemComponent("TestService1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
                component);
        child.registerModelObject(ep);
        Assert.assertNotNull(child.getContext("TestService1EP").getInstance(null));
        Assert.assertNotNull(parent.getContext("test.child").getInstance(new QualifiedName("./TestService1EP")));

        // now expose the child entry point from the parent context
        EntryPoint parentEp = MockFactory.createEntryPointWithStringRef("TestService1EP", ModuleScopeSystemComponent.class,
                "TestService1", "test.child/TestService1EP");
        parent.registerModelObject(parentEp);
        Assert.assertNotNull(parent.getContext("TestService1EP").getInstance(null));

        parent.publish(new ModuleStop(this));
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

    public void build(AssemblyObject modelObject) throws BuilderException {
        if (!(modelObject instanceof EntryPoint)) {
            return;
        }
        EntryPoint entryPoint = (EntryPoint) modelObject;
        if (!(entryPoint.getBindings().get(0) instanceof SystemBinding)
                || entryPoint.getContextFactory() != null) {
            return;
        }
        try {
            String targetName;
            ConfiguredService targetService = entryPoint.getConfiguredReference().getTargetConfiguredServices().get(0);
            Class serviceInterface = entryPoint.getConfiguredReference().getPort().getServiceContract().getInterface();
            if (targetService.getPart() == null) {
                // FIXME not correct
                if (targetService.getPort() == null) {
                    BuilderInitException e = new BuilderInitException("No target service specified on ");
                    e.setIdentifier(entryPoint.getName());
                }
                targetName = targetService.getPort().getName();
            } else {
                targetName = targetService.getPart().getName();
            }
            SystemEntryPointContextFactory contextFactory = new SystemEntryPointContextFactory(entryPoint.getName(),
                    targetName, serviceInterface);
            entryPoint.setContextFactory(contextFactory);
        } catch (FactoryInitException e) {
            e.addContextName(entryPoint.getName());
            throw e;
        }
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

     */
    public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName, Part target) {
        JavaServiceContract contract = systemFactory.createJavaServiceContract();
        contract.setInterface(interfaz);

        EntryPoint ep = systemFactory.createEntryPoint();
        ep.setName(name);

        Reference ref = systemFactory.createReference();
        ref.setName(refName);
        ref.setServiceContract(contract);
        ConfiguredReference configuredReference = systemFactory.createConfiguredReference();
        configuredReference.setPort(ref);
        Service service = systemFactory.createService();
        service.setServiceContract(contract);

        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cService.initialize(assemblyContext);

        configuredReference.getTargetConfiguredServices().add(cService);
        ep.setConfiguredReference(configuredReference);

        Service epService = systemFactory.createService();
        epService.setServiceContract(contract);

        ConfiguredService epCService = systemFactory.createConfiguredService();
        epCService.initialize(assemblyContext);
        epCService.setPort(epService);

        ep.setConfiguredService(epCService);
        SystemBinding binding = systemFactory.createSystemBinding();
        ep.getBindings().add(binding);
        if (target != null) {
            if (target instanceof Component) {
                ((Component) target).getConfiguredServices().add(cService);
                // cService.
            } else if (target instanceof ExternalService) {
                ((ExternalService) target).setConfiguredService(cService);
            }
            target.initialize(assemblyContext);
        }
        ep.initialize(null);
        return ep;
    }
View Full Code Here

Examples of org.apache.tuscany.model.assembly.EntryPoint

     * @param interfaz      the inteface exposed by the entry point
     * @param refName       the name of the entry point reference
     * @param componentName the name of the target to resolve
     */
    public static EntryPoint createEntryPointWithStringRef(String name, Class interfaz, String refName, String componentName) {
        EntryPoint ep = createEPSystemBinding(name, interfaz, refName, null);
        ConfiguredReference cRef = systemFactory.createConfiguredReference();
        Reference ref = systemFactory.createReference();
        cRef.setPort(ref);
        Service service = systemFactory.createService();
        service.setName(componentName);
        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cRef.getTargetConfiguredServices().add(cService);
        cRef.initialize(assemblyContext);
        cService.initialize(assemblyContext);
        JavaServiceContract contract = systemFactory.createJavaServiceContract();
        contract.setInterface(interfaz);
        ref.setServiceContract(contract);
        ep.setConfiguredReference(cRef);
        ep.initialize(assemblyContext);
        return ep;
    }
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.