matlabcontrol
Class RemoteMatlabProxyFactory

java.lang.Object
  extended by matlabcontrol.RemoteMatlabProxyFactory

public class RemoteMatlabProxyFactory
extends java.lang.Object

Use this class to create instances of RemoteMatlabProxy. Creating a proxy will launch MATLAB. Each proxy created will control the session launched.

Author:
Joshua Kaplan

Constructor Summary
RemoteMatlabProxyFactory()
          Constructs this factory with a default location or alias for the MATLAB executable (on an operating system specific basis).
RemoteMatlabProxyFactory(java.lang.String matlabLocation)
          Constructs this factory with a specified location or alias for the MATLAB executable.
 
Method Summary
 void addConnectionListener(MatlabConnectionListener listener)
          Adds a listener to be notified when MATLAB connections are established and lost.
 java.lang.String getMatlabLocation()
          Returns the location or alias of the MATLAB program.
 RemoteMatlabProxy getProxy()
          Returns a RemoteMatlabProxy.
 RemoteMatlabProxy getProxy(long timeout)
          Returns a RemoteMatlabProxy.
 void removeConnectionListener(MatlabConnectionListener listener)
          Removes a listener so that it is no longer notified.
 java.lang.String requestProxy()
          Requests a RemoteMatlabProxy.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteMatlabProxyFactory

public RemoteMatlabProxyFactory(java.lang.String matlabLocation)
                         throws MatlabConnectionException
Constructs this factory with a specified location or alias for the MATLAB executable. Typically this will not be necessary and so using the the other constructor will be the preferred option. The location or alias specified by matlabLocation will not be verified at construction time, and so if the value is invalid it will not cause this constructor to throw an exception. If it is invalid then an exception will be thrown when creating a proxy with requestProxy(), getProxy(), or getProxy(long).

Parameters:
matlabLocation -
Throws:
MatlabConnectionException - thrown if the initialization necessary for connecting to MATLAB cannot be properly configured

RemoteMatlabProxyFactory

public RemoteMatlabProxyFactory()
                         throws MatlabConnectionException
Constructs this factory with a default location or alias for the MATLAB executable (on an operating system specific basis). If that default does not work, then construct this class with the other constructor so that the correct location or alias can be specified.

Throws:
MatlabConnectionException - thrown if the initialization necessary for connecting to MATLAB cannot be properly configured
Method Detail

getMatlabLocation

public java.lang.String getMatlabLocation()
Returns the location or alias of the MATLAB program. If no location or alias was assigned when constructing this factory then the value returned will be the default which differs depending on the operating system this code is executing on.

Returns:
MATLAB location

requestProxy

public java.lang.String requestProxy()
                              throws MatlabConnectionException
Requests a RemoteMatlabProxy. When the proxy has been made (there is a possibility it will not be if errors occur), all listeners will be notified. The identifier of the proxy that will be created is returned. A proxy's identifier can be accessed by calling RemoteMatlabProxy.getIdentifier().

Returns:
proxy's unique identifier
Throws:
MatlabConnectionException
See Also:
addConnectionListener(MatlabConnectionListener), RemoteMatlabProxy.getIdentifier(), getProxy(), getProxy(long)

getProxy

public RemoteMatlabProxy getProxy()
                           throws MatlabConnectionException
Returns a RemoteMatlabProxy. This will take some time as it involves launching MATLAB. If a connection cannot be established within 60 seconds then this method will end execution and an exception will be thrown.

Returns:
proxy
Throws:
MatlabConnectionException
See Also:
requestProxy(), getProxy(long)

getProxy

public RemoteMatlabProxy getProxy(long timeout)
                           throws MatlabConnectionException
Returns a RemoteMatlabProxy. This will take some time as it involves launching MATLAB. If a connection cannot be established within the specified number of milliseconds specified by timeout then this method will end execution and an exception will be thrown.

Parameters:
timeout - time to wait in milliseconds for a proxy to be created
Returns:
proxy
Throws:
MatlabConnectionException
See Also:
requestProxy(), getProxy()

addConnectionListener

public void addConnectionListener(MatlabConnectionListener listener)
Adds a listener to be notified when MATLAB connections are established and lost.

Parameters:
listener -

removeConnectionListener

public void removeConnectionListener(MatlabConnectionListener listener)
Removes a listener so that it is no longer notified.

Parameters:
listener -