Class CasObjectNetworkCasProcessorImpl
- java.lang.Object
-
- org.apache.uima.collection.impl.cpm.container.CasObjectNetworkCasProcessorImpl
-
- All Implemented Interfaces:
CasObjectProcessor
,CasProcessor
public class CasObjectNetworkCasProcessorImpl extends java.lang.Object implements CasObjectProcessor
Implementation of theCasObjectProcessor
interface used for both Local and Remote CasObjectProcessors. This objects plugs in a transport object defined in the CPE Descriptor and uses it to delegate analysis of CAS to a remote AE.
-
-
Field Summary
Fields Modifier and Type Field Description private ProcessingResourceMetaData
metadata
The metadata.private java.lang.String
name
The name.private java.net.Socket
socket
The socket.private long
timeout
The timeout.private SocketTransport
transport
The transport.
-
Constructor Summary
Constructors Constructor Description CasObjectNetworkCasProcessorImpl(CpeCasProcessor aCasProcessor)
Using information from the CPE descriptor creates an instance of Transport class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
batchProcessComplete(ProcessTrace aTrace)
Completes the processing of a batch.void
collectionProcessComplete(ProcessTrace aTrace)
Closes the connection to the remote service.void
connect(java.net.URL aURL)
Connects to a service endpoint defined in the given URL.java.net.URL
getEndpoint()
Creates URL object containing service endpoint info ( host and port).ProcessingResourceMetaData
getProcessingResourceMetaData()
ReturnsProcessingResourceMetaData
object returned from the remote CasProcessor.boolean
isReadOnly()
Gets whether this is a read-only CAS Processor, which does not modify the CAS.boolean
isStateless()
Gets whether this is a stateless CAS Processor.private SocketTransport
pluginTransport(java.lang.String aTransportClass)
Create Transport object from a given class and associate it with this CasProcessor.void
processCas(CAS aCAS)
Uses configured transport to delegate given CAS to the remote service.void
processCas(CAS[] aCASes)
Uses configured transport to delegate given CASes to the remote service.void
typeSystemInit(TypeSystem aTypeSystem)
Informs this CasConsumer that the CAS TypeSystem has changed.
-
-
-
Field Detail
-
transport
private SocketTransport transport
The transport.
-
name
private java.lang.String name
The name.
-
socket
private java.net.Socket socket
The socket.
-
timeout
private long timeout
The timeout.
-
metadata
private ProcessingResourceMetaData metadata
The metadata.
-
-
Constructor Detail
-
CasObjectNetworkCasProcessorImpl
public CasObjectNetworkCasProcessorImpl(CpeCasProcessor aCasProcessor) throws ResourceConfigurationException
Using information from the CPE descriptor creates an instance of Transport class. The transport class will delegate analysis of CAS to a remote object.- Parameters:
aCasProcessor
- - Cas Process configuration from the CPE descriptor- Throws:
ResourceConfigurationException
- the resource configuration exception
-
-
Method Detail
-
pluginTransport
private SocketTransport pluginTransport(java.lang.String aTransportClass) throws java.lang.Exception
Create Transport object from a given class and associate it with this CasProcessor.- Parameters:
aTransportClass
- - name of the Transport class- Returns:
- - instance of SocketTransport
- Throws:
java.lang.Exception
- passthru
-
getEndpoint
public java.net.URL getEndpoint()
Creates URL object containing service endpoint info ( host and port).- Returns:
- URL
-
connect
public void connect(java.net.URL aURL) throws ResourceInitializationException
Connects to a service endpoint defined in the given URL.- Parameters:
aURL
- - contains service endpoint info (hots and port)- Throws:
ResourceInitializationException
- wraps SocketException
-
processCas
public void processCas(CAS aCAS) throws ResourceProcessException
Uses configured transport to delegate given CAS to the remote service.- Specified by:
processCas
in interfaceCasObjectProcessor
- Parameters:
aCAS
- CAS to be analyzed- Throws:
ResourceProcessException
- wraps Exception, SocketException
-
processCas
public void processCas(CAS[] aCASes) throws ResourceProcessException
Uses configured transport to delegate given CASes to the remote service.- Specified by:
processCas
in interfaceCasObjectProcessor
- Parameters:
aCASes
- - an array of CASes to be analyzed- Throws:
ResourceProcessException
- wraps SocketException, SocketTimeoutException
-
typeSystemInit
public void typeSystemInit(TypeSystem aTypeSystem) throws ResourceInitializationException
Description copied from interface:CasObjectProcessor
Informs this CasConsumer that the CAS TypeSystem has changed. The CPM calls this method prior to initiating collection processing, and will call it again whenever the CAS TypeSystem changes.In this method, the CasConsumer should use the
TypeSystem
to resolve the names of Type and Features to the actualType
andFeature
objects, which can then be used during processing.- Specified by:
typeSystemInit
in interfaceCasObjectProcessor
- Parameters:
aTypeSystem
- the type system to use- Throws:
ResourceInitializationException
- if the type system is not compatible with this Cas Consumer
-
isStateless
public boolean isStateless()
Description copied from interface:CasProcessor
Gets whether this is a stateless CAS Processor. Stateless CAS Processors do not maintain any data between calls to their process methods.- Specified by:
isStateless
in interfaceCasProcessor
- Returns:
- true if this CAS processor is stateless, false if it is stateful.
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:CasProcessor
Gets whether this is a read-only CAS Processor, which does not modify the CAS.- Specified by:
isReadOnly
in interfaceCasProcessor
- Returns:
- true if this CAS processor does not modify the CAS, false if it does.
-
getProcessingResourceMetaData
public ProcessingResourceMetaData getProcessingResourceMetaData()
ReturnsProcessingResourceMetaData
object returned from the remote CasProcessor.- Specified by:
getProcessingResourceMetaData
in interfaceCasProcessor
- Returns:
- the processing resource meta data
-
batchProcessComplete
public void batchProcessComplete(ProcessTrace aTrace) throws ResourceProcessException, java.io.IOException
Description copied from interface:CasProcessor
Completes the processing of a batch. A collection may be divided into one or more batches - it is up to the CollectionProcessingManager or the application to determine the number and size of batches.- Specified by:
batchProcessComplete
in interfaceCasProcessor
- Parameters:
aTrace
- an object that records information, such as timing, about this method's execution.- Throws:
ResourceProcessException
- if an exception occurs during processingjava.io.IOException
- if an I/O failure occurs
-
collectionProcessComplete
public void collectionProcessComplete(ProcessTrace aTrace) throws ResourceProcessException, java.io.IOException
Closes the connection to the remote service.- Specified by:
collectionProcessComplete
in interfaceCasProcessor
- Parameters:
aTrace
- the a trace- Throws:
ResourceProcessException
- the resource process exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
-