Search in sources :

Example 11 with Object

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();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 12 with Object

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());
}
Also used : MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Object(org.omg.CORBA.Object) Test(org.junit.Test)

Example 13 with Object

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());
}
Also used : MvpView(com.hannesdorfmann.mosby3.mvp.MvpView) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Object(org.omg.CORBA.Object) Test(org.junit.Test)

Example 14 with Object

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");
}
Also used : Object(org.omg.CORBA.Object) ConcurrentModificationException(java.util.ConcurrentModificationException)

Example 15 with Object

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;
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) Object(org.omg.CORBA.Object) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) Any(org.omg.CORBA.Any)

Aggregations

Object (org.omg.CORBA.Object)23 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)9 BadParametersException (com.cosylab.acs.maci.BadParametersException)8 CoreException (com.cosylab.acs.maci.CoreException)8 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)8 BAD_PARAM (org.omg.CORBA.BAD_PARAM)8 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)8 UNKNOWN (org.omg.CORBA.UNKNOWN)8 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 Component (com.cosylab.acs.maci.Component)5 URI (java.net.URI)5 URISyntaxException (java.net.URISyntaxException)5 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 AcsJComponentNotAlreadyActivatedEx (alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx)2 AcsJComponentSpecIncompatibleWithActiveComponentEx (alma.maciErrType.wrappers.AcsJComponentSpecIncompatibleWithActiveComponentEx)2 AcsJIncompleteComponentSpecEx (alma.maciErrType.wrappers.AcsJIncompleteComponentSpecEx)2 AcsJInvalidComponentSpecEx (alma.maciErrType.wrappers.AcsJInvalidComponentSpecEx)2 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)2 ComponentSpec (com.cosylab.acs.maci.ComponentSpec)2