/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/RestManager.java
ViewVC logotype

Annotation of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/RestManager.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2890 - (hide annotations) (download)
Sun Jan 31 21:56:30 2016 UTC (8 years, 4 months ago) by torben
File size: 2323 byte(s)
Rest interface to afstandandenrute subsystem
1 torben 2890 package dk.daoas.adressevedligehold;
2    
3     import java.beans.ExceptionListener;
4     import java.util.Collections;
5     import java.util.HashMap;
6     import java.util.Map;
7     import java.util.Set;
8    
9     import javax.ws.rs.ApplicationPath;
10     import javax.ws.rs.core.Application;
11    
12    
13     @ApplicationPath("rest")
14     public class RestManager extends Application {
15    
16     @Override
17     public Set<Class<?>> getClasses() {
18    
19     Set<Class<?>> resources = new java.util.HashSet<>();
20    
21     System.out.println("REST configuration starting: getClasses()");
22    
23     //features
24     //this will register MOXy JSON providers
25     resources.add(org.glassfish.jersey.moxy.json.MoxyJsonFeature.class);
26     //we could also use this
27     //resources.add(org.glassfish.jersey.moxy.xml.MoxyXmlFeature.class);
28    
29     //instead let's do it manually:
30     //resources.add(JsonMoxyConfigurationContextResolver.class);
31    
32     //resources.add(ExceptionListener.class);
33    
34    
35     resources.add(RestCommands.class);
36     //==> we could also choose packages, see below getProperties()
37    
38     System.out.println("REST configuration ended successfully.");
39    
40     return resources;
41     }
42    
43     @Override
44     public Set<Object> getSingletons() {
45     return Collections.emptySet();
46     }
47    
48     @Override
49     public Map<String, Object> getProperties() {
50     System.out.println("Application->properties");
51     Map<String, Object> properties = new HashMap<>();
52    
53     //in Jersey WADL generation is enabled by default, but we don't
54     //want to expose too much information about our apis.
55     //therefore we want to disable wadl (http://localhost:8080/service/application.wadl should return http 404)
56     //see https://jersey.java.net/nonav/documentation/latest/user-guide.html#d0e9020 for details
57     properties.put("jersey.config.server.wadl.disableWadl", true);
58    
59     //we could also use something like this instead of adding each of our resources
60     //explicitely in getClasses():
61     //properties.put("jersey.config.server.provider.packages", "com.nabisoft.tutorials.mavenstruts.service");
62    
63    
64     return properties;
65     }
66     }

  ViewVC Help
Powered by ViewVC 1.1.20