use of alma.cdbErrType.wrappers.AcsJCDBXMLErrorEx in project ACS by ACS-Community.
the class DALImpl method get_DAO_Servant.
/**
* create DAO servant with requested XML
*/
public synchronized DAO get_DAO_Servant(String curl) throws CDBRecordDoesNotExistEx, CDBXMLErrorEx {
totalDALInvocationCounter.incrementAndGet();
// make sure CURL->DAO mapping is surjective function, remove leading slash
if (curl.length() > 1 && curl.charAt(0) == '/')
curl = curl.substring(1);
// make sure there are no identical DAOs created
synchronized (daoMap) {
if (daoMap.containsKey(curl))
return daoMap.get(curl);
}
// do the hardwork here
XMLHandler xmlSolver;
try {
xmlSolver = loadRecords(curl, false);
} catch (AcsJCDBXMLErrorEx e) {
// @todo watch if this log also needs a repeat guard, similar to logRecordNotExistWithRepeatGuard
m_logger.log(AcsLogLevel.NOTICE, "Failed to read curl '" + curl + "'.", e);
throw e.toCDBXMLErrorEx();
} catch (AcsJCDBRecordDoesNotExistEx e) {
logRecordNotExistWithRepeatGuard(curl);
throw e.toCDBRecordDoesNotExistEx();
}
if (xmlSolver == null) {
// @TODO can this happen? Should we not throw an exception then?
return null;
}
try {
DAO href = null;
// bind to map
synchronized (daoMap) {
// execution when different DAO are created
if (daoMap.containsKey(curl))
return daoMap.get(curl);
final DAOImpl servantDelegate = new DAOImpl(curl, xmlSolver.m_rootNode, poa, m_logger);
DAOOperations topLevelServantDelegate = servantDelegate;
if (Boolean.getBoolean(Server.LOG_CDB_CALLS_PROPERTYNAME)) {
// Currently we only intercept the functional IDL-defined methods, by wrapping servantDelegate.
// If we want to also intercept the CORBA admin methods, then *servant* below should be wrapped with a dynamic proxy instead.
DAOOperations interceptingServantDelegate = SimpleCallInterceptor.createSimpleInterceptor(DAOOperations.class, servantDelegate, m_logger);
topLevelServantDelegate = interceptingServantDelegate;
}
final Servant servant = new DAOPOATie(topLevelServantDelegate);
// create object id.
// Note that the ID *must* be derived from the curl, because DAOImpl#destroy will do the same in POA#deactivate_object.
byte[] id = curl.getBytes();
// activate object
poa.activate_object_with_id(id, servant);
href = DAOHelper.narrow(poa.servant_to_reference(servant));
// map DAO reference
daoMap.put(curl, href);
}
m_logger.log(AcsLogLevel.DEBUG, "Returning DAO servant for: " + curl);
return href;
} catch (Throwable t) {
String info = "DAO::get_DAO_Servant " + t;
AcsJCDBXMLErrorEx xmlErr = new AcsJCDBXMLErrorEx(t);
xmlErr.setErrorString(info);
m_logger.log(AcsLogLevel.NOTICE, info);
throw xmlErr.toCDBXMLErrorEx();
}
}
Aggregations