matlabcontrol
Class MatlabProxyFactory

java.lang.Object
  extended by matlabcontrol.MatlabProxyFactory

public class MatlabProxyFactory
extends java.lang.Object

Creates instances of MatlabProxy. Any number of proxies may be created with a factory.

How the proxies will connect to a session of MATLAB depends on whether the factory is running inside or outside MATLAB:

Running inside MATLAB
The proxy will connect to the session of MATLAB this factory is running in.

Running outside MATLAB
By default a new session of MATLAB will be started and connected to, but the factory may be configured via the options provided to this factory to connect to a previously controlled session.

This class is unconditionally thread-safe. Any number of proxies may be created simultaneously.

Since:
4.0.0

Nested Class Summary
static interface MatlabProxyFactory.Request
          A request for a proxy.
static interface MatlabProxyFactory.RequestCallback
          Provides the requested proxy.
 
Constructor Summary
MatlabProxyFactory()
          Constructs the factory using default options.
MatlabProxyFactory(MatlabProxyFactoryOptions options)
          Constructs the factory with the specified options.
 
Method Summary
 MatlabProxy getProxy()
          Returns a MatlabProxy.
 MatlabProxyFactory.Request requestProxy(MatlabProxyFactory.RequestCallback callback)
          Requests a MatlabProxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatlabProxyFactory

public MatlabProxyFactory()
Constructs the factory using default options.

Throws:
MatlabConnectionException

MatlabProxyFactory

public MatlabProxyFactory(MatlabProxyFactoryOptions options)
Constructs the factory with the specified options. Depending on the whether the factory is running inside MATLAB or outside MATLAB will determine if a given option is used.

Parameters:
options -
Method Detail

getProxy

public MatlabProxy getProxy()
                     throws MatlabConnectionException
Returns a MatlabProxy. If a connection cannot be established before the timeout then this method will end execution and an exception will be thrown. A timeout can be specified with the options provided to this factory. If no timeout was specified, then a default of 180 seconds will be used.

While this method blocks the calling thread until a proxy is created (or the timeout is reached), any number of threads may call getProxy() simultaneously.

Returns:
proxy
Throws:
MatlabConnectionException

requestProxy

public MatlabProxyFactory.Request requestProxy(MatlabProxyFactory.RequestCallback callback)
                                        throws MatlabConnectionException
Requests a MatlabProxy. When the proxy has been created it will be provided to the callback. The proxy may be provided to the callback before this method returns. There is no timeout. The returned MatlabProxyFactory.Request instance provides information about the request and can be used to cancel the request.

This method is non-blocking. Any number of requests may be made simultaneously from the same thread or different threads.

Returns:
request
Throws:
MatlabConnectionException