lib/mizuno.rb in mizuno-0.6.1 vs lib/mizuno.rb in mizuno-0.6.3

- old
+ new

@@ -2,25 +2,38 @@ # A Rack handler for Jetty 8. # # Written by Don Werve <don@madwombat.com> # +require 'java' + # Save our launch environment for spawning children later. module Mizuno LAUNCH_ENV = $LOAD_PATH.map { |i| "-I#{i}" }.push($0) -end -# Load up Java dependencies. -require 'java' -jars = File.join(File.dirname(__FILE__), 'java', '*.jar') -Dir[jars].each { |j| require j } + HOME = File.expand_path(File.dirname(__FILE__)) -# Tell log4j not to complain to the console about a missing -# log4j.properties file, as we configure it programmatically in -# Mizuno::HttpServer (http://stackoverflow.com/questions/6849887) -Java.org.apache.log4j.Logger.getRootLogger.setLevel( \ - Java.org.apache.log4j.Level::INFO) + # + # Tell log4j not to complain to the console about a missing + # log4j.properties file, as we configure it programmatically in + # Mizuno::Server (http://stackoverflow.com/questions/6849887) + # + def Mizuno.initialize_logger + require_jars(%w(log4j slf4j-api slf4j-log4j12)) + Java.org.apache.log4j.Logger.getRootLogger.setLevel( \ + Java.org.apache.log4j.Level::INFO) + end -require 'rack' -require 'mizuno/rack/chunked' -require 'mizuno/rack_servlet' -require 'mizuno/http_server' + # + # Loads jarfiles independent of versions. + # + def Mizuno.require_jars(*names) + names.flatten.each do |name| + file = Dir[File.join(HOME, 'java', "#{name}-*.jar")].first + file ||= Dir[File.join(HOME, 'java', "#{name}.jar")].first + raise("Unknown or missing jar: #{name}") unless file + require file + end + end +end + +Mizuno.initialize_logger