|
22 | 22 | import javax.ws.rs.GET;
|
23 | 23 | import javax.ws.rs.Path;
|
24 | 24 | import javax.ws.rs.Produces;
|
| 25 | +import javax.ws.rs.core.Application; |
25 | 26 | import javax.ws.rs.core.MultivaluedMap;
|
26 | 27 | import javax.ws.rs.core.SecurityContext;
|
27 | 28 |
|
@@ -56,23 +57,41 @@ public void boot(Map<String, String> properties, ClassLoader loader) {
|
56 | 57 | if (appPath == null) {
|
57 | 58 | appPath = "";
|
58 | 59 | }
|
59 |
| - String res = properties.get("jersey.app.resources"); |
60 |
| - List<Class> clzList = new ArrayList<Class>(); |
61 |
| - if (res != null) { |
62 |
| - for (String clz : res.split(",") ) { |
63 |
| - try { |
64 |
| - clzList.add(loader.loadClass(clz.trim())); |
65 |
| - } catch (Throwable e) { |
66 |
| - NginxClojureRT.log.warn("can not load resource %s, skiping", clz, e); |
| 60 | + |
| 61 | + String application = properties.get("jersey.app.Appclass"); |
| 62 | + if (application != null) { |
| 63 | + Class appClz = null; |
| 64 | + try { |
| 65 | + appClz = loader.loadClass(application.trim()); |
| 66 | + } catch (ClassNotFoundException e) { |
| 67 | + NginxClojureRT.log.warn("can not load jersey.app.Appclass %s", application, e); |
| 68 | + throw new RuntimeException("can not load jersey.app.Appclass " + e.getMessage(), e); |
| 69 | + } |
| 70 | + try { |
| 71 | + appHandler = new ApplicationHandler((Class<? extends Application>) appClz.newInstance()); |
| 72 | + } catch (Exception e) { |
| 73 | + throw new RuntimeException("can not create jersey.app.Appclass" + e.getMessage(), e); |
| 74 | + } |
| 75 | + }else { |
| 76 | + String res = properties.get("jersey.app.resources"); |
| 77 | + List<Class> clzList = new ArrayList<Class>(); |
| 78 | + if (res != null) { |
| 79 | + for (String clz : res.split(",") ) { |
| 80 | + try { |
| 81 | + clzList.add(loader.loadClass(clz.trim())); |
| 82 | + } catch (Throwable e) { |
| 83 | + NginxClojureRT.log.warn("can not load resource %s, skiping", clz, e); |
| 84 | + } |
67 | 85 | }
|
| 86 | + appResources = clzList.toArray(new Class[clzList.size()]); |
| 87 | + } |
| 88 | + |
| 89 | + if (appResources == null || appResources.length == 0){ |
| 90 | + NginxClojureRT.log.warn("no resource defined, property %s is null", "jersey.app.resources"); |
68 | 91 | }
|
69 |
| - appResources = clzList.toArray(new Class[clzList.size()]); |
| 92 | + appHandler = new ApplicationHandler(configure()); |
70 | 93 | }
|
71 | 94 |
|
72 |
| - if (appResources == null || appResources.length == 0){ |
73 |
| - NginxClojureRT.log.warn("no resource defined, property %s is null", "jersey.app.resources"); |
74 |
| - } |
75 |
| - appHandler = new ApplicationHandler(configure()); |
76 | 95 | }
|
77 | 96 |
|
78 | 97 | @Override
|
|
0 commit comments