Search in sources :

Example 6 with AcsJContainerServicesEx

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

the class ContainerServicesImpl method checkOffShoot.

/**
	 * @param cbServant
	 * @throws ContainerException
	 */
private void checkOffShoot(Object servant) throws AcsJContainerServicesEx {
    if (servant == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("servant");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    if (!(servant instanceof OffShootOperations)) {
        String msg = "invalid offshoot servant provided. Must implement " + OffShootOperations.class.getName();
        m_logger.fine(msg);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo(msg);
        throw ex;
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) OffShootOperations(alma.ACS.OffShootOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 7 with AcsJContainerServicesEx

use of alma.JavaContainerError.wrappers.AcsJContainerServicesEx 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 8 with AcsJContainerServicesEx

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

the class ContainerServicesImpl method findComponents.

/**
	 * @see alma.acs.container.ContainerServices#findComponents(java.lang.String, java.lang.String)
	 */
@Override
public String[] findComponents(String curlWildcard, String typeWildcard) throws AcsJContainerServicesEx {
    if (curlWildcard == null) {
        curlWildcard = "*";
    }
    if (typeWildcard == null) {
        typeWildcard = "*";
    }
    String msgSpec = "curlWildcard='" + curlWildcard + "' and typeWildcard='" + typeWildcard + "'.";
    if (m_logger.isLoggable(Level.FINER)) {
        m_logger.finer("about to call Manager#get_component_info with " + msgSpec);
    }
    ComponentInfo[] components = null;
    try {
        components = m_acsManagerProxy.get_component_info(new int[0], curlWildcard, typeWildcard, false);
    } catch (AcsJNoPermissionEx ex) {
        m_logger.log(Level.FINE, "No permission to find components with " + msgSpec, ex);
        AcsJContainerServicesEx ex2 = new AcsJContainerServicesEx(ex);
        ex2.setContextInfo(msgSpec);
        throw ex2;
    } catch (Throwable thr) {
        m_logger.log(Level.FINE, "Unexpected failure calling 'get_component_info' with " + msgSpec, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msgSpec);
        throw ex;
    }
    ArrayList<String> curls = new ArrayList<String>();
    if (components != null) {
        for (int i = 0; i < components.length; i++) {
            curls.add(components[i].name);
        }
    }
    if (m_logger.isLoggable(Level.FINER)) {
        m_logger.finer("received " + curls.size() + " curls from get_component_info.");
    }
    return curls.toArray(new String[curls.size()]);
}
Also used : AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ArrayList(java.util.ArrayList) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 9 with AcsJContainerServicesEx

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

the class SimpleSupplierReconnClient method createPublisherAndSubscriber.

public void createPublisherAndSubscriber() {
    try {
        m_client = new ComponentClient(m_logger, System.getProperty("ACS.manager"), "SimpleSupplierReconnClient");
        m_publisher = m_client.getContainerServices().createNotificationChannelPublisher(CHANNEL_NAME, IDLEntity.class);
        ((NCPublisher) m_publisher).setAutoreconnect(m_autoreconnect);
        m_publisher.enableEventQueue(100, m_cbObj);
    //m_publisher.setAutoreconnect(m_autoreconnect);
    } catch (AcsJContainerServicesEx e) {
    // Silently ignore the errors
    } catch (AcsJException e) {
    // Shouldn't happen
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ComponentClient(alma.acs.component.client.ComponentClient) AcsJException(alma.acs.exceptions.AcsJException) NCPublisher(alma.acs.nc.NCPublisher) IDLEntity(org.omg.CORBA.portable.IDLEntity) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) AcsJException(alma.acs.exceptions.AcsJException)

Example 10 with AcsJContainerServicesEx

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

the class AdvancedComponentClient method createContainerServices.

/**
	 * Factory method for additional container service instances. This method should only be used by specialized clients
	 * such as the OMC GUI which needs independent ContainerServices instances for the plug-ins it runs.
	 * <p>
	 * Make sure to call {@link #destroyContainerServices(ContainerServices)} when done with the new CS.
	 * 
	 * @param clientName
	 *            name for {@link ContainerServices#getName()}
	 * @param csLogger
	 *            logger to be used internally by the new ContainerServices instance (which is different from the Logger
	 *            returned in {@link ContainerServices#getLogger()}). 
	 *            Since ACS 8.0 it is recommended to supply an {@link AcsLogger} instead of a plain JDK Logger because a 
	 *            plain Logger will have to be wrapped inside this method.
	 */
public ContainerServices createContainerServices(String clientName, Logger csLogger) throws AcsJContainerServicesEx {
    if (clientName == null) {
        throw new IllegalArgumentException("clientName must not be null");
    }
    if (csLogger == null) {
        throw new IllegalArgumentException("csLogger must not be null");
    }
    try {
        // wrap csLogger if necessary
        AcsLogger acsLogger = AcsLogger.fromJdkLogger(csLogger, null);
        ThreadFactory threadFactory = new CleaningDaemonThreadFactory(clientName, csLogger);
        // separately log in to the manager to get a new client handle.
        // TODO: if this does not work, then we need a way to get a new handle from manager without logging in separately.
        // Note that when activating components, the container receives the new handle directly from the manager.
        AcsManagerProxy acsManagerProxy = m_acsManagerProxy.createInstance();
        ManagerClient clImpl = new ManagerClient(clientName, acsLogger);
        Client managerClient = clImpl._this(acsCorba.getORB());
        acsManagerProxy.loginToManager(managerClient, 0);
        int clientHandle = acsManagerProxy.getManagerHandle();
        DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
        ContainerServicesImpl cs = new ContainerServicesImpl(acsManagerProxy, cdb, acsCorba.getRootPOA(), acsCorba, acsLogger, clientHandle, clientName, null, threadFactory);
        additionalContainerServices.put(cs, acsManagerProxy);
        return cs;
    } catch (Throwable thr) {
        throw new AcsJContainerServicesEx(thr);
    }
}
Also used : CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) Client(si.ijs.maci.Client) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL) AcsLogger(alma.acs.logging.AcsLogger) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Aggregations

AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)51 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)10 AcsJException (alma.acs.exceptions.AcsJException)6 AcsJmaciErrTypeEx (alma.maciErrType.wrappers.AcsJmaciErrTypeEx)6 ComponentDescriptor (alma.acs.component.ComponentDescriptor)5 DAL (com.cosylab.CDB.DAL)5 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 OffShootOperations (alma.ACS.OffShootOperations)3 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)3 EntityT (alma.entities.commonentity.EntityT)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Any (org.omg.CORBA.Any)3 NamingContext (org.omg.CosNaming.NamingContext)3 Servant (org.omg.PortableServer.Servant)3 OffShoot (alma.ACS.OffShoot)2 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)2 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)2 ComponentClient (alma.acs.component.client.ComponentClient)2 AcsManagerProxy (alma.acs.container.AcsManagerProxy)2