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


Java Filter.CONTINUE属性代码示例

本文整理汇总了Java中org.restlet.routing.Filter.CONTINUE属性的典型用法代码示例。如果您正苦于以下问题:Java Filter.CONTINUE属性的具体用法?Java Filter.CONTINUE怎么用?Java Filter.CONTINUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.restlet.routing.Filter的用法示例。


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

示例1: createInboundRoot

@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,代码行数:26,代码来源:RestApiServer.java

示例2: createInboundRoot

@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,代码行数:26,代码来源:RestApiServer.java

示例3: createInboundRoot

@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,代码行数:25,代码来源:RestApiServer.java

示例4: beforeHandle

/**
 * Skip the call to the server resource if the {@link #skippingResourceForCorsOptions} is true and if the current
 * request use the OPTIONS method and is a CORS request.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
@Override
protected int beforeHandle(Request request, Response response) {
    if (skippingResourceForCorsOptions
            && Method.OPTIONS.equals(request.getMethod())
            && getCorsResponseHelper().isCorsRequest(request)) {
        response.setAllowedMethods(getDefaultAllowedMethods());
        return Filter.SKIP;
    } else {
        return Filter.CONTINUE;
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:20,代码来源:CorsFilter.java

示例5: createInboundRoot

@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:zhenshengcai,项目名称:floodlight-hardware,代码行数:26,代码来源:RestApiServer.java

示例6: beforeHandle

@Override
protected int beforeHandle( Request request, Response response )
{
    List<String> segments = request.getResourceRef().getSegments();
    if( segments.get( segments.size() - 1 ).equals( "" ) )
    {
        return Filter.CONTINUE;
    }

    String extensions = request.getResourceRef().getExtensions();
    if( extensions != null )
    {
        int idx = extensions.lastIndexOf( "." );
        if( idx != -1 )
        {
            extensions = extensions.substring( idx + 1 );
        }

        MetadataService metadataService = getApplication().getMetadataService();
        Metadata metadata = metadataService.getMetadata( extensions );
        if( metadata != null && metadata instanceof MediaType )
        {
            request.getClientInfo()
                .setAcceptedMediaTypes( Collections.singletonList( new Preference<MediaType>( (MediaType) metadata ) ) );
            String path = request.getResourceRef().getPath();
            path = path.substring( 0, path.length() - extensions.length() - 1 );
            request.getResourceRef().setPath( path );
        }
    }

    return Filter.CONTINUE;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:32,代码来源:ExtensionMediaTypeFilter.java

示例7: beforeHandle

@Override
protected int beforeHandle( Request request, Response response )
{
    List<String> segments = request.getResourceRef().getSegments();
    if (segments.get( segments.size()-1 ).equals(""))
      return Filter.CONTINUE;

    String extensions = request.getResourceRef().getExtensions();
    if( extensions != null )
    {
        int idx = extensions.lastIndexOf( "." );
        if( idx != -1 )
        {
            extensions = extensions.substring( idx + 1 );
        }

        MetadataService metadataService = getApplication().getMetadataService();
        Metadata metadata = metadataService.getMetadata( extensions );
        if( metadata != null && metadata instanceof MediaType )
        {
            request.getClientInfo()
                .setAcceptedMediaTypes( Collections.singletonList( new Preference<>( (MediaType) metadata ) ) );
            String path = request.getResourceRef().getPath();
            path = path.substring( 0, path.length() - extensions.length() - 1 );
            request.getResourceRef().setPath( path );
        }
    }

    return Filter.CONTINUE;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:30,代码来源:ExtensionMediaTypeFilter.java

示例8: beforeHandle

@Override
protected int beforeHandle( Request request, Response response )
{
	Reference reference = request.getResourceRef();
	String name = reference.getLastSegment( true, false );
	try
	{
		boolean validate = false;
		boolean minify = false;
		if( name.equals( unifiedFilename ) )
			validate = true;
		else if( name.equals( unifiedMinifiedFilename ) )
		{
			validate = true;
			minify = true;
		}

		if( validate )
		{
			long now = System.currentTimeMillis();
			long lastValidityCheck = this.lastValidityCheck.get();
			if( lastValidityCheck == 0 || ( now - lastValidityCheck > minimumTimeBetweenValidityChecks ) )
			{
				if( this.lastValidityCheck.compareAndSet( lastValidityCheck, now ) )
					unify( targetDirectory, minify );
			}
		}
	}
	catch( IOException x )
	{
		response.setStatus( Status.SERVER_ERROR_INTERNAL, x );
		return Filter.STOP;
	}

	return Filter.CONTINUE;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:36,代码来源:UnifyMinifyFilter.java

示例9: beforeHandle

protected int beforeHandle(Request request, Response response) {
   Object o = request.getAttributes().get(DB_NAME_ATTRIBUTE);
   String dbName = o==null ? null : o.toString();
   if (dbName!=null) {
      for (String name : names) {
         String value = getValue(name,dbName,request);
         if (value!=null) {
            request.getAttributes().put(name, value);
         }
      }
      request.getAttributes().put(APP_PATH_ATTRIBUTE,request.getResourceRef().getBaseRef().getPath());
   }
   return Filter.CONTINUE;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:14,代码来源:DatabaseNameFilter.java

示例10: beforeHandle

protected int beforeHandle(Request request, Response response) {
   if (cacheDir==null || duration<1) {
      return Filter.CONTINUE;
   }
   String href = request.getResourceRef().getRemainingPart();
   getLogger().info("Checking cache for "+href);
   request.getAttributes().put("cache.href", href);
   File cacheFile = getCacheFile(href);
   File cacheMetadataFile = getCacheMetadataFile(href);
   if (cacheFile.exists()) {
      if (isCacheValid(cacheFile.lastModified(),request)) {
         getLogger().info("Using cache file: "+cacheFile);
         try {
            makeResponse(cacheFile,cacheMetadataFile,response);
         } catch (IOException ex) {
            getLogger().log(Level.SEVERE,"I/O error processing cache files.",ex);
            response.setStatus(Status.SERVER_ERROR_INTERNAL, "I/O error processing cache files.");
            return Filter.STOP;
         }
         return Filter.STOP;
      } else {
         cacheFile.delete();
         cacheMetadataFile.delete();
      }
   } else if (cacheMetadataFile.exists()) {
      cacheMetadataFile.delete();
   }
   return Filter.CONTINUE;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:29,代码来源:ResponseCacheFilter.java

示例11: beforeHandle

protected int beforeHandle(Request request,Response response) {
   if (request.getMethod().equals(Method.OPTIONS)) {
      response.setStatus(Status.SUCCESS_NO_CONTENT);
      addAccessControl(response);
      return Filter.STOP;
   }
   return Filter.CONTINUE;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:8,代码来源:CORSFilter.java

示例12: beforeHandle

protected int beforeHandle(Request request,Response response) {
   for (SecureRoute route : routes) {
      getLogger().info("Checking "+route.getTemplate().getPattern()+" against "+request.getResourceRef().getRemainingPart());
      if (route.matches(request)) {
         getLogger().info("Route matched, checking authorization...");
         switch (route.area.isAuthorized(request)) {
            case -1: // No identity
               if (route.area.getLoginReference()==null) {
                  response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
               } else {
                  getLogger().info("No identity, redirecting to "+route.area.getLoginReference()+" for login.");
                  response.redirectSeeOther(route.area.getLoginReference()+"?url="+request.getResourceRef());
               }
               return Filter.STOP;
            case 0: // Not authorized
               if (route.area.getNotAuthorizedReference()==null) {
                  response.setStatus(Status.CLIENT_ERROR_FORBIDDEN);
               } else {
                  getLogger().info("Not authorized , redirecting to "+route.area.getNotAuthorizedReference());
                  response.redirectSeeOther(route.area.getNotAuthorizedReference()+"?url="+request.getResourceRef());
               }
               return Filter.STOP;
            case 1: // OK
               return Filter.CONTINUE;
         }
      }
   }
   return Filter.CONTINUE;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:29,代码来源:SecurityGuard.java

示例13: createInboundRoot

/**
 * Sets up the Restlet for the APIs under test using a Router.  Also, a
 * filter is installed to deal with double slashes in URLs.
 * This code is adapted from
 * net.floodlightcontroller.restserver.RestApiServer
 *
 * @return Router object for the APIs under test.
 */
