本文整理了Java中org.restlet.Request.getResourceRef
方法的一些代码示例,展示了Request.getResourceRef
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getResourceRef
方法的具体详情如下:
包路径:org.restlet.Request
类名称:Request
方法名:getResourceRef
[英]Returns the reference of the target resource. This reference is especially important during routing, dispatching and resource finding. During such processing, its base reference is constantly updated to reflect the reference of the parent Restlet or resource and the remaining part of the URI that must be routed or analyzed. If you need to get the URI reference originally requested by the client, then you should use the #getOriginalRef() method instead. Also, note that beside the update of its base property, the resource reference can be modified during the request processing. For example, the org.restlet.service.TunnelService associated to an application can extract some special extensions or query parameters and replace them by semantically equivalent properties on the request object. Therefore, the resource reference can become different from the original reference. Finally, when sending out requests via a dispatcher such as Context#getClientDispatcher() or Context#getServerDispatcher(), if the reference contains URI template variables, those variables are automatically resolved using the request's attributes.
[中]返回目标资源的引用。在路由、调度和资源查找期间,此参考尤其重要。在这种处理过程中,它的基本引用会不断更新,以反映父Restlet或资源的引用,以及必须路由或分析的URI的其余部分。如果需要获取客户端最初请求的URI引用,那么应该使用#getOriginalRef()方法。另外,请注意,除了更新其基本属性之外,还可以在请求处理期间修改资源引用。例如,组织。restlet。服务与应用程序关联的TunnelService可以提取一些特殊的扩展或查询参数,并用请求对象上语义等价的属性替换它们。因此,资源引用可能会与原始引用不同。最后,当通过调度程序(如Context#getClientDispatcher()或Context#getServerDispatcher())发送请求时,如果引用包含URI模板变量,则会使用请求的属性自动解析这些变量。
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the reference of the target resource.
*
* @return The reference of the target resource.
*/
@Override
public Reference getResourceRef() {
return getWrappedRequest().getResourceRef();
}
代码示例来源:origin: org.restlet.osgi/org.restlet
@Override
public int beforeHandle(Request request, Response response) {
int result = super.beforeHandle(request, response);
// This causes the baseRef of the resource reference to be set
// as if it had actually arrived from a server connector.
request.getResourceRef().setBaseRef(
request.getResourceRef().getHostIdentifier());
return result;
}
代码示例来源:origin: apache/helix
private String getZKPath() {
String relativeRef = getRequest().getResourceRef().getRelativeRef().toString();
if (relativeRef.equals(".")) {
relativeRef = "";
}
// strip off trailing "/"
while (relativeRef.endsWith("/")) {
relativeRef = relativeRef.substring(0, relativeRef.length() - 1);
}
return "/" + relativeRef;
}
代码示例来源:origin: apache/helix
private String getZKPath() {
String relativeRef = getRequest().getResourceRef().getRelativeRef().toString();
if (relativeRef.equals(".")) {
relativeRef = "";
}
// strip off trailing "/"
while (relativeRef.endsWith("/")) {
relativeRef = relativeRef.substring(0, relativeRef.length() - 1);
}
return "/" + relativeRef;
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Returns the URI reference.
*
* @return The URI reference.
*/
public static Reference getReference() {
return getRequest() == null ? null : getRequest().getResourceRef();
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public void write( Writer buf )
throws IOException
{
PrintWriter out = new PrintWriter( buf );
out.println( "<html><head><title>All entities</title></head><body><h1>All entities</h1><ul>" );
query.forEach( entity -> out.println( "<li><a href=\""
+ getRequest().getResourceRef().clone().addSegment( entity.identity() + ".html" )
+ "\">" + entity.identity() + "</a></li>" ) );
out.println( "</ul></body></html>" );
}
};
代码示例来源:origin: jtalks-org/jcommune
@SuppressWarnings("unchecked")
private void writeRequestInfoToLog(ClientResource clientResource) {
ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes();
Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS);
logger.info("Request to Poulpe: requested URI - {}, request headers - {}, request body - {}",
new Object[]{clientResource.getRequest().getResourceRef(), headers, clientResource.getRequest()});
}
代码示例来源:origin: com.whizzosoftware.hobson.hub/hobson-hub-setup
@Override
public void handle(Request request, Response response) {
Reference ref = request.getResourceRef();
if (PATH.equals(ref.getPath()) || (PATH + "/").equals(ref.getPath())) {
response.redirectPermanent(PATH + "/index.html");
} else {
super.handle(request, response);
}
}
}
代码示例来源:origin: org.restlet.osgi/org.restlet
@Override
protected int beforeHandle(Request request, Response response) {
final int result = super.beforeHandle(request, response);
// Set the request's root reference
request.setRootRef(request.getResourceRef().getBaseRef());
// Save the hash code of the current host
setCurrent(VirtualHost.this.hashCode());
return result;
}
};
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
private void addQueryParam(Request request, String representationAsText,
Annotation annotation) {
request.getResourceRef().addQueryParameter(
new Parameter(((QueryParam) annotation).value(),
representationAsText));
}
代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server
private String getUsecaseName( Request request )
{
if( request.getMethod().equals( org.restlet.data.Method.DELETE ) )
{
return "delete";
}
else
{
return request.getResourceRef().getLastSegment();
}
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
/**
* Generate the FOAF representation of this resource.
*/
@Get("rdf")
public Representation toFoaf() throws ResourceException {
return getFoafRepresentation(this.contact, getRequest()
.getResourceRef());
}
代码示例来源:origin: apache/attic-polygene-java
private String getUsecaseName( Request request )
{
if( request.getMethod().equals( org.restlet.data.Method.DELETE ) )
{
return "delete";
}
else
{
return request.getResourceRef().getLastSegment();
}
}
代码示例来源:origin: org.codeartisans.qipki/qipki-ca-http
protected final String getQueryParamValue( String key, String defaultValue )
{
String value = getRequest().getResourceRef().getQueryAsForm().getFirstValue( key );
if ( Strings.isEmpty( value ) ) {
value = defaultValue;
}
return value;
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public void challenge(Response response, boolean stale) {
// Load the FreeMarker template
Representation ftl = new ClientResource(
LocalReference.createClapReference(getClass().getPackage())
+ "/Login.ftl").get();
// Wraps the bean with a FreeMarker representation
response.setEntity(new TemplateRepresentation(ftl, response
.getRequest().getResourceRef(), MediaType.TEXT_HTML));
response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl
/**
* Returns the resource's relative path.
*
* @return The resource's relative path.
*/
protected String getResourcePath() {
Reference ref = new Reference(getRequest().getRootRef(), getRequest()
.getResourceRef());
return ref.getRemainingPart();
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
/**
* Remove this resource.
*/
@Delete
public void removeUser() throws ResourceException {
getObjectsFacade().deleteUser(this.user);
getResponse().redirectSeeOther(
getRequest().getResourceRef().getParentRef());
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public void handle(Request request, Response response) {
String entity = "Method : " + request.getMethod()
+ "\nResource URI : " + request.getResourceRef()
+ "\nIP address : " + request.getClientInfo().getAddress()
+ "\nAgent name : " + request.getClientInfo().getAgentName()
+ "\nAgent version: "
+ request.getClientInfo().getAgentVersion();
response.setEntity(entity, MediaType.TEXT_PLAIN);
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
/**
* Update the underlying user according to the given representation.
*/
@Put
public void storeUser(Representation entity) throws ResourceException {
Form form = new Form(entity);
this.user.setFirstName(form.getFirstValue("firstName"));
this.user.setLastName(form.getFirstValue("lastName"));
this.user.setImage(form.getFirstValue("image"));
getObjectsFacade().updateUser(this.user);
getResponse().redirectSeeOther(getRequest().getResourceRef());
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public RestLink post( RestForm form )
{
String name = form.field( "name" ).value().get();
Class<? extends HasIdentity> entityType = parameters.entityType().get();
Identity identity = identityManager.generate( entityType, name );
locator.find( entityType ).create( identity );
doParameterization( form, entityType, identity );
return resourceBuilder.createRestLink( identity.toString(), parameters.request().get().getResourceRef(), Method.GET );
}
内容来源于网络,如有侵权,请联系作者删除!