All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.gwt.test.spring.GwtSpringHelper Maven / Gradle / Ivy

There is a newer version: 0.63
Show newest version
package com.googlecode.gwt.test.spring;

import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.springframework.context.ApplicationContext;

import java.util.Map;

/**
 * Helper for gwt-test-utils / Spring integration. For internal use only.
 *
 * @author Gael Lazzari
 */
class GwtSpringHelper {

    public static Object findRpcServiceInSpringContext(ApplicationContext applicationContext,
                                                       Class remoteServiceClass, String remoteServiceRelativePath) {

        Map beans = applicationContext.getBeansOfType(remoteServiceClass);

        switch (beans.size()) {

            case 0:
                return null;
            case 1:
                return beans.values().iterator().next();
            default:
                for (Object bean : beans.values()) {
                    RemoteServiceRelativePath annotation = bean.getClass().getAnnotation(
                            RemoteServiceRelativePath.class);

                    if (annotation != null && remoteServiceRelativePath.equals(annotation.value())) {
                        return bean;
                    }
                }

                return null;
        }
    }

    private GwtSpringHelper() {

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy