use of org.omg.CORBA.StringHolder in project ACS by ACS-Community.
the class StartServicesHelper method internalGetServicesDescription.
/**
* Return the the XML string describing the services to start by reading the services from the
* TMCDB.
*
* @param daemon That services daemon
* @return The XML and the list of services describing the services to start
* @throws HibernateException In case of error reading the services from the TMCDB
* @throws DaemonException In case of error from the daemon
* @throws TMCDBException If the list of service read from the TMCDB is empty
*/
private AlarmServicesDefinitionHolder internalGetServicesDescription(ServicesDaemon daemon) throws HibernateException, DaemonException, TMCDBException {
if (daemon == null) {
throw new IllegalArgumentException("The daemon can't be null");
}
// Get the service definition builder for the current instance
ServiceDefinitionBuilder srvDefBuilder = null;
try {
srvDefBuilder = daemon.create_service_definition_builder((short) instance);
} catch (Throwable t) {
throw new DaemonException("Error getting the service definition builder", t);
}
logger.log(AcsLogLevel.DEBUG, "ServiceDefinitionBuilder got from the ACS services daemon");
// Get the services from the TMCDB
List<AcsServiceToStart> services = getServicesList();
if (services.isEmpty()) {
throw new TMCDBException("No services to start from TMCDB");
}
logger.log(AcsLogLevel.DEBUG, "Read " + services.size() + " to start from TMCDB");
// Add the services to the service definition builder
try {
/*
* NOTE: some of the paremeters required to start the services are hardcoded
* because the tables of the database do not allow to have them stored
* in the TMCDB.
* For this release it is good enough but if we want to have them available
* in the TMCDB and the explorer then we have to change the table of
* the database too.
*/
for (AcsServiceToStart svc : services) {
if (svc.serviceName == null) {
logger.log(AcsLogLevel.DEBUG, "Adding " + svc.serviceType + "@" + svc.hostName + " to the ServicesDefinitionBuilder");
} else {
logger.log(AcsLogLevel.DEBUG, "Adding " + svc.serviceType + "@" + svc.hostName + " with name " + svc.serviceName + " to the ServicesDefinitionBuilder");
}
switch(svc.serviceType) {
case MANAGER:
{
srvDefBuilder.add_manager(svc.hostName, "", false);
break;
}
case ALARM:
{
srvDefBuilder.add_alarm_service(svc.hostName);
break;
}
case CDB:
{
srvDefBuilder.add_rdb_cdb(svc.hostName, false, configurationName);
break;
}
case IFR:
{
srvDefBuilder.add_interface_repository(svc.hostName, true, false);
break;
}
case LOGGING:
{
srvDefBuilder.add_logging_service(svc.hostName, "Log");
break;
}
case LOGPROXY:
{
srvDefBuilder.add_acs_log(svc.hostName);
break;
}
case NAMING:
{
srvDefBuilder.add_naming_service(svc.hostName);
break;
}
case NOTIFICATION:
{
srvDefBuilder.add_notification_service(svc.serviceName, svc.hostName);
break;
}
default:
{
throw new Exception("Unknown type of service to start: " + svc.serviceType + ", on " + svc.hostName);
}
}
}
} catch (Throwable t) {
throw new DaemonException("Error adding services to the daemon", t);
}
logger.log(AcsLogLevel.DEBUG, "All the services have been added to the ServiceDefinitionBuilder");
String svcsXML = srvDefBuilder.get_services_definition();
StringHolder errorStr = new StringHolder();
if (!srvDefBuilder.is_valid(errorStr)) {
// Error in the XML
throw new DaemonException("Error in the services definition: " + errorStr.value);
} else {
logger.log(AcsLogLevel.DEBUG, "Services successfully validated by the ServicesDefinitionBuilder");
}
return new AlarmServicesDefinitionHolder(svcsXML, Collections.unmodifiableList(services));
}
use of org.omg.CORBA.StringHolder in project ACS by ACS-Community.
the class StartServicesHelper method startACSServices.
/**
* Starts the services whose XML definition is in the parameter.
* <P>
* The real starting of services is delegated to {@link #internalStartServices(ServicesDaemon, ServiceDefinitionBuilder, String)}
*
* The starting of the services is delegated to a acs service daemon.
* @param xmlListOfServices The XML describing the list of services to start.
* It is generally returned by getServicesDescription()
*
* @throws GettingDaemonException in case of error getting the services daemon
* @throws DaemonException In case of error from the daemon
*/
public void startACSServices(String xmlListOfServices) throws GettingDaemonException, DaemonException {
if (xmlListOfServices == null || xmlListOfServices.isEmpty()) {
throw new IllegalArgumentException("The XML list of services can't be null nor empty");
}
// Get the reference to the daemon
ServicesDaemon daemon = getServicesDaemon();
// Get the service definition builder for the current instance
ServiceDefinitionBuilder srvDefBuilder = null;
try {
srvDefBuilder = daemon.create_service_definition_builder((short) instance);
} catch (Throwable t) {
throw new DaemonException("Error getting the service definition builder", t);
}
logger.log(AcsLogLevel.DEBUG, "ServiceDefinitionBuilder got from the ACS services daemon");
try {
srvDefBuilder.add_services_definition(xmlListOfServices);
} catch (Throwable t) {
throw new DaemonException("Error adding the list of services to the daemon", t);
}
StringHolder errorStr = new StringHolder();
if (!srvDefBuilder.is_valid(errorStr)) {
// Error in the XML
throw new DaemonException("Invalid XML list of services: " + errorStr.value);
}
internalStartServices(daemon, xmlListOfServices);
}
use of org.omg.CORBA.StringHolder in project ACS by ACS-Community.
the class CorbaNullFinderTest method testNullFinderInContainerSealant.
/**
* Strictly speaking this is a test for {@link ContainerSealant}, but practically fits well in here.
*/
public void testNullFinderInContainerSealant() throws Exception {
// activate the null checker
System.setProperty(ContainerSealant.CHECK_NULLS_CORBA_OUT_PROPERTYNAME, "true");
// The test component, with the real interceptor around it
LogRecordCollectingLogger collectingLogger = LogRecordCollectingLogger.getCollectingLogger("Collecting_" + getName());
ComponentWithBadNullsImpl compImpl = new ComponentWithBadNullsImpl();
ComponentWithBadNullsOperations sealedComponent = ContainerSealant.createContainerSealant(ComponentWithBadNullsOperations.class, compImpl, "InstanceForUnitTest", false, collectingLogger, null, null);
// invocation of methodWithReturnData
String instring = null;
Struct1 instruct1 = ComponentWithBadNullsImpl.createGoodStruct1();
instruct1.myenum1 = null;
instruct1.mystring = null;
StringHolder inoutstringHolder = new StringHolder();
Struct1Holder inoutstruct1Holder = new Struct1Holder();
StringHolder outstringHolder = new StringHolder();
Struct1Holder outstruct1Holder = new Struct1Holder();
sealedComponent.methodWithReturnData(instring, instruct1, inoutstringHolder, inoutstruct1Holder, outstringHolder, outstruct1Holder);
// check the logs produced by the ContainerSealant who uses CorbaNullFinder
LogRecord[] logRecords = collectingLogger.getCollectedLogRecords();
assertEquals(3, logRecords.length);
assertEquals("intercepted a call to 'InstanceForUnitTest#methodWithReturnData'.", logRecords[0].getMessage());
assertTrue(logRecords[1].getMessage().startsWith("returning from InstanceForUnitTest#methodWithReturnData after"));
System.out.println(logRecords[2].getMessage());
assertEquals("Illegal null value in out parameter(s) of method methodWithReturnData:\n" + " Parameter StringHolder: \n" + " Null string in field StringHolder/value\n" + " Parameter Struct1Holder: \n" + " Null string in field Struct1Holder/value/mystring\n" + " Null enum in field Struct1Holder/value/myenum1\n" + " Parameter StringHolder: \n" + " Null string in field StringHolder/value\n" + " Parameter Struct1Holder: \n" + " Null string in field Struct1Holder/value/mystring\n" + " Null enum in field Struct1Holder/value/myenum1\n", logRecords[2].getMessage());
}
use of org.omg.CORBA.StringHolder in project ACS by ACS-Community.
the class OtherComponentClient method testGetDynamicDummyComponent.
public void testGetDynamicDummyComponent() {
StringHolder compNameHolder = new StringHolder();
boolean ret = m_contSrvTesterComp.testGetDynamicDummyComponent(compNameHolder);
assertTrue("test execution successful on the server component", ret);
System.out.println("got dummy component called " + compNameHolder.value);
// assertEquals("OPERATIONAL", compNameHolder.value);
}
use of org.omg.CORBA.StringHolder in project ACS by ACS-Community.
the class OtherComponentClient method testComponentName.
public void testComponentName() {
StringHolder nameHolder = new StringHolder();
boolean ret = m_contSrvTesterComp.testComponentName(nameHolder);
assertTrue("test execution successful on the server component", ret);
assertEquals(CONTSRVCOMP_INSTANCE, nameHolder.value);
}
Aggregations