【问题标题】:VirtualHost still active after removing from component从组件中删除后,VirtualHost 仍然处于活动状态
【发布时间】:2013-08-10 12:58:37
【问题描述】:

当我从正在运行的组件的主机列表中删除之前添加的 VirtualHost 时,虚拟主机仍会继续使用。

    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8080);
    component.getDefaultHost().attachDefault(DefaultResource.class);

    VirtualHost host = new VirtualHost(new Context());
    host.setHostDomain("myhost\\.org");
    host.attachDefault(MyHostResource.class);
    component.getHosts().add(host);
    component.start();
    Thread.currentThread().sleep(5000);
    System.out.println("Stopping myhost");
    component.getHosts().remove(host);

5 秒后,对http://myhost.org 的 GET 查询应该给出 DefaultResource 的输出,但它会一直给出 MyHostResource 的输出,但仅在前 5 秒内提交 GET 之后。好像有一些路由信息保存在缓存中。

我目前正在构建一个动态插入/删除 VirtualHosts 的 OSGi 应用程序。但是,如果虚拟主机没有正确断开连接,我会得到 ServiceUnavailableExeptions。

我应该如何移除虚拟主机并正确更新路由缓存?

谢谢!

【问题讨论】:

    标签: restlet


    【解决方案1】:

    我找到了。调用

     component.updateHosts()
    

    成功了。

    【讨论】:

      猜你喜欢
      • 2023-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      • 2019-02-15
      • 2013-07-07
      • 2011-11-28
      相关资源
      最近更新 更多