org.jppf.jca.cci
Class JPPFConnectionImpl

java.lang.Object
  extended by org.jppf.jca.util.JPPFAccessorImpl
      extended by org.jppf.jca.cci.JPPFConnectionImpl
All Implemented Interfaces:
Connection, JPPFConnection, JPPFAccessor

public class JPPFConnectionImpl
extends JPPFAccessorImpl
implements JPPFConnection

Implementation of a JCA connection. This class provides an API to send tasks to a JPPF driver.

Author:
Laurent Cohen

Field Summary
 
Fields inherited from class org.jppf.jca.util.JPPFAccessorImpl
jppfClient, logWriter
 
Constructor Summary
JPPFConnectionImpl(JPPFManagedConnection conn)
          Initialize this connection from a managed connection.
 
Method Summary
 void addSubmissionStatusListener(String submissionId, SubmissionStatusListener listener)
          Add a listener to the submission with the specified id.
 void close()
          Close this connection and notify the associated managed connection.
 Interaction createInteraction()
          Create an interaction.
 Collection<String> getAllSubmissionIds()
          Get the ids of all currently available submissions.
 LocalTransaction getLocalTransaction()
          Transaction management is not supported in this version.
 JPPFManagedConnection getManagedConnection()
          Get the associated managed connection.
 ConnectionMetaData getMetaData()
          Get the connection metadata.
 ResultSetInfo getResultSetInfo()
          This method is not supported in this version.
 List<JPPFTask> getSubmissionResults(String submissionId)
          Get the results of an execution request.
 SubmissionStatus getSubmissionStatus(String submissionId)
          Get the execution status of a tasks submission.
 boolean isClosed()
          Determine whether this connection has been closed.
 void removeSubmissionStatusListener(String submissionId, SubmissionStatusListener listener)
          Remove a listener from the submission with the specified id.
 void setAvailable()
          Set the closed state of this connection.
 void setManagedConnection(JPPFManagedConnection conn)
          Set the associated managed connection.
 String submitNonBlocking(JPPFJob job)
          Submit an asynchronous execution request to the JPPF client.
 String submitNonBlocking(JPPFJob job, SubmissionStatusListener listener)
          Submit an asynchronous execution request to the JPPF client.
 List<JPPFTask> waitForResults(String submissionId)
          Wait until all results for the specfied job submission have been received.
 
Methods inherited from class org.jppf.jca.util.JPPFAccessorImpl
getJppfClient, getLogWriter, setJppfClient, setLogWriter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jppf.jca.util.JPPFAccessor
getJppfClient, getLogWriter, setJppfClient, setLogWriter
 

Constructor Detail

JPPFConnectionImpl

public JPPFConnectionImpl(JPPFManagedConnection conn)
Initialize this connection from a managed connection.

Parameters:
conn - a ManagedConnection instance.
Method Detail

close

public void close()
Close this connection and notify the associated managed connection.

Specified by:
close in interface Connection
See Also:
Connection.close()

createInteraction

public Interaction createInteraction()
Create an interaction.

Specified by:
createInteraction in interface Connection
Returns:
an Interaction instance.
See Also:
Connection.createInteraction()

getLocalTransaction

public LocalTransaction getLocalTransaction()
                                     throws ResourceException
Transaction management is not supported in this version.

Specified by:
getLocalTransaction in interface Connection
Returns:
nothing.
Throws:
ResourceException - this method always throws a NotSupportedException.
See Also:
Connection.getLocalTransaction()

getMetaData

public ConnectionMetaData getMetaData()
Get the connection metadata.

Specified by:
getMetaData in interface Connection
Returns:
a JPPFConnectionMetaData instance.
See Also:
Connection.getMetaData()

getResultSetInfo

public ResultSetInfo getResultSetInfo()
                               throws ResourceException
This method is not supported in this version.

Specified by:
getResultSetInfo in interface Connection
Returns:
nothing.
Throws:
ResourceException - this method always throws a NotSupportedException.
See Also:
Connection.getResultSetInfo()

submitNonBlocking

