use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.
the class ComponentClientTestCase method connectToManager.
/**
* Connects to the ACS Manager using {@link AcsManagerProxy}.
* @throws Exception
*/
protected void connectToManager() throws Exception {
if (System.getProperty("ACS.manager") != null) {
m_managerLoc = System.getProperty("ACS.manager").trim();
} else {
// default = localhost
String host = ACSPorts.getIP();
m_managerLoc = "corbaloc::" + host + ":" + ACSPorts.getManagerPort() + "/Manager";
}
managerClientImpl = new ManagerClient(getFullName(), m_logger) {
public void disconnect() {
m_logger.info("disconnected from manager");
m_acsManagerProxy.logoutFromManager();
m_acsManagerProxy = null;
throw new RuntimeException("disconnected from the manager");
}
};
ORB orb = acsCorba.getORB();
m_managerClient = managerClientImpl._this(orb);
m_acsManagerProxy = new AcsManagerProxy(m_managerLoc, orb, m_logger);
m_acsManagerProxy.loginToManager(m_managerClient, 1);
}
use of alma.acs.container.AcsManagerProxy 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);
}
}
use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.
the class AdvancedComponentClient method destroyContainerServices.
/**
* "un-factory" method which inverts {@link #createContainerServices(String, Logger)}.
* @param cs ContainerServices instance created by {@link #createContainerServices(String, Logger)}.
*/
public void destroyContainerServices(ContainerServices cs) throws AcsJContainerServicesEx {
if (!additionalContainerServices.containsKey(cs)) {
AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
ex.setContextInfo("The given ContainerServices object was not created by this AdvancedComponentClient!");
throw ex;
}
try {
ContainerServicesImpl csImpl = (ContainerServicesImpl) cs;
AcsManagerProxy acsManagerProxy = additionalContainerServices.get(cs);
acsManagerProxy.shutdownNotify();
csImpl.releaseAllComponents();
((CleaningDaemonThreadFactory) csImpl.getThreadFactory()).cleanUp();
acsManagerProxy.logoutFromManager();
additionalContainerServices.remove(cs);
csImpl.cleanUp();
} catch (Throwable thr) {
AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
ex.setContextInfo("Failed to destroy additional container services instance");
throw ex;
}
}
use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.
the class ComponentClient method initAcs.
private void initAcs(String managerLoc, POA rootPOA) throws Exception {
try {
ManagerClient clImpl = new ManagerClient(m_clientName, m_logger) {
public void disconnect() {
m_logger.info("disconnected from manager");
m_acsManagerProxy.logoutFromManager();
m_acsManagerProxy = null;
throw new RuntimeException("disconnected from the manager");
}
};
m_managerClient = clImpl._this(acsCorba.getORB());
m_acsManagerProxy = new AcsManagerProxy(managerLoc, acsCorba.getORB(), m_logger);
m_acsManagerProxy.loginToManager(m_managerClient, 1);
DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
m_threadFactory = new CleaningDaemonThreadFactory(m_clientName, m_logger);
m_containerServices = new ContainerServicesImpl(m_acsManagerProxy, cdb, rootPOA, acsCorba, m_logger, 0, m_clientName, null, m_threadFactory);
clImpl.setContainerServices(m_containerServices);
initAlarmSystem();
} catch (Exception ex) {
// "or to set up the container services.", ex);
if (acsCorba.getORB() != null) {
acsCorba.getORB().destroy();
}
throw ex;
}
}
Aggregations