Package org.apache.tuscany.core.builder

Examples of org.apache.tuscany.core.builder.BuilderConfigException


            externalService.setContextFactory(contextFactory);
        } else if (externalService.getConfiguredService().getPort().getServiceContract().getInterface() != null) {
            // autowire
            Class<Object> claz = externalService.getConfiguredService().getPort().getServiceContract().getInterface();
            if (claz == null) {
                BuilderException e = new BuilderConfigException("Interface type not specified");
                e.setIdentifier(externalService.getName());
                e.addContextName(externalService.getName());
                throw e;
            }
            SystemExternalServiceContextFactory config = new SystemExternalServiceContextFactory(externalService
                    .getName(), new AutowireObjectFactory<Object>(claz));
            externalService.setContextFactory(config);
View Full Code Here


        if (SystemCompositeContext.class.isAssignableFrom(declaringClass)
                && !(paramClass.equals(ConfigurationContext.class)
                        || paramClass.equals(MonitorFactory.class)
                        || paramClass.equals(RuntimeContext.class) || paramClass.equals(
                        AutowireContext.class))) {
            BuilderConfigException e = new BuilderConfigException("Illegal autowire type for system context");
            e.setIdentifier(paramClass.getName());
            throw e;
        }
    }
View Full Code Here

        for (Service service : services) {
            // calculate and validate the scope of the component; ensure that all service scopes are the same unless stateless
            Scope current = service.getServiceContract().getScope();
            if (previous != null && current != null && current != previous
                    && (current != Scope.INSTANCE && previous != Scope.INSTANCE)) {
                BuilderException e = new BuilderConfigException("Incompatible scopes specified for services on component");
                e.setIdentifier(component.getName());
                throw e;
            }
            if (scope != null && current != Scope.INSTANCE) {
                scope = current;
            }
        }
        ContextFactory contextFactory;
        try {
            contextFactory = createContextFactory(component.getName(), component.getImplementation(), scope);
            // create target-side wire invocation chains for each service offered by the implementation
            for (ConfiguredService configuredService : component.getConfiguredServices()) {
                Service service = configuredService.getPort();
                TargetWireFactory wireFactory = wireFactoryService.createTargetFactory(configuredService);
                contextFactory.addTargetWireFactory(service.getName(), wireFactory);
            }
            // handle properties
            List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
            if (configuredProperties != null) {
                for (ConfiguredProperty property : configuredProperties) {
                    contextFactory.addProperty(property.getName(), property.getValue());
                }
            }
            // handle references and source side reference chains
            List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
            if (configuredReferences != null) {
                for (ConfiguredReference reference : configuredReferences) {
                    if (reference.getPort().getMultiplicity() == Multiplicity.ZERO_N || reference.getPort().getMultiplicity() == Multiplicity.ZERO_ONE){
                        if (reference.getTargetConfiguredServices().size() < 1 && reference.getTargets().size() <1 ){
                            continue; // not required, not configured fix TUSCANY-299
                        }
                    }
                    List<SourceWireFactory> wireFactories = wireFactoryService.createSourceFactory(reference);
                    String refName = reference.getPort().getName();
                    Class refClass = reference.getPort().getServiceContract().getInterface();
                    boolean multiplicity = reference.getPort().getMultiplicity() == Multiplicity.ONE_N
                            || reference.getPort().getMultiplicity() == Multiplicity.ZERO_N;
                    contextFactory.addSourceWireFactories(refName, refClass, wireFactories, multiplicity);
                }
            }
            component.setContextFactory(contextFactory);
        } catch (BuilderException e) {
            e.addContextName(component.getName());
            throw e;
        }
    }
