本文整理匯總了Java中org.restlet.Request.setRootRef方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.setRootRef方法的具體用法?Java Request.setRootRef怎麽用?Java Request.setRootRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.Request
的用法示例。
在下文中一共展示了Request.setRootRef方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testResolveResourceId
import org.restlet.Request; //導入方法依賴的package包/類
@Test
public void testResolveResourceId () throws Exception {
Request testRequest = new Request();
Reference rootRef = new Reference("http://solr.apache.org/");
testRequest.setRootRef(rootRef);
Reference resourceRef = new Reference("http://solr.apache.org/schema/analysis/synonyms/de");
testRequest.setResourceRef(resourceRef);
String resourceId = RestManager.ManagedEndpoint.resolveResourceId(testRequest);
assertEquals(resourceId, "/schema/analysis/synonyms/de");
}
示例2: testResolveResourceIdDecodeUrlEntities
import org.restlet.Request; //導入方法依賴的package包/類
@Test
public void testResolveResourceIdDecodeUrlEntities () throws Exception {
Request testRequest = new Request();
Reference rootRef = new Reference("http://solr.apache.org/");
testRequest.setRootRef(rootRef);
Reference resourceRef = new Reference("http://solr.apache.org/schema/analysis/synonyms/de/%C3%84ndern");
testRequest.setResourceRef(resourceRef);
String resourceId = RestManager.ManagedEndpoint.resolveResourceId(testRequest);
assertEquals(resourceId, "/schema/analysis/synonyms/de/Ändern");
}
示例3: beforeHandle
import org.restlet.Request; //導入方法依賴的package包/類
@Override
protected int beforeHandle( Request request, Response response )
{
if( !isApplying() )
return CONTINUE;
String forwardedScheme = request.getHeaders().getFirstValue( X_FORWARDED_PROTO_HEADER );
String forwardedDomain = request.getHeaders().getFirstValue( X_FORWARDED_HOST_HEADER );
String forwardedPortString = request.getHeaders().getFirstValue( X_FORWARDED_PORT_HEADER );
if( ( forwardedScheme != null ) || ( forwardedDomain != null ) || ( forwardedPortString != null ) )
{
int forwardedPort = -1;
if( forwardedDomain != null )
{
int colon = forwardedDomain.indexOf( ':' );
if( colon != -1 )
{
// Parse host:port
try
{
forwardedPort = Integer.parseInt( forwardedDomain.substring( 0, colon ) );
}
catch( NumberFormatException x )
{
// Invalid
}
forwardedDomain = forwardedDomain.substring( 0, colon );
}
}
if( forwardedPortString != null )
// Note: will override port in X-Forwarded-Host
forwardedPort = Integer.parseInt( forwardedPortString );
Reference reference;
reference = request.getResourceRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setResourceRef( reference );
}
reference = request.getRootRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setRootRef( reference );
}
reference = request.getOriginalRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setOriginalRef( reference );
}
}
return CONTINUE;
}