All Downloads are FREE. Search and download functionalities are using the official Maven repository.

public.javadoc.org.spincast.plugins.routing.SpincastRouter.html Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version






SpincastRouter (org.spincast:spincast-framework 0.9.25 API)












org.spincast.plugins.routing

Class SpincastRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>

    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

    • Method Detail

      • init

        @Inject
        protected void init()
      • validation

        protected void validation()
      • addDefaultFilters

        protected void addDefaultFilters()
      • getServer

        protected IServer getServer()
      • getGlobalBeforeFiltersPerPosition

        protected Map<Integer,List<IRoute<R>>> getGlobalBeforeFiltersPerPosition()
      • getGlobalAfterFiltersPerPosition

        protected Map<Integer,List<IRoute<R>>> getGlobalAfterFiltersPerPosition()
      • validateId

        protected void validateId(String id)
      • validatePath

        protected void validatePath(String path)
        Validate the path of a route. Throws an exception if not valide.
      • route

        public IRoutingResult<R> route(R requestContext)
        Description copied from interface: IRouter
        Find the route to use to handle the current request. The result contains all handlers to use.
        Specified by:
        route in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        Returns:
        the routing result or null if no route matches.
      • route

        public IRoutingResult<R> route(R requestContext,
                                       RoutingType routingType)
        Description copied from interface: IRouter
        Find the route to use to handle the current request, given the specified routing type. The result contains all handlers to use.
        Specified by:
        route in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        Returns:
        the routing result or null if no route matches.
      • isRoutingTypeMatch

        protected boolean isRoutingTypeMatch(RoutingType routingType,
                                             IRoute<R> route)
      • createRegularHandlerMatches

        protected List<IRouteHandlerMatch<R>> createRegularHandlerMatches(RoutingType routingType,
                                                                          IRoute<R> route,
                                                                          HttpMethod httpMethod,
                                                                          List<String> acceptedContentTypes,
                                                                          URL url,
                                                                          int position)
        Get the matches (filters and main handle) if the route matches the URL and HTTP method, or returns NULL otherwise.
      • isRouteMatchAcceptedContentType

        protected boolean isRouteMatchAcceptedContentType(IRoute<R> route,
                                                          List<String> requestContentTypes)
      • createNoMatchingParamsHandlerMatch

        protected IRouteHandlerMatch<R> createNoMatchingParamsHandlerMatch(IRoute<R> route,
                                                                           String id,
                                                                           IHandler<R> handler,
                                                                           int position)
        Creates an handler match with no matching params.
      • createHandlerMatchForBeforeOrAfterFilter

        protected IRouteHandlerMatch<R> createHandlerMatchForBeforeOrAfterFilter(IRouteHandlerMatch<R> mainRouteHandlerMatch,
                                                                                 IHandler<R> beforeOrAfterMethod,
                                                                                 int position)
        Creates a new match for a "before" or "after" handler specific to a route. THis measn keeping the same informations as the main handler.
      • isRouteMatchHttpMethod

        protected boolean isRouteMatchHttpMethod(IRoute<R> route,
                                                 HttpMethod httpMethod)
        Validate if a route matches the given HTTP method.
      • validatePath

        protected Map<String,String> validatePath(String routePath,
                                                  URL url)
        Validate if url matches the path of the route and if so, returns the parsed parameters, if any. Returns NULL if there is no match.
      • getPatternFromAlias

        protected String getPatternFromAlias(String alias)
        Get a path pattern from its alias.
        Returns:
        the pattern or NULL if not found.
      • addRouteParamPatternAlias

        public void addRouteParamPatternAlias(String alias,
                                              String pattern)
        Description copied from interface: IRouter
        Adds an alias for a path pattern. For example, the path of a route may be "/${param1:<XXX>}" : here "XXX" is the alias for the regular expression pattern to use.
        Specified by:
        addRouteParamPatternAlias in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • before

        public void before(IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a "before" filter. Synonym of : ALL("/*{path}").pos(-1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        before in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • before

        public void before(String path,
                           IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a "before" filter. Synonym of : ALL(path).pos(-1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        before in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • after

        public void after(IHandler<R> handler)
        Description copied from interface: IRouter
        Creates an "after" filter. Synonym of : ALL("/*{path}").pos(1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        after in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • after

        public void after(String path,
                          IHandler<R> handler)
        Description copied from interface: IRouter
        Creates an "after" filter. Synonym of : ALL(path).pos(1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        after in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • beforeAndAfter

        public void beforeAndAfter(IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a "before" and an "after" filters. Synonym of : ALL("/*{path}").pos(-1).save(handler) and ALL("/*{path}").pos(1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        beforeAndAfter in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • beforeAndAfter

        public void beforeAndAfter(String path,
                                   IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a "before" and an "after" filters. Synonym of : ALL(path).pos(-1).save(handler) and ALL(path).pos(1).save(handler) and with the Routing types as returned by ISpincastRouterConfig#getFilterDefaultRoutingTypes()
        Specified by:
        beforeAndAfter in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • exception

        public void exception(IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a route considered during an "Exception" routing process. Synonym of : ALL("/*{path}").exception().save(handler)
        Specified by:
        exception in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • notFound

        public void notFound(IHandler<R> handler)
        Description copied from interface: IRouter
        Creates a route considered during an "Not Found" routing process. Synonym of : ALL("/*{path}").notFound().save(handler)
        Specified by:
        notFound in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
      • cors

        public void cors()
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on all matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context)
      • cors

        public void cors(Set<String> allowedOrigins)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins)
      • cors

        public void cors(Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeReadt)
      • cors

        public void cors(Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
      • cors

        public void cors(Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
      • cors

        public void cors(Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies,
                         Set<HttpMethod> allowedMethods)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
      • cors

        public void cors(Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies,
                         Set<HttpMethod> allowedMethods,
                         int maxAgeInSeconds)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on matching requests (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
      • cors

        public void cors(String path)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on all requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies,
                         Set<HttpMethod> allowedMethods)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods)
      • cors

        public void cors(String path,
                         Set<String> allowedOrigins,
                         Set<String> extraHeadersAllowedToBeRead,
                         Set<String> extraHeadersAllowedToBeSent,
                         boolean allowCookies,
                         Set<HttpMethod> allowedMethods,
                         int maxAgeInSeconds)
        Description copied from interface: IRouter
        Enables Cross-Origin Resource Sharing (Cors) on requests matching the specified path (except the static resources, for whom cors has to be activated directly!)
        Specified by:
        cors in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        See Also:
        ISpincastFilters#cors(R context, Set<String> allowedOrigins, Set<String> extraHeadersAllowedToBeRead, Set<String> extraHeadersAllowedToBeSent, boolean allowCookies, Set<HttpMethod> allowedMethods, int maxAgeInSeconds)
      • file

        public IStaticResourceBuilder<R> file(String url)
        Description copied from interface: IRouter
        Start the creation of a static resource file.

        Only a GET or a HEAD request will be able to access this resource.

        No "before" and "after" filters will be applied to those, since the request won't even reach the framework.

        Specified by:
        file in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        Parameters:
        url - The url which will trigger the output of this static resource.
      • dir

        public IStaticResourceBuilder<R> dir(String url)
        Description copied from interface: IRouter
        Start the creation of a static resource directory.

        Only a GET or a HEAD request will be able to access the resources below this directory.

        No "before" and "after" filters will be applied to those, since the request won't even reach the framework.

        Specified by:
        dir in interface IRouter<R extends IRequestContext<?>,W extends IWebsocketContext<?>>
        Parameters:
        url - The url which will trigger the output of this static resource.
      • isCreateStaticResourceOnDisk

        protected boolean isCreateStaticResourceOnDisk()
      • createHttpRouteFromWebsocketRoute

        protected IRoute<R> createHttpRouteFromWebsocketRoute(IWebsocketRoute<R,W> websocketRoute)

Copyright © 2016. All rights reserved.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy