当前位置: 首页>>代码示例>>Java>>正文


Java Template类代码示例

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


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

示例1: createInboundRoot

import org.restlet.routing.Template; //导入依赖的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;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:27,代码来源:RestApiServer.java

示例2: createInboundRoot

import org.restlet.routing.Template; //导入依赖的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;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:RestApiServer.java

示例3: beforeHandle

import org.restlet.routing.Template; //导入依赖的package包/类
/**
 * Handles the call after resolving any URI template on the request's target
 * resource reference.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
public int beforeHandle(Request request, Response response) {
    // Associate the response to the current thread
    Protocol protocol = request.getProtocol();

    if (protocol == null) {
        throw new UnsupportedOperationException(
                "Unable to determine the protocol to use for this call.");
    }

    String targetUri = request.getResourceRef().toString(true, false);

    if (targetUri.contains("{")) {
        // Template URI detected, create the template
        Template template = new Template(targetUri);

        // Set the formatted target URI
        request.setResourceRef(template.format(request, response));
    }

    request.setOriginalRef(ReferenceUtils.getOriginalRef(request.getResourceRef(), request.getHeaders()));
    return CONTINUE;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:32,代码来源:TemplateDispatcher.java

示例4: start

import org.restlet.routing.Template; //导入依赖的package包/类
/**
 * Starts the log service by attempting to read the log properties if the
 * {@link #getLogPropertiesRef()} returns a non null URI reference.
 */
