TorqueBox 3.1.2

org.torquebox.core.runtime
Class SharedRubyRuntimePool

java.lang.Object
  extended by org.torquebox.core.pool.SharedPool<org.jruby.Ruby>
      extended by org.torquebox.core.runtime.SharedRubyRuntimePool
All Implemented Interfaces:
Pool<org.jruby.Ruby>, BasicRubyRuntimePoolMBean, RubyRuntimePool

public class SharedRubyRuntimePool
extends SharedPool<org.jruby.Ruby>
implements RubyRuntimePool, BasicRubyRuntimePoolMBean

Ruby interpreter pool which shares a single Ruby instance.

If constructed with an instance, the instance will be given out to all consumers of the pool, without bounds.

If constructed with an instance factory, the factory will be used to create exactly one instance, which is then shared with all consumers, without bounds.

Author:
Bob McWhirter

Field Summary
 
Fields inherited from class org.torquebox.core.pool.SharedPool
log
 
Constructor Summary
SharedRubyRuntimePool()
           
SharedRubyRuntimePool(org.jruby.Ruby ruby)
          Construct with an instance.
SharedRubyRuntimePool(RubyRuntimeFactory factory)
          Construct with a factory.
 
Method Summary
 org.jruby.Ruby borrowRuntime(String requester)
           
 RubyRuntimePool duplicate()
           
 Object evaluate(String code)
           
 Set<String> getAllRuntimeNames()
           
 int getAvailable()
           
 int getBorrowed()
           
 int getMaximumInstances()
           
 int getMinimumInstances()
           
 RubyRuntimeFactory getRubyRuntimeFactory()
          Retrieve the runtime instance factory used.
 org.jruby.Ruby getRuntime()
          Retrieve the shared runtime instance.
 int getSize()
           
 void returnRuntime(org.jruby.Ruby runtime)
           
 void setMaximumInstances(int maxInstances)
           
 void setMinimumInstances(int minInstances)
           
 
Methods inherited from class org.torquebox.core.pool.SharedPool
borrowInstance, borrowInstance, getInstance, getInstanceFactory, getName, getNamespaceContextSelector, isDeferredUntilRequested, isDrained, isLazy, isStarted, newInstance, releaseInstance, setDeferUntilRequested, setInstance, setInstanceFactory, setName, setNamespaceContextSelector, start, startPool, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.torquebox.core.runtime.RubyRuntimePool
getName, isDeferredUntilRequested, isDrained, isLazy, isStarted, setDeferUntilRequested, setInstanceFactory, setNamespaceContextSelector, start, stop
 
Methods inherited from interface org.torquebox.core.runtime.BasicRubyRuntimePoolMBean
getName, isLazy, isStarted
 

Constructor Detail

SharedRubyRuntimePool

public SharedRubyRuntimePool()

SharedRubyRuntimePool

public SharedRubyRuntimePool(RubyRuntimeFactory factory)
Construct with a factory.

Parameters:
factory - The factory to create the shared instance.

SharedRubyRuntimePool

public SharedRubyRuntimePool(org.jruby.Ruby ruby)
Construct with an instance.

Parameters:
ruby - The shared instance.
Method Detail

borrowRuntime

public org.jruby.Ruby borrowRuntime(String requester)
                             throws Exception
Specified by:
borrowRuntime in interface RubyRuntimePool
Throws:
Exception

returnRuntime

public void returnRuntime(org.jruby.Ruby runtime)
Specified by:
returnRuntime in interface RubyRuntimePool

getRubyRuntimeFactory

public RubyRuntimeFactory getRubyRuntimeFactory()
Retrieve the runtime instance factory used.

Returns:
The instance factory, or null if an instance was provided directly.

getRuntime

public org.jruby.Ruby getRuntime()
Retrieve the shared runtime instance.

Returns:
The shared runtime instance, if initialized, otherwise null.

evaluate

public Object evaluate(String code)
                throws Exception
Specified by:
evaluate in interface BasicRubyRuntimePoolMBean
Specified by:
evaluate in interface RubyRuntimePool
Throws:
Exception

getAllRuntimeNames

public Set<String> getAllRuntimeNames()
Specified by:
getAllRuntimeNames in interface BasicRubyRuntimePoolMBean
Specified by:
getAllRuntimeNames in interface RubyRuntimePool

duplicate

public RubyRuntimePool duplicate()
Specified by:
duplicate in interface RubyRuntimePool

setMinimumInstances

public void setMinimumInstances(int minInstances)
Specified by:
setMinimumInstances in interface BasicRubyRuntimePoolMBean
Specified by:
setMinimumInstances in interface RubyRuntimePool

getMinimumInstances

public int getMinimumInstances()
Specified by:
getMinimumInstances in interface BasicRubyRuntimePoolMBean
Specified by:
getMinimumInstances in interface RubyRuntimePool

setMaximumInstances

public void setMaximumInstances(int maxInstances)
Specified by:
setMaximumInstances in interface BasicRubyRuntimePoolMBean
Specified by:
setMaximumInstances in interface RubyRuntimePool

getMaximumInstances

public int getMaximumInstances()
Specified by:
getMaximumInstances in interface BasicRubyRuntimePoolMBean
Specified by:
getMaximumInstances in interface RubyRuntimePool

getSize

public int getSize()
Specified by:
getSize in interface BasicRubyRuntimePoolMBean
Specified by:
getSize in interface RubyRuntimePool

getBorrowed

public int getBorrowed()
Specified by:
getBorrowed in interface BasicRubyRuntimePoolMBean
Specified by:
getBorrowed in interface RubyRuntimePool

getAvailable

public int getAvailable()
Specified by:
getAvailable in interface BasicRubyRuntimePoolMBean
Specified by:
getAvailable in interface RubyRuntimePool

TorqueBox 3.1.2

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.