【发布时间】:2013-08-21 10:58:00
【问题描述】:
我正在使用 Restlet 框架,但现在我想更改为合适的服务器而不是使用 localhost。 我已经将我的 php 文件(它们使用 rest_server URL 访问 java 文件)添加到服务器的文件夹和我的 java 文件中,但我不确定如何更改代码,以便它识别文件的新位置在哪里.
这是来自 IdentiscopeServer 的代码(构造函数为空):
public static void main(String[] args) throws Exception {
//setsup our security manager
if (System.getSecurityManager() == null){
System.setSecurityManager(new SecurityManager());
}
identiscopeServerApp = new IdentiscopeServerApplication();
IdentiscopeServer server = new IdentiscopeServer();
server.getServers().add(Protocol.HTTP,8888);
server.getDefaultHost().attach("", identiscopeServerApp);
server.start();
}
我猜想更改的正确行是带有“Protocol.HTTP, 8888”的行。如果我的新服务器地址是http://devweb2013.co.uk/research/Identiscope,我该如何设置呢?除了将文件移动到服务器中的文件夹之外,还有其他必要的工作吗?
IdensicopeServerApplication 如下:
public class IdentiscopeServerApplication extends Application {
public IdentiscopeServerApplication() {
}
public Restlet createInboundRoot() {
Router router = new Router(getContext());
//attaches the /tweet path to the TweetRest class
router.attach("/collectionPublic", CollectionPublicREST.class);
router.attach("/collectionPrivate", CollectionPrivateREST.class);
router.attach("/analysis", AnalysisREST.class);
return router;
}
}
提前谢谢你,这是我第一次使用这个框架。
【问题讨论】:
-
如果不了解 IdentiscopeServerApplication 和 IdentiscopeServer 类,很难提供帮助
-
很抱歉。更新了帖子,见上文。
-
我想查看这些类的代码,因为我相信所有其余的服务连接逻辑都在那里。您在问题中提供的代码来自一个非常抽象的层。
-
有什么想法吗?只需忽略 IdentiscopeServerApplication 类上的注释“//将 /tweet 路径附加到 TweetRest 类”
-
restlet 代码通常会根据请求 URL 的上下文检测它部署的服务器。您希望如何部署应用程序?在 Servlet 容器中?使用其中一个 Restlet 引擎?
标签: java php rest web-hosting restlet