-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding callback support for Operation, clean up leftovers argument re…
…solvers
- Loading branch information
Showing
7 changed files
with
105 additions
and
124 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/community/ogcapi/src/main/java/org/geoserver/api/APIConfigurationSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.geoserver.api; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
import org.geoserver.ows.Dispatcher; | ||
import org.geoserver.ows.DispatcherCallback; | ||
import org.geoserver.ows.Request; | ||
import org.geoserver.platform.Operation; | ||
import org.springframework.web.method.HandlerMethod; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
import org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod; | ||
|
||
public class APIConfigurationSupport extends WebMvcConfigurationSupport { | ||
|
||
static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger("org.geoserver.api"); | ||
|
||
List<DispatcherCallback> callbacks; | ||
|
||
class APIRequestMappingHandlerAdapter extends RequestMappingHandlerAdapter { | ||
@Override | ||
protected ServletInvocableHandlerMethod createInvocableHandlerMethod( | ||
HandlerMethod handlerMethod) { | ||
return new APIInvocableHandlerMethod(handlerMethod); | ||
} | ||
} | ||
|
||
class APIInvocableHandlerMethod extends ServletInvocableHandlerMethod { | ||
|
||
public APIInvocableHandlerMethod(HandlerMethod handlerMethod) { | ||
super(handlerMethod); | ||
} | ||
|
||
@Override | ||
protected Object doInvoke(Object... args) throws Exception { | ||
Request request = Dispatcher.REQUEST.get(); | ||
Operation operation = | ||
new Operation( | ||
request.getRequest(), | ||
request.getServiceDescriptor(), | ||
getBridgedMethod(), | ||
args); | ||
operation = fireOperationDispatchedCallback(request, operation); | ||
try { | ||
return operation | ||
.getMethod() | ||
.invoke(operation.getService().getService(), operation.getParameters()); | ||
} catch (InvocationTargetException e) { | ||
Throwable targetException = e.getTargetException(); | ||
if (targetException instanceof RuntimeException) { | ||
throw (RuntimeException) targetException; | ||
} else if (targetException instanceof Error) { | ||
throw (Error) targetException; | ||
} else if (targetException instanceof Exception) { | ||
throw (Exception) targetException; | ||
} else { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { | ||
return new APIRequestMappingHandlerAdapter(); | ||
} | ||
|
||
public List<DispatcherCallback> getCallbacks() { | ||
return callbacks; | ||
} | ||
|
||
public void setCallbacks(List<DispatcherCallback> callbacks) { | ||
this.callbacks = callbacks; | ||
} | ||
|
||
// SHARE (or move to a callback handler/list class of sort?) | ||
Operation fireOperationDispatchedCallback(Request req, Operation op) { | ||
for (DispatcherCallback cb : callbacks) { | ||
Operation o = cb.operationDispatched(req, op); | ||
op = o != null ? o : op; | ||
} | ||
return op; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/community/ogcapi/src/main/java/org/geoserver/api/BaseURL.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
src/community/ogcapi/src/main/java/org/geoserver/api/BaseURLArgumentResolver.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/community/ogcapi/src/main/java/org/geoserver/api/NegotiatedContentType.java
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
...mmunity/ogcapi/src/main/java/org/geoserver/api/NegotiatedContentTypeArgumentResolver.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters