AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

communication question

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and CORBA
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun Jul 30, 2006 7:11 pm    Post subject: communication question Reply with quote



Hello,

In my program, I create one NamingContextExt obj (one connection to
orbix naming server), and from that point, every object I need to
resolve - I use the same NamingContextExt.

My question: how can I know if the naming context reference is up and
valid, or if there is a communication problem and it is down?

Can I perforn a test to check the validity of the NamingContextExt
before I return the ncRef object? Are there a built in functions?
Is there some kind of special exception?

Thanks,
Asaf

P.S

My singleton which hold the NamingContextExt is:

package com.comverse.tcm.SCEConnector;

import com.comverse.tcm.vfit.ConfLoader;

import org.omg.CORBA.ORB;
import org.omg.CORBA.ShortHolder;
import org.omg.CORBA.StringHolder;
import org.omg.CORBA.UserException;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.CosNaming.NamingContextPackage.*;

import SCE.VsCollector;
import SCE.VsCollectorHelper;

import com.comverse.model.Event;
import com.comverse.model.KeyModel;
import com.comverse.model.KeyModelInterface;
import com.comverse.model.Listener;

import com.comverse.cap.cifs.log.LogWriterIfc;
import com.comverse.cap.cifs.log.LogWriter;

public class NamingServiceHolder {

private LogWriterIfc log =
LogWriter.getInstance(NamingServiceHolder.class);/* logger */

private ConfLoader conf = null;

private boolean isConnected;

private static NamingServiceHolder instance = null;

private static NamingContextExt ncRef = null;

private NamingServiceHolder() {
isConnected = false;
conf = ConfLoader.getInstance();
log.debug("Got new NamingServiceHolder");
}

public static NamingServiceHolder getInstance() {
if (instance == null) {
instance = new NamingServiceHolder();
}
return instance;
}

public boolean connect() {
log.debug("Connecting to ORBIX server");
String version = conf.getNamingServiceVersion();
String ip = conf.getNamingServiceIP();
int port = conf.getNamingServicePort();
String namingServiceName = conf.getNamingServiceName();

// create and initialize the ORB
String[] array = null;
ORB orb = ORB.init(array, null);

// get the root naming context
StringBuffer sb = new StringBuffer();
sb.append("corbaloc:iiop:").append(version).append('@').append(ip).append(':').append(port).append('/').append(namingServiceName);
String corbalocStr = sb.toString();
log.debug("corbaloc String: " + corbalocStr);

try {
org.omg.CORBA.Object objRef = orb.string_to_object(corbalocStr);
if(objRef == null) {
log.error("Could not get object of the NamingService");
isConnected = false;
return false;
}
ncRef = NamingContextExtHelper.narrow(objRef);
log.debug("Got handle to the naming service, found ORBD");
isConnected = true;
return true;
}
catch (org.omg.CORBA.COMM_FAILURE cf) {
log.error("Communication failure (probably problem with the
naming service): " + cf.toString());
isConnected = false;
return false;
}
}

public NamingContextExt getNcRef() {
return ncRef;
}

public boolean getIsConnected() {
return isConnected;
}

}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and CORBA All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.