Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.Service


                // First process nested composites
                configureNestedCompositeServices((Composite)implementation);

                // Process the component services declared on components in this composite
                for (ComponentService componentService : component.getServices()) {
                    Service implService = componentService.getService();
                    if (implService != null && implService instanceof CompositeService) {
                        CompositeService compositeService = (CompositeService)implService;

                        // Get the innermost promoted service
                        ComponentService promotedService =
View Full Code Here


              modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
    }
   
    public ComponentType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        ComponentType componentType = null;
        Service service = null;
        Reference reference = null;
        Contract contract = null;
        Property property = null;
        Callback callback = null;
        QName name = null;
       
        // Read the componentType document
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();

                    if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {

                        // Read a <componentType>
                        componentType = assemblyFactory.createComponentType();
                        componentType.setConstrainingType(readConstrainingType(reader));

                    } else if (Constants.SERVICE_QNAME.equals(name)) {

                        // Read a <service>
                        service = assemblyFactory.createService();
                        contract = service;
                        service.setName(getString(reader, Constants.NAME));
                        componentType.getServices().add(service);
                        policyProcessor.readPolicies(service, reader);

                    } else if (Constants.REFERENCE_QNAME.equals(name)) {
View Full Code Here

        if (annotation == null) {
            // scan interfaces for remotable
            Set<Class> interfaces = getAllInterfaces(clazz);
            for (Class<?> interfaze : interfaces) {
                if (interfaze.isAnnotationPresent(Remotable.class) || interfaze.isAnnotationPresent(Callback.class)) {
                    Service service;
                    try {
                        service = createService(interfaze);
                    } catch (InvalidInterfaceException e) {
                        throw new IntrospectionException(e);
                    }
                    type.getServices().add(service);
                }
            }
            return;
        }
        Class<?>[] interfaces = annotation.interfaces();
        if (interfaces.length == 0) {
            Class<?> interfaze = annotation.value();
            if (Void.class.equals(interfaze)) {
                //throw new IllegalServiceDefinitionException("No interfaces specified");
                logger.warning("Ignoring @Service annotation.  No interfaces specified. class = "+clazz.getName());
            } else {
                interfaces = new Class<?>[1];
                interfaces[0] = interfaze;
            }
        }
        for (Class<?> interfaze : interfaces) {
            try {
                Service service = createService(interfaze);
                type.getServices().add(service);
            } catch (InvalidInterfaceException e) {
                throw new IntrospectionException(e);
            }
        }
View Full Code Here

     * @param element
     * @throws IllegalCallbackReferenceException
     */
    private void createCallback(JavaImplementation type, JavaElementImpl element)
        throws IllegalCallbackReferenceException {
        Service callbackService = null;
        Class<?> callbackClass = element.getType();
        Type genericType = element.getGenericType();
        Class<?> baseType = callbackClass;
        if(CallableReference.class.isAssignableFrom(baseType)) {
            // @Callback protected CallableReference<MyCallback> callback;
View Full Code Here

        }
        type.getCallbackMembers().get(baseType.getName()).add(element);
    }

    public Service createService(Class<?> interfaze) throws InvalidInterfaceException {
        Service service = assemblyFactory.createService();
        JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
        service.setInterfaceContract(interfaceContract);

        // create a relative URI
        service.setName(interfaze.getSimpleName());

        JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
        service.getInterfaceContract().setInterface(callInterface);
        if (callInterface.getCallbackClass() != null) {
            JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
            service.getInterfaceContract().setCallbackInterface(callbackInterface);
        }
        return service;
    }
View Full Code Here

     * @return
     */
    private ComponentService getPromotedComponentService(CompositeService compositeService) {
        ComponentService componentService = compositeService.getPromotedService();
        if (componentService != null) {
            Service service = componentService.getService();
            if (componentService.getName() != null && service instanceof CompositeService) {

                // Continue to follow the service promotion chain
                return getPromotedComponentService((CompositeService)service);

View Full Code Here

     * @return
     */
    private Component getPromotedComponent(CompositeService compositeService) {
        ComponentService componentService = compositeService.getPromotedService();
        if (componentService != null) {
            Service service = componentService.getService();
            if (componentService.getName() != null && service instanceof CompositeService) {

                // Continue to follow the service promotion chain
                return getPromotedComponent((CompositeService)service);

View Full Code Here

    public List<Service> getServices() {
        return services;
    }
   
    public Service getService(String name){
        Service service = null;
       
        for (Service tmp : getServices()){
            if (tmp.getName().equals(name)){
                service = tmp;
                break;
View Full Code Here

           
        } else {
           
            // We have no component type description, simply introspect the POJO and
            // create a single Service for it
            Service service = assemblyFactory.createService();
            service.setName(pojoClass.getSimpleName());
            JavaInterface javaInterface;
            try {
                javaInterface = javaFactory.createJavaInterface(pojoClass);
            } catch (InvalidInterfaceException e) {
                throw new ContributionResolveException(e);
            }
            JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
            interfaceContract.setInterface(javaInterface);
            service.setInterfaceContract(interfaceContract);
            implementation.getServices().add(service);
        }
       
        // Mark the implementation resolved now
        implementation.setUnresolved(false);
View Full Code Here

            String uri = namespaceResolver.getURIForPrefix(prefix, false);
            if (uri.startsWith(SCA_SERVICE_PREFIX)) {
                String serviceName = prefix;
                String className = uri.substring(SCA_SERVICE_PREFIX.length());
                Class<?> interfaze = resolveClass(resolver, className);
                Service theService = createService(interfaze, serviceName);
                xqueryImplementation.getServices().add(theService);
            } else if (uri.startsWith(SCA_REFERENCE_PREFIX)) {
                String referenceName = prefix;
                String className = uri.substring(SCA_REFERENCE_PREFIX.length());
                Class<?> interfaze = resolveClass(resolver, className);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.Service

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.