class PIM::Services::ProxyService

Public Class Methods

has_external_service?(name = nil) click to toggle source
# File services.rb, line 46
def self.has_external_service? name = nil

  unless name.nil?
    # FIXME: Add a "callback" to determine if the specified service actually exists!
    return false if DISABLED_EXTERNAL_SERVICES.include?(name.to_s)
  end

  return ::Object.private_method_defined?(:__external_service_callback)
end
has_java_service?(name = nil) click to toggle source
# File services.rb, line 56
def self.has_java_service? name = nil
  return false unless PIM.has_java?
  begin
    java_import 'com.lansa.lax.ruby.ServicesRegistry'
    return com.lansa.lax.ruby.ServicesRegistry.has_service(name) unless name.nil?
    return com.lansa.lax.ruby.ServicesRegistry.has_any_service()
  rescue NameError
    return false
  end
end
has_service?(name) click to toggle source
# File services.rb, line 42
def self.has_service? name
  return (has_external_service?(name) or has_java_service?(name))
end
new(service_name) click to toggle source
# File services.rb, line 17
def initialize service_name
  @service_name = service_name.to_s
end

Public Instance Methods

method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File services.rb, line 21
def method_missing name, *args, &block

  if ProxyService.has_external_service?(@service_name)

    # Call '__external_service_callback' method directly
    return __external_service_callback(@service_name, name.to_s, *args)

  elsif ProxyService.has_java_service?(@service_name)

    # Use service defined in Java services registry
    # TODO: Ensure only methods are being called which have the proper annotation!
    java_service = com.lansa.lax.ruby.ServicesRegistry.get_service(@service_name)
    raise "No java service for '#{@service_name}' registered" if java_service.nil?
    return java_service.send(name, *args, &block)

  end

  super

end