public class StorageSOPClassSCPDispatcher
extends java.lang.Object
implements java.lang.Runnable
This class waits for incoming connections and association requests for the SCP role of SOP Classes of the Storage Service Class, the Study Root Query Retrieve Information Model Find, Get and Move SOP Classes, and the Verification SOP Class.
The class has a constructor and a run()
method. The
constructor is passed a socket on which to listen for transport
connection open indications. The run()
method waits
for transport connection open indications, then instantiates
StorageSOPClassSCP
to accept an association and wait for storage or verification commands, storing
data sets in Part 10 files in the specified folder.
An instance of ReceivedObjectHandler
can be supplied in the constructor to process the received data set stored in the file
when it has been completely received.
For example:
try { new Thread(new StorageSOPClassSCPDispatcher(104,"STORESCP",new File("/tmp"),new OurReceivedObjectHandler(),0)).start(); } catch (IOException e) { slf4jlogger.error("",e); }
If it is necessary to shutdown the StorageSOPClassSCPDispatcher, for example after changing the
properties that define the listening port or AE Title, the
shutdown()
method can be called.
Debugging messages with a varying degree of verbosity can be activated.
The main method is also useful in its own right as a command-line Storage SCP utility, which will store incoming files in a specified directory.
For example, on Unix:
% java -cp ./pixelmed.jar com.pixelmed.network.StorageSOPClassSCPDispatcher "104" "STORESCP" "/tmp" 0
On Windows, the classpath syntax would use a different separator, e.g. .\pixelmed.jar
Note that the main method can also be used without command line arguments, in which case it looks for a properties file or uses defaults (refer to the main() method documentation for details).
StorageSOPClassSCP
,
ReceivedObjectHandler
Modifier and Type | Field and Description |
---|---|
protected StoredFilePathStrategy |
storedFilePathStrategy |
Constructor and Description |
---|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
ReceivedObjectHandler receivedObjectHandler)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
ReceivedObjectHandler receivedObjectHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler,
AssociationStatusHandler associationStatusHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
PresentationContextSelectionPolicy presentationContextSelectionPolicy,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
PresentationContextSelectionPolicy presentationContextSelectionPolicy,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
int ourMaximumLengthReceived,
int socketReceiveBufferSize,
int socketSendBufferSize,
java.io.File savedImagesFolder,
ReceivedObjectHandler receivedObjectHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
int ourMaximumLengthReceived,
int socketReceiveBufferSize,
int socketSendBufferSize,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler,
AssociationStatusHandler associationStatusHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
PresentationContextSelectionPolicy presentationContextSelectionPolicy,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
StorageSOPClassSCPDispatcher(int port,
java.lang.String calledAETitle,
int ourMaximumLengthReceived,
int socketReceiveBufferSize,
int socketSendBufferSize,
java.io.File savedImagesFolder,
StoredFilePathStrategy storedFilePathStrategy,
ReceivedObjectHandler receivedObjectHandler,
QueryResponseGeneratorFactory queryResponseGeneratorFactory,
RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory,
NetworkApplicationInformation networkApplicationInformation,
boolean secureTransport)
Construct an instance of dispatcher that will wait for transport
connection open indications, and handle associations and commands.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isReady()
Is the dispatcher ready to receive connections?
|
static void |
main(java.lang.String[] arg)
For testing.
|
void |
run()
Waits for a transport connection indications, then spawns
new threads to act as association acceptors, which then wait for storage or
verification commands, storing data sets in Part 10 files in the specified folder, until the associations
are released or the transport connections are closed.
|
void |
shutdown()
Request the dispatcher to stop listening and exit the thread.
|
protected StoredFilePathStrategy storedFilePathStrategy
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, ReceivedObjectHandler receivedObjectHandler) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)receivedObjectHandler
- the handler to call after each data set has been received and storedjava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, ReceivedObjectHandler receivedObjectHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)receivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file namequeryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressessecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and foldersreceivedObjectHandler
- the handler to call after each data set has been received and storedjava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler, AssociationStatusHandler associationStatusHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, PresentationContextSelectionPolicy presentationContextSelectionPolicy, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and folders, or null for the defaultreceivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file nameassociationStatusHandler
- the handler to call when the Association is closed, or null if none requiredqueryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressespresentationContextSelectionPolicy
- which SOP Classes and Transfer Syntaxes to accept and reject, or null for the defaultsecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and folders, or null for the defaultreceivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file namequeryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressessecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, PresentationContextSelectionPolicy presentationContextSelectionPolicy, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitlesavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and folders, or null for the defaultreceivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file namequeryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressespresentationContextSelectionPolicy
- which SOP Classes and Transfer Syntaxes to accept and reject, or null for the defaultsecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, java.io.File savedImagesFolder, ReceivedObjectHandler receivedObjectHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitleourMaximumLengthReceived
- the maximum PDU length that we will offer to receivesocketReceiveBufferSize
- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize
- the TCP socket send buffer size to set (if possible), 0 means leave at the defaultsavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)receivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file namequeryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressessecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler, AssociationStatusHandler associationStatusHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, PresentationContextSelectionPolicy presentationContextSelectionPolicy, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitleourMaximumLengthReceived
- the maximum PDU length that we will offer to receivesocketReceiveBufferSize
- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize
- the TCP socket send buffer size to set (if possible), 0 means leave at the defaultsavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and folders, or null for the defaultreceivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file nameassociationStatusHandler
- the handler to call when the Association is closed, or null if none requiredqueryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressespresentationContextSelectionPolicy
- which SOP Classes and Transfer Syntaxes to accept and reject, or null for the defaultsecureTransport
- true if to use secure transport protocoljava.io.IOException
public StorageSOPClassSCPDispatcher(int port, java.lang.String calledAETitle, int ourMaximumLengthReceived, int socketReceiveBufferSize, int socketSendBufferSize, java.io.File savedImagesFolder, StoredFilePathStrategy storedFilePathStrategy, ReceivedObjectHandler receivedObjectHandler, QueryResponseGeneratorFactory queryResponseGeneratorFactory, RetrieveResponseGeneratorFactory retrieveResponseGeneratorFactory, NetworkApplicationInformation networkApplicationInformation, boolean secureTransport) throws java.io.IOException
Construct an instance of dispatcher that will wait for transport connection open indications, and handle associations and commands.
port
- the port on which to listen for connectionscalledAETitle
- our AE TitleourMaximumLengthReceived
- the maximum PDU length that we will offer to receivesocketReceiveBufferSize
- the TCP socket receive buffer size to set (if possible), 0 means leave at the defaultsocketSendBufferSize
- the TCP socket send buffer size to set (if possible), 0 means leave at the defaultsavedImagesFolder
- the folder in which to store received data sets (may be null, to ignore received data for testing)storedFilePathStrategy
- the strategy to use for naming received files and foldersreceivedObjectHandler
- the handler to call after each data set has been received and stored, or null for the default that prints the file namequeryResponseGeneratorFactory
- the factory to make handlers to generate query responses from a supplied query messageretrieveResponseGeneratorFactory
- the factory to make handlers to generate retrieve responses from a supplied retrieve messagenetworkApplicationInformation
- from which to obtain a map of application entity titles to presentation addressessecureTransport
- true if to use secure transport protocoljava.io.IOException
public boolean isReady()
Is the dispatcher ready to receive connections?
Useful for unit tests so as to know when to start sending to it.
return true if readypublic static void main(java.lang.String[] arg)
For testing.
Wait for connections, accept associations and store received files in the specified folder.
arg
- array of zero, thre, four, five, seven or eight strings - our port, our AE Title,
optionally the max PDU size, socket receive and send buffer sizes,
the folder in which to stored received files (zero length or "-" if want to ignore received data),
optionally a string flag valued SECURE or NONSECURE (defaults to NONSECURE);
optionally the range of Transfer Syntaxes accepted, either UNCOMPRESSED or ANY (defaults to UNCOMPRESSED);
if no arguments are supplied the properties in "~/.com.pixelmed.network.StorageSOPClassSCPDispatcher.properties" will be used if present,
otherwise the defaults (11112,STORESCP,~/tmp) will be used - in this mode the service will also be self-registered with dns-sd if possiblepublic void run()
Waits for a transport connection indications, then spawns new threads to act as association acceptors, which then wait for storage or verification commands, storing data sets in Part 10 files in the specified folder, until the associations are released or the transport connections are closed.
run
in interface java.lang.Runnable
public void shutdown()
Request the dispatcher to stop listening and exit the thread.