Skip to content

Commit

Permalink
dbeaver-vscode#3 servlets filter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Sep 19, 2024
1 parent 252f34b commit 6706f10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* Servlet service
*/
public interface DBWServiceBindingServlet<APPLICATION extends WebApplication> extends DBWServiceBinding {
default boolean isApplicable(WebApplication application) {
return true;
}

void addServlets(APPLICATION application, DBWServletContext servletContext) throws DBException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ public void runServer() {
// Add extensions from services

CBJettyServletContext servletContext = new CBJettyServletContext(servletContextHandler);
for (DBWServiceBindingServlet wsd : WebServiceRegistry.getInstance().getWebServices(DBWServiceBindingServlet.class)) {
try {
wsd.addServlets(this.application, servletContext);
} catch (DBException e) {
log.error(e.getMessage(), e);
for (DBWServiceBindingServlet wsd : WebServiceRegistry.getInstance()
.getWebServices(DBWServiceBindingServlet.class)
) {
if (wsd.isApplicable(this.application)) {
try {
wsd.addServlets(this.application, servletContext);
} catch (DBException e) {
log.error(e.getMessage(), e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ public static WebSQLContextInfo getSQLContext(WebSQLProcessor processor, String

@Override
public void addServlets(WebApplication application, DBWServletContext servletContext) throws DBException {
if (!application.isMultiuser()) {
return;
}
servletContext.addServlet(
"sqlResultValueViewer",
new WebSQLResultServlet(application, getServiceImpl()),
Expand All @@ -311,6 +308,11 @@ public void addServlets(WebApplication application, DBWServletContext servletCon
);
}

@Override
public boolean isApplicable(WebApplication application) {
return application.isMultiuser();
}

private static class WebSQLConfiguration {
private final Map<WebConnectionInfo, WebSQLProcessor> processors = new HashMap<>();

Expand Down

0 comments on commit 6706f10

Please sign in to comment.