Class: Trinidad::Extensions::WorkerWebAppExtension::WorkerLifecycle

Inherits:
Lifecycle::Base
  • Object
show all
Defined in:
lib/trinidad_worker_extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ WorkerLifecycle

Returns a new instance of WorkerLifecycle.

Raises:

  • (ArgumentError)


72
73
74
75
# File 'lib/trinidad_worker_extension.rb', line 72

def initialize(params)
  @context_parameters = params || {}
  raise ArgumentError, "no context parameters" if @context_parameters.empty?
end

Instance Attribute Details

#context_parametersObject (readonly)

Returns the value of attribute context_parameters.



70
71
72
# File 'lib/trinidad_worker_extension.rb', line 70

def context_parameters
  @context_parameters
end

Instance Method Details

#configure_start(event) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/trinidad_worker_extension.rb', line 77

def configure_start(event)
  context = event.lifecycle
  configure = context.findApplicationListeners.any? # in rackup mode empty
  configure ||= Java::JavaLang::Boolean.getBoolean('trinidad.extensions.worker')
  unless configure
    context.logger.info "Skipped configuration of worker extension (due rackup mode)"
    return
  end
  add_context_parameters(context)
  add_class_loader_jar_url(context)
  # NOTE: it's important for this listener to be added after
  # the Rack setup as it expectd to find the RackFactory ...
  # that's why we hook into #configure_start which happens
  # right after #before_start but before the actual #start !
  add_application_listener(context)
end