use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class AlarmSystemCorbaServer method getCDB.
/**
* Get a reference to the DAL.
*
* @return The DAL
* @throws Exception In case of error getting the DAL
*/
private DAL getCDB() throws Exception {
NamingContext context = getNamingContext();
NameComponent[] nameCom = new NameComponent[1];
nameCom[0] = new NameComponent("CDB", "");
Object obj = context.resolve(nameCom);
return DALHelper.narrow(obj);
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class AcsManagerProxy method findManager.
/**
* Finds the Manger using the supplied <code>managerLoc</code>.
*
* If the manager can't be found, this method enters a loop and tries again after every 3 seconds.
* The number of iterations of the loop is bounded by <code>attempts</code>.
*
* @param managerLoc the corbaloc string that uniquely identifies the manager
* as a CORBA service.
* @param attempts The number of attempts to contact the manager (0 means forever).
* If 0, this method will only return when it has successfully contacted the manager service;
* if greater then 0, this method will simply throw a <code>AcsJContainerServicesEx</code>
* if it fails to resolve the manager.
* @throws AcsJContainerEx if anything goes wrong.
*/
private synchronized void findManager(String managerLoc, int attempts) throws AcsJContainerEx {
if (attempts < 0) {
throw new IllegalArgumentException("Invalid number of attempts to contact the manager: " + attempts);
}
int currentAttempt = attempts;
do {
if (m_shuttingDown) {
//
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("Abandoned because we are shutting down.");
throw ex;
}
try {
org.omg.CORBA.Object object = m_orb.string_to_object(m_managerLoc);
m_logger.finest("manager corbaloc '" + managerLoc + "' resolved.");
m_manager = ManagerHelper.narrow(object);
if (m_manager == null) {
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("received null reference to ACS Manager.");
throw ex;
}
m_logger.finest("manager narrow successful.");
// Set attempts=1 and currentAttempt=0 to exit the loop
attempts = 1;
currentAttempt = 0;
} catch (Throwable thr) {
String msg = "Failed to obtain the manager reference from the corbaloc '" + m_managerLoc + "'. ";
if (attempts == 0 || currentAttempt > 0) {
m_logger.log(Level.INFO, msg + "Will keep trying.");
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
// nada
}
} else {
m_logger.log(Level.WARNING, msg + thr.getMessage());
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo(msg);
throw ex;
}
}
currentAttempt = (attempts == 0) ? 0 : currentAttempt - 1;
} while (attempts == 0 || currentAttempt > 0);
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class AdministratorProxy method component_activated.
/**
* @see com.cosylab.acs.maci.Administrator#component_activated(com.cosylab.acs.maci.ComponentInfo, long, long)
*/
public void component_activated(ComponentInfo info, long timeStamp, long executionId) throws RemoteException {
try {
// invalid info (replacement for null)
final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
si.ijs.maci.ComponentInfo componentInfo = invalidInfo;
if (info != null) {
Object obj = null;
if (info.getComponent() != null)
obj = (Object) info.getComponent().getObject();
String[] interfaces;
if (info.getInterfaces() != null)
interfaces = info.getInterfaces();
else
interfaces = new String[0];
componentInfo = new si.ijs.maci.ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), ManagerProxyImpl.mapAccessRights(info.getAccessRights()), interfaces);
}
administrator.component_activated(componentInfo, UTCUtility.utcJavaToOmg(timeStamp), executionId);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'component_activated()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'component_activated()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'component_activated()' method.", ex);
}
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class ClientProxy method wrapForRoundtripTimeout.
/**
* <p>
* Impl note: The corba spec (v 2.4, 4.3.8.1) describes the difference between
* SetOverrideType.SET_OVERRIDE and SetOverrideType.ADD_OVERRIDE. It is not clear to me (HSO)
* which one should be used, or if there is no practical difference.
* @param corbaRef
* @param timeoutSeconds
* @return
* @throws AcsJCORBAProblemEx
*/
public si.ijs.maci.Client wrapForRoundtripTimeout(si.ijs.maci.Client corbaRef, double timeoutSeconds) throws AcsJCORBAProblemEx {
try {
org.omg.CORBA.ORB orb = getOrb();
Any rrtPolicyAny = orb.create_any();
rrtPolicyAny.insert_ulonglong(UTCUtility.durationJavaMillisToOmg((long) timeoutSeconds * 1000));
Policy p = orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value, rrtPolicyAny);
org.omg.CORBA.Object ret = corbaRef._set_policy_override(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
p.destroy();
return si.ijs.maci.ClientHelper.narrow(ret);
} catch (Throwable thr) {
AcsJCORBAProblemEx ex2 = new AcsJCORBAProblemEx(thr);
ex2.setInfo("Failed to set the object-level client-side corba roundtrip timeout to " + timeoutSeconds);
throw ex2;
}
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class ClientProxy method components_available.
/**
* @see com.cosylab.acs.maci.Client#components_available(ComponentInfo[])
*/
public void components_available(ComponentInfo[] cobs) throws RemoteException {
try {
// invalid info (replacement for null)
final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
// transform to CORBA specific
si.ijs.maci.ComponentInfo[] infos = null;
if (cobs != null) {
infos = new si.ijs.maci.ComponentInfo[cobs.length];
for (int i = 0; i < cobs.length; i++) if (cobs[i] == null)
infos[i] = invalidInfo;
else {
Object obj = null;
if (cobs[i].getComponent() != null)
obj = (Object) cobs[i].getComponent().getObject();
String[] interfaces;
if (cobs[i].getInterfaces() != null)
interfaces = cobs[i].getInterfaces();
else
interfaces = new String[0];
infos[i] = new si.ijs.maci.ComponentInfo(cobs[i].getType(), cobs[i].getCode(), obj, cobs[i].getName(), cobs[i].getClients().toArray(), cobs[i].getContainer(), cobs[i].getContainerName(), cobs[i].getHandle(), ManagerProxyImpl.mapAccessRights(cobs[i].getAccessRights()), interfaces);
}
} else
infos = new si.ijs.maci.ComponentInfo[0];
client.components_available(infos);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'components_available()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'components_available()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'component_available()' method.", ex);
}
}
Aggregations