當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。