Search in sources :

Example 1 with Client

use of si.ijs.maci.Client in project ACS by ACS-Community.

the class ManagerDynComponentTest method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl();
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Example 2 with Client

use of si.ijs.maci.Client in project ACS by ACS-Community.

the class BlockingPingClient method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @param	sleepTimeMs	ping sleep time in ms.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager, long sleepTimeMs) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl(sleepTimeMs);
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Example 3 with Client

use of si.ijs.maci.Client 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)

Example 4 with Client

use of si.ijs.maci.Client in project ACS by ACS-Community.

the class DumpManagerState method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl();
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Example 5 with Client

use of si.ijs.maci.Client in project ACS by ACS-Community.

the class BACIRemoteAccess method resolveManager.

/**
	 * Insert the method's description here.
	 * Creation date: (1.11.2000 14:29:17)
	 */
private void resolveManager() {
    if (managerLoc == null)
        throw new IllegalStateException("Cannot resolve manager corbaloc when it is null.");
    try {
        org.omg.CORBA.Object object = orb.string_to_object(managerLoc);
        notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager reference string_to_object OK with managerLoc = '" + managerLoc + "'.");
        manager = ManagerHelper.narrow(object);
        notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager reference narrowing OK.");
        notifier.reportMessage("Obtained reference to 'Manager'.");
        if (manager == null)
            throw new NullPointerException("Manager is null after ManagerHelper.narrow()");
    } catch (Exception e) {
        throw new RemoteException("Could not resolve manager reference: " + e);
    }
    try {
        client = new ClientImpl();
        Client cIF = client._this(orb);
        notifier.reportDebug("BACIRemoteAccess::resolveManager", "Instantiated Client servant.");
        ClientInfo info = manager.login(cIF);
        if (info == null)
            throw new Exception("Failed to login to the manager when returned ClientInfo is null.");
        handle = info.h;
        notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager login OK.");
    } catch (Exception e1) {
        throw new RemoteException("Cannot login to the manager: " + e1);
    }
    new Thread(new Runnable() {

        public void run() {
            notifier.reportDebug("BACIRemoteAccess::resolveManager", "Initializing remote logging...");
            ClientLogManager.getAcsLogManager().initRemoteLogging(orb, manager, handle, true);
            notifier.reportDebug("BACIRemoteAccess::resolveManager", "Remote logging initialized.");
        }
    }, "InitRemoteLogging").start();
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) Client(si.ijs.maci.Client) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Aggregations

Client (si.ijs.maci.Client)7 ClientInfo (si.ijs.maci.ClientInfo)6 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 AcsManagerProxy (alma.acs.container.AcsManagerProxy)1 CleaningDaemonThreadFactory (alma.acs.container.CleaningDaemonThreadFactory)1 ContainerServicesImpl (alma.acs.container.ContainerServicesImpl)1 AcsJException (alma.acs.exceptions.AcsJException)1 AcsLogger (alma.acs.logging.AcsLogger)1 DAL (com.cosylab.CDB.DAL)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 DataException (si.ijs.acs.objectexplorer.engine.DataException)1 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)1 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)1 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)1