Package org.jboss.services.binding

Examples of org.jboss.services.binding.ServiceBinding


   }

   public synchronized ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
         throws NoSuchBindingException
   {
      ServiceBinding binding = bindings.get(new ServiceBindingKey(serverName, serviceName, bindingName));
      if (binding == null)
      {
         throw new NoSuchBindingException(serverName, serviceName, bindingName);
      }
      return binding;
View Full Code Here


   private void addServiceBindingInternal(String serverName, ServiceBindingMetadata metadata, boolean addToBindingSet)
      throws DuplicateServiceException, UnknownHostException
   {     
      validateServerName(serverName);
      ServiceBindingSet bindingSet = bindingSets.get(serverName);
      ServiceBinding binding = new ServiceBinding(metadata, bindingSet.getDefaultHostName(), bindingSet.getPortOffset());
      ServiceBinding oldBinding = bindings.putIfAbsent(new ServiceBindingKey(serverName, metadata), binding);
      if (oldBinding != null &&
            (safeEquals(oldBinding.getHostName(), binding.getHostName()) == false
               || oldBinding.getPort() != binding.getPort()))
      {
         throw new DuplicateServiceException(serverName, binding);
      }
     
      if (addToBindingSet)
View Full Code Here

  
   public void testNullMetadata() throws Exception
   {
      try
      {
         new ServiceBinding(null, "host", 0);
         fail("null metadata should fail");
      }
      catch (IllegalArgumentException good) {}
   }
View Full Code Here

  
   public void testNullServiceName() throws Exception
   {
      try
      {
         new ServiceBinding(new ServiceBindingMetadata(), "host", 0);
         fail("null serviceName should fail");
      }
      catch (IllegalStateException good) {}
   }
View Full Code Here

   public void testServiceBindingValueSource() throws Exception
   {
      ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc");
      String className = XSLTServiceBindingValueSourceImpl.class.getName();
      metadata.setServiceBindingValueSourceClassName(className);
      ServiceBinding binding = new ServiceBinding(metadata, "localhost", 1);
      assertEquals(className, binding.getServiceBindingValueSourceClassName());
      assertTrue(binding.getServiceBindingValueSource() instanceof XSLTServiceBindingValueSourceImpl);
     
      MockServiceBindingValueSource mock = new MockServiceBindingValueSource();
      metadata.setServiceBindingValueSource(mock);
      Object config = new Object();
      metadata.setServiceBindingValueSourceConfig(config);
      binding = new ServiceBinding(metadata, "localhost", 1);
      assertSame(mock, binding.getServiceBindingValueSource());
      assertEquals(mock.getClass().getName(), binding.getServiceBindingValueSourceClassName());
      assertSame(config, binding.getServiceBindingValueSourceConfig());
   }
View Full Code Here

   {
      ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, true);
      String className = XSLTServiceBindingValueSourceImpl.class.getName();
      metadata.setServiceBindingValueSourceClassName(className);
     
      ServiceBinding binding = new ServiceBinding(metadata, "192.168.0.2", 10);
      assertEquals(metadata.getServiceName(), binding.getServiceName());
      assertEquals(metadata.getBindingName(), binding.getBindingName());
      assertEquals(metadata.getHostName(), binding.getHostName());
      assertEquals(InetAddress.getByName(metadata.getHostName()), binding.getBindAddress());
     
      assertEquals(1, metadata.getPort());
      assertEquals(11, binding.getPort());
   }
View Full Code Here

    * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int, String)}.
    */
   public void testGetOffsetBindingWithHost() throws Exception
   {
      ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, true);
      ServiceBinding binding = new ServiceBinding(metadata, "192.168.0.3", 10);
      assertEquals(metadata.getServiceName(), binding.getServiceName());
      assertEquals(metadata.getBindingName(), binding.getBindingName());
      assertEquals(metadata.getHostName(), binding.getHostName());
      assertEquals(InetAddress.getByName(metadata.getHostName()), binding.getBindAddress());
     
      assertEquals(1, metadata.getPort());
      assertEquals(11, binding.getPort());
     
      metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, false);
      binding =  new ServiceBinding(metadata, "192.168.0.3", 10);
      assertEquals(metadata.getServiceName(), binding.getServiceName());
      assertEquals(metadata.getBindingName(), binding.getBindingName());
      assertEquals("192.168.0.3", binding.getHostName());
      assertEquals(InetAddress.getByName("192.168.0.3"), binding.getBindAddress());
     
      assertEquals(1, metadata.getPort());
      assertEquals(11, binding.getPort());
   }
