GhApplication.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package hello;
  2. import hello.home.entity.*;
  3. import hello.home.handler.*;
  4. import com.techempower.*;
  5. import com.techempower.gemini.*;
  6. import com.techempower.gemini.exceptionhandler.*;
  7. import com.techempower.gemini.path.*;
  8. import com.techempower.gemini.pyxis.*;
  9. import com.techempower.js.*;
  10. /**
  11. * GeminiHello Application. As a subclass of GeminiApplication, this
  12. * class acts as the central "hub" of references to components such as
  13. * the Dispatcher and EntityStore.
  14. *
  15. * Development history:
  16. * 2012-04-19 - mh - Created
  17. *
  18. * @author mhixson
  19. */
  20. public class GhApplication
  21. extends GeminiApplication
  22. {
  23. //
  24. // Static variables.
  25. //
  26. private static final GhApplication INSTANCE = new GhApplication();
  27. //
  28. // Member methods.
  29. //
  30. /**
  31. * Constructor. This method can be extended to construct references
  32. * to custom components for the application.
  33. */
  34. public GhApplication()
  35. {
  36. super();
  37. }
  38. //
  39. // Protected component constructors.
  40. //
  41. /**
  42. * Constructs a Version reference. This is overloaded to return a
  43. * custom GhVersion object.
  44. */
  45. @Override
  46. protected Version constructVersion()
  47. {
  48. return new GhVersion();
  49. }
  50. /**
  51. * Creates a JavaScriptWriter for writing JSON.
  52. */
  53. @Override
  54. protected JavaScriptWriter constructJavaScriptWriter()
  55. {
  56. return JavaScriptWriter.custom()
  57. .addVisitorFactory(World.class, World.VISITOR_FACTORY)
  58. .build();
  59. }
  60. /**
  61. * Constructs a Dispatcher.
  62. */
  63. @Override
  64. protected Dispatcher constructDispatcher()
  65. {
  66. final PathDispatcher.Configuration<Context> config = new PathDispatcher.Configuration<>();
  67. config.setDefault(new HelloHandler(this))
  68. .add(new BasicExceptionHandler(this));
  69. return new PathDispatcher<>(this, config);
  70. }
  71. //
  72. // Static methods.
  73. //
  74. public static GhApplication getInstance()
  75. {
  76. return INSTANCE;
  77. }
  78. } // End GhApplication.