component.go 606 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package mhayaFacade
  2. type (
  3. IComponent interface {
  4. Name() string
  5. App() IApplication
  6. IComponentLifecycle
  7. }
  8. IComponentLifecycle interface {
  9. Set(app IApplication)
  10. Init()
  11. OnAfterInit()
  12. OnBeforeStop()
  13. OnStop()
  14. }
  15. )
  16. // Component base component
  17. type Component struct {
  18. app IApplication
  19. }
  20. func (*Component) Name() string {
  21. return ""
  22. }
  23. func (p *Component) App() IApplication {
  24. return p.app
  25. }
  26. func (p *Component) Set(app IApplication) {
  27. p.app = app
  28. }
  29. func (*Component) Init() {
  30. }
  31. func (*Component) OnAfterInit() {
  32. }
  33. func (*Component) OnBeforeStop() {
  34. }
  35. func (*Component) OnStop() {
  36. }