View Full Code Here

   /**
    * Test method for {@link org.jboss.services.binding.ServiceBinding#equals(java.lang.Object)}.
    */
   public void testEquals() throws Exception
   {
      ServiceBinding bindingAA0 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 1);
      ServiceBinding bindingAA1 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 2);
      ServiceBinding bindingAA2 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.1", 1);
      ServiceBinding bindingAB = new ServiceBinding(new ServiceBindingMetadata("A", "B"), "192.168.0.2", 1);
      ServiceBinding bindingBA = new ServiceBinding(new ServiceBindingMetadata("B", "A"), "192.168.0.2", 1);
      ServiceBinding bindingAnull = new ServiceBinding(new ServiceBindingMetadata("A", null), "192.168.0.2", 1);
      ServiceBinding bindingBnull = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 1);
      ServiceBinding bindingBnull1 = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 2);
     
      assertEquals(bindingAA0, bindingAA1);
      assertEquals(bindingAA0, bindingAA2);
      assertFalse(bindingAA0.equals(bindingAB));
      assertFalse(bindingAA0.equals(bindingBA));
View Full Code Here

   /**
    * Test method for {@link org.jboss.services.binding.ServiceBinding#hashCode()}.
    */
   public void testHashCode() throws Exception
   {
      ServiceBinding bindingAA0 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 1);
      ServiceBinding bindingAA1 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 2);
      ServiceBinding bindingAA2 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.1", 1);
      ServiceBinding bindingAB = new ServiceBinding(new ServiceBindingMetadata("A", "B"), "192.168.0.2", 1);
      ServiceBinding bindingBA = new ServiceBinding(new ServiceBindingMetadata("B", "A"), "192.168.0.2", 1);
      ServiceBinding bindingAnull = new ServiceBinding(new ServiceBindingMetadata("A", null), "192.168.0.2", 1);
      ServiceBinding bindingBnull = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 1);
      ServiceBinding bindingBnull1 = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 2);
     
      assertEquals(bindingAA0.hashCode(), bindingAA1.hashCode());
      assertEquals(bindingAA0.hashCode(), bindingAA2.hashCode());
      assertFalse(bindingAA0.hashCode() == bindingAB.hashCode());
      assertFalse(bindingAA0.hashCode() == bindingBA.hashCode());
     
      // A quirk of the values means these have same hashcode
      assertEquals(bindingAB.hashCode(), bindingBA.hashCode());
     
      assertFalse(bindingAA0.hashCode() == bindingAnull.hashCode());
      assertFalse(bindingBA.hashCode() == bindingBnull.hashCode());
      assertFalse(bindingAnull.hashCode() == bindingBnull.hashCode());
      assertEquals(bindingBnull.hashCode(), bindingBnull1.hashCode());
   }
View Full Code Here

      for (ServiceBinding binding : bindings)
      {
         byFQN.put(binding.getFullyQualifiedName(), binding);
      }
     
      ServiceBinding aa = byFQN.get(AA.getFullyQualifiedName());
      assertNotNull(aa);
      assertEquals(AA.getServiceName(), aa.getServiceName());
      assertEquals(AA.getBindingName(), aa.getBindingName());
      assertEquals(AA.getDescription(), aa.getDescription());
      assertEquals("192.168.0.10", aa.getHostName());
      assertEquals(AA.getPort() + 30, aa.getPort());
     
      ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
      assertNotNull(aa);
      assertEquals(AB.getServiceName(), ab.getServiceName());
      assertEquals(AB.getBindingName(), ab.getBindingName());
      assertEquals(AB.getDescription(), ab.getDescription());
      assertEquals("192.168.0.10", ab.getHostName());
      assertEquals(AB.getPort() + 30, ab.getPort());
     
      ServiceBinding anull = byFQN.get(Anull.getFullyQualifiedName());
      assertNotNull(anull);
      assertEquals(Anull.getServiceName(), anull.getServiceName());
      assertEquals(Anull.getBindingName(), anull.getBindingName());
      assertEquals(Anull.getDescription(), anull.getDescription());
      assertEquals("192.168.0.10", anull.getHostName());
      assertEquals(Anull.getPort() + 30, anull.getPort());
     
      ServiceBinding newOne = byFQN.get(BA.getFullyQualifiedName());
      assertNotNull(newOne);
      assertEquals(BA.getServiceName(), newOne.getServiceName());
      assertEquals(BA.getBindingName(), newOne.getBindingName());
      assertEquals(BA.getDescription(), newOne.getDescription());
      assertEquals("192.168.0.10", newOne.getHostName());
      assertEquals(BA.getPort() + 30, newOne.getPort());
     
      bindings = testee.getServiceBindings().get(B);
      assertNotNull(bindings);
      byFQN = new HashMap<String, ServiceBinding>();
      for (ServiceBinding binding : bindings)
View Full Code Here

TOP

Related Classes of org.jboss.services.binding.ServiceBinding

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.