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;
}
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;
}
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;
}
}
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();
}
}
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();
}
}
Aggregations