Class: TorqueBox::MSC

Inherits:
Object
  • Object
show all
Defined in:
core/lib/torquebox/msc.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) deployment_unit



28
29
30
# File 'core/lib/torquebox/msc.rb', line 28

def deployment_unit
  TorqueBox::Registry['deployment-unit']
end

+ (Object) get_service(service_name)



36
37
38
# File 'core/lib/torquebox/msc.rb', line 36

def get_service(service_name)
  service_registry.get_service(service_name)
end

+ (Object) get_services(regexp, &block)



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'core/lib/torquebox/msc.rb', line 49

def get_services(regexp, &block)
  services = []

  TorqueBox::MSC.service_names.each do |name|
    if name.canonical_name =~ regexp
      service = TorqueBox::MSC.get_service(name)
      services << service unless service.nil?
    end
  end

  if block
    services.each do |s|
      yield s
    end
  else
    services
  end
end

+ (Object) java_web_context



68
69
70
71
72
73
74
75
76
77
78
# File 'core/lib/torquebox/msc.rb', line 68

def java_web_context
   = deployment_unit.get_attachment(org.jboss.as.web.deployment.WarMetaData::ATTACHMENT_KEY)
  return nil if .nil? # no web component in this application
   = .
  virtual_host = .virtual_hosts.first || 'default-host'
  context_path = .context_root
  context_path = "/#{context_path}" unless context_path.start_with?('/')
  deployment_service_name = org.jboss.msc.service.ServiceName.parse("jboss.web.deployment")
  service_name = deployment_service_name.append(virtual_host).append(context_path)
  get_service(service_name).value
end

+ (Object) service_names



32
33
34
# File 'core/lib/torquebox/msc.rb', line 32

def service_names
  service_registry.service_names
end

+ (Object) service_registry



24
25
26
# File 'core/lib/torquebox/msc.rb', line 24

def service_registry
  TorqueBox::Registry['service-registry']
end

+ (Object) wait_for_service_to_start(service, seconds_to_wait)



87
88
89
90
91
92
93
94
95
# File 'core/lib/torquebox/msc.rb', line 87

def wait_for_service_to_start(service, seconds_to_wait)
  unless service.state.to_s == 'UP'
    listener = org.torquebox.core.gem.MSCServiceListener.new(service)
    service.add_listener(listener)
    service.set_mode(org.jboss.msc.service.ServiceController::Mode::ACTIVE)
    listener.wait_for_start_or_failure(seconds_to_wait)
  end
  service.state.to_s
end