use of com.ibm.designer.runtime.domino.adapter.ComponentModule in project org.openntf.xsp.jakartaee by OpenNTF.
the class JAXRSServletFactory method getServletPath.
/**
* Determines the effective base servlet path for the provided module.
*
* @param module the {@link ComponentModule} housing the servlet.
* @return the base servlet path for JAX-RS, e.g. {@code "/xsp/.jaxrs/"}
*/
public static String getServletPath(ComponentModule module) {
Map<String, Object> attrs = module.getAttributes();
// Module attributes aren't reset on app refresh, so check here
Object refresh = attrs.get(ATTR_REFRESH);
if (refresh == null || (Long) refresh < module.getLastRefresh()) {
attrs.remove(ATTR_PATH);
}
attrs.put(ATTR_REFRESH, module.getLastRefresh());
String path = (String) attrs.computeIfAbsent(JAXRSServletFactory.class.getName() + "_path", key -> {
// $NON-NLS-1$
Properties props = new Properties();
try (InputStream is = module.getResourceAsStream("/WEB-INF/xsp.properties")) {
// $NON-NLS-1$
if (is != null) {
props.load(is);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return props.getProperty(PROP_SERVLET_PATH);
});
if (StringUtil.isEmpty(path)) {
path = SERVLET_PATH_DEFAULT;
}
// $NON-NLS-1$
path = PathUtil.concat("/xsp", path, '/');
if (!path.endsWith("/")) {
// $NON-NLS-1$
// $NON-NLS-1$
path += "/";
}
return path;
}
use of com.ibm.designer.runtime.domino.adapter.ComponentModule in project openliberty-domino by OpenNTF.
the class ReverseProxyHttpService method notifyMessage.
@Override
public void notifyMessage(EventObject event) {
if (event instanceof ReverseProxyConfigChangedEvent) {
this.targets.values().forEach(ComponentModule::destroyModule);
ReverseProxyConfig config = ((ReverseProxyConfigChangedEvent) event).getSource();
this.enabled = config.isEnabled(this);
this.targets = buildModules(config.getTargets());
}
}
use of com.ibm.designer.runtime.domino.adapter.ComponentModule in project org.openntf.xsp.jakartaee by OpenNTF.
the class OldServletContextWrapper method getRequestDispatcher.
@Override
public RequestDispatcher getRequestDispatcher(String path) {
// Unsupported on Domino, so try to replicate the behavior from the ComponentModule
ServletMatch match = getServletFactories().stream().map(f -> {
try {
return f.getServletMatch(getContextPath(), path);
} catch (javax.servlet.ServletException e) {
throw new RuntimeException(e);
}
}).filter(Objects::nonNull).findFirst().orElse(null);
if (match != null) {
// TODO figure out if this behavior should change
return new RequestDispatcher() {
@Override
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
Servlet servlet = ServletUtil.oldToNew(match.getServlet());
servlet.service(request, response);
}
@Override
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
Servlet servlet = ServletUtil.oldToNew(match.getServlet());
servlet.service(request, response);
}
};
}
return null;
}
Aggregations