Search in sources :

Example 16 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsCorba method initPOAForContainer.

private void initPOAForContainer() throws AcsJContainerEx {
    if (m_containerPOA != null) {
        return;
    }
    Policy[] contPolicies = null;
    try {
        contPolicies = new Policy[4];
        contPolicies[0] = m_rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
        contPolicies[1] = m_rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
        contPolicies[2] = m_rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
        contPolicies[3] = m_rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
        m_containerPOA = m_rootPOA.create_POA("ContainerPOA", sharedPoaManager, contPolicies);
        if (m_containerPOA == null) {
            throw new NullPointerException("ContainerPOA reference == null");
        }
        m_logger.finest("ContainerPOA created.");
    } catch (Throwable thr) {
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo("ContainerPOA creation failed");
        throw ex;
    } finally {
        if (contPolicies != null) {
            for (Policy policy : contPolicies) {
                if (policy != null) {
                    policy.destroy();
                }
            }
        }
    }
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx)

Example 17 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsCorba method deactivateOffShoot.

public void deactivateOffShoot(Servant servant, POA compPOA) throws AcsJContainerEx {
    if (servant == null || compPOA == null) {
        String msg = "deactivateOffShoot called with missing parameter.";
        AcsJContainerEx ex = new AcsJContainerEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    byte[] id = null;
    try {
        POA offshootPoa = getPOAForOffshoots(compPOA);
        id = offshootPoa.servant_to_id(servant);
        offshootPoa.deactivate_object(id);
    } catch (AcsJContainerEx e) {
        throw e;
    } catch (Throwable thr) {
        String msg = "failed to deactivate offshoot of type '" + servant.getClass().getName() + "' (ID=" + String.valueOf(id) + ")";
        m_logger.log(Level.WARNING, msg, thr);
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA)

Example 18 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsCorba method initPOAForComponents.

/**
	 * Creates <code>m_componentPOA</code> as a child of the root POA.
	 * This POA will be the parent of the POAs for the individual components. 
	 * Uses <code>LifespanPolicyValue.PERSISTENT</code>.
	 * 
	 * @throws AcsJContainerServicesEx
	 */
private void initPOAForComponents() throws AcsJContainerEx {
    if (m_componentPOA != null) {
        return;
    }
    try {
        m_compPolicies = new Policy[4];
        m_compPolicies[0] = m_rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
        m_compPolicies[1] = m_rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
        m_compPolicies[2] = m_rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
        m_compPolicies[3] = m_rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
        m_componentPOA = m_rootPOA.create_POA("ComponentPOA", sharedPoaManager, m_compPolicies);
        if (m_componentPOA == null) {
            throw new NullPointerException("ComponentPOA reference == null");
        }
        m_logger.finest("ComponentPOA created.");
    } catch (Throwable thr) {
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo("ComponentPOA creation failed");
        throw ex;
    }
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx)

Example 19 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx 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 20 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsCorba method getPOAForOffshoots.

/**
	 * Creates (or reuses) the non-persistent POA for offshoot objects as a child of the given POA.
	 * In spite of the suggestive name 'componentPOA', this POA can actually be any kind of POA,
	 * so that also client application can use the offshoot mechanism. 
	 * <p>
	 * This method is synchronized inside to avoid race conditions between several offshoot POA creation/retrievals,
	 * where otherwise the POA would fail to be created even though first it was not found for reuse.
	 * 
	 * @param componentPOA  the POA of the component that owns the offshoot object;
	 * 							 will become the parent of the offshoot POA.
	 * @return POA  non-persistent POA for offshoot objects for the current component.
	 * 
	 * @throws AcsJContainerServicesEx
	 */
public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    POA offshootPoa = null;
    synchronized (componentPOA) {
        try {
            // can we reuse it? 
            offshootPoa = componentPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            m_logger.finest("will have to create offshoot POA");
            if (m_offshootPolicies == null) {
                m_offshootPolicies = new Policy[4];
                m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = componentPOA.create_POA(offshootPoaName, sharedPoaManager, m_offshootPolicies);
                m_logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
    return offshootPoa;
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Aggregations

AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)27 POA (org.omg.PortableServer.POA)6 Object (org.omg.CORBA.Object)4 Policy (org.omg.CORBA.Policy)4 AdapterAlreadyExists (org.omg.PortableServer.POAPackage.AdapterAlreadyExists)4 InvalidPolicy (org.omg.PortableServer.POAPackage.InvalidPolicy)4 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)3 AdapterNonExistent (org.omg.PortableServer.POAPackage.AdapterNonExistent)3 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)2 AcsJException (alma.acs.exceptions.AcsJException)2 AcsLogger (alma.acs.logging.AcsLogger)2 LogConfigException (alma.acs.logging.config.LogConfigException)2 StopWatch (alma.acs.util.StopWatch)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 Servant (org.omg.PortableServer.Servant)2 CouldntAccessComponentEx (alma.ACSErrTypeCommon.CouldntAccessComponentEx)1 CouldntAccessPropertyEx (alma.ACSErrTypeCommon.CouldntAccessPropertyEx)1 TypeNotSupportedEx (alma.ACSErrTypeCommon.TypeNotSupportedEx)1 AcsComponentClassLoader (alma.acs.classloading.AcsComponentClassLoader)1 ComponentLifecycle (alma.acs.component.ComponentLifecycle)1