本文整理匯總了Java中org.restlet.data.Reference.setPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Reference.setPath方法的具體用法?Java Reference.setPath怎麽用?Java Reference.setPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.data.Reference
的用法示例。
在下文中一共展示了Reference.setPath方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@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 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: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@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 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;
}
示例3: newClient
import org.restlet.data.Reference; //導入方法依賴的package包/類
public synchronized ContextResourceClient newClient( String relativePath )
{
if( relativePath.startsWith( "http://" ) )
{
return contextResourceFactory.newClient( new Reference( relativePath ) );
}
Reference reference = this.reference.clone();
if( relativePath.startsWith( "/" ) )
{
reference.setPath( relativePath );
}
else
{
reference.setPath( reference.getPath() + relativePath );
reference = reference.normalize();
}
return contextResourceFactory.newClient( reference );
}
示例4: getReference
import org.restlet.data.Reference; //導入方法依賴的package包/類
public URL getReference(final Reference baseRef, String query, List<?> parts) {
if (!refCache.containsKey(baseRef)) {
refCache.put(baseRef, prepareReference(baseRef));
}
Reference r = new Reference(refCache.get(baseRef));
String currPath = r.getPath();
StringBuilder sb = new StringBuilder(currPath == null ? "" : currPath);
for (Object pe : parts) {
if (pe instanceof String && ((String) pe).startsWith("/")) {
sb.append(pe);
} else {
sb.append("/").append(pe);
}
}
r.setPath(sb.toString());
if (query != null) {
r.setQuery(query);
}
return r.toUrl();
}
示例5: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@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 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;
}
示例6: handle
import org.restlet.data.Reference; //導入方法依賴的package包/類
public Response handle(final Restlet resource, final Request request) throws Exception {
String path = null;
Reference ref = request.getResourceRef();
path = this.hostReference.toString() + ref;
ref.setPath(path);
return execute(resource, new ICallBack<Response>() {
@Override
public Response execute() throws Exception {
request.setHostRef(hostReference);
Response response = component.getContext().getServerDispatcher().handle(request);
return response;
}
});
}
示例7: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的package包/類
@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 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;
}
示例8: createInboundRoot
import org.restlet.data.Reference; //導入方法依賴的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;
}
示例9: buildAddress
import org.restlet.data.Reference; //導入方法依賴的package包/類
private String buildAddress(final ExtensionInfo extensionInfo, final String path) {
final Reference ref = new Reference(extensionInfo.getBaseUrl());
ref.setPath(path);
return ref.toString();
}