Search in sources :

Example 1 with Binding

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

the class EventModel method discoverNotifyServicesAndChannels.

/**
	 * Discovers services and bindings, retrieving only once the list of all
	 * bindings from the naming service.
	 */
private synchronized boolean discoverNotifyServicesAndChannels() {
    boolean ret = true;
    BindingListHolder bl = new BindingListHolder();
    BindingIteratorHolder bi = new BindingIteratorHolder();
    try {
        // Get names of all objects bound in the naming service
        nctx.list(-1, bl, bi);
        // Extract the useful binding information Id and Kind
        Map<String, String> bindingMap = new HashMap<String, String>();
        for (Binding binding : bl.value) {
            bindingMap.put(binding.binding_name[0].id, binding.binding_name[0].kind);
        }
        // notify services
        discoverNotifyServices(bindingMap);
        // channels (NCs)
        discoverChannels(bindingMap);
    } catch (Exception e) {
        ret = false;
    }
    return ret;
}
Also used : Binding(org.omg.CosNaming.Binding) HashMap(java.util.HashMap) BindingIteratorHolder(org.omg.CosNaming.BindingIteratorHolder) BindingListHolder(org.omg.CosNaming.BindingListHolder) AcsJException(alma.acs.exceptions.AcsJException)

Example 2 with Binding

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

the class Helper method getChannelTimestamp.

/**
     * Returns the current channel's timestamp registered in the Naming Service.
     */
public Date getChannelTimestamp() {
    Date timestamp = new Date(0);
    BindingListHolder bl = new BindingListHolder();
    BindingIteratorHolder bi = new BindingIteratorHolder();
    String chNameAndDomain = combineChannelAndDomainName(channelName, domainName);
    try {
        // Get names of all objects bound in the naming service
        getNamingService().list(-1, bl, bi);
        // Extract the useful binding information Id and Kind
        for (Binding binding : bl.value) {
            if (binding.binding_name[0].kind.equals(NC_KIND_NCSUPPORT.value)) {
                if (binding.binding_name[0].id.startsWith(chNameAndDomain)) {
                    String sts = binding.binding_name[0].id.substring(chNameAndDomain.length() + 1);
                    DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
                    try {
                        timestamp = df.parse(sts);
                    } catch (ParseException e) {
                    }
                }
            }
        }
    } catch (Exception e) {
    }
    return timestamp;
}
Also used : Binding(org.omg.CosNaming.Binding) BindingIteratorHolder(org.omg.CosNaming.BindingIteratorHolder) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) BindingListHolder(org.omg.CosNaming.BindingListHolder) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ParseException(java.text.ParseException) AcsJException(alma.acs.exceptions.AcsJException)

Example 3 with Binding

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

the class ConsumerWithComponentClientTestCaseTest method namingBindingsContain.

private boolean namingBindingsContain(String firstBindingName) {
    BindingListHolder blh = new BindingListHolder();
    ncHelper.getNamingService().list(100, blh, new BindingIteratorHolder());
    for (Binding binding : blh.value) {
        if (binding.binding_name[0].id.equals(firstBindingName)) {
            return true;
        }
    }
    return false;
}
Also used : Binding(org.omg.CosNaming.Binding) BindingIteratorHolder(org.omg.CosNaming.BindingIteratorHolder) BindingListHolder(org.omg.CosNaming.BindingListHolder)

Example 4 with Binding

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

the class CorbaNamingContext method list.

public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi) {
    if (this.destroyed)
        return;
    Binding[] result;
    this.cleanup();
    int size = how_many();
    Iterator<Name> names = this.names.keySet().iterator();
    Iterator<Name> contexts = this.contexts.keySet().iterator();
    if (how_many < size) {
        // counter for copies
        int how_many_ctr = how_many;
        // set up an array with "how_many" bindings
        result = new Binding[how_many];
        for (; names.hasNext() && how_many_ctr > 0; how_many_ctr--) result[how_many_ctr - 1] = new Binding((names.next()).components(), BindingType.nobject);
        for (; contexts.hasNext() && how_many_ctr > 0; how_many_ctr--) result[how_many_ctr - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
        // create a new BindingIterator for the remaining arrays
        size -= how_many;
        Binding[] rest = new Binding[size];
        for (; names.hasNext() && size > 0; size--) rest[size - 1] = new Binding((names.next()).components(), BindingType.nobject);
        for (; contexts.hasNext() && size > 0; size--) rest[size - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
        org.omg.CORBA.Object o;
        try {
            // Iterators are activated with the RootPOA (transient)
            byte[] oid = rootPoa.activate_object(new BindingIteratorImpl(rest));
            o = rootPoa.id_to_reference(oid);
        } catch (Exception e) {
            IIOPLogger.ROOT_LOGGER.logInternalError(e);
            throw new INTERNAL(e.toString());
        }
        bi.value = BindingIteratorHelper.narrow(o);
    } else {
        result = new Binding[size];
        for (; names.hasNext() && size > 0; size--) result[size - 1] = new Binding((names.next()).components(), BindingType.nobject);
        for (; contexts.hasNext() && size > 0; size--) result[size - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
    }
    bl.value = result;
}
Also used : Binding(org.omg.CosNaming.Binding) INTERNAL(org.omg.CORBA.INTERNAL) IOException(java.io.IOException) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName)

Example 5 with Binding

use of org.omg.CosNaming.Binding in project narayana by jbosstm.

the class NamingServiceClient method test.

@Ignore
public void test() throws InvalidName {
    String[] args = new String[2];
    args[0] = "-ORBInitRef";
    args[1] = "NameService=corbaloc::localhost:3528/NameService";
    Properties props = new Properties();
    props.put("org.omg.CORBA.ORBInitialPort", "3528");
    props.put("org.omg.CORBA.ORBInitialHost", "localhost");
    ORB orb = ORB.init(args, props);
    NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
    BindingListHolder bl = new BindingListHolder();
    BindingIteratorHolder blIt = new BindingIteratorHolder();
    nc.list(1000, bl, blIt);
    Binding[] bindings = bl.value;
    List<String> toResolve = new ArrayList<String>();
    toResolve.add("TransactionManagerService");
    for (int i = 0; i < bindings.length; i++) {
        int lastIx = bindings[i].binding_name.length - 1;
        // check to see if this is a naming context
        if (bindings[i].binding_type == BindingType.ncontext) {
            log.info("Context: " + bindings[i].binding_name[lastIx].id);
        } else {
            log.info("Object: " + bindings[i].binding_name[lastIx].id);
        }
        toResolve.remove(bindings[i].binding_name[lastIx].id);
    }
    assertTrue(toResolve.isEmpty());
}
Also used : Binding(org.omg.CosNaming.Binding) BindingIteratorHolder(org.omg.CosNaming.BindingIteratorHolder) NamingContextExt(org.omg.CosNaming.NamingContextExt) ArrayList(java.util.ArrayList) BindingListHolder(org.omg.CosNaming.BindingListHolder) Properties(java.util.Properties) ORB(org.omg.CORBA.ORB) Ignore(org.junit.Ignore)

Aggregations

Binding (org.omg.CosNaming.Binding)5 BindingIteratorHolder (org.omg.CosNaming.BindingIteratorHolder)4 BindingListHolder (org.omg.CosNaming.BindingListHolder)4 AcsJException (alma.acs.exceptions.AcsJException)2 IOException (java.io.IOException)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 Ignore (org.junit.Ignore)1 INTERNAL (org.omg.CORBA.INTERNAL)1 ORB (org.omg.CORBA.ORB)1 NamingContextExt (org.omg.CosNaming.NamingContextExt)1 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)1