Search in sources :

Example 16 with Object

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

the class AcsCorba method activateContainer.

/**
	 * Activates the container using the respective POA, so that the container
	 * becomes a CORBA object.
	 * 
	 * @param container  the container servant
	 * @param name	 a name assigned to the container, used as the CORBA id.
	 * @return the container CORBA object, never null
	 * @throws AcsJContainerEx  if args are null or the activation fails for whatever reason.
	 */
public org.omg.CORBA.Object activateContainer(AcsContainer container, String name) throws AcsJContainerEx {
    if (name == null || name.length() == 0 || container == null) {
        String msg = "activateContainer called with missing parameter.";
        AcsJContainerEx ex = new AcsJContainerEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    m_logger.finer("entering activateContainer name=" + name);
    org.omg.CORBA.Object actObj = null;
    try {
        byte[] id = name.getBytes();
        // container is a CORBA Servant...
        m_containerPOA.activate_object_with_id(id, container);
        actObj = m_containerPOA.servant_to_reference(container);
        // just to provoke an exc. if something is wrong with our new object
        actObj._hash(Integer.MAX_VALUE);
    } catch (Throwable thr) {
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo("failed to activate container object " + name);
        throw ex;
    }
    return actObj;
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) Object(org.omg.CORBA.Object)

Example 17 with Object

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

the class AcsCorba method activateComponent.

/**
	 * Activates a component using a given component POA.
	 * @param servant
	 * @param name
	 * @param compPOA
	 * @return the component as a CORBA object
	 * @throws AcsJContainerServicesEx
	 */
public org.omg.CORBA.Object activateComponent(Servant servant, String name, POA compPOA) throws AcsJContainerEx {
    if (name == null || name.length() == 0 || servant == null || compPOA == null) {
        AcsJContainerEx ex = new AcsJContainerEx();
        ex.setContextInfo("activateComponent called with missing parameter.");
        throw ex;
    }
    m_logger.finer("entering activateComponent: name=" + name);
    org.omg.CORBA.Object actObj = null;
    try {
        byte[] id = name.getBytes();
        compPOA.activate_object_with_id(id, servant);
        actObj = compPOA.servant_to_reference(servant);
        // just to provoke an exc. if something is wrong with our new object
        actObj._hash(Integer.MAX_VALUE);
        m_logger.finer("component '" + name + "' activated as CORBA object.");
    } catch (Throwable thr) {
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo("failed to activate component " + name);
        throw ex;
    }
    return actObj;
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) Object(org.omg.CORBA.Object)

Example 18 with Object

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

the class ManagerProxy method getComponent.

/**
     * @see com.cosylab.acs.maci.Manager#getComponent(int, java.net.URI, boolean, com.cosylab.acs.maci.StatusHolder)
     */
public Component getComponent(int id, URI curl, boolean activate, StatusHolder status) throws AcsJNoPermissionEx {
    try {
        Component retVal = null;
        org.omg.CORBA.Object object = manager.get_component(id, curl.toString(), activate);
        if (object != null) {
            retVal = new ComponentProxy(curl.toString(), object);
        }
        return retVal;
    } catch (NoPermissionEx npex) {
        AcsJNoPermissionEx npe = new AcsJNoPermissionEx();
        npe.setReason("Remote manager has thrown no permission exception.");
        npe.setID(HandleHelper.toString(id));
        npe.setProtectedResource(curl.toString());
        throw npe;
    } catch (Exception ex) {
        //throw re;
        return null;
    }
}
Also used : AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) Object(org.omg.CORBA.Object) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) Component(com.cosylab.acs.maci.Component) IOException(java.io.IOException) NoDefaultComponentException(com.cosylab.acs.maci.NoDefaultComponentException)

Example 19 with Object

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

the class ManagerProxyImpl method get_component.

/**
	 * Get a Component, activating it if necessary.
	 * 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.
	 * @param activate True if the Component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the Component. If the Component could not be activated, an exception is throw.
	 */
public Object get_component(int id, String component_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx, ComponentNotAlreadyActivatedEx, ComponentConfigurationNotFoundEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.getComponent(id, uri, activate, statusHolder);
        // extract Component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        /**
			 * @todo GCH 2006.10.11
			 *       notice that we can get a ComponentStatus != COMPONENT_ACTIVATED
			 *       also if the component is properly returned.
			 *       There is an incoherence here in the interfaces that shall be resolved.
			 *       We have to cleanup here or go back to return a status
			 *       to the caller.
			 *       My point is: the caller is interested in more than just 
			 *       getting the component of an indication of failure if not?
			 *       Is it interesting to know that the component was not activated,
			 *       presumably because already active? 
			 */
        if (component == null || component.getObject() == null) {
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_NOT_ACTIVATED && !activate) {
                AcsJComponentNotAlreadyActivatedEx ex = new AcsJComponentNotAlreadyActivatedEx();
                ex.setCURL(component_url);
                throw ex;
            }
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_DOES_NO_EXIST) {
                AcsJComponentConfigurationNotFoundEx ex = new AcsJComponentConfigurationNotFoundEx();
                ex.setCURL(component_url);
                throw ex;
            } else {
                AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx();
                ex.setCURL(component_url);
                throw ex;
            }
        }
        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 (AcsJComponentConfigurationNotFoundEx ccnfe) {
        // rethrow CORBA specific
        throw ccnfe.toComponentConfigurationNotFoundEx();
    } 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) StatusHolder(com.cosylab.acs.maci.StatusHolder) 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) AcsJComponentConfigurationNotFoundEx(alma.maciErrType.wrappers.AcsJComponentConfigurationNotFoundEx) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 20 with Object

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

the class ManagerProxyImpl method get_service.

/**
	 * Get a service, activating it if necessary (components).
	 * The client represented by id (the handle) must have adequate access rights to access the service.
	 * NOTE: a component is also a service, i.e. a service activated by a container.
	 * 
	 * @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 service_url CURL of the service whose reference is to be retrieved.
	 * @param activate True if the component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @param status Status of the request. One of COMPONENT_ACTIVATED, COMPONENT_DOES_NO_EXIST and COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the service. If the service could not be obtained, a nil reference is returned,
	 *		  and the status contains an error code detailing the cause of failure (one of the COMPONENT_* constants).
	 * @see #get_component
	 */
public Object get_service(int id, String service_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (service_url != null)
            uri = CURLHelper.createURI(service_url);
        Component component = manager.getService(id, uri, activate, statusHolder);
        if (component == null || (Object) component.getObject() == null)
            throw new AcsJCannotGetComponentEx();
        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 (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } 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) StatusHolder(com.cosylab.acs.maci.StatusHolder) 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)

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