添加要在Intershop 7.4应用程序服务器上下文中运行的Servlet [英] Adding a servlet to run in Intershop 7.4 application server context

查看:0
本文介绍了添加要在Intershop 7.4应用程序服务器上下文中运行的Servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试包含一个第三方Servlet,以便在我们的IS7应用服务器的上下文中运行。我该如何着手将Servlet和映射添加到web.xml?

在知识库中,我仅找到有关Enfinity Suite 6的信息。提供的步骤似乎都不起作用。

编辑:

我找到了一个建议的IS7解决方案,它使用Guice并通过如下所示的特定Servlet模块绑定Servlet

package com.intershop.test;

import com.google.inject.servlet.ServletModule;

public class MyServletModule extends ServletModule
{
    @Override
    protected void configureServlets()
    {
        bind(MyServlet.class).in(Singleton.class);
        serve("/my/*").with(MyServlet.class);
    }
}

我已将ServletModule添加到对象图示.properties文件中,但在尝试访问它时仍未调用Servlet。

有什么建议吗?

推荐答案

我知道这在ICM7.7中有效,但我相信它从7.4开始就存在了。

您可以使用Guice Servlet Extension

1.取消对盒式磁带中Guice Servlet的依赖build.gradle示例

dependencies 
{
    ...
    compile group: 'com.intershop.platform', name: 'servletengine'
    compile 'com.google.inject.extensions:guice-servlet'
    ...
}
2.在插件中定义Servlet模块objectgraph.properties示例

global.modules = com.example.modules.DemoServletModule

3.实现Servlet。示例

public class DemoServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        resp.getWriter().append("Hello, world!");
    }
}
4.创建模块实现。Gotcha:名称应以评论中指出的/servlet/开头。示例

import javax.inject.Singleton;
import com.google.inject.servlet.ServletModule;

public class DemoServletModule extends ServletModule
{
    @Override
    protected void configureServlets()
    {
        bind(DemoServlet.class).in(Singleton.class);

        serve("/servlet/DEMO/*").with(DemoServlet.class);
    }
}
4.构建、重新启动、尝试。示例

GET /servlet/DEMO/hey HTTP/1.1
Host: example.com:10054
....

存储库:

Hello, world!

更新:

如果希望您的Servlet通过Web适配器可见,则必须允许它。

1.打开IS_SHAREsystemconfigclusterwebadapter.properties

2.导航到此部分:

## The list of servlets, which can be accessed through the generic
## .servlet mapping. The WebAdapter forwards only requests of the form
## /servlet/<group><servlet.allow.x>...
3.为您的Servlet添加条目。示例

servlet.allow.4=/DEMO

4.通过类似的URL访问Servlet:

https://example.com/INTERSHOP/servlet/WFS/DEMO/hey

这篇关于添加要在Intershop 7.4应用程序服务器上下文中运行的Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