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


Java Filter类代码示例

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


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

示例1: createInboundRoot

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

import org.restlet.routing.Filter; //导入依赖的package包/类
private Restlet createInterceptors( Filter guard )
{
    Filter inner = createInnerInterceptor();
    if( inner != null )
    {
        inner.setNext( router );
        guard.setNext( inner );             // guard -> interceptor -> router
    }
    else
    {
        guard.setNext( router );            // guard -> router
    }
    inner = guard;                      // inner = guard

    Filter outer = createOuterInterceptor();
    if( outer != null )
    {
        outer.setNext( inner );             // outer -> inner
        return outer;
    }
    return inner;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:23,代码来源:PolygeneRestApplication.java

示例4: createInboundRoot

import org.restlet.routing.Filter; //导入依赖的package包/类
/**
 * (non-Javadoc)
 * 
 * @see org.restlet.ext.jaxrs.JaxRsApplication#createInboundRoot()
 */
@Override
public Restlet createInboundRoot() {
	Restlet root = super.createInboundRoot();
	if (this.getFilters() != null) {
		Restlet next = root;
		for (int index = this.getFilters().size() - 1; index >= 0; index--) {
			Filter filter = this.getFilters().get(index);
			filter.setNext(next);
			next = filter;
		}
		return next;
	} else {
		return root;
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:21,代码来源:Application.java

示例5: createInboundRoot

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

示例6: ReportRouter

import org.restlet.routing.Filter; //导入依赖的package包/类
public ReportRouter(Context context, Application application) throws ConfigurationException, ValidationException {
	super(context);

	String reportsLocation = Configuration.getInstance().getProperty("slipstream.reports.location");

	Authorizer authorizer = new ReportsAuthorizer();
	Authenticator authenticator = new CookieAuthenticator(getContext());
	authenticator.setOptional(false);
	authenticator.setEnroler(new SuperEnroler(application));
	authenticator.setNext(authorizer);

	ResultsDirectory directory = new ResultsDirectory(getContext(), "file://" + reportsLocation);
	Filter decorator = new ReportDecorator();
	decorator.setNext(directory);
	authorizer.setNext(decorator);
	attach("", authenticator);
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:18,代码来源:ReportRouter.java

示例7: beforeHandle

import org.restlet.routing.Filter; //导入依赖的package包/类
/**
 * 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,代码行数:21,代码来源:CorsFilter.java

示例8: addInboundFilter

import org.restlet.routing.Filter; //导入依赖的package包/类
/**
 * Adds a new inbound filter to the chain.
 * 
 * @param filter
 *            The inbound filter to add.
 */
protected synchronized void addInboundFilter(Filter filter) {
    Restlet next = getInboundNext();

    if (getFirstInboundFilter() == null) {
        setFirstInboundFilter(filter);
    } else if (getLastInboundFilter() != null) {
        getLastInboundFilter().setNext(filter);
    }

    setLastInboundFilter(filter);
    setInboundNext(next);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:CompositeHelper.java

示例9: addOutboundFilter

import org.restlet.routing.Filter; //导入依赖的package包/类
/**
 * Adds a new outbound filter to the chain.
 * 
 * @param filter
 *            The outbound filter to add.
 */
protected synchronized void addOutboundFilter(Filter filter) {
    Restlet next = getOutboundNext();

    if (getFirstOutboundFilter() == null) {
        setFirstOutboundFilter(filter);
    } else if (getLastOutboundFilter() != null) {
        getLastOutboundFilter().setNext(filter);
    }

    setLastOutboundFilter(filter);
    setOutboundNext(next);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:19,代码来源:CompositeHelper.java

示例10: createInboundFilter

import org.restlet.routing.Filter; //导入依赖的package包/类
@Override
public Filter createInboundFilter(Context context) {
    return new CorsFilter().setAllowedCredentials(allowedCredentials)
            .setAllowedOrigins(allowedOrigins)
            .setAllowingAllRequestedHeaders(allowingAllRequestedHeaders)
            .setAllowedHeaders(allowedHeaders)
            .setExposedHeaders(exposedHeaders)
            .setSkippingResourceForCorsOptions(skippingResourceForCorsOptions)
            .setDefaultAllowedMethods(getDefaultAllowedMethods())
            .setMaxAge(maxAge);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:12,代码来源:CorsService.java

示例11: createInboundRoot

import org.restlet.routing.Filter; //导入依赖的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:zhenshengcai,项目名称:floodlight-hardware,代码行数:27,代码来源:RestApiServer.java

示例12: beforeHandle

import org.restlet.routing.Filter; //导入依赖的package包/类
@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,代码行数:33,代码来源:ExtensionMediaTypeFilter.java

示例13: beforeHandle

import org.restlet.routing.Filter; //导入依赖的package包/类
@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,代码行数:31,代码来源:ExtensionMediaTypeFilter.java

示例14: createInboundRoot

import org.restlet.routing.Filter; //导入依赖的package包/类
@Override
public Restlet createInboundRoot()
{
    Context context = getContext();
    Engine.getInstance().getRegisteredConverters().add( new PolygeneConverter( objectFactory ) );

    if( polygeneApplication.mode() == Application.Mode.development )
    {
        setDebugging( true );
    }
    router = new Router( context );

    addRoutes( router );
    router.attach( basePath, newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) );

    Verifier verifier = createVerifier();
    Enroler enroler = createEnroler();
    if( verifier == null && enroler == null )
    {
        return createInterceptors(new Filter()
            {
            } );
    }
    else
    {
        ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, getName() + " Realm" );

        if( verifier != null )
        {
            guard.setVerifier( verifier );
        }

        if( enroler != null )
        {
            guard.setEnroler( enroler );
        }
        return createInterceptors( guard );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:40,代码来源:PolygeneRestApplication.java

示例15: beforeHandle

import org.restlet.routing.Filter; //导入依赖的package包/类
@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,代码行数:37,代码来源:UnifyMinifyFilter.java


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