Sha256: 8e147d248d1711a73cb6a4e027b8348b383ae7ce2d83d787f4fe23a529d1af39

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 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#deploWAR and should be removed
          # once Lifecycle::Host inherits func 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

2 entries across 2 versions & 1 rubygems

Version Path
trinidad-1.4.5 lib/trinidad/lifecycle/web_app/war.rb
trinidad-1.4.5.B1 lib/trinidad/lifecycle/web_app/war.rb