本文整理汇总了Java中org.omg.CosNaming.NamingContextHelper.narrow方法的典型用法代码示例。如果您正苦于以下问题:Java NamingContextHelper.narrow方法的具体用法?Java NamingContextHelper.narrow怎么用?Java NamingContextHelper.narrow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.omg.CosNaming.NamingContextHelper
的用法示例。
在下文中一共展示了NamingContextHelper.narrow方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listBindings
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name - object bindings that
* are present the given subcontext. The enumeration elements have the type of
* {@link Binding}, providing also information about the class of the bound
* object. The behaviour in the case if the bindings are added or removed
* later is not defined. The contents of the subcontexts are not included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration listBindings(Name name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
if (name.size() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve(toGiop(name))));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListBindingsEnumeration(bl, bi, howMany, subcontext);
}
示例2: listBindings
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name - object bindings that
* are present the given subcontext. The enumeration elements have the type of
* {@link Binding}, providing also information about the class of the bound
* object. The behaviour in the case if the bindings are added or removed
* later is not defined. The contents of the subcontexts are not included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration listBindings(Name name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
if (name.size() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve(toGiop(name))));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListBindingsEnumeration(bl, bi, howMany, subcontext);
}
示例3: connect
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Connect to the RMI server
*
* @throws RemoteException
*/
public void connect() {
try {
// ghetto hardcode the parameters
ORB orb = ORB.init(new String[]{"-ORBInitialHost", "localhost", "-ORBInitialPort", "8989"}, null);
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent nc = new NameComponent(station, "");
NameComponent path[] = {nc};
instance = StationInterfaceHelper.narrow(ncRef.resolve(path));
this.log.log("Connected!");
} catch (Exception ex) {
log.log(ex.toString() + ex.getMessage());
}
}
示例4: resolveFirstAsContext
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Implements resolving a NameComponent in this context and
* narrowing it to CosNaming::NamingContext. It will throw appropriate
* exceptions if not found or not narrowable.
* @param impl an implementation of NamingContextDataStore
* @param n a NameComponents which is the name to be found.
* @exception org.omg.CosNaming.NamingContextPackage.NotFound The
* first component could not be resolved.
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed
* in resolving the first component of the supplied name.
* @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.
* @see resolve
*/
protected static NamingContext resolveFirstAsContext(NamingContextDataStore impl,
NameComponent[] n)
throws org.omg.CosNaming.NamingContextPackage.NotFound {
org.omg.CORBA.Object topRef = null;
BindingTypeHolder bth = new BindingTypeHolder();
NamingContext context = null;
synchronized (impl) {
// Resolve first - must be resolveable
topRef = impl.Resolve(n[0],bth);
if (topRef == null) {
// It was not bound
throw new NotFound(NotFoundReason.missing_node,n);
}
}
// Was it bound as a context?
if (bth.value != BindingType.ncontext) {
// It was not a context
throw new NotFound(NotFoundReason.not_context,n);
}
// Narrow to a naming context
try {
context = NamingContextHelper.narrow(topRef);
} catch (org.omg.CORBA.BAD_PARAM ex) {
// It was not a context
throw new NotFound(NotFoundReason.not_context,n);
}
// Hmm. must be ok
return context;
}
示例5: list
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name bindings that are present
* the given subcontext. The enumeration elements have the type of
* {@link NameClassPair}, providing also information about the class of the
* bound object. The behaviour in the case if the bindings are added or
* removed later is not defined. The contents of the subcontexts are not
* included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration list(Name name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
if (name.size() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve(toGiop(name))));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListEnumeration(bl, bi, howMany);
}
示例6: list
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name bindings that are present
* the given subcontext. The enumeration elements have the type of
* {@link NameClassPair}, providing also information about the class of the
* bound object. The behaviour in the case if the bindings are added or
* removed later is not defined. The contents of the subcontexts are not
* included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration list(String name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
String [] n = split(name);
NamingContextExt service = getService(n[0]);
if (n[1].length() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve_str(n[1])));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListEnumeration(bl, bi, howMany);
}
示例7: listBindings
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name - object bindings that
* are present the given subcontext. The enumeration elements have the type of
* {@link Binding}, providing also information about the class of the bound
* object. The behaviour in the case if the bindings are added or removed
* later is not defined. The contents of the subcontexts are not included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration listBindings(String name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
String [] n = split(name);
NamingContextExt service = getService(n[0]);
if (n[1].length() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve_str(n[1])));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListBindingsEnumeration(bl, bi, howMany, subcontext);
}
示例8: list
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name bindings that are present
* the given subcontext. The enumeration elements have the type of
* {@link NameClassPair}, providing also information about the class of the
* bound object. The behaviour in the case if the bindings are added or
* removed later is not defined. The contents of the subcontexts are not
* included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration list(Name name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
if (name.size() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve(toGiop(name))));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListEnumeration(bl, bi, howMany);
}
示例9: list
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name bindings that are present
* the given subcontext. The enumeration elements have the type of
* {@link NameClassPair}, providing also information about the class of the
* bound object. The behaviour in the case if the bindings are added or
* removed later is not defined. The contents of the subcontexts are not
* included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration list(String name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
String [] n = split(name);
NamingContextExt service = getService(n[0]);
if (n[1].length() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve_str(n[1])));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListEnumeration(bl, bi, howMany);
}
示例10: listBindings
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Creates and returns the enumeration over the name - object bindings that
* are present the given subcontext. The enumeration elements have the type of
* {@link Binding}, providing also information about the class of the bound
* object. The behaviour in the case if the bindings are added or removed
* later is not defined. The contents of the subcontexts are not included.
*
* @param name
* the name of the subcontext
* @return the enumeration over the names, known for the given subcontext.
* @throws NamingException
*/
public NamingEnumeration listBindings(String name) throws NamingException
{
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
NamingContext subcontext;
String [] n = split(name);
NamingContextExt service = getService(n[0]);
if (n[1].length() == 0)
subcontext = service;
else
{
try
{
subcontext = (NamingContextHelper.narrow(service.resolve_str(n[1])));
}
catch (Exception e)
{
throw new NamingException(e.toString());
}
}
subcontext.list(howMany, bl, bi);
return new ListBindingsEnumeration(bl, bi, howMany, subcontext);
}
示例11: main
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
public static void main(String args[]) {
try {
System.out.println("Initializing Service...");
// Create and initialize the ORB
ORB orb = ORB.init(args, null);
// Get a reference from rootpoa & Activate the POAManager
POA rootpoa = POAHelper.narrow(orb
.resolve_initial_references(Names.ROOT_POA));
rootpoa.the_POAManager().activate();
// get the root naming context
org.omg.CORBA.Object objRef = orb
.resolve_initial_references(Names.NAME_SERVICE);
NamingContext namingContext = NamingContextHelper.narrow(objRef);
// Create instance of a Service Servant
ServiceServant serviceServant = new ServiceServant(namingContext, orb);
// Register it with the ORB and get the reference to servant
org.omg.CORBA.Object serviceServantCORBA = rootpoa
.servant_to_reference(serviceServant);
// Bind the reference to the Naming Service
NameComponent[] servicePath = { new NameComponent(
Names.SERVICE_NAME_CONTEXT, "Object") };
namingContext.rebind(servicePath, serviceServantCORBA);
System.out.println("Service initialized");
// Run orb to keep it alive and safe from the garbage collector
orb.run();
} catch (Exception e) {
System.err.println("Error: " + e);
e.printStackTrace(System.out);
}
}
示例12: NameService
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
/**
* Create NameService which starts the Root Naming Context in Persistent CosNaming
* @param orb an ORB object.
* @param logDir a File
* @exception java.lang.Exception a Java exception.
*/
public NameService(ORB orb, File logDir)
throws Exception
{
theorb = orb;
// Moved this to the creation of the ORB that is passed into this
// constructor.
//
// This is required for creating Persistent Servants under this ORB
// Right now the Persistent NameService and ORBD are launched together
// Find out a better way of doing this, Since ORBD is an important
// process which should not be killed because of some external process
// orb.setPersistentServerId( (int) 1000 );
// get and activate the root naming POA
POA rootPOA = (POA)orb.resolve_initial_references(
ORBConstants.ROOT_POA_NAME ) ;
rootPOA.the_POAManager().activate();
// create a new POA for persistent Naming Contexts
// With Non-Retain policy, So that every time Servant Manager
// will be contacted when the reference is made for the context
// The id assignment is made by the NameServer, The Naming Context
// id's will be in the format NC<Index>
int i=0;
Policy[] poaPolicy = new Policy[4];
poaPolicy[i++] = rootPOA.create_lifespan_policy(
LifespanPolicyValue.PERSISTENT);
poaPolicy[i++] = rootPOA.create_request_processing_policy(
RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
poaPolicy[i++] = rootPOA.create_id_assignment_policy(
IdAssignmentPolicyValue.USER_ID);
poaPolicy[i++] = rootPOA.create_servant_retention_policy(
ServantRetentionPolicyValue.NON_RETAIN);
nsPOA = rootPOA.create_POA("NameService", null, poaPolicy);
nsPOA.the_POAManager().activate( );
// create and set the servant manager
contextMgr = new
ServantManagerImpl(orb, logDir, this );
// The RootObject key will be NC0
String rootKey = contextMgr.getRootObjectKey( );
// initialize the root Naming Context
NamingContextImpl nc =
new NamingContextImpl( orb, rootKey, this, contextMgr );
nc = contextMgr.addContext( rootKey, nc );
nc.setServantManagerImpl( contextMgr );
nc.setORB( orb );
nc.setRootNameService( this );
nsPOA.set_servant_manager(contextMgr);
rootContext = NamingContextHelper.narrow(
nsPOA.create_reference_with_id( rootKey.getBytes( ),
NamingContextHelper.id( ) ) );
}
示例13: main
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
public static void main(String args[]) {
try {
System.out.println("Initializing Client...");
// Create and initialize the ORB
ORB orb = ORB.init(args, null);
// Get a reference from rootpoa & Activate the POAManager
POA rootpoa = POAHelper.narrow(orb
.resolve_initial_references(Names.ROOT_POA));
rootpoa.the_POAManager().activate();
// get the root naming context
org.omg.CORBA.Object objRef = orb
.resolve_initial_references(Names.NAME_SERVICE);
NamingContext namingContext = NamingContextHelper.narrow(objRef);
String clientName = args[0];
String firstTag = args[1];
String secondTag = args[2];
// String clientName = "FUNCIONARIO";
// String firstTag = "T";
// String secondTag = "H";
ClientServant clientServant = new ClientServant(clientName, firstTag, secondTag);
org.omg.CORBA.Object clientServantCORBA = rootpoa
.servant_to_reference(clientServant);
final String clientNameServiceName = Names.CLIENT_NAME_CONTEXT + "_" + clientName;
// Bind the reference to the Naming Service
NameComponent[] servicePath = { new NameComponent(
clientNameServiceName, "Object") };
namingContext.rebind(servicePath, clientServantCORBA);
NameComponent[] serviceName = { new NameComponent(
Names.SERVICE_NAME_CONTEXT, "Object") };
Service service = ServiceHelper.narrow(namingContext
.resolve(serviceName));
service.registerClient(clientNameServiceName, firstTag, secondTag);
System.out.println("Client initialized");
// Run orb to keep it alive and safe from the garbage collector
orb.run();
} catch (Exception e) {
System.out.println("Error " + e);
e.printStackTrace(System.out);
}
}
示例14: main
import org.omg.CosNaming.NamingContextHelper; //导入方法依赖的package包/类
public static void main(String args[]) {
try {
System.out.println("Initializing Sensor...");
// Create and initialize the ORB
ORB orb = ORB.init(args, null);
// Get a reference from rootpoa & Activate the POAManager
POA rootpoa = POAHelper.narrow(orb
.resolve_initial_references(Names.ROOT_POA));
rootpoa.the_POAManager().activate();
// get the root naming context
org.omg.CORBA.Object objRef = orb
.resolve_initial_references(Names.NAME_SERVICE);
NamingContext namingContext = NamingContextHelper.narrow(objRef);
NameComponent[] serviceName = { new NameComponent(
Names.SERVICE_NAME_CONTEXT, "Object") };
Service service = ServiceHelper.narrow(namingContext
.resolve(serviceName));
String tag = args[0]; // First argument should be the type (T, P, H)
String name = args[1]; // Second argument should be the name
// String tag = "H";
// String name = "Sacada";
SensorServant sensorServant = new SensorServant(name, tag, service);
org.omg.CORBA.Object sensorServantCORBA = rootpoa
.servant_to_reference(sensorServant);
// Bind the reference to the Naming Service
NameComponent[] servicePath = { new NameComponent(
Names.SENSOR_NAME_CONTEXT + tag + "_" + name, "Object") };
namingContext.rebind(servicePath, sensorServantCORBA);
System.out.println("Sensor initialized");
// Run orb to keep it alive and safe from the garbage collector
orb.run();
} catch (Exception e) {
System.out.println("Error " + e);
e.printStackTrace(System.out);
}
}