• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Route类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.restlet.routing.Route的典型用法代码示例。如果您正苦于以下问题:Java Route类的具体用法?Java Route怎么用?Java Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Route类属于org.restlet.routing包,在下文中一共展示了Route类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBest

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Returns the best route match for a given call.
 * 
 * @param request
 *            The request to score.
 * @param response
 *            The response to score.
 * @param requiredScore
 *            The minimum score required to have a match.
 * @return The best route match or null.
 */
public Route getBest(Request request, Response response, float requiredScore) {
    Route result = null;
    float bestScore = 0F;
    float score;

    for (Route current : this) {
        score = current.score(request, response);

        if ((score > bestScore) && (score >= requiredScore)) {
            bestScore = score;
            result = current;
        }
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:28,代码来源:RouteList.java


示例2: getNext

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Returns a next route match in a round robin mode for a given call.
 * 
 * @param request
 *            The request to score.
 * @param response
 *            The response to score.
 * @param requiredScore
 *            The minimum score required to have a match.
 * @return A next route or null.
 */
public synchronized Route getNext(Request request, Response response,
        float requiredScore) {
    if (!isEmpty()) {
        for (final int initialIndex = this.lastIndex++; initialIndex != this.lastIndex; this.lastIndex++) {
            if (this.lastIndex >= size()) {
                this.lastIndex = 0;
            }

            final Route route = get(this.lastIndex);
            if (route.score(request, response) >= requiredScore) {
                return route;
            }
        }
    }

    // No match found
    return null;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:30,代码来源:RouteList.java


示例3: stopHostApplications

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Stop all applications attached to a virtual host
 * 
 * @param host
 * @throws Exception
 */
private void stopHostApplications(VirtualHost host) throws Exception {
    for (Route route : host.getRoutes()) {
        if (route.getNext().isStarted()) {
            route.getNext().stop();
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:14,代码来源:ComponentHelper.java


示例4: getFirst

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Returns the first route match for a given call.
 * 
 * @param request
 *            The request to score.
 * @param response
 *            The response to score.
 * @param requiredScore
 *            The minimum score required to have a match.
 * @return The first route match or null.
 */
public Route getFirst(Request request, Response response,
        float requiredScore) {
    for (Route current : this) {
        if (current.score(request, response) >= requiredScore) {
            return current;
        }
    }

    // No match found
    return null;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:23,代码来源:RouteList.java


示例5: getLast

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Returns the last route match for a given call.
 * 
 * @param request
 *            The request to score.
 * @param response
 *            The response to score.
 * @param requiredScore
 *            The minimum score required to have a match.
 * @return The last route match or null.
 */
public synchronized Route getLast(Request request, Response response,
        float requiredScore) {
    for (int j = size() - 1; (j >= 0); j--) {
        final Route route = get(j);
        if (route.score(request, response) >= requiredScore) {
            return route;
        }
    }

    // No match found
    return null;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:24,代码来源:RouteList.java


示例6: getRandom

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Returns a random route match for a given call. Note that the current
 * implementation doesn't uniformly return routes unless they all score
 * above the required score.
 * 
 * @param request
 *            The request to score.
 * @param response
 *            The response to score.
 * @param requiredScore
 *            The minimum score required to have a match.
 * @return A random route or null.
 */
public synchronized Route getRandom(Request request, Response response,
        float requiredScore) {
    int length = size();

    if (length > 0) {
        int j = new Random().nextInt(length);
        Route route = get(j);

        if (route.score(request, response) >= requiredScore) {
            return route;
        }

        boolean loopedAround = false;

        do {
            if ((j == length) && (loopedAround == false)) {
                j = 0;
                loopedAround = true;
            }

            route = get(j++);

            if (route.score(request, response) >= requiredScore) {
                return route;
            }
        } while ((j < length) || !loopedAround);
    }

    // No match found
    return null;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:45,代码来源:RouteList.java


示例7: createEntryPoint

import org.restlet.routing.Route; //导入依赖的package包/类
private EntryPoint createEntryPoint()
        {
            Map<String, RestLink> entryPoints = new HashMap<>();
            for( Route r : parameters.router().get().getRoutes() )
            {
                if( r instanceof TemplateRoute)
                {
                    TemplateRoute route = (TemplateRoute) r;
                    Template template = route.getTemplate();
                    // Only include patterns that doesn't have variables, and has a proper name.
                    if( template.getVariableNames().isEmpty() && route.getName().indexOf( '>' ) == -1 )
                    {
                        Reference hostRef = parameters.request().get().getOriginalRef();
//                        Reference reference = new Reference( hostRef, template.getPattern() );
                        RestLink link;
                        if( route.getDescription() == null )
                        {
                            link = resourceBuilder.createRestLink( template.getPattern(), hostRef, Method.GET );
                        }
                        else
                        {
                            link = resourceBuilder.createRestLink( template.getPattern(), hostRef, Method.GET, route.getDescription() );
                        }
                        entryPoints.put( route.getName(), link );
                    }
                }
            }
            ValueBuilder<EntryPoint> builder = vbf.newValueBuilder( EntryPoint.class );
            builder.prototype().identity().set( StringIdentity.identityOf( "/" ) );
            builder.prototype().api().set( entryPoints );
            return builder.newInstance();
        }
 
开发者ID:apache,项目名称:polygene-java,代码行数:33,代码来源:EntryPointResource.java


示例8: attachFallback

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * @param pathTemplate
 *        The URI path template that must match the relative part of the
 *        resource URI.
 * @param target
 *        The target Restlet to attach.
 * @return The created route.
 */
public TemplateRoute attachFallback( String pathTemplate, Restlet target )
{
	TemplateRoute existingRoute = null;
	for( Route route : getRoutes() )
	{
		if( route instanceof TemplateRoute )
		{
			TemplateRoute templateRoute = (TemplateRoute) route;
			if( templateRoute.getTemplate().getPattern().equals( pathTemplate ) )
			{
				existingRoute = templateRoute;
				break;
			}
		}
	}

	if( existingRoute != null )
	{
		Restlet current = existingRoute.getNext();
		if( current instanceof Fallback )
		{
			// Add to current Fallback
			( (Fallback) current ).addTarget( target );
		}
		else
		{
			// Replace current target with Fallback
			Fallback fallback = new Fallback( getContext(), cacheDuration, current, target );
			existingRoute.setNext( fallback );
		}

		return existingRoute;
	}

	return attach( pathTemplate, target );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:45,代码来源:FallbackRouter.java


示例9: list

import org.restlet.routing.Route; //导入依赖的package包/类
private void list(Map<Restlet, String> all, Restlet restlet, String path) {
	all.put(restlet, path);
	if (restlet instanceof Router) {
		for (Route r : ((Router)restlet).getRoutes()) {
			list(all, r, path + ((TemplateRoute)r).getTemplate().getPattern());
		}
	} else if (restlet instanceof Filter) {
		list(all, ((Filter) restlet).getNext(), path);
	}
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:11,代码来源:APIInfoResource.java


示例10: RouteList

import org.restlet.routing.Route; //导入依赖的package包/类
/**
 * Constructor.
 */
public RouteList() {
    super(new CopyOnWriteArrayList<Route>());
    this.lastIndex = -1;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:8,代码来源:RouteList.java


示例11: findRoute

import org.restlet.routing.Route; //导入依赖的package包/类
@Override
public Route findRoute( String name, Router router )
{
    return router.getRoutes().stream().filter( route -> name.equals( route.getName() ) ).findFirst().orElse( null );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:6,代码来源:ResourceBuilder.java


示例12: detach

import org.restlet.routing.Route; //导入依赖的package包/类
@Override
public void detach( Restlet target )
{
	boolean found = false;
	Route dead = null;
	for( Route route : getRoutes() )
	{
		Restlet restlet = route.getNext();
		if( restlet instanceof Fallback )
		{
			Fallback fallback = (Fallback) restlet;

			for( Restlet fallbackRestlet : fallback.getTargets() )
			{
				if( fallbackRestlet == target )
				{
					found = true;
					break;
				}
			}

			if( found )
			{
				fallback.getTargets().remove( target );
				int size = fallback.getTargets().size();
				if( size == 1 )
					// No need for fallback anymore
					route.setNext( fallback.getTargets().get( 0 ) );
				else if( size == 0 )
					// No need for route anymore
					dead = route;
				break;
			}
		}
	}

	if( dead != null )
		getRoutes().remove( dead );
	else if( !found )
		super.detach( target );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:42,代码来源:FallbackRouter.java


示例13: createRoot

import org.restlet.routing.Route; //导入依赖的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


示例14: describeRoutes

import org.restlet.routing.Route; //导入依赖的package包/类
private void describeRoutes(StringBuilder b, Router router, String path) {
	RouteList routes = router.getRoutes();
	
	b.append("[").append(path).append("] = Router: ").append(router.getName()).append(": ").append(router.getDescription()).append("\n");
	
	for (Route r : routes) {
		if (r instanceof TemplateRoute) {
			describe(b, r.getNext(), path + ((TemplateRoute)r).getTemplate().getPattern());
		}
		
	}
	
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:14,代码来源:APIInfoResource.java



注:本文中的org.restlet.routing.Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConsumerConnection类代码示例发布时间:2022-05-22
下一篇:
Java StringGroovyMethods类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap