Sha256: 3ae1817f2c4ccb9596bcd69a9d3e04a38bf54c68eaea3cdce8897c0d465454a0

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'trinidad/lifecycle/base'
require 'trinidad/lifecycle/web_app/shared'

module Trinidad
  module Lifecycle
    module WebApp
      class War < Base
        include Shared

        def before_init(event)
          # NOTE: esp. important for .war applications that the name matches the path
          # to work-around ProxyDirContext constructor's `contextPath = contextName;`
          # @see {#adjust_context} also need to restore possible context name change!
          context = event.lifecycle
          context.name = context.path if context.name
          super
        end

        def configure(context)
          super # Shared#configure
          configure_class_loader(context)
        end

        protected

        def adjust_context(context)
          name = context.name
          super
        ensure # @see {#before_init}
          context.name = name
          # NOTE: mimics HostConfig#deployWAR and might/should be removed
          # once Lifecycle::Host inherits functionality from HostConfig ...
          # context_name = Trinidad::Tomcat::ContextName.new(name)
          # context.setName context_name.getName()
          # context.setPath context_name.getPath()
          # context.setWebappVersion context_name.getVersion()
          # context.setDocBase context_name.getBaseName() + '.war'
        end

        def configure_class_loader(context)
          class_loader = web_app.class_loader || JRuby.runtime.jruby_class_loader
          loader = Trinidad::Tomcat::WebappLoader.new(class_loader)
          loader.container = context
          context.loader = loader
        end

        def remove_defaults(context = nil)
          # NOTE: do not remove defaults (welcome files)
        end

      end
    end
    War = Trinidad::Lifecycle::WebApp::War # backwards compatibility
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trinidad-1.4.6 lib/trinidad/lifecycle/web_app/war.rb