public String submitNonBlocking(JPPFJob job)
                         throws Exception
Submit an asynchronous execution request to the JPPF client.
This method exits immediately after adding the request to the requests queue.
The returned id is used to later retieve the results and sttaus of the execution.

Specified by:
submitNonBlocking in interface JPPFConnection
Parameters:
job - the job to execute.
Returns:
the id of the submission, to use for later retrieval of the results and status of the submission.
Throws:
IllegalArgumentException - if the job is null or empty.
Exception - if an error occurs while submitting the request.

submitNonBlocking

public String submitNonBlocking(JPPFJob job,
                                SubmissionStatusListener listener)
                         throws Exception
Submit an asynchronous execution request to the JPPF client.
This method exits immediately after adding the request to the requests queue.
The returned id is used to later retieve the results and sttaus of the execution.

Specified by:
submitNonBlocking in interface JPPFConnection
Parameters:
job - the job to execute.
listener - an optional listener to receive submission status change notifications, may be null.
Returns:
the id of the submission, to use for later retrieval of the results and status of the submission.
Throws:
IllegalArgumentException - if the job is null or empty.
Exception - if an error occurs while submitting the request.

addSubmissionStatusListener

public void addSubmissionStatusListener(String submissionId,
                                        SubmissionStatusListener listener)
Add a listener to the submission with the specified id.

Specified by:
addSubmissionStatusListener in interface JPPFConnection
Parameters:
submissionId - the id of the submission.
listener - the listener to add.

removeSubmissionStatusListener

public void removeSubmissionStatusListener(String submissionId,
                                           SubmissionStatusListener listener)
Remove a listener from the submission with the specified id.

Specified by:
removeSubmissionStatusListener in interface JPPFConnection
Parameters:
submissionId - the id of the submission.
listener - the listener to remove.

getSubmissionStatus

public SubmissionStatus getSubmissionStatus(String submissionId)
                                     throws Exception
Get the execution status of a tasks submission.

Specified by:
getSubmissionStatus in interface JPPFConnection
Parameters:
submissionId - the id of the submission for which to get the status.
Returns:
the submission status.
Throws:
Exception - if an error occurs while submitting the request.

getSubmissionResults

public List<JPPFTask> getSubmissionResults(String submissionId)
                                    throws Exception
Get the results of an execution request.
This method should be called only once a call to getSubmissionStatus(submissionId) has returned either COMPLETE or FAILED

Specified by:
getSubmissionResults in interface JPPFConnection
Parameters:
submissionId - the id of the submission for which to get the execution results.
Returns:
the list of resulting JPPF tasks, or null if the execution failed.
Throws:
Exception - if an error occurs while submitting the request.

getAllSubmissionIds

public Collection<String> getAllSubmissionIds()
Get the ids of all currently available submissions.

Specified by:
getAllSubmissionIds in interface JPPFConnection
Returns:
a collection of ids as strings.

isClosed

public boolean isClosed()
Determine whether this connection has been closed.

Specified by:
isClosed in interface JPPFConnection
Returns:
true if the connection was closed, false otherwise.

setAvailable

public void setAvailable()
Set the closed state of this connection.

Specified by:
setAvailable in interface JPPFConnection

getManagedConnection

public JPPFManagedConnection getManagedConnection()
Get the associated managed connection.

Specified by:
getManagedConnection in interface JPPFConnection
Returns:
a JPPFManagedConnection instance.

setManagedConnection

public void setManagedConnection(JPPFManagedConnection conn)
Set the associated managed connection.

Specified by:
setManagedConnection in interface JPPFConnection
Parameters:
conn - a JPPFManagedConnection instance.

waitForResults

public List<JPPFTask> waitForResults(String submissionId)
                              throws Exception
Wait until all results for the specfied job submission have been received.

Specified by:
waitForResults in interface JPPFConnection
Parameters:
submissionId - the id of the job submission.
Returns:
the results as a list of JPPFTask instances.
Throws:
Exception - if any error occurs.


Copyright © 2005-2010 JPPF Team.