Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Corba > communication q...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 445 of 534
Post > Topic >>

communication question

by asaf.galili@[EMAIL PROTECTED] Jul 30, 2006 at 07:11 AM

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('@[EMAIL PROTECTED]
').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;
    }
    
}




 1 Posts in Topic:
communication question
asaf.galili@[EMAIL PROTEC  2006-07-30 07:11:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 0:48:55 CDT 2008.