本文整理汇总了Java中org.restlet.routing.Redirector类的典型用法代码示例。如果您正苦于以下问题:Java Redirector类的具体用法?Java Redirector怎么用?Java Redirector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Redirector类属于org.restlet.routing包,在下文中一共展示了Redirector类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: redirectClient
import org.restlet.routing.Redirector; //导入依赖的package包/类
/**
* Redirects a URI to a new URI. You can use template variables in the URIs.
* <p>
* Enforces matching mode {@link Template#MODE_EQUALS}.
* <p>
* This is handled via a {@link NormalizingRedirector}.
*
* @param uriTemplate
* The URI path template that must match the relative part of the
* resource URI
* @param targetUriTemplate
* The target URI template
* @param statusCode
* HTTP status code (must be 301, 302, 303 or 307)
* @return The created route
* @see NormalizingRedirector
*/
public TemplateRoute redirectClient( String uriTemplate, String targetUriTemplate, int statusCode )
{
int mode;
switch( statusCode )
{
case 301:
mode = Redirector.MODE_CLIENT_PERMANENT;
break;
case 302:
mode = Redirector.MODE_CLIENT_FOUND;
break;
case 303:
mode = Redirector.MODE_CLIENT_SEE_OTHER;
break;
case 307:
mode = Redirector.MODE_CLIENT_TEMPORARY;
break;
default:
throw new IllegalArgumentException( "Unsupported status code: " + statusCode );
}
TemplateRoute route = attach( uriTemplate, new NormalizingRedirector( getContext(), targetUriTemplate, mode ) );
route.setMatchingMode( Template.MODE_EQUALS );
return route;
}
开发者ID:tliron,项目名称:prudence,代码行数:43,代码来源:PrudenceRouter.java
示例2: additionalRouterConfig
import org.restlet.routing.Redirector; //导入依赖的package包/类
@Override
public void additionalRouterConfig(final Router router) {
final String baseURL = getExtConfigManager().getExtensionInfo().getBaseUrl();
router.attach("/", new Redirector(getContext(), baseURL + ExtensionServerConstants.EXTENSION_INFO, Redirector.MODE_CLIENT_FOUND));
router.attach(ExtensionServerConstants.EXTENSION_INFO, ExtensionInfoServerResource.class);
router.attach(ExtensionServerConstants.GLOBAL_CONFIG_VALUES, GlobalConfigServerResource.class);
router.attach(ExtensionServerConstants.USER_CONFIG_VALUES, UserConfigServerResource.class);
}
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:9,代码来源:RestletApplication.java
示例3: beforeHandle
import org.restlet.routing.Redirector; //导入依赖的package包/类
@Override
protected int beforeHandle( Request request, Response response )
{
Object r = delegatedHandler.handleWithConversation( entryPointNameForBefore );
if( r instanceof Number )
// Returned number
return ( (Number) r ).intValue();
else if( r != null )
{
// Returned string
String action = r.toString();
if( action != null )
{
if( action.startsWith( "/" ) )
{
// Capture!
String reference = "riap://application" + action + "?{rq}";
Redirector redirector = new CapturingRedirector( delegatedHandler.getAttributes().getContext(), reference );
redirector.handle( request, response );
return STOP;
}
action = action.toUpperCase();
if( action.equals( "CONTINUE" ) )
return CONTINUE;
else if( action.equals( "SKIP" ) )
return SKIP;
else if( action.equals( "STOP" ) )
return STOP;
}
}
return defaultBeforeAction;
}
开发者ID:tliron,项目名称:prudence,代码行数:36,代码来源:DelegatedFilter.java
示例4: GraphiteRouter
import org.restlet.routing.Redirector; //导入依赖的package包/类
public GraphiteRouter(Context context) throws ConfigurationException, ValidationException {
super(context);
// contains full url, including different port
String hostname = Configuration.getInstance().getProperty(
RequiredParameters.SLIPSTREAM_METERING_HOSTNAME.getName());
String target = hostname + "/render?{query}";
Redirector redirector = new GraphiteRedirector(getContext(), target, Redirector.MODE_SERVER_OUTBOUND);
TemplateRoute route = attach("/render?{query}", redirector);
route.setMatchingQuery(true);
route.getTemplate().getVariables().put("query", new Variable(Variable.TYPE_URI_QUERY));
}
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:14,代码来源:GraphiteRouter.java
示例5: createInboundRoot
import org.restlet.routing.Redirector; //导入依赖的package包/类
@Override
public Restlet createInboundRoot() {
// Remove server-side HTTP timeout (see http://stackoverflow.com/questions/12943447/restlet-server-socket-timeout)
getContext().getParameters().add("maxIoIdleTimeMs", ONE_HOUR_IN_MILLIS);
getContext().getParameters().add("ioMaxIdleTimeMs", ONE_HOUR_IN_MILLIS);
router = new Router(getContext());
router.setDefaultMatchingMode(Template.MODE_EQUALS);
/**
* Start Routers 2.0
*/
attachRoutesForClass(router, PinotTenantRestletResource.class);
attachRoutesForClass(router, PinotSchemaRestletResource.class);
attachRoutesForClass(router, PinotTableRestletResource.class);
// GET
attachRoutesForClass(router, PinotTableInstances.class);
attachRoutesForClass(router, PinotTableSchema.class);
attachRoutesForClass(router, PinotSegmentRestletResource.class);
// PUT
attachRoutesForClass(router, PinotTableSegmentConfigs.class);
attachRoutesForClass(router, PinotTableIndexingConfigs.class);
attachRoutesForClass(router, PinotTableTenantConfigs.class);
attachRoutesForClass(router, PinotTableMetadataConfigs.class);
// Uploading Downloading segments
attachRoutesForClass(router, PinotSegmentUploadRestletResource.class);
attachRoutesForClass(router, PinotVersionRestletResource.class);
router.attach("/api", SwaggerResource.class);
/**
* End Routes 2.0
*/
attachRoutesForClass(router, PinotInstanceRestletResource.class);
router.attach("/pinot-controller/admin", PinotControllerHealthCheck.class);
router.attach("/pql", PqlQueryResource.class);
final Restlet mainpage = new Restlet() {
@Override
public void handle(Request request, Response response) {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<html>");
stringBuilder.append("<head><title>Restlet Cluster Management page</title></head>");
stringBuilder.append("<body bgcolor=white>");
stringBuilder.append("<table border=\"0\">");
stringBuilder.append("<tr>");
stringBuilder.append("<td>");
stringBuilder.append("<h1>Rest cluster management interface V1</h1>");
stringBuilder.append("</td>");
stringBuilder.append("</tr>");
stringBuilder.append("</table>");
stringBuilder.append("</body>");
stringBuilder.append("</html>");
response.setEntity(new StringRepresentation(stringBuilder.toString(), MediaType.TEXT_HTML));
}
};
final Directory webdir = new Directory(getContext(), CONSOLE_WEBAPP_ROOT_PATH);
webdir.setDeeplyAccessible(true);
webdir.setIndexName("index.html");
router.attach("/query", webdir);
final Directory swaggerUiDir = new Directory(getContext(), getClass().getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/2.1.8-M1").toString());
swaggerUiDir.setDeeplyAccessible(true);
router.attach("/swagger-ui", swaggerUiDir);
final Redirector redirector = new Redirector(getContext(), "/swagger-ui/index.html?url=/api", Redirector.MODE_CLIENT_TEMPORARY);
router.attach("/help", redirector);
return router;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:80,代码来源:ControllerRestApplication.java
示例6: createRoot
import org.restlet.routing.Redirector; //导入依赖的package包/类
public Restlet createRoot() {
Router router = new Router(getContext());
//router.setDefaultMatchingMode(Router.BEST);
//System.out.println("MatchingMode: "+ router.getDefaultMatchingMode() + " : "+ router.getRequiredScore());
router.attach(URL_DATASOURCES, DataSources.class);
//Register the route for the home page url pattern
String target = "http://bridgedb.org/wiki/BridgeWebservice";
Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_CLIENT_TEMPORARY);
router.attach(URL_HOME, redirector);
router.attach(URL_CONFIG, Config.class);
router.attach(URL_CONTENTS, Contents.class);
/* IDMapper methods */
//Register the route for the xrefs url pattern
Route xrefsRoute = router.attach(URL_XREFS, Xrefs.class);
//Specify that the dataSource parameter needs to be included
//in the attributes
xrefsRoute.extractQuery(PAR_TARGET_SYSTEM, PAR_TARGET_SYSTEM, true);
Route searchRoute = router.attach( URL_SEARCH, FreeSearch.class );
searchRoute.extractQuery( PAR_TARGET_LIMIT, PAR_TARGET_LIMIT, true );
router.attach(URL_XREF_EXISTS, XrefExists.class);
/* IDMapperCapabilities methods */
router.attach (URL_PROPERTIES, Properties.class );
router.attach (
URL_SUPPORTED_SOURCE_DATASOURCES, SupportedSourceDataSources.class );
router.attach (
URL_SUPPORTED_TARGET_DATASOURCES, SupportedTargetDataSources.class );
router.attach(URL_ATTRIBUTE_SET, AttributeSet.class);
router.attach(URL_IS_FREE_SEARCH_SUPPORTED, IsFreeSearchSupported.class);
router.attach(URL_IS_MAPPING_SUPPORTED, IsMappingSupported.class);
/* AttributeMapper methods */
Route attrSearchRoute = router.attach( URL_ATTRIBUTE_SEARCH, AttributeSearch.class );
attrSearchRoute.extractQuery( PAR_TARGET_LIMIT, PAR_TARGET_LIMIT, true );
attrSearchRoute.extractQuery( PAR_TARGET_ATTR_NAME, PAR_TARGET_ATTR_NAME, true );
Route attributesRoute = router.attach(URL_ATTRIBUTES, Attributes.class );
attributesRoute.extractQuery( PAR_TARGET_ATTR_NAME, PAR_TARGET_ATTR_NAME, true );
/* Extra methods */
// Register the route for backPageText
router.attach( URL_BACK_PAGE_TEXT, BackPageText.class );
//Register the route for a url pattern that doesn't match other patterns
router.attach(URL_NO_MATCH, NoMatch.class);
return router;
}
开发者ID:bridgedb,项目名称:BridgeDb,代码行数:61,代码来源:IDMapperService.java
注:本文中的org.restlet.routing.Redirector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论