View Full Code Here

            for (SourceInvocationConfiguration sourceInvocationConfig : sourceFactory.getConfiguration()
                    .getInvocationConfigurations().values()) {
                // match wire chains
                TargetInvocationConfiguration targetInvocationConfig = targetInvocationConfigs.get(sourceInvocationConfig.getMethod());
                if (targetInvocationConfig == null){
                    BuilderConfigException e= new BuilderConfigException("Incompatible source and target interface types for reference");
                    //FIXME xcv
                    e.setIdentifier(sourceFactory.getConfiguration().getReferenceName());
                    throw e;
                }
                // if handler is configured, add that
                if (targetInvocationConfig.getRequestHandlers() != null) {
                    sourceInvocationConfig.setTargetRequestChannel(new MessageChannelImpl(targetInvocationConfig
                            .getRequestHandlers()));
                    sourceInvocationConfig.setTargetResponseChannel(new MessageChannelImpl(targetInvocationConfig
                            .getResponseHandlers()));
                } else {
                    // no handlers, just connect interceptors
                    if (targetInvocationConfig.getHeadInterceptor() == null) {
                        BuilderConfigException e = new BuilderConfigException("No target handler or interceptor for operation");
                        e.setIdentifier(targetInvocationConfig.getMethod().getName());
                        throw e;
                    }
                    //xcv if (!(sourceInvocationConfig.getLastTargetInterceptor() instanceof InvokerInterceptor && targetInvocationConfig
                    if (!(sourceInvocationConfig.getTailInterceptor() instanceof InvokerInterceptor && targetInvocationConfig
                            .getHeadInterceptor() instanceof InvokerInterceptor)) {
View Full Code Here

            AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
            serviceClient = new ServiceClient(configurationContext, axisService);

        } catch (AxisFault e) {
            BuilderConfigException bce = new BuilderConfigException("AxisFault creating external service", e);
            bce.addContextName(externalServiceName);
            throw bce;
        }

        return serviceClient;
    }
View Full Code Here

    private void initServlet(EntryPointContext epc) {
        AxisService axisService;
        try {
            axisService = createAxisService(epc, wsBinding);
        } catch (AxisFault e) {
            throw new BuilderConfigException(e);
        }
        WebServiceEntryPointServlet servlet = new WebServiceEntryPointServlet(axisService);
        ServletConfig sc = createDummyServletConfig();
        try {
            servlet.init(sc );
        } catch (ServletException e) {
            throw new BuilderConfigException(e);
        }

        String servletMapping = wsBinding.getWebAppName() + "/services/" + epc.getName();
        tomcatHost.registerMapping(servletMapping, servlet);
    }
View Full Code Here

            sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
            if (m.getName().equals(sb.toString())) {
                return m;
            }
        }
        throw new BuilderConfigException("no operation named " + operationName + " found on service interface: " + serviceInterface.getName());
    }
View Full Code Here

                    throw e;
                }
                registerConfiguration(configuration);
                registerAutowire(service);
            } else {
                BuilderConfigException e = new BuilderConfigException("Unknown model type");
                e.setIdentifier(model.getClass().getName());
                e.addContextName(getName());
                throw e;
            }
        }
    }
View Full Code Here

            sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
            if (m.getName().equals(sb.toString())) {
                return m;
            }
        }
        throw new BuilderConfigException("no operation named " + operationName
                                         + " found on service interface: " + serviceInterface.getName());
    }
