Skip to content

Commit 80a3a99

Browse files
committed
Replace server's JAX-RS application (don't touch other <servlet-name>s)
New `Dispatcher::getProxyClass` method
1 parent c8bb105 commit 80a3a99

File tree

3 files changed

+49
-39
lines changed

3 files changed

+49
-39
lines changed

platform/web.xsl

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ xmlns:jee="https://jakarta.ee/xml/ns/jakartaee"
88

99
<xsl:param name="jee:servlet-name"/>
1010

11-
<xsl:template match="jee:servlet-name/text()">
11+
<!-- replace server's JAX-RS application (don't touch other <servlet-name>s) -->
12+
<xsl:template match="jee:servlet-name/text()[. = 'com.atomgraph.linkeddatahub.Application']">
1213
<xsl:choose>
1314
<xsl:when test="$jee:servlet-name">
1415
<xsl:value-of select="$jee:servlet-name"/>

src/main/java/com/atomgraph/linkeddatahub/server/model/impl/Dispatcher.java

+46-38
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,39 @@ public Dispatcher(@Context UriInfo uriInfo, Optional<Dataset> dataset, com.atomg
6666
}
6767

6868
/**
69-
* Returns JAX-RS resource that will handle this request.
69+
* Returns proxy class that takes precedence over the default JAX-RS path matching.
7070
* The request is proxied in two cases:
7171
* <ul>
7272
* <li>externally (URI specified by the <code>?uri</code> query param)</li>
7373
* <li>internally if it matches a <code>lapp:Dataset</code> specified in the system app config</li>
7474
* </ul>
75-
* Otherwise, fall back to SPARQL Graph Store backed by the app's service.
76-
*
77-
* @return resource
75+
* @return optional class
7876
*/
79-
@Path("{path: .*}")
80-
public Object getSubResource()
77+
public Optional<Class> getProxyClass()
8178
{
8279
if (getUriInfo().getQueryParameters().containsKey(AC.uri.getLocalName()))
8380
{
8481
if (log.isDebugEnabled()) log.debug("No Application matched request URI <{}>, dispatching to ProxyResourceBase", getUriInfo().getQueryParameters().getFirst(AC.uri.getLocalName()));
85-
return ProxyResourceBase.class;
82+
return Optional.of(ProxyResourceBase.class);
8683
}
8784
if (getDataset().isPresent())
8885
{
8986
if (log.isDebugEnabled()) log.debug("Serving request URI <{}> from Dataset <{}>, dispatching to ProxyResourceBase", getUriInfo().getAbsolutePath(), getDataset().get());
90-
return ProxyResourceBase.class;
87+
return Optional.of(ProxyResourceBase.class);
9188
}
92-
93-
return getResourceClass();
89+
90+
return Optional.empty();
91+
}
92+
93+
/**
94+
* Returns JAX-RS resource that will handle this request.
95+
*
96+
* @return resource
97+
*/
98+
@Path("{path: .*}")
99+
public Class getSubResource()
100+
{
101+
return getProxyClass().orElse(getResourceClass());
94102
}
95103

96104
// TO-DO: move @Path annotations onto respective classes?
@@ -101,9 +109,9 @@ public Object getSubResource()
101109
* @return endpoint resource
102110
*/
103111
@Path("sparql")
104-
public Object getSPARQLEndpoint()
112+
public Class getSPARQLEndpoint()
105113
{
106-
return SPARQLEndpointImpl.class;
114+
return getProxyClass().orElse(SPARQLEndpointImpl.class);
107115
}
108116

109117
/**
@@ -112,9 +120,9 @@ public Object getSPARQLEndpoint()
112120
* @return endpoint resource
113121
*/
114122
@Path("service")
115-
public Object getGraphStore()
123+
public Class getGraphStore()
116124
{
117-
return GraphStoreImpl.class;
125+
return getProxyClass().orElse(GraphStoreImpl.class);
118126
}
119127

120128
/**
@@ -123,9 +131,9 @@ public Object getGraphStore()
123131
* @return endpoint resource
124132
*/
125133
@Path("ns")
126-
public Object getNamespace()
134+
public Class getNamespace()
127135
{
128-
return Namespace.class;
136+
return getProxyClass().orElse(Namespace.class);
129137
}
130138

131139
/**
@@ -134,9 +142,9 @@ public Object getNamespace()
134142
* @return namespace resource
135143
*/
136144
@Path("ns/{slug}/")
137-
public Object getSubOntology()
145+
public Class getSubOntology()
138146
{
139-
return Namespace.class;
147+
return getProxyClass().orElse(Namespace.class);
140148
}
141149

