use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsCorba method createPOAForComponent.
/**
* Creates a new POA that is responsible for exactly one component.
* Dependent CORBA objects (offshoots) are activated through a child POA.
* The new POA is created as a child of the shared ComponentPOA.
* <p>
* The new component POA uses its own POA manager, which allows discarding requests for this component
* (w/o discarding requests for other components, the container, or even this component's offshoots).
*
* @param compName the name of the component; used to construct the POA name by prepending "ComponentPOA_"
* @return the new component POA; never null.
* @throws AcsJContainerServicesEx if creation of the POA fails.
*/
public POA createPOAForComponent(String compName) throws AcsJContainerEx {
if (m_componentPOA == null) {
throw new IllegalStateException("Must call 'initPOAForComponents()' before 'createPOAForComponent'.");
}
POA compChildPOA = null;
String compChildPOAName = "ComponentPOA_" + compName;
try {
try {
// will create its own POAManager
compChildPOA = m_componentPOA.create_POA(compChildPOAName, null, m_compPolicies);
} catch (org.omg.PortableServer.POAPackage.AdapterAlreadyExists ex1) {
// todo: perhaps better create a new POA, since the old POA of the same name may belong
// to a shutting down component for which etherealization timed out.
// Perhaps mark a component POA as "useless" once manager calls deactivate on the container
m_logger.warning(compChildPOAName + " already exists even though it should not. Will try to reuse it...");
compChildPOA = m_componentPOA.find_POA(compChildPOAName, true);
}
compChildPOA.the_POAManager().activate();
} catch (Throwable thr) {
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("failed to create POA for component " + compName);
throw ex;
}
return compChildPOA;
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsCorba method activateOffShoot.
/**
* Activates an offshoot object (which is a regular CORBA object
* owned by a component).
* <p>
* All offshoot objects for a component are activated using a non-persistent "offshootPOA".
*
* @param servant the offshoot servant.
* @param compPOA the POA responsible for the component which activates the offshoot.
* @return the activated offshoot corba object.
* @throws AcsJContainerServicesEx
*/
public org.omg.CORBA.Object activateOffShoot(Servant servant, POA compPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
if (servant == null || compPOA == null) {
String msg = "activateOffShoot called with missing parameter.";
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo(msg);
throw ex;
}
POA offshootPoa = getPOAForOffshoots(compPOA);
org.omg.CORBA.Object actObj = null;
try {
offshootPoa.activate_object(servant);
actObj = offshootPoa.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("offshoot of type '" + servant.getClass().getName() + "' activated as a CORBA object.");
} catch (Throwable thr) {
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo("failed to activate offshoot of type '" + servant.getClass().getName());
throw ex;
}
return actObj;
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class ContainerServicesImpl method deactivateOffShoot.
@Override
public void deactivateOffShoot(Object offshootImpl) throws AcsJContainerServicesEx {
checkOffShoot(offshootImpl);
try {
acsCorba.deactivateOffShoot(m_activatedOffshootsMap.get(offshootImpl), m_clientPOA);
m_activatedOffshootsMap.remove(offshootImpl);
m_logger.fine("successfully deactivated offshoot of type " + offshootImpl.getClass().getName());
} catch (AcsJContainerEx e) {
throw new AcsJContainerServicesEx(e);
}
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsCorba method setServantManagerOnComponentPOA.
/**
* Creates a servant manager of type <code>ComponentServantManager</code>,
* attaches it to the POA, and activates the servant manager.
* <p>
* This <code>ComponentServantManager</code> can be used as a semaphore to synchronize
* with component etherealization during POA destruction.
* <p>
* Note that {@link org.omg.PortableServer.POAOperations#get_servant_manager()} will not return
* the <code>ComponentServantManager</code> implementation class, but instead a proxy object (_ServantActivatorStub).
* @param componentPOA a component POA
*
* @return the new <code>ComponentServantManager</code>.
* @throws AcsJContainerServicesEx
*/
public ComponentServantManager setServantManagerOnComponentPOA(POA componentPOA) throws AcsJContainerEx {
ComponentServantManager servantManager;
try {
servantManager = new ComponentServantManager(m_logger);
componentPOA.set_servant_manager(servantManager);
} catch (Throwable thr) {
String msg = "Failed to set a servant activator on the component POA " + componentPOA.the_name();
m_logger.log(Level.FINE, msg, thr);
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo(msg);
throw ex;
}
return servantManager;
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsCorba method initCorba.
/**
* Initializes the ORB and POAs to be used by a Java container.
* <p>
* Calls {@link #setPortOptions(Integer, Integer) setPortOptions} to ensure that for container ORBs
* the specified port gets used. Thus any previous settings of port finding options will be overwritten.
*
* @param args command line arguments for the ORB
* @param port fixed port to be used by the ORB; this method will fail if the port is busy,
* since no retries with different ports will be done.
* @throws AcsJContainerServicesEx
*/
public synchronized void initCorba(String[] args, int port) throws AcsJContainerEx {
if (isInitialized()) {
throw new IllegalStateException("Illegal call to initCorba. ORB/POAs have already been initialized.");
}
try {
setPortOptions(new Integer(port), new Integer(0));
prepareOrb(args);
// for a container we need the following POAs:
initPOAForContainer();
initPOAForComponents();
setInitialized(true);
} catch (Throwable thr) {
if (thr instanceof AcsJContainerEx) {
throw (AcsJContainerEx) thr;
}
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo("initCorba failed.");
throw ex;
}
// Our start script 'acsStartJavaContainer' sets the property alma.acs.orb.profiler.class,
// either using optional env var "JAVA_OPTIONS_ORB_PROFILER" or otherwise 'ContainerOrbProfiler' as default profiler.
initOrbProfiling();
}
Aggregations