use of com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class ChannelProperties method getCDBAdminProps.
// //////////////////////////////////////////////////////////////////////////
/**
* Given a channel name that exists in the ACS CDB
* ($ACS_CDB/CDB/MACI/Channels/channelName/channelName.xml), this function
* returns the channels administrative properties in their CORBA format.
*
* @param channelName
* name of the channel found in $ACS_CDB/CDB/MACI/Channels
* @return channel's admin properties
* @throws AcsJException
* if the channel's CDB entry is corrupted in any way
*/
public Property[] getCDBAdminProps(String channelName) throws AcsJException {
// use this object to get at channel information from the CDB
DAO tempDAO = null;
try {
tempDAO = m_services.getCDB().get_DAO_Servant("MACI/Channels/" + channelName);
} catch (alma.cdbErrType.CDBXMLErrorEx e) {
m_logger.log(Level.WARNING, "Bad CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx(e);
} catch (alma.cdbErrType.CDBRecordDoesNotExistEx e) {
m_logger.log(Level.WARNING, "No CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJFileNotFoundEx(e);
} catch (AcsJContainerServicesEx e) {
m_logger.log(Level.WARNING, "CDB unavailable");
throw new alma.ACSErrTypeCommon.wrappers.AcsJNoResourcesEx(e);
}
// MaxQueueLength - TAO 1.1 had a queque of ~5 events. TAO 1.3 allows an
// infinite amount of events to be stored. 20 seems like
// a reasonable default.
Any maxQLAny = m_services.getAdvancedContainerServices().getAny();
try {
maxQLAny.insert_long(tempDAO.get_long("MaxQueueLength"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxQL = new Property(MaxQueueLength.value, maxQLAny);
// MaxConsumers - ///////////////////////////////////////////////////////
Any maxConsumersAny = m_services.getAdvancedContainerServices().getAny();
try {
maxConsumersAny.insert_long(tempDAO.get_long("MaxConsumers"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxConsumers = new Property(MaxConsumers.value, maxConsumersAny);
// MaxSuppliers - ///////////////////////////////////////////////////////
Any maxSuppliersAny = m_services.getAdvancedContainerServices().getAny();
try {
maxSuppliersAny.insert_long(tempDAO.get_long("MaxSuppliers"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxSuppliers = new Property(MaxSuppliers.value, maxSuppliersAny);
// RejectNewEvents - if the queque is full, suppliers get exceptions when
// trying to push events onto the channel.
Any rejectNEAny = m_services.getAdvancedContainerServices().getAny();
boolean tBool = true;
try {
if (tempDAO.get_string("RejectNewEvents").equals("false")) {
tBool = false;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
rejectNEAny.insert_boolean(tBool);
Property rejectNE = new Property(RejectNewEvents.value, rejectNEAny);
Property[] adminProps = { maxQL, maxConsumers, maxSuppliers, rejectNE };
return adminProps;
}
use of com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class HibernateWDALImpl method get_DAO_Servant.
/* (non-Javadoc)
* @see com.cosylab.CDB.DALOperations#get_DAO_Servant(java.lang.String)
*/
public DAO get_DAO_Servant(String curl) throws CDBXMLErrorEx, CDBRecordDoesNotExistEx {
checkAccess();
// remove trailing slashes, to have unique curl (used for key)
if (curl.length() > 0 && curl.charAt(0) == '/')
curl = curl.substring(1);
// make sure there are no identical DAOs created
synchronized (daoMap) {
// get cached
if (daoMap.containsKey(curl))
return daoMap.get(curl);
Object node = curl.length() == 0 ? rootNode : DOMJavaClassIntrospector.getNode(curl, rootNode);
if (node == null || DOMJavaClassIntrospector.isPrimitive(node.getClass())) {
AcsJCDBRecordDoesNotExistEx ex = new AcsJCDBRecordDoesNotExistEx();
ex.setCurl(curl);
m_logger.log(AcsLogLevel.NOTICE, "DAL::get_DAO_Servant " + ex.getShortDescription());
throw ex.toCDBRecordDoesNotExistEx();
}
try {
// create object id
byte[] id = curl.getBytes();
Object objImpl = null;
DAOPOA daoImpl = null;
if (node instanceof DAOPOA)
objImpl = daoImpl = (DAOPOA) node;
else if (node instanceof DAOImpl)
objImpl = daoImpl = new DAOPOATie((DAOImpl) node);
else if (node instanceof XMLTreeNode)
//objImpl = daoImpl = new DAOImpl(curl, (XMLTreeNode)node, poa, m_logger);
objImpl = daoImpl = new DAOPOATie(new NoDestroyDAOImpl(curl, (XMLTreeNode) node, poa, m_logger));
else {
//daoImpl = new HibernateDAOImpl(curl, node, poa, m_logger);
HibernateWDAOImpl impl = new HibernateWDAOImpl(mainSession, curl, node, poa, m_logger);
objImpl = impl;
daoImpl = new DAOPOATie(impl);
impl.setSetvant(daoImpl);
}
// activate object
poa.activate_object_with_id(id, daoImpl);
DAO href = DAOHelper.narrow(poa.servant_to_reference(daoImpl));
// map DAO reference
daoMap.put(curl, href);
daoObjMap.put(curl, objImpl);
m_logger.log(AcsLogLevel.INFO, "Returning DAO servant for: " + curl);
return href;
} catch (Throwable t) {
// @todo not clean, just to be consistent v DAL impl
t.printStackTrace();
String info = "DAL::get_DAO_Servant " + t;
AcsJCDBXMLErrorEx xmlErr = new AcsJCDBXMLErrorEx(t);
xmlErr.setErrorString(info);
m_logger.log(AcsLogLevel.NOTICE, info);
throw xmlErr.toCDBXMLErrorEx();
}
}
}
Aggregations