Class: RBoss::Slimming

Inherits:
Object
  • Object
show all
Includes:
FileUtils, Component
Defined in:
lib/rboss/components/slimming.rb

Overview

A class for slimming a JBoss profile

Configuration:

Pass an array with the services to remove, the current supported are:

Admin Console       => :admin_console
Web Console         => :web_console
Mail Service        => :mail
BeanShell           => :bean_shell
Hot Deploy          => :hot_deploy
UDDI                => :uddi
UUID Key Generator  => :key_generator
Scheduling          => :scheduling
JMX Console         => :jmx_console
JBoss WS            => :jboss_ws
JMX Remoting        => :jmx_remoting
ROOT Page           => :root_page
Management          => :management
IIOP                => :iiop
JBoss Web           => :jboss_web
SNMP                => :snmp
Profile Service     => :profile
EJB3                => :ejb3
EJB2                => :ejb2
JMX Invoker         => :jmx_invoker
HA HTTP Invoker     => :ha_http_invoker
Legacy Invoker      => :legacy_invoker
Transaction         => :transaction
Remoting            => :remoting
Properties Service  => :properties
Database/Datasource => :database
JSR-88              => :jsr88
XNIO                => :xnio

author: Marcelo Guimarães <[email protected]>

Direct Known Subclasses

Restore

Instance Method Summary collapse

Methods included from Component

#initialize, #load_yaml, #new_file_processor

Instance Method Details

#configure(services_to_remove) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/rboss/components/slimming.rb', line 65

def configure services_to_remove
  @services_to_remove = [*services_to_remove]
  @mapping = {}
  load_yaml('slimming').each do |key, values|
    @mapping[key.to_sym] = values
  end
end

#handle(file) ⇒ Object



100
101
102
103
# File 'lib/rboss/components/slimming.rb', line 100

def handle file
  file = "#{@jboss.profile}/" + file unless file.start_with? '/'
  mv(file, file + ".rej") if File.exist? file
end

#log(service) ⇒ Object



96
97
98
# File 'lib/rboss/components/slimming.rb', line 96

def log service
  @logger.info "Disabling #{service}"
end

#processObject



73
74
75
76
77
78
# File 'lib/rboss/components/slimming.rb', line 73

def process
  @services_to_remove.each do |service|
    log service
    slim service
  end
end

#slim(service) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rboss/components/slimming.rb', line 80

def slim service
  sym = service.to_s.gsub(/-/, '_').to_sym
  entry = @mapping[sym]
  method = "remove_#{service}".to_sym
  if respond_to? method
    self.send method
  elsif entry
    entry.each do |file|
      handle file if file.is_a? String
      slim file if file.is_a? Symbol
    end
  else
    raise "Unrecognized service: #{service}"
  end
end