Package org.jrest4guice.rest.annotations

Examples of org.jrest4guice.rest.annotations.Path


        binder.bind(Engine.class).toProvider(CTLEngineProvider.class);
        binder.bind(Context.class).toProvider(CTLContextProvider.class);

        // 注册所有的Restful服务对象
        ServiceHelper jRestContext = ServiceHelper.getInstance();
        Path annotation;
        String[] uris;
        String mimiType, name;
        String[] mimiTypes;
        Field[] fields;
        RemoteReference remoteServiceAnnotation;
        RESTful resourceAnnotation;
        Class<RemoteReference> remoteServiceClass = RemoteReference.class;
        Class type;
        for (Class clazz : classes) {
          if (clazz.isAnnotationPresent(RESTful.class)) {
            resourceAnnotation = (RESTful)clazz.getAnnotation(RESTful.class);
            if(resourceAnnotation.remoteable()){
              name = resourceAnnotation.name();
              if (name == null || name.trim().equals(""))
                name = clazz.getName();
 
              jRestContext.addRemoteService(name, clazz);
            }

          }

          // 绑定远程服务引用的Provider
          fields = clazz.getDeclaredFields();
          for (Field f : fields) {
            if (f.isAnnotationPresent(remoteServiceClass)) {
              remoteServiceAnnotation = f
                  .getAnnotation(remoteServiceClass);
              type = f.getType();
              binder.bind(type).annotatedWith(
                  remoteServiceClass).toProvider(
                  RemoteServiceProvider.create(type));
            }
          }

          if (clazz.isAnnotationPresent(Path.class)) {
            // 注册Rest服务
            annotation = (Path) clazz.getAnnotation(Path.class);
            uris = annotation.value();
            int index = 0;
            for (String uri : uris)
              jRestContext.addResource(uri, clazz, index++ == 0);
          }else if (clazz.isAnnotationPresent(RESTful.class)) {
            jRestContext.addResourceByClassMethodInfo(clazz);
View Full Code Here

TOP

Related Classes of org.jrest4guice.rest.annotations.Path

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.