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;
}
}
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;
}
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()]);
}
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();
}
}
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);
}
}
Aggregations