use of org.omg.CosNaming.NamingContext in project wildfly by wildfly.
the class ExceptionMapper method mapException.
public static NamingException mapException(Exception e, CNCtx ctx, NameComponent[] inputName) throws NamingException {
if (e instanceof NamingException) {
return (NamingException) e;
}
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
NamingException ne;
if (e instanceof NotFound) {
if (ctx.federation) {
return tryFed((NotFound) e, ctx, inputName);
} else {
ne = new NameNotFoundException();
}
} else if (e instanceof CannotProceed) {
ne = new CannotProceedException();
NamingContext nc = ((CannotProceed) e).cxt;
NameComponent[] rest = ((CannotProceed) e).rest_of_name;
// NotFound doesn't set rest as expected. -RL
if (inputName != null && (inputName.length > rest.length)) {
NameComponent[] resolvedName = new NameComponent[inputName.length - rest.length];
System.arraycopy(inputName, 0, resolvedName, 0, resolvedName.length);
// Wrap resolved NamingContext inside a CNCtx
// Guess that its name (which is relative to ctx)
// is the part of inputName minus rest_of_name
ne.setResolvedObj(new CNCtx(ctx._orb, nc, ctx._env, ctx.makeFullName(resolvedName)));
} else {
ne.setResolvedObj(ctx);
}
ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
} else if (e instanceof InvalidName) {
ne = new InvalidNameException();
} else if (e instanceof AlreadyBound) {
ne = new NameAlreadyBoundException();
} else if (e instanceof NotEmpty) {
ne = new ContextNotEmptyException();
} else {
ne = new NamingException();
}
ne.setRootCause(e);
return ne;
}
use of org.omg.CosNaming.NamingContext in project wildfly by wildfly.
the class CorbaNamingContext method bind_new_context.
public NamingContext bind_new_context(NameComponent[] nc) throws NotFound, CannotProceed, InvalidName, AlreadyBound {
if (this.destroyed)
throw new CannotProceed();
if (nc == null || nc.length == 0)
throw new InvalidName();
NamingContext context = new_context();
if (context == null)
throw new CannotProceed();
bind_context(nc, context);
return context;
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class AlarmSystemContainerServices method createNotificationChannelSubscriber.
@Override
public <T> AcsEventSubscriber<T> createNotificationChannelSubscriber(String channelName, String channelNotifyServiceDomainName, Class<T> eventType) throws AcsJContainerServicesEx {
if (eventType == null || !IDLEntity.class.isAssignableFrom(eventType)) {
throw new IllegalArgumentException("With Corba-NC based pub-sub, the event must be an instance of IDLEntity.");
}
AcsEventSubscriber<T> subscriber = null;
try {
// TODO: try to get the naming service ref in a nicer way (from ORB etc)
NamingContext namingService = Helper.getNamingServiceInitial(this);
// This is dirty omitting of <T> because NCSubscriber needs something like "<U extends T & IDLEntity>"
// Note that this problem does not exist in the ContainerServicesImpl because there we instantiate via reflection.
subscriber = new NCSubscriber(channelName, channelNotifyServiceDomainName, this, namingService, this.getName(), eventType);
} catch (Throwable e) {
logger.log(AcsLogLevel.ERROR, "Unexpected error while creating new AcsEventSubscriber object", e);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
throw ex;
}
// m_subscribers.put( (channelNotifyServiceDomainName == null ? "" : channelNotifyServiceDomainName) + "/" + channelName, subscriber);
return subscriber;
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class AlarmSystemCorbaServer method getServiceFromNameServer.
/**
* Get an object by browsing the name service
*
* @param serviceName The name of the service to get from the server
* @return
* @throws org.omg.CosNaming.NamingContextPackage.InvalidName
* @throws CannotProceed
* @throws NotFound
*/
public Object getServiceFromNameServer(final String serviceName) throws Exception {
if (serviceName == null || serviceName.isEmpty()) {
throw new IllegalArgumentException("Invalid null or emopty name");
}
try {
NamingContext context = getNamingContext();
NameComponent[] nameComponent = new NameComponent[1];
nameComponent[0] = new NameComponent(serviceName, "");
return context.resolve(nameComponent);
} catch (Throwable t) {
throw new Exception("Error getting " + serviceName, t);
}
}
use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.
the class AlarmServiceUtils method getAlarmService.
/**
* Get a reference to the {@link AlarmService}.
*
* @return The {@link AlarmService}
*/
public AlarmService getAlarmService() throws Exception {
String name = alma.alarmsystem.AlarmServiceName.value;
try {
// try naming service first
NamingContext ns = getNamingContext();
NameComponent[] nameComponent = new NameComponent[1];
nameComponent[0] = new NameComponent(name, "");
Object alarmObj = ns.resolve(nameComponent);
return AlarmServiceHelper.narrow(alarmObj);
} catch (Throwable th) {
logger.info("Failed to obtain alarm service reference from naming service, trying corbaloc...");
}
String corbaloc = "corbaloc::" + ACSPorts.getIP() + ":" + ACSPorts.getAlarmServicePort() + "/" + name;
Object alarmObj = orb.string_to_object(corbaloc);
return AlarmServiceHelper.narrow(alarmObj);
}
Aggregations