Class: LogStash::Inputs::Log4j::Log4jInputStream

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/log4j.rb

Constant Summary collapse

ALLOWED_CLASSES =
["org.apache.log4j.spi.LoggingEvent"]

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Log4jInputStream

Returns a new instance of Log4jInputStream.



264
265
266
267
# File 'lib/logstash/inputs/log4j.rb', line 264

def initialize(*args)
  super
  @class_loader = org.jruby.Ruby.getGlobalRuntime.getJRubyClassLoader 
end

Instance Method Details

#resolveClass(desc) ⇒ Object



273
274
275
276
277
# File 'lib/logstash/inputs/log4j.rb', line 273

def resolveClass(desc)
  name = desc.getName
  safety_check(name)
  java.lang.Class.forName(name, false, @class_loader)
end

#safety_check(name) ⇒ Object

Raises:

  • (java.io.InvalidObjectException)


269
270
271
# File 'lib/logstash/inputs/log4j.rb', line 269

def safety_check(name)
  raise java.io.InvalidObjectException.new("Object type #{name} is not allowed.") if !ALLOWED_CLASSES.include?(name)
end