Class: VertxServiceDiscovery::ServiceReference
- Inherits:
- 
      Object
      
        - Object
- VertxServiceDiscovery::ServiceReference
 
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb
Overview
    Once a consumer has chosen a service, it builds a ServiceReference managing the binding with the chosen
 service provider.
 
The reference lets the consumer: * access the service (via a proxy or a client) with the #get method * release the reference - so the binding between the consumer and the provider is removed
Constant Summary
- @@j_api_type =
- Object.new 
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
- 
  
    
      - (Object) cached 
    
    
  
  
  
  
  
  
  
  
  
    Gets the service object if already retrieved.
- 
  
    
      - (Object) cached_as(x = nil) 
    
    
  
  
  
  
  
  
  
  
  
    Gets the service object if already retrieved.
- 
  
    
      - (Object) get 
    
    
  
  
  
  
  
  
  
  
  
    Gets the object to access the service.
- 
  
    
      - (Object) get_as(x = nil) 
    
    
  
  
  
  
  
  
  
  
  
    Gets the object to access the service.
- 
  
    
      - (true, false) holding?(object = nil) 
    
    
  
  
  
  
  
  
  
  
  
    Checks whether or not the service reference has the given service object.
- 
  
    
      - (Hash) record 
    
    
  
  
  
  
  
  
  
  
  
    The service record.
- 
  
    
      - (void) release 
    
    
  
  
  
  
  
  
  
  
  
    Releases the reference.
Class Method Details
+ (Boolean) accept?(obj)
| 22 23 24 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 22 def @@j_api_type.accept?(obj) obj.class == ServiceReference end | 
+ (Object) j_api_type
| 31 32 33 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 31 def self.j_api_type @@j_api_type end | 
+ (Object) j_class
| 34 35 36 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 34 def self.j_class Java::IoVertxServicediscovery::ServiceReference.java_class end | 
+ (Object) unwrap(obj)
| 28 29 30 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 28 def @@j_api_type.unwrap(obj) obj.j_del end | 
+ (Object) wrap(obj)
| 25 26 27 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 25 def @@j_api_type.wrap(obj) ServiceReference.new(obj) end | 
Instance Method Details
- (Object) cached
    Gets the service object if already retrieved. It won't try to acquire the service object if not retrieved yet.
  
| 79 80 81 82 83 84 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 79 def cached if !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:cached, []).call()) end raise ArgumentError, "Invalid arguments when calling cached()" end | 
- (Object) cached_as(x = nil)
    Gets the service object if already retrieved. It won't try to acquire the service object if not retrieved yet.
 Unlike #cached, this method return the warpped object to the desired (given) type.
  
| 71 72 73 74 75 76 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 71 def cached_as(x=nil) if x.class == Class && !block_given? return ::Vertx::Util::Utils.v_type_of(x).wrap(@j_del.java_method(:cachedAs, [Java::JavaLang::Class.java_class]).call(::Vertx::Util::Utils.j_class_of(x))) end raise ArgumentError, "Invalid arguments when calling cached_as(#{x})" end | 
- (Object) get
    Gets the object to access the service. It can be a proxy, a client or whatever object. The type depends on the
 service type and the server itself. This method returns the Java version and primary facet of the object, use
 #get_as to retrieve the polyglot instance of the object or another facet..
  
| 51 52 53 54 55 56 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 51 def get if !block_given? return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, []).call()) end raise ArgumentError, "Invalid arguments when calling get()" end | 
- (Object) get_as(x = nil)
    Gets the object to access the service. It can be a proxy, a client or whatever object. The type depends on the
 service type and the server itself. This method wraps the service object into the desired type.
  
| 61 62 63 64 65 66 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 61 def get_as(x=nil) if x.class == Class && !block_given? return ::Vertx::Util::Utils.v_type_of(x).wrap(@j_del.java_method(:getAs, [Java::JavaLang::Class.java_class]).call(::Vertx::Util::Utils.j_class_of(x))) end raise ArgumentError, "Invalid arguments when calling get_as(#{x})" end | 
- (true, false) holding?(object = nil)
    Checks whether or not the service reference has the given service object.
  
| 97 98 99 100 101 102 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 97 def holding?(object=nil) if ::Vertx::Util::unknown_type.accept?(object) && !block_given? return @j_del.java_method(:isHolding, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(object)) end raise ArgumentError, "Invalid arguments when calling holding?(#{object})" end | 
- (Hash) record
    Returns the service record.
  
| 38 39 40 41 42 43 44 45 46 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 38 def record if !block_given? if @cached_record != nil return @cached_record end return @cached_record = @j_del.java_method(:record, []).call() != nil ? JSON.parse(@j_del.java_method(:record, []).call().toJson.encode) : nil end raise ArgumentError, "Invalid arguments when calling record()" end | 
- (void) release
This method returns an undefined value.
Releases the reference. Once released, the consumer must not use the reference anymore. This method must be idempotent and defensive, as multiple call may happen.| 88 89 90 91 92 93 | # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-service-discovery/service_reference.rb', line 88 def release if !block_given? return @j_del.java_method(:release, []).call() end raise ArgumentError, "Invalid arguments when calling release()" end |