use of org.omg.CosNaming.NameComponent in project ACS by ACS-Community.
the class ClientLogManager method getLogServiceFromNameSarvice.
/**
* Get the log service from the name server. It is used by ACS services that do
* not log into the manager and therefore can't use {@link #getLogService(Manager, int)}.
*
* @param orb The not <code>null</code> ORB
* @return The log service
* @throws InvalidName
*/
protected AcsLogServiceOperations getLogServiceFromNameSarvice(ORB orb) throws InvalidName {
if (orb == null) {
throw new IllegalArgumentException("The ORB can't be null!");
}
org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService");
NamingContext context = NamingContextExtHelper.narrow(obj);
if (context == null) {
throw new NullPointerException("Got a null NamingContext");
}
try {
// try naming service first
NameComponent[] nameComponent = new NameComponent[1];
nameComponent[0] = new NameComponent("Log", "");
org.omg.CORBA.Object logObj = context.resolve(nameComponent);
return AcsLogServiceHelper.narrow(logObj);
} catch (Throwable th) {
System.out.println("Failed to obtain alarm service reference from naming service, trying corbaloc...");
}
String corbaloc = "corbaloc::" + ACSPorts.getIP() + ":" + ACSPorts.getLogPort() + "/Log";
org.omg.CORBA.Object logObj = orb.string_to_object(corbaloc);
return AcsLogServiceHelper.narrow(logObj);
}
use of org.omg.CosNaming.NameComponent in project ACS by ACS-Community.
the class EventModel method resolveNotifyService.
/**
* Resolves the notify service that is bound in the naming service with the given name.
* <p>
* This method may get called when the notify service is not reachable.
* Therefore we do not return the narrowed object, since the narrow operation makes a remote "is_a" call
* that in this case would take very long.
*/
private org.omg.CORBA.Object resolveNotifyService(String notifyBindingName) throws CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, NotFound {
NameComponent[] ncomp = new NameComponent[1];
ncomp[0] = new NameComponent(notifyBindingName, "");
return nctx.resolve(ncomp);
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class EjbIIOPService method rebind.
/**
* (Re)binds an object to a name in a given CORBA naming context, creating
* any non-existent intermediate contexts along the way.
* <p/>
* This method is synchronized on the class object, if multiple services attempt to bind the
* same context name at once it will fail
*
* @param ctx a reference to the COSNaming service.
* @param strName the name under which the CORBA object is to be bound.
* @param obj the CORBA object to be bound.
* @throws Exception if an error occurs while binding the object.
*/
public static synchronized void rebind(final NamingContextExt ctx, final String strName, final org.omg.CORBA.Object obj) throws Exception {
final NameComponent[] name = ctx.to_name(strName);
NamingContext intermediateCtx = ctx;
for (int i = 0; i < name.length - 1; i++) {
final NameComponent[] relativeName = new NameComponent[] { name[i] };
try {
intermediateCtx = NamingContextHelper.narrow(intermediateCtx.resolve(relativeName));
} catch (NotFound e) {
intermediateCtx = intermediateCtx.bind_new_context(relativeName);
}
}
intermediateCtx.rebind(new NameComponent[] { name[name.length - 1] }, obj);
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class EjbIIOPService method stop.
@Override
public synchronized void stop(final StopContext context) {
// Get local (in-VM) CORBA naming context
final NamingContextExt corbaContext = corbaNamingContext.getValue();
// Unregister bean home from local CORBA naming context
try {
NameComponent[] name = corbaContext.to_name(this.name);
corbaContext.unbind(name);
} catch (InvalidName invalidName) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(invalidName);
} catch (NotFound notFound) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(notFound);
} catch (CannotProceed cannotProceed) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(cannotProceed);
}
// Deactivate the home servant and the bean servant
try {
homeServantRegistry.unbind(homeServantName(this.name));
} catch (Exception e) {
EjbLogger.ROOT_LOGGER.cannotDeactivateHomeServant(e);
}
try {
beanServantRegistry.unbind(beanServantName(this.name));
} catch (Exception e) {
EjbLogger.ROOT_LOGGER.cannotDeactivateBeanServant(e);
}
if (iri != null) {
// Deactivate the interface repository
iri.shutdown();
}
this.name = null;
}
use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.
the class CorbaNamingContext method bind_context.
public void bind_context(NameComponent[] nc, NamingContext obj) throws NotFound, CannotProceed, InvalidName, AlreadyBound {
if (this.destroyed)
throw new CannotProceed();
Name n = new Name(nc);
Name ctx = n.ctxName();
NameComponent nb = n.baseNameComponent();
if (ctx == null) {
if (this.names.containsKey(n)) {
// if the name is still in use, try to ping the object
org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.names.get(n);
if (isDead(ref))
unbind(n.components());
else
throw new AlreadyBound();
} else if (this.contexts.containsKey(n)) {
// if the name is still in use, try to ping the object
org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.contexts.get(n);
if (isDead(ref)) {
rebind_context(n.components(), obj);
return;
}
throw new AlreadyBound();
}
if ((this.contexts.put(n, obj)) != null)
throw new CannotProceed(_this(), n.components());
IIOPLogger.ROOT_LOGGER.debugf("Bound context: %s", n);
} else {
NameComponent[] ncx = new NameComponent[] { nb };
org.omg.CORBA.Object context = this.resolve(ctx.components());
// try first to call the context implementation object directly.
String contextOID = this.getObjectOID(context);
CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
if (jbossContext != null)
jbossContext.bind_context(ncx, obj);
else
NamingContextExtHelper.narrow(context).bind_context(ncx, obj);
}
}
Aggregations