@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 out multiple slashes in URLs to make them a single slash.
     */
    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,代码行数:36,代码来源:TestRestApiServer.java

示例14: beforeHandle

@Override
protected int beforeHandle( Request request, Response response )
{
	request.getAttributes().put( ATTRIBUTE, virtualHost );
	return Filter.CONTINUE;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:6,代码来源:VirtualHostInjector.java

示例15: beforeHandle

@Override
protected int beforeHandle( Request request, Response response )
{
	Reference reference = request.getResourceRef();
	String path = reference.getRemainingPart( true, false );
	try
	{
		// String name = reference.getLastSegment( true, false );
		String zussPath = null;
		boolean minify = false;
		if( path.endsWith( CSS_MIN_EXTENSION ) )
		{
			zussPath = path.substring( 0, path.length() - CSS_MIN_EXTENSION_LENGTH ) + ZUSS_EXTENSION;
			minify = true;
		}
		else if( path.endsWith( CSS_EXTENSION ) )
			zussPath = path.substring( 0, path.length() - CSS_EXTENSION_LENGTH ) + ZUSS_EXTENSION;

		if( zussPath != null )
		{
			long now = System.currentTimeMillis();
			AtomicLong lastValidityCheckAtomic = getLastValidityCheck( path );
			long lastValidityCheck = lastValidityCheckAtomic.get();
			if( lastValidityCheck == 0 || ( now - lastValidityCheck > minimumTimeBetweenValidityChecks ) )
			{
				if( lastValidityCheckAtomic.compareAndSet( lastValidityCheck, now ) )
				{
					for( File sourceDirectory : sourceDirectories )
					{
						File zussFile = new File( sourceDirectory, zussPath );
						if( zussFile.exists() )
						{
							File cssFile = new File( targetDirectory, path );
							translate( zussFile, cssFile, minify );
							break;
						}
					}

					// ZUSS file was not found, so don't keep the entry for
					// it
					this.lastValidityChecks.remove( path );
				}
			}
		}
	}
	catch( IOException x )
	{
		response.setStatus( Status.SERVER_ERROR_INTERNAL, x );
		return Filter.STOP;
	}

	return Filter.CONTINUE;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:53,代码来源:ZussFilter.java


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