in src/cas/sofastream.cpp [83:181]
int RemoteSofaDataStream::open(size_t minbufsize) {
std::string sofauri;
std::string urischeme;
util::Filename const * pDllFile=NULL;
//get the sofa uri as UTF-8 string
iv_psofafs->getSofaURI().extract(0,
iv_psofafs->getSofaURI().length(),
sofauri,
CCSID::getDefaultSBCSInputCCSID() );
//get the uri scheme
int32_t pos = sofauri.find(":");
if (pos != -1) {
//get the uri scheme
urischeme = sofauri.substr(0,pos);
} else {
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_INVALID_SOFAURI);
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
//look up sofa stream handler for uri scheme
if (urischeme.size() > 0) {
pDllFile = uima::ResourceManager::getInstance().getStreamHandlerForURIScheme(urischeme);
if (pDllFile == NULL) {
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_SCHEMEHANDLER_NOT_REGISTERED);
errMsg.addParam(urischeme);
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
} else {
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_INVALID_SOFAURI);
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
//load the handler
iv_pHandlerDll = new util::DllProcLoaderFile(*pDllFile);
//assert(EXISTS(iv_pHandlerDll));
if (iv_pHandlerDll == NULL) {
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_SCHEMEHANDLER_LOAD);
errMsg.addParam(pDllFile->getName());
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
uima::TyMakeStreamHandler procMaker = (TyMakeStreamHandler) iv_pHandlerDll->getProcedure(UIMA_SOFASTREAM_MAKE_HANDLER);
assert(EXISTS(procMaker));
if (NOTEXISTS(procMaker)) {
ResourceManager::getInstance().getLogger().logError("RemoteSofaDataStream::open() Could not get procedure makeHandler() ");
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_SCHEMEHANDLER_GETPROC);
errMsg.addParam(pDllFile->getName());
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
/* first we need to create the handler */
iv_pHandler = (procMaker) ();
if (NOTEXISTS(iv_pHandler)) {
ResourceManager::getInstance().getLogger().logError("RemoteSofaDataStream::open() Could not instantiate stream handler. ");
ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_EXC_SCHEMEHANDLER_GETPROC);
errMsg.addParam(pDllFile->getName());
errMsg.addParam(sofauri);
UIMA_EXC_THROW_NEW(SofaDataStreamException,
UIMA_ERR_SOFADATASTREAM,
errMsg,
UIMA_MSG_ID_EXCON_SOFADATASTREAM,
ErrorInfo::unrecoverable);
}
/* open the stream */
if (minbufsize > 0) {
iv_pHandler->openStream(sofauri.data(), minbufsize);
} else {
iv_pHandler->openStream(sofauri.data());
}
return 0;
}