View Full Code Here

            // The component is a system component, implemented by a Java class
            SystemImplementation implementation = (SystemImplementation) componentImplementation;
            if (componentImplementation.getComponentType().getServices() == null
                    || componentImplementation.getComponentType().getServices().size() < 1) {
                BuilderConfigException e = new BuilderConfigException("No service configured on component type");
                e.setIdentifier(component.getName());
                throw e;
            }
            implClass = implementation.getImplementationClass();
            Scope previous = null;
            scope = Scope.MODULE;
            List<Service> services = component.getImplementation().getComponentType().getServices();
            for (Service service : services) {
                // calculate and validate the scope of the component; ensure that all service scopes are the same unless
                // a scope is stateless
                Scope current = service.getServiceContract().getScope();
                if (previous != null && current != null && current != previous
                        && (current != Scope.INSTANCE && previous != Scope.INSTANCE)) {
                    BuilderException e = new BuilderConfigException("Incompatible scopes specified for services on component");
                    e.setIdentifier(component.getName());
                    throw e;
                }
                if (current != null && current != Scope.MODULE) {
                    scope = current;
                }
            }

        } else if (componentImplementation instanceof Composite) {
            implClass = ((Composite) componentImplementation).getImplementationClass();
            if (implClass == null) {
                // FIXME this is a hack
                if (((Module) componentImplementation).getName().startsWith("org.apache.tuscany.core.system"))
                {
                    // The component is a system module component, fix the implementation class to our implementation
                    // of system module component context
                    implClass = SystemCompositeContextImpl.class;
                } else if (componentImplementation instanceof SystemModule) {
                    implClass = SystemCompositeContextImpl.class;
                } else {
                    // The component is an app module component, fix the implementation class to our implementation
                    // of app module component context
                    //FIXME this should be extensible, i.e. the model should specify the impl class of the module
                    implClass = CompositeContextImpl.class;
                }
                //END hack
            }
            scope = Scope.AGGREGATE;
        } else {
            return;
        }
        Set<Field> fields;
        Set<Method> methods;
        SystemContextFactory contextFactory;
        try {
            fields = JavaIntrospectionHelper.getAllFields(implClass);
            methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
            String name = component.getName();
            if (componentImplementation instanceof Module) {
                Module module = (Module) componentImplementation;
                contextFactory = new SystemContextFactory(name, module, JavaIntrospectionHelper.getDefaultConstructor(implClass), scope);

            } else {
                contextFactory = new SystemContextFactory(name, JavaIntrospectionHelper.getDefaultConstructor(implClass), scope);
            }

            //ContextObjectFactory contextObjectFactory = new ContextObjectFactory(contextFactory);

            List<Injector> injectors = new ArrayList<Injector>();

            // handle properties
            List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
            if (configuredProperties != null) {
                for (ConfiguredProperty property : configuredProperties) {
                    Injector injector = createPropertyInjector(property, fields, methods);
                    injectors.add(injector);
                }
            }

            // FIXME do not inject references on an application module yet
            if (implClass != CompositeContextImpl.class) {
                // handle references
                List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
                if (configuredReferences != null) {
                    for (ConfiguredReference reference : configuredReferences) {
                        Injector injector = createReferenceInjector(reference, fields, methods, contextFactory);
                        injectors.add(injector);
                    }
                }
            }
            List<Object> elements = componentImplementation.getComponentType().getExtensibilityElements();
            for (Object element : elements) {
                if (element instanceof InitInvokerExtensibilityElement) {
                    InitInvokerExtensibilityElement invokerElement = (InitInvokerExtensibilityElement) element;
                    EventInvoker<Object> initInvoker = invokerElement.getEventInvoker();
                    boolean eagerInit = invokerElement.isEager();
                    contextFactory.setEagerInit(eagerInit);
                    contextFactory.setInitInvoker(initInvoker);
                } else if (element instanceof DestroyInvokerExtensibilityElement) {
                    DestroyInvokerExtensibilityElement invokerElement = (DestroyInvokerExtensibilityElement) element;
                    EventInvoker<Object> destroyInvoker = invokerElement.getEventInvoker();
                    contextFactory.setDestroyInvoker(destroyInvoker);
                } else if (element instanceof ComponentNameExtensibilityElement) {
                    ComponentNameExtensibilityElement nameElement = (ComponentNameExtensibilityElement) element;
                    injectors.add(nameElement.getEventInvoker(name));
                } else if (element instanceof ContextExtensibilityElement) {
                    ContextExtensibilityElement contextElement = (ContextExtensibilityElement) element;
                    injectors.add(contextElement.getInjector(contextFactory));
                } else if (element instanceof InjectorExtensibilityElement) {
                    InjectorExtensibilityElement injectorElement = (InjectorExtensibilityElement) element;
                    injectors.add(injectorElement.getInjector(contextFactory));
                } else if (element instanceof SystemInjectorExtensibilityElement) {
                    SystemInjectorExtensibilityElement injectorElement = (SystemInjectorExtensibilityElement) element;
                    injectors.add(injectorElement.getInjector(contextFactory));
                } else if (element instanceof MonitorExtensibilityElement) {
                    MonitorExtensibilityElement monitorElement = (MonitorExtensibilityElement) element;
                    injectors.add(monitorElement.getInjector(monitorFactory));
                }
            }
            contextFactory.setSetters(injectors);
            // decorate the logical model
            component.setContextFactory(contextFactory);
        } catch (BuilderConfigException e) {
            e.addContextName(component.getName());
            throw e;
        } catch (NoSuchMethodException e) {
            BuilderConfigException ce = new BuilderConfigException("Class does not have a no-arg constructor", e);
            ce.setIdentifier(implClass.getName());
            throw ce;
        } catch (FactoryInitException e) {
            BuilderConfigException ce = new BuilderConfigException("Error building component", e);
            ce.addContextName(component.getName());
            throw ce;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.builder.BuilderConfigException

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.