@Override
public synchronized void start() throws Exception {
    super.start();

    this.responseLogTemplate = (getResponseLogFormat() == null) ? null
            : new Template(getResponseLogFormat());
    if (getLogPropertiesRef() != null) {
        Representation logProperties = new ClientResource(getContext(),
                getLogPropertiesRef()).get();

        if (logProperties != null) {
            java.util.logging.LogManager.getLogManager().readConfiguration(
                    logProperties.getStream());
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:LogService.java

示例5: createInboundRoot

import org.restlet.routing.Template; //导入依赖的package包/类
@Override
public synchronized Restlet createInboundRoot() {
    seqNo = SEQNO_PREFIX + mf.getNoToString();
    logger.info(seqNo + "\t" + "createInboundRoot() Start");
    Router router = new Router(getContext());

    router.attach(CST_PATH, ComponentManagerStarter.class);
    router.attach(NWCST_PATH, NWCStarter.class);
    router.attach(LGCST_PATH, LGCStarter.class);
    router.attach(CONNECTION_PATH, ConnectionCreator.class);
    router.attach(GUI_PATH, GUIRestApi.class);
    router.attach(ROUTER_PATH, RMNodeRestApi.class);
    router.attach(LAYERIZER_PATH, RMLinkLayerizerRestApi.class, Template.MODE_STARTS_WITH);

    logger.info(seqNo + "\t" + "createInboundRoot() End");
    return router;
}
 
开发者ID:o3project,项目名称:ocnrm,代码行数:18,代码来源:RMrouterApplication.java

示例6: redirectClient

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

示例7: handle

import org.restlet.routing.Template; //导入依赖的package包/类
@Override
public void handle( Request request, Response response )
{
	// RIAP ignores hide
	if( request.getProtocol() != Protocol.RIAP )
	{
		String remainingPart = request.getResourceRef().getRemainingPart();
		for( Template hiddenUriTemplate : hiddenUriTemplates )
		{
			if( hiddenUriTemplate.match( remainingPart ) != -1 )
			{
				response.setStatus( Status.CLIENT_ERROR_NOT_FOUND );
				return;
			}
		}
	}

	super.handle( request, response );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:20,代码来源:PrudenceRouter.java

示例8: getTargetRef

import org.restlet.routing.Template; //导入依赖的package包/类
@Override
protected Reference getTargetRef( Request request, Response response )
{
	// This is essentially the original Restlet code modified to use
	// ResolvingTemplate.

	// Create the template
	Template rt = new ResolvingTemplate( this.targetTemplate );
	rt.setLogger( getLogger() );

	// Return the formatted target URI
	if( new Reference( this.targetTemplate ).isRelative() )
		// Be sure to keep the resource's base reference.
		return new Reference( request.getResourceRef(), rt.format( request, response ) );

	return new Reference( rt.format( request, response ) );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:18,代码来源:ResolvingRedirector.java

示例9: createInboundRoot

import org.restlet.routing.Template; //导入依赖的package包/类
@Override
    public Restlet createInboundRoot() {
        // Create a router
        Router router = new Router(getContext());

        // Attach the resources to the router
        adminGuard = getAdminGuard();
        adminGuard.setNext(AdminResource.class);
        router.attach("/admin/{ares}/{idr}", adminGuard, Template.MODE_STARTS_WITH);
        router.attach("/admin/{ares}", adminGuard, Template.MODE_STARTS_WITH);
        router.attach("/admin", adminGuard, Template.MODE_STARTS_WITH);
//        Directory directory = new Directory(getContext(),getDocumentRoot());
//        directory.setIndexName("index.html");
        router.attach("/js", new Directory(getContext(),"file:///"+getDocumentRoot()+"/js"));
        router.attach("/css", new Directory(getContext(),"file:///"+getDocumentRoot()+"/css"));

        userGuard = getUserGuard();
        userGuard.setNext(PrintResource.class);
        router.attach("/print/", userGuard);
        router.attach("/", RootResource.class);
        
        
        // Return the root router
        return router;
    }
 
开发者ID:edabg,项目名称:fpgate,代码行数:26,代码来源:FPServer.java

示例10: createInboundRoot

import org.restlet.routing.Template; //导入依赖的package包/类
@Override
public Restlet createInboundRoot() {
	// encoding service that allows disabling
	setEncoderService(new OntopiaEncoderService());
	
	Router versions = new Router(getContext());
	versions.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
	versions.setRoutingMode(Router.MODE_BEST_MATCH);
	versions.setName("Ontopia API root router");
	
	versions.attach("/", APIInfoResource.class);
	
	for (APIVersions version : APIVersions.values()) {
		if (isEnabled(version)) {
			logger.info("Exposing API {}", version.getName());
			versions.attach("/" + version.getName(), new OntopiaAPIVersionFilter(getContext(), version.createChain(this), version));
		}
	}

	return versions;
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:22,代码来源:OntopiaRestApplication.java

示例11: ConfiguredHost

import org.restlet.routing.Template; //导入依赖的package包/类
/** Creates a new instance of ConfiguredHost */
public ConfiguredHost(Context context,Configuration.Server server,Configuration.Host hostConf)
{
   this.context = context;
   this.server = server;
   this.hostConf = hostConf;
   this.router = new Router(context);
   this.router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
   hostConf.attach(router);
   if (hostConf.getLogConfiguration().get("pattern")!=null) {
      String name = hostConf.getName();
      if (name.equals("*")) {
         name = "any";
      }
      name = "host."+name;
      this.hostLog = Logger.getLogger(name);
      setupLog();
   }
   this.defaultVHost = getVirtualHost(hostConf.getName());
   
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:22,代码来源:ConfiguredHost.java

示例12: createInboundRoot

import org.restlet.routing.Template; //导入依赖的package包/类
public Restlet createInboundRoot() {
   String viewValue = getContext().getParameters().getFirstValue("login.view");
   boolean viewEnabled = viewValue==null || "true".equals(viewValue.trim());
   
   Router router = new Router(getContext());
   if (viewEnabled) {
      getLogger().info("Enabling view on login.");
      router.attach("/",LoginView.class);
      router.attach("/js/",new ClassResourceFinder(getContext(),LoginApplication.class,"js")).getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
      router.attach("/logout",LogoutView.class);
   }  
   router.attach("/auth",LoginAction.class);
   router.attach("/status/check",CheckAction.class);
   router.attach("/status",StatusAction.class);
   router.attach("/expire",LogoutAction.class);
   return router;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:LoginApplication.java

示例13: createInboundRoot

import org.restlet.routing.Template; //导入依赖的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;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:26,代码来源:RestApiServer.java

示例14: attach

import org.restlet.routing.Template; //导入依赖的package包/类
protected TemplateRoute attach(Router router, Class<?> targetClass) {
    TemplateRoute route = null;
    Resource resource = AnnotationUtils.findAnnotation(targetClass, Resource.class);
    if (resource != null) {
        route = router.attach(resource.path(), new ServerResourceInjectedFinder(getContext(), targetClass));
        if (resource.strict()) {
            route.getTemplate().setMatchingMode(Template.MODE_EQUALS);
        } else {
            route.getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
        }
    } else {
        throw new RuntimeException("Resource " + targetClass + " require @Resouce annotation.");
    }

    return route;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:17,代码来源:ShindigRoute.java

示例15: attach

import org.restlet.routing.Template; //导入依赖的package包/类
/**
 * 
 * @param router
 * @param strict
 *            The matching mode to use when parsing a formatted reference.
 * @param uriPattern
 * @param target
 * @return
 */
@Override
public TemplateRoute attach(Router router, boolean strict, String uriPattern, Restlet target) {
	if (logger.isDebugEnabled()) {
		logger.debug("Attaching Restlet of class '" + target.getClass().getName() + "' to URI='" + uriPattern
				+ "' (strict='" + strict + "')");
	}

	TemplateRoute route = router.attach(uriPattern, target);

	if (strict) {
		route.getTemplate().setMatchingMode(Template.MODE_EQUALS);
	} else {
		route.getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
	}
	return route;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:26,代码来源:RestletSpringApplication.java


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