Search in sources :

Example 26 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CorbaNamingContext method resolve.

public org.omg.CORBA.Object resolve(NameComponent[] nc) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    Name n = new Name(nc[0]);
    if (nc.length > 1) {
        org.omg.CORBA.Object next_context = (org.omg.CORBA.Object) this.contexts.get(n);
        if ((next_context == null) || (isDead(next_context)))
            throw new NotFound(NotFoundReason.missing_node, nc);
        NameComponent[] nc_prime = new NameComponent[nc.length - 1];
        System.arraycopy(nc, 1, nc_prime, 0, nc_prime.length);
        // try first to call the context implementation object directly.
        String contextOID = this.getObjectOID(next_context);
        CorbaNamingContext jbossContext = (contextOID == null ? null : contextImpls.get(contextOID));
        if (jbossContext != null)
            return jbossContext.resolve(nc_prime);
        else
            return NamingContextExtHelper.narrow(next_context).resolve(nc_prime);
    } else {
        org.omg.CORBA.Object result = (org.omg.CORBA.Object) this.contexts.get(n);
        if (result == null)
            result = (org.omg.CORBA.Object) this.names.get(n);
        if (result == null)
            throw new NotFound(NotFoundReason.missing_node, n.components());
        if (!noPing && isDead(result))
            throw new NotFound(NotFoundReason.missing_node, n.components());
        return result;
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 27 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CorbaNamingContext method rebind.

public void rebind(NameComponent[] nc, org.omg.CORBA.Object obj) throws NotFound, CannotProceed, InvalidName {
    if (this.destroyed)
        throw new CannotProceed();
    if (nc == null || nc.length == 0)
        throw new InvalidName();
    if (obj == null)
        throw new org.omg.CORBA.BAD_PARAM();
    Name n = new Name(nc);
    Name ctx = n.ctxName();
    NameComponent nb = n.baseNameComponent();
    if (ctx == null) {
        // the name is bound, but it is bound to a context - the client should have been using rebind_context!
        if (this.contexts.containsKey(n))
            throw new NotFound(NotFoundReason.not_object, new NameComponent[] { nb });
        // try remove an existing binding.
        org.omg.CORBA.Object ref = (org.omg.CORBA.Object) this.names.remove(n);
        if (ref != null)
            ref._release();
        // do the rebinding in this context
        this.names.put(n, obj);
        IIOPLogger.ROOT_LOGGER.debugf("Bound name: %s", n);
    } else {
        // rebind in the correct context
        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.rebind(ncx, obj);
        else
            NamingContextExtHelper.narrow(context).rebind(ncx, obj);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 28 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class Name method getComponent.

/**
     * @return a single NameComponent, parsed from sn
     */
private static org.omg.CosNaming.NameComponent getComponent(String sn) throws org.omg.CosNaming.NamingContextPackage.InvalidName {
    char ch;
    int len = sn.length();
    boolean inKind = false;
    StringBuffer id = new StringBuffer();
    StringBuffer kind = new StringBuffer();
    for (int i = 0; i < len; i++) {
        ch = sn.charAt(i);
        if (ch == '\\') {
            // Escaped character
            i++;
            if (i >= len) {
                throw new InvalidName();
            }
            ch = sn.charAt(i);
        } else if (ch == '.') {
            if (inKind) {
                throw new InvalidName();
            }
            inKind = true;
            continue;
        }
        if (inKind) {
            kind.append(ch);
        } else {
            id.append(ch);
        }
    }
    return (new org.omg.CosNaming.NameComponent(id.toString(), kind.toString()));
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName)

Example 29 with NameComponent

use of org.omg.CosNaming.NameComponent in project ACS by ACS-Community.

the class EventModel method resolveMonitorControl.

/**
	 * Resolves the TAO monitor-control object that is bound in the naming service with the given name.
	 */
private NotificationServiceMonitorControl resolveMonitorControl(String notifyBindingName) throws CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, NotFound {
    String name = "MC_" + notifyBindingName;
    NameComponent[] ncomp = new NameComponent[1];
    ncomp[0] = new NameComponent(name, "");
    NotificationServiceMonitorControl nsmc = NotificationServiceMonitorControlHelper.narrow(nctx.resolve(ncomp));
    return nsmc;
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NotificationServiceMonitorControl(gov.sandia.CosNotification.NotificationServiceMonitorControl)

Example 30 with NameComponent

use of org.omg.CosNaming.NameComponent in project ACS by ACS-Community.

the class EventModel method resolveNotificationChannel.

/**
	 * Resolves a notification channel in the naming service.
	 * 
	 * @return Reference to the event channel specified by channelName.
	 * @param bindingName
	 *           Name of the event channel and trailing domain name, as the NC is registered with the CORBA Naming Service
	 * @throws AcsJException
	 *            Standard ACS Java exception.
	 */
protected EventChannel resolveNotificationChannel(String bindingName) throws AcsJException {
    EventChannel retValue = null;
    String nameServiceKind = alma.acscommon.NC_KIND.value;
    //m_logger.info("Will call 'nctx.resolve' for binding='" + bindingName + "', kind='" + nameServiceKind + "'.");
    try {
        NameComponent[] t_NameSequence = { new NameComponent(bindingName, nameServiceKind) };
        retValue = EventChannelHelper.narrow(nctx.resolve(t_NameSequence));
    } catch (OBJECT_NOT_EXIST ex) {
        m_logger.severe("The NC '" + bindingName + "' no longer exists, probably because its notify service was restarted. The naming service still lists this NC.");
        throw new AcsJUnexpectedExceptionEx(ex);
    } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) {
        // No other suppliers have created the channel yet
        m_logger.info("The '" + bindingName + "' channel has not been created yet.");
        throw new AcsJUnexpectedExceptionEx(e);
    } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed e) {
        // Think there is virtually no chance of this every happening but...
        throw new AcsJUnexpectedExceptionEx(e);
    } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) {
        // Think there is virtually no chance of this every happening but...
        throw new AcsJUnexpectedExceptionEx(e);
    }
    return retValue;
}
Also used : EventChannel(org.omg.CosNotifyChannelAdmin.EventChannel) NameComponent(org.omg.CosNaming.NameComponent) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed)

Aggregations

NameComponent (org.omg.CosNaming.NameComponent)37 NamingContext (org.omg.CosNaming.NamingContext)13 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)10 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)9 CannotProceed (org.omg.CosNaming.NamingContextPackage.CannotProceed)8 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)3 NamingException (javax.naming.NamingException)3 NamingContextExt (org.omg.CosNaming.NamingContextExt)3 POA (org.omg.PortableServer.POA)3 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)2 EventChannel (gov.sandia.NotifyMonitoringExt.EventChannel)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 Properties (java.util.Properties)2 CannotProceedException (javax.naming.CannotProceedException)2 Name (javax.naming.Name)2 NameNotFoundException (javax.naming.NameNotFoundException)2 ORB (org.omg.CORBA.ORB)2 Object (org.omg.CORBA.Object)2 AlreadyBound (org.omg.CosNaming.NamingContextPackage.AlreadyBound)2