Class SpaBundle

  • All Implemented Interfaces:
    ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle

    public class SpaBundle
    extends java.lang.Object
    implements ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
    Provides support for SPA (for example, angular apps). Such applications often use html5 pretty url, like "/app/someroute/subroute". When user bookmark such url or simply refresh page, browser requests complete url on server and server must support it: redirect to main index page (without changing url, so client could handle routing).

    Use dropwizard-assets servlet internally, but wraps it with special filter, which reacts on resource not found errors (by default, all calls pass to assets filter!). Applies no-cache header for index page.

    You can register multiple SPA applications on main or admin contexts (or both). All applications must have unique names. In case of duplicate names or mapping on the same path, error will be thrown.

    Since:
    02.04.2017
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SpaBundle.Builder
      Spa bundle builder.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_PATTERN  
    • Constructor Summary

      Constructors 
      Constructor Description
      SpaBundle()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SpaBundle.Builder adminApp​(java.lang.String name, java.lang.String resourcePath, java.lang.String uriPath)
      Register SPA application in admin context.
      static SpaBundle.Builder app​(java.lang.String name, java.lang.String resourcePath, java.lang.String uriPath)
      Register SPA application in main context.
      void initialize​(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap)  
      void run​(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • SpaBundle

        public SpaBundle()
    • Method Detail

      • initialize

        public void initialize​(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBootstrap bootstrap)
        Specified by:
        initialize in interface ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
      • run

        public void run​(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment)
        Specified by:
        run in interface ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyBundle
      • app

        public static SpaBundle.Builder app​(java.lang.String name,
                                            java.lang.String resourcePath,
                                            java.lang.String uriPath)
        Register SPA application in main context. Note: application names must be unique (when you register multiple SPA applications.
        Parameters:
        name - application name (used as servlet name)
        resourcePath - application resources classpath location (may use slash or dots as separator)
        uriPath - mapping uri
        Returns:
        builder instance for SPA configuration
      • adminApp

        public static SpaBundle.Builder adminApp​(java.lang.String name,
                                                 java.lang.String resourcePath,
                                                 java.lang.String uriPath)
        Register SPA application in admin context. Note: application names must be unique (when you register multiple SPA applications.
        Parameters:
        name - application name (used as servlet name)
        resourcePath - path to application resources (classpath)
        uriPath - mapping uri
        Returns:
        builder instance for SPA configuration