142150
/**
@@ -145,9 +153,9 @@ public Object getSubOntology()
145153
* @return endpoint resource
146154
*/
147155
@Path("sign up")
148-
public Object getSignUp()
156+
public Class getSignUp()
149157
{
150-
return SignUp.class;
158+
return getProxyClass().orElse(SignUp.class);
151159
}
152160

153161
/**
@@ -156,9 +164,9 @@ public Object getSignUp()
156164
* @return endpoint resource
157165
*/
158166
@Path("request access")
159-
public Object getRequestAccess()
167+
public Class getRequestAccess()
160168
{
161-
return RequestAccess.class;
169+
return getProxyClass().orElse(RequestAccess.class);
162170
}
163171

164172
/**
@@ -168,9 +176,9 @@ public Object getRequestAccess()
168176
* @see com.atomgraph.linkeddatahub.apps.model.Application#UPLOADS_PATH
169177
*/
170178
@Path("uploads/{sha1sum}")
171-
public Object getFileItem()
179+
public Class getFileItem()
172180
{
173-
return com.atomgraph.linkeddatahub.resource.upload.sha1.Item.class;
181+
return getProxyClass().orElse(com.atomgraph.linkeddatahub.resource.upload.sha1.Item.class);
174182
}
175183

176184
/**
@@ -179,9 +187,9 @@ public Object getFileItem()
179187
* @return endpoint resource
180188
*/
181189
@Path("importer")
182-
public Object getImportEndpoint()
190+
public Class getImportEndpoint()
183191
{
184-
return Importer.class;
192+
return getProxyClass().orElse(Importer.class);
185193
}
186194

187195
/**
@@ -190,9 +198,9 @@ public Object getImportEndpoint()
190198
* @return endpoint resource
191199
*/
192200
@Path("add")
193-
public Object getAddEndpoint()
201+
public Class getAddEndpoint()
194202
{
195-
return Add.class;
203+
return getProxyClass().orElse(Add.class);
196204
}
197205

198206
/**
@@ -201,9 +209,9 @@ public Object getAddEndpoint()
201209
* @return endpoint resource
202210
*/
203211
@Path("transform")
204-
public Object getTransformEndpoint()
212+
public Class getTransformEndpoint()
205213
{
206-
return Transform.class;
214+
return getProxyClass().orElse(Transform.class);
207215
}
208216

209217
/**
@@ -212,9 +220,9 @@ public Object getTransformEndpoint()
212220
* @return endpoint resource
213221
*/
214222
@Path("generate")
215-
public Object getGenerateEndpoint()
223+
public Class getGenerateEndpoint()
216224
{
217-
return Generate.class;
225+
return getProxyClass().orElse(Generate.class);
218226
}
219227

220228
/**
@@ -223,9 +231,9 @@ public Object getGenerateEndpoint()
223231
* @return endpoint resource
224232
*/
225233
@Path("clear")
226-
public Object getClearEndpoint()
234+
public Class getClearEndpoint()
227235
{
228-
return Clear.class;
236+
return getProxyClass().orElse(Clear.class);
229237
}
230238

231239
/**
@@ -234,9 +242,9 @@ public Object getClearEndpoint()
234242
* @return endpoint resource
235243
*/
236244
@Path("oauth2/authorize/google")
237-
public Object getAuthorizeGoogle()
245+
public Class getAuthorizeGoogle()
238246
{
239-
return com.atomgraph.linkeddatahub.resource.admin.oauth2.google.Authorize.class;
247+
return getProxyClass().orElse(com.atomgraph.linkeddatahub.resource.admin.oauth2.google.Authorize.class);
240248
}
241249

242250
/**
@@ -245,9 +253,9 @@ public Object getAuthorizeGoogle()
245253
* @return endpoint resource
246254
*/
247255
@Path("oauth2/login")
248-
public Object getOAuth2Login()
256+
public Class getOAuth2Login()
249257
{
250-
return com.atomgraph.linkeddatahub.resource.admin.oauth2.Login.class;
258+
return getProxyClass().orElse(com.atomgraph.linkeddatahub.resource.admin.oauth2.Login.class);
251259
}
252260

253261
/**

src/main/java/com/atomgraph/linkeddatahub/server/model/impl/ProxyResourceBase.java

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public ContainerRequestContext getContainerRequestContext()
299299
*
300300
* @return URI info
301301
*/
302+
@Override
302303
public UriInfo getUriInfo()
303304
{
304305
return uriInfo;

0 commit comments

Comments
 (0)