use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class ManagerProxyImpl method restart_component.
/**
* Restarts an component.
* @param id identification of the caller. Called has to be an owner of the component.
* @param component_url CURL of the component to be restarted.
* @return CORBA reference of the restarted component, <code>null</code> if it fails.
*/
public Object restart_component(int id, String component_url) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// returned value
Object retVal = null;
// transform to CORBA specific
URI uri = null;
if (component_url != null)
uri = CURLHelper.createURI(component_url);
Component component = manager.restartComponent(id, uri);
// extract component CORBA reference
if (component != null)
retVal = (Object) component.getObject();
return retVal;
} catch (URISyntaxException usi) {
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(usi.getMessage());
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (AcsJBadParameterEx bpe) {
reportException(bpe);
//throw bpe.toBadParameterEx();
throw new BAD_PARAM(bpe.getMessage());
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of org.omg.CORBA.Object in project mosby by sockeqwe.
the class MviBasePresenterTest method resetOnViewDetachedPermanently.
@Test
public void resetOnViewDetachedPermanently() {
final AtomicInteger bindInvocations = new AtomicInteger(0);
final AtomicInteger unbindInvocations = new AtomicInteger(0);
MvpView view = new MvpView() {
};
MviBasePresenter<MvpView, Object> presenter = new MviBasePresenter<MvpView, Object>() {
@Override
protected void bindIntents() {
bindInvocations.incrementAndGet();
}
@Override
protected void unbindIntents() {
super.unbindIntents();
unbindInvocations.incrementAndGet();
}
};
presenter.attachView(view);
presenter.detachView();
presenter.destroy();
presenter.attachView(view);
presenter.detachView();
presenter.attachView(view);
presenter.detachView();
presenter.destroy();
Assert.assertEquals(2, bindInvocations.get());
Assert.assertEquals(2, unbindInvocations.get());
}
use of org.omg.CORBA.Object in project mosby by sockeqwe.
the class MviBasePresenterTest method bindIntentsAndUnbindIntentsOnlyOnce.
@Test
public void bindIntentsAndUnbindIntentsOnlyOnce() {
final AtomicInteger bindInvocations = new AtomicInteger(0);
final AtomicInteger unbindInvocations = new AtomicInteger(0);
MvpView view = new MvpView() {
};
MviBasePresenter<MvpView, Object> presenter = new MviBasePresenter<MvpView, Object>() {
@Override
protected void bindIntents() {
bindInvocations.incrementAndGet();
}
@Override
protected void unbindIntents() {
super.unbindIntents();
unbindInvocations.incrementAndGet();
}
};
presenter.attachView(view);
presenter.detachView();
presenter.attachView(view);
presenter.detachView();
presenter.attachView(view);
presenter.detachView();
presenter.destroy();
Assert.assertEquals(1, bindInvocations.get());
Assert.assertEquals(1, unbindInvocations.get());
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class AcsCorba method initRootPoa.
// /**
// * Initializes the <code>m_rootPOA</code> and <code>m_poaManager</code> fields
// * with the root POA and its POA manager.
// * @throws AcsJContainerServicesEx
// */
// private void initRootPoa() throws AcsJContainerServicesEx
// {
// m_rootPOA = null;
// try {
// m_rootPOA = POAHelper.narrow(m_orb.resolve_initial_references("RootPOA"));
//
// if (m_rootPOA != null) {
// m_logger.finest("RootPOA initialized.");
// }
// else {
// throw new AcsJContainerServicesEx("RootPOA == null");
// }
//
// // POA manager, same for all POAs
// m_poaManager = m_rootPOA.the_POAManager();
// if (m_poaManager == null) {
// throw new AcsJContainerServicesEx("POAManager == null");
// }
// }
// catch (AcsJContainerServicesEx ex) {
// throw ex;
// }
// catch (Exception ex) {
// throw new AcsJContainerServicesEx("Cannot resolve RootPOA: ", ex);
// }
//
// }
/**
* Initializes the root poa on the ORB provided as an argument.
* Also obtains the POA manager, but does not yet initialize it. See {@link #runCorba()}.
* <p>
* Note that this method does not work on <code>m_orb</code> member variable,
* since in method <code>trialAndError</code> we use tentative OBRs.
*
* @param orb
* @throws IllegalStateException if allocation failed, likely due to an unavailable port.
* TODO: use a better fitting exception instead
*/
protected void initRootPoa(ORB orb) {
m_rootPOA = null;
try {
m_logger.fine("calling orb.resolve_initial_references");
Object obj = orb.resolve_initial_references("RootPOA");
m_rootPOA = POAHelper.narrow(obj);
} catch (org.omg.CORBA.ORBPackage.InvalidName exc) {
throw new IllegalStateException("couldn't retrieve RootPOA: " + exc);
} catch (RuntimeException exc) {
throw new IllegalStateException("port taken?, couldn't retrieve RootPOA:" + exc);
}
try {
sharedPoaManager = m_rootPOA.the_POAManager();
} catch (Exception exc) {
throw new IllegalStateException("Failed to get POA manager: " + exc);
}
m_logger.fine("POA activated");
}
use of org.omg.CORBA.Object in project ACS by ACS-Community.
the class AcsCorba 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 AcsJContainerServicesEx
* @see {@link #setORBLevelRoundtripTimeout(double)}
*/
public org.omg.CORBA.Object wrapForRoundtripTimeout(org.omg.CORBA.Object corbaRef, double timeoutSeconds) throws AcsJContainerServicesEx {
if (!isInitialized()) {
throw new IllegalStateException("Only call when this object has been initialized!");
}
org.omg.CORBA.Object ret = null;
try {
Any rrtPolicyAny = m_orb.create_any();
rrtPolicyAny.insert_ulonglong(UTCUtility.durationJavaMillisToOmg((long) timeoutSeconds * 1000));
Policy p = m_orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value, rrtPolicyAny);
ret = corbaRef._set_policy_override(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
p.destroy();
} catch (Throwable thr) {
AcsJContainerServicesEx ex2 = new AcsJContainerServicesEx(thr);
ex2.setContextInfo("Failed to set the object-level client-side corba roundtrip timeout to " + timeoutSeconds);
throw ex2;
}
return ret;
}
Aggregations