Search in sources :

Example 1 with AcsJmaciErrTypeEx

use of alma.maciErrType.wrappers.AcsJmaciErrTypeEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getCollocatedComponent.

public org.omg.CORBA.Object getCollocatedComponent(ComponentQueryDescriptor spec, boolean markAsDefaul, String targetCompUrl) throws AcsJContainerServicesEx {
    if (spec == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("ComponentQueryDescriptor");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    if (targetCompUrl == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("targetCompUrl");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    ComponentInfo cInfo = null;
    try {
        // the call
        cInfo = m_acsManagerProxy.get_collocated_component(getEffectiveClientHandle(), spec.toComponentSpec(), false, targetCompUrl);
    } catch (AcsJmaciErrTypeEx ex) {
        String msg = "Failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
        // it's serious, but the caller is supposed to log this. Container only logs just in case.
        m_logger.log(Level.FINE, msg, ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "Unexpectedly failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    // @todo check and remove this
    if (cInfo.reference == null) {
        String msg = "Failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
        m_logger.info(msg);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    m_usedComponentsMap.put(cInfo.name, cInfo.reference);
    m_componentDescriptorMap.put(cInfo.name, new ComponentDescriptor(cInfo));
    return cInfo.reference;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 2 with AcsJmaciErrTypeEx

use of alma.maciErrType.wrappers.AcsJmaciErrTypeEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getDynamicComponent.

/**
	 * @see alma.acs.container.ContainerServices#getDynamicComponent(si.ijs.maci.ComponentSpec, boolean)
	 */
public org.omg.CORBA.Object getDynamicComponent(ComponentSpec compSpec, boolean markAsDefault) throws AcsJContainerServicesEx {
    String entryMsg = "getDynamicComponent called with" + " compName=" + compSpec.component_name + " compType=" + compSpec.component_type + " compCode=" + compSpec.component_code + " compContainer=" + compSpec.container_name + " markAsDefault=" + markAsDefault;
    m_logger.fine(entryMsg);
    ComponentInfo cInfo = null;
    try {
        // the call
        cInfo = m_acsManagerProxy.get_dynamic_component(getEffectiveClientHandle(), compSpec, markAsDefault);
        m_usedComponentsMap.put(cInfo.name, cInfo.reference);
        m_componentDescriptorMap.put(cInfo.name, new ComponentDescriptor(cInfo));
    } catch (AcsJmaciErrTypeEx ex) {
        m_logger.log(Level.FINE, "Failed to create dynamic component", ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "Unexpectedly failed to create dynamic component for unexpected reasons!";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    return cInfo.reference;
}
Also used : ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 3 with AcsJmaciErrTypeEx

use of alma.maciErrType.wrappers.AcsJmaciErrTypeEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getNameService.

private NamingContext getNameService() throws AcsJContainerServicesEx {
    NamingContext nameService = null;
    try {
        org.omg.CORBA.Object nameServiceObj = m_acsManagerProxy.get_service("NameService", false);
        nameService = NamingContextHelper.narrow(nameServiceObj);
    } catch (AcsJmaciErrTypeEx ex) {
        m_logger.log(Level.FINE, "Failed to get the reference to the NameService service", ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "Unexpectedly failed to get the NameService reference!";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    return nameService;
}
Also used : AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) NamingContext(org.omg.CosNaming.NamingContext) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 4 with AcsJmaciErrTypeEx

use of alma.maciErrType.wrappers.AcsJmaciErrTypeEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getComponent.

/**
	 * @see alma.acs.container.ContainerServices#getComponent(String)
	 */
public org.omg.CORBA.Object getComponent(String curl) throws AcsJContainerServicesEx {
    if (curl == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("curl");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    // check if our component has requested the other component before
    org.omg.CORBA.Object stub = m_usedComponentsMap.get(curl);
    if (stub != null) {
        // reusing seems ok as long as there is one separate 
        // instance of ContainerServicesImpl for each component.
        // This reuse does not cut off the manager from component access,
        // since it only happens at second or further access attempts;
        // the first time, the component reference is obtained through the manager
        // (independently of whether the components are collocated inside the same container),
        // so that the manager is aware of component dependencies.    
        m_logger.info("client '" + m_clientName + "' attempts to retrieve component '" + curl + "' more than once; will return existing reference.");
    } else {
        m_logger.fine("will retrieve remote component '" + curl + "' using ACS Manager#get_component with client handle " + getEffectiveClientHandle());
        try {
            stub = m_acsManagerProxy.get_component(getEffectiveClientHandle(), curl, true);
            m_logger.fine("component " + curl + " retrieved successfully.");
            m_usedComponentsMap.put(curl, stub);
        } catch (AcsJmaciErrTypeEx ex) {
            String msg = "Failed to retrieve component " + curl;
            // only a low-level log because the client component is supposed to log the exception which contains all context data 
            m_logger.log(Level.FINE, msg, ex);
            throw new AcsJContainerServicesEx(ex);
        } catch (Throwable thr) {
            String msg = "Failed to retrieve component " + curl + " for unexpected reasons.";
            m_logger.log(Level.FINE, msg, thr);
            AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
            ex.setContextInfo(msg);
            throw ex;
        }
    }
    return stub;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 5 with AcsJmaciErrTypeEx

use of alma.maciErrType.wrappers.AcsJmaciErrTypeEx in project ACS by ACS-Community.

the class ContainerServicesImpl method getDefaultComponent.

/**
	 * @see alma.acs.container.ContainerServices#getDefaultComponent(java.lang.String)
	 */
public org.omg.CORBA.Object getDefaultComponent(String componentIDLType) throws AcsJContainerServicesEx {
    if (componentIDLType == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("componentIDLType");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    ComponentInfo cInfo = null;
    try {
        // the call
        cInfo = m_acsManagerProxy.get_default_component(getEffectiveClientHandle(), componentIDLType);
    } catch (AcsJmaciErrTypeEx ex) {
        String msg = "failed to retrieve default component for type " + componentIDLType;
        // higher-level log should be produced by the calling client from the exception later
        m_logger.log(Level.FINE, msg, ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "failed to retrieve default component for type " + componentIDLType + " for unexpected reasons!";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    // @todo check and remove this
    if (cInfo.reference == null) {
        String msg = "Default component for type '" + componentIDLType + "' could not be accessed. ";
        m_logger.info(msg);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    m_usedComponentsMap.put(cInfo.name, cInfo.reference);
    m_componentDescriptorMap.put(cInfo.name, new ComponentDescriptor(cInfo));
    return cInfo.reference;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Aggregations

AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)6 AcsJmaciErrTypeEx (alma.maciErrType.wrappers.AcsJmaciErrTypeEx)6 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)4 ComponentDescriptor (alma.acs.component.ComponentDescriptor)3 ComponentInfo (si.ijs.maci.ComponentInfo)3 NamingContext (org.omg.CosNaming.NamingContext)1