Search in sources :

Example 16 with NamingContext

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;
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) NamingContext(org.omg.CosNaming.NamingContext) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidNameException(javax.naming.InvalidNameException) CannotProceedException(javax.naming.CannotProceedException) ContextNotEmptyException(javax.naming.ContextNotEmptyException) NamingException(javax.naming.NamingException) AlreadyBound(org.omg.CosNaming.NamingContextPackage.AlreadyBound) NotEmpty(org.omg.CosNaming.NamingContextPackage.NotEmpty) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 17 with NamingContext

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;
}
Also used : InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) NamingContext(org.omg.CosNaming.NamingContext)

Example 18 with NamingContext

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;
}
Also used : NCSubscriber(alma.acs.nc.NCSubscriber) NamingContext(org.omg.CosNaming.NamingContext) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 19 with NamingContext

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);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NamingContext(org.omg.CosNaming.NamingContext) ConcurrentModificationException(java.util.ConcurrentModificationException)

Example 20 with NamingContext

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);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) Object(org.omg.CORBA.Object) NamingContext(org.omg.CosNaming.NamingContext)

Aggregations

NamingContext (org.omg.CosNaming.NamingContext)24 NameComponent (org.omg.CosNaming.NameComponent)11 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)4 Object (org.omg.CORBA.Object)4 Properties (java.util.Properties)3 CannotProceedException (javax.naming.CannotProceedException)3 NameNotFoundException (javax.naming.NameNotFoundException)3 NamingException (javax.naming.NamingException)3 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)3 POA (org.omg.PortableServer.POA)3 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 NotContextException (javax.naming.NotContextException)2 AcsORBProfiler (org.jacorb.orb.acs.AcsORBProfiler)2 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)2 ORB (org.omg.CORBA.ORB)2 CannotProceed (org.omg.CosNaming.NamingContextPackage.CannotProceed)2 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)2 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)1