Package javax.naming

Examples of javax.naming.Binding


            return nextElement();
        }

        public Object nextElement() {
            Map.Entry entry = getNext();
            return new Binding((String) entry.getKey(), entry.getValue());
        }
View Full Code Here


    }

    public static void contextToMap(Context context, String baseName, Map<String,Object> results) throws NamingException {
        NamingEnumeration<Binding> namingEnumeration = context.listBindings("");
        while (namingEnumeration.hasMoreElements()) {
            Binding binding = namingEnumeration.nextElement();
            String name = binding.getName();
            String fullName = baseName + name;
            Object object = binding.getObject();
            results.put(fullName, object);
            if (object instanceof Context) {
                contextToMap((Context) object, fullName + "/", results);
            }
        }
View Full Code Here

        protected void buildEnumeration(Vector vect) {
            for (int i = 0; i < vect.size(); i++) {
                NameNode node = (NameNode) vect.elementAt(i);
                String className = node.getBinding().getClass().getName();
                vect.setElementAt(new Binding(node.getAtomicName(), className, node.getBinding()), i);
            }
            myEnum = vect.elements();
        }
View Full Code Here

    }

    private Map toListBindingResults(NamingEnumeration enumeration) {
        Map result = new HashMap();
        while (enumeration.hasMoreElements()) {
            Binding binding = (Binding) enumeration.nextElement();
            String name = binding.getName();
            assertFalse(result.containsKey(name));
            result.put(name, binding.getObject());
        }
        return result;
    }
View Full Code Here

        NamingEnumeration ne;
        ne = envContext.listBindings("");
        int count = 0;
        while (ne.hasMore()) {
            count ++;
            Binding pair = (Binding) ne.next();
            assertTrue(envBinding.containsKey(pair.getName()));
            if (! (envBinding.get(pair.getName()) instanceof ReadOnlyContext)) {
                assertEquals(pair.getObject(), envBinding.get(pair.getName()));
            }
        }
        assertEquals(envBinding.size(), count);

        try {
View Full Code Here

    private void assertBindings(NamingEnumeration<Binding> namingEnumeration) {
        assertNotNull("namingEnumeration", namingEnumeration);

        Map<String, Object> map = new HashMap<String, Object>();
        while (namingEnumeration.hasMoreElements()) {
            Binding pair = namingEnumeration.nextElement();
            map.put(pair.getName(), pair.getObject());
        }

        assertTrue("OrangeRemote", map.containsKey("OrangeRemote"));
        assertTrue("OrangeRemote is FruitRemote", map.get("OrangeRemote") instanceof FruitRemote);
View Full Code Here

        blueprintIdToComponentBindings = new Binding[componentIds.size()];
        Iterator<String> idIterator= componentIds.iterator();
        for (int i=0; i < blueprintIdToComponentBindings.length; i++) {
          String id = idIterator.next();
          Object o = blueprintContainer.getComponentInstance(id);
          blueprintIdToComponentBindings[i] = new Binding (id, o);
        }
        processor = p;
      } finally {
        callersBundle.getBundleContext().ungetService(blueprintContainerRef);
      }
View Full Code Here

    @Override
    public T nextElement()
    {
      if (!hasMoreElements()) throw new NoSuchElementException();
      Binding bindingToProcess = blueprintIdToComponentBindings[position];
      position++;
      T result = processor.get(bindingToProcess);
      return result;
    }
View Full Code Here

   
    NamingEnumeration<Binding> ne = ctx.listBindings("osgi:servicelist/" + className);
   
    assertTrue(ne.hasMoreElements());
   
    Binding bnd = ne.nextElement();
   
    assertEquals(String.valueOf(reg.getReference().getProperty(Constants.SERVICE_ID)), bnd.getName());
    assertTrue("Class name not correct. Was: " + bnd.getClassName(), bnd.getClassName().contains("Proxy") || bnd.getClassName().contains("EnhancerByCGLIB"));
   
    Runnable r = (Runnable) bnd.getObject();
   
    assertNotNull(r);
   
    r.run();
   
    Skeleton.getSkeleton(t).assertCalledExactNumberOfTimes(run, 1);
    Skeleton.getSkeleton(t2).assertNotCalled(run);
   
    assertTrue(ne.hasMoreElements());
   
    bnd = ne.nextElement();
   
    assertEquals(String.valueOf(reg2.getReference().getProperty(Constants.SERVICE_ID)), bnd.getName());
    assertTrue("Class name not correct. Was: " + bnd.getClassName(), bnd.getClassName().contains("Proxy") || bnd.getClassName().contains("EnhancerByCGLIB"));
   
    r = (Runnable) bnd.getObject();
   
    assertNotNull(r);
   
    r.run();
   
View Full Code Here

  private Object checkThreadRetrievedViaListBindingsMethod(NamingEnumeration<Binding> serviceList)
      throws NamingException
  {
    assertTrue("The repository was empty", serviceList.hasMoreElements());
   
    Binding binding = serviceList.nextElement();
   
    assertNotNull("We didn't get a service back from our lookup :(", binding);
   
    assertNotNull("The object from the SR was null", binding.getObject());
   
    assertTrue("The service retrieved was not of the correct type", binding.getObject() instanceof Thread);
   
    assertEquals("osgi:service/java.lang.Runnable/(rubbish=smelly)", binding.getName().toString());
   
    return binding.getObject();
  }
View Full Code Here

TOP

Related Classes of javax.naming.Binding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.