use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class CDBAccess method queryNSForDALReference.
private DAL queryNSForDALReference() {
try {
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent[] path = { new NameComponent("CDB", "") };
org.omg.CORBA.Object objectReference = ncRef.resolve(path);
DAL dalRef = DALHelper.narrow(objectReference);
return dalRef;
} catch (Throwable th) {
throw new RuntimeException("Failed to get DAL object from the naming service.", th);
}
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class ContainerServicesImpl method getNameService.
private NamingContext getNameService() throws AcsJContainerServicesEx {
NamingContext nameService = null;
try {
org.omg.CORBA.Object nameServiceObj = m_acsManagerProxy.get_service("NameService", false);
nameService = NamingContextHelper.narrow(nameServiceObj);
} catch (AcsJmaciErrTypeEx ex) {
m_logger.log(Level.FINE, "Failed to get the reference to the NameService service", ex);
throw new AcsJContainerServicesEx(ex);
} catch (Throwable thr) {
String msg = "Unexpectedly failed to get the NameService reference!";
m_logger.log(Level.FINE, msg, thr);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
ex.setContextInfo(msg);
throw ex;
}
return nameService;
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class ACSRemoteAccess method initialize.
/**
* Initialize the connection.
*
* @param theORB The ORB.
* If it is null then a new CORBA connection is initialized.
* @param manager A reference to the Manager
* If it is null a reference is built by reading the properties.
*/
public void initialize(ORB theORB, Manager manager) {
isExternalORB = (theORB != null);
this.orb = theORB;
if (orb == null) {
listenersDispatcher.publishReport("Initializing CORBA...");
// ORB stanza
java.util.Properties orbprops = java.lang.System.getProperties();
orb = ORB.init(new String[0], orbprops);
// POA stanza -- use RootPOA
POA rootPOA = null;
try {
rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
} catch (org.omg.CORBA.ORBPackage.InvalidName in) {
throw new IllegalStateException("Cannot resolve RootPOA: " + in);
}
POAManager poaManager = rootPOA.the_POAManager();
try {
poaManager.activate();
} catch (Exception e) {
throw new IllegalStateException("POAManager activation failed." + e);
}
// setup ORB profiling
try {
if (orb instanceof AcsProfilingORB) {
AcsORBProfiler profiler = new AcsORBProfilerImplBase(logger);
((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
logger.finer("Orb profiling set up, using class " + AcsORBProfilerImplBase.class.getName());
}
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
}
// end of CORBA stanza
listenersDispatcher.publishReport("CORBA initialized.");
}
Manager maciManager = manager;
if (maciManager == null) {
maciManager = resolveManagerReference();
if (maciManager == null) {
// HSO: Ale, should this not throw an exception?
return;
}
}
NamingContext namingContext = resolveNamingServiceContext(maciManager);
if (namingContext == null) {
return;
}
if (!resolveNotifyChannel(LOGGING_XML_CHANNEL, namingContext)) {
return;
}
boolean isConsumerAdminCreated = createConsumerAdmin();
if (!isConsumerAdminCreated) {
return;
}
isInitialized = createStructuredPushConsumer();
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class ManagerContainerServices method createNotificationChannelPublisher.
@Override
public <T> AcsEventPublisher<T> createNotificationChannelPublisher(String channelName, String channelNotifyServiceDomainName, Class<T> eventType) throws AcsJContainerServicesEx {
AcsEventPublisher<T> publisher = null;
try {
// TODO: Matej please help, is there a more elegant way to get the naming service ref?
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
Object[] args = new Object[] { channelName, channelNotifyServiceDomainName, this, ncRef };
// // TODO: Can we do this without the direct cast? The usual "asSubclass" is not enough
// because we don't create a subclass of Class<T> but rather of Class<U<T>>.
// Also the getGenericInterfaces / ParameterizedType trick does not work because because we don't have a
// concrete parameterized type.
Class<AcsEventPublisher<T>> clazz = (Class<AcsEventPublisher<T>>) Class.forName(CLASSNAME_NC_PUBLISHER);
Constructor<? extends AcsEventPublisher<T>> constructor = clazz.getConstructor(String.class, String.class, ContainerServicesBase.class, NamingContext.class);
publisher = constructor.newInstance(args);
} catch (ClassNotFoundException e) {
// TODO: maybe we could prevent future NCPublisher creation tries, since the class isn't and will not be loaded
// The same applies for the next "catch" block
logger.log(AcsLogLevel.ERROR, "Cannot create NC publisher because the 'NCPublisher' class is not present in the classpath", e);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
ex.setContextInfo("'" + CLASSNAME_NC_PUBLISHER + "' class not present in the classpath");
throw ex;
} catch (ClassCastException e) {
logger.log(AcsLogLevel.ERROR, "Cannot create NC publisher because loaded class '" + CLASSNAME_NC_PUBLISHER + "' is not of type 'AcsEventPublisher", e);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
ex.setContextInfo("'" + CLASSNAME_NC_PUBLISHER + "' class does not extend 'AcsEventPublisher'");
throw ex;
} catch (Throwable e) {
logger.log(AcsLogLevel.ERROR, "Unexpected error while creating new AcsEventPublisher object", e);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
throw ex;
}
return publisher;
}
Aggregations