本文整理汇总了Java中net.floodlightcontroller.restserver.RestletRoutable类的典型用法代码示例。如果您正苦于以下问题:Java RestletRoutable类的具体用法?Java RestletRoutable怎么用?Java RestletRoutable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RestletRoutable类属于net.floodlightcontroller.restserver包,在下文中一共展示了RestletRoutable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInboundRoot
import net.floodlightcontroller.restserver.RestletRoutable; //导入依赖的package包/类
/**
* Sets up the Restlet for the APIs under test using a Router. Also, a
* filter is installed to deal with double slashes in URLs.
* This code is adapted from
* net.floodlightcontroller.restserver.RestApiServer
*
* @return Router object for the APIs under test.
*/
@Override
public Restlet createInboundRoot() {
Router baseRouter = new Router(context);
baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
for (RestletRoutable rr : restlets) {
baseRouter.attach(rr.basePath(), rr.getRestlet(context));
}
/**
* Filter out multiple slashes in URLs to make them a single slash.
*/
Filter slashFilter = new Filter() {
@Override
protected int beforeHandle(Request request, Response response) {
Reference ref = request.getResourceRef();
String originalPath = ref.getPath();
if (originalPath.contains("//")) {
String newPath = originalPath.replaceAll("/+", "/");
ref.setPath(newPath);
}
return Filter.CONTINUE;
}
};
slashFilter.setNext(baseRouter);
return slashFilter;
}
示例2: startServer
import net.floodlightcontroller.restserver.RestletRoutable; //导入依赖的package包/类
/**
* Start up the REST server. A list of the Restlets being tested is
* passed in. The usual use of this method is in the @Before (startUp)
* of a JUnit test.
*
* @param restletsUnderTest list of Restlets to run as part of the server.
*/
public void startServer(final List<RestletRoutable> restletsUnderTest) {
restlets = restletsUnderTest;
restApplication = new RestApplication();
restApplication.run();
}
示例3: addRestlet
import net.floodlightcontroller.restserver.RestletRoutable; //导入依赖的package包/类
/**
* Add a restlet to the web server. Tests call this to add the specific
* REST APIs they are testing. Call this before starting the server via
* setUp().
*
* @param newRestlet restlet to add to the web server
*/
void addRestlet(final RestletRoutable newRestlet) {
restlets.add(newRestlet);
}