Search in sources :

Example 6 with Object

use of org.omg.CORBA.Object in project ACS by ACS-Community.

the class ManagerProxyImpl method get_default_component.

/**
	 * Returns the default component of specific type.
	 * @param	id		identification of the caller.
	 * @param	type	component type, IDL ID.
	 * @return	<code>ComponentInfo</code> of requested component.
	 */
public ComponentInfo get_default_component(int id, String type) throws NoPermissionEx, NoDefaultComponentEx, CannotGetComponentEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        ComponentInfo retVal = null;
        // transform to CORBA specific
        com.cosylab.acs.maci.ComponentInfo info = manager.getDefaultComponent(id, type);
        if (info == null || info.getComponent() == null)
            throw new AcsJCannotGetComponentEx();
        Object obj = null;
        obj = (Object) info.getComponent().getObject();
        String[] interfaces;
        if (info.getInterfaces() != null)
            interfaces = info.getInterfaces();
        else
            interfaces = new String[0];
        retVal = new ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), mapAccessRights(info.getAccessRights()), interfaces);
        return retVal;
    } catch (NoDefaultComponentException ndce) {
        NoDefaultComponentException hndce = new NoDefaultComponentException(ndce.getMessage(), ndce);
        reportException(hndce);
        // rethrow CORBA specific
        throw new AcsJNoDefaultComponentEx().toNoDefaultComponentEx();
    } 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 (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } 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 : BAD_PARAM(org.omg.CORBA.BAD_PARAM) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) NoDefaultComponentException(com.cosylab.acs.maci.NoDefaultComponentException) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoDefaultComponentEx(alma.maciErrType.wrappers.AcsJNoDefaultComponentEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) ComponentInfo(si.ijs.maci.ComponentInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 7 with Object

use of org.omg.CORBA.Object in project ACS by ACS-Community.

the class ManagerProxyImpl method get_component_non_sticky.

/**
	 * Get a component, do not activate it and also do not do any reference counting.
	 * The client represented by id (the handle)
	 * must have adequate access rights to access the Component. This is untrue of components:
	 * components always have unlimited access rights to other components.
	 *
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param component_url CURL of the Component whose reference is to be retrieved.
	 * @return Reference to the Component.
	 */
public Object get_component_non_sticky(int id, String component_url) throws NoPermissionEx, CannotGetComponentEx, ComponentNotAlreadyActivatedEx {
    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.getComponentNonSticky(id, uri);
        // extract Component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        // @todo
        if (component == null)
            throw new AcsJComponentNotAlreadyActivatedEx();
        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 (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } catch (AcsJComponentNotAlreadyActivatedEx cnaae) {
        // rethrow CORBA specific
        throw cnaae.toComponentNotAlreadyActivatedEx();
    } 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 : BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) AcsJComponentNotAlreadyActivatedEx(alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx) 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 8 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 9 with Object

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);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) Object(org.omg.CORBA.Object) NamingContext(org.omg.CosNaming.NamingContext)

Example 10 with Object

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);
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) Object(org.omg.CORBA.Object)

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