Examples of ServiceRegistry


Examples of org.apache.felix.ipojo.context.ServiceRegistry

  }
 
  public void testRegistrationAndListener() {
    ComponentInstance im = new FakeComponent();
    ComponentInstance im2 = new FakeComponent();
    ServiceRegistry registry = new ServiceRegistry(getContext());
    assertNotNull("Assert registry not null", registry);
    svcListener all = new svcListener();
    try {
      assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
    registry.addServiceListener(all);
   
    ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), null);
   
    try {
      assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage());
     }
 
      ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);
     
     try {
      assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
     
    assertEquals("Check the number of registration", 2, all.registration);
   
    Properties props = new Properties();
    props.put("foo", "bar");
    reg1.setProperties(props);
    assertEquals("Check the number of modification", 1, all.modification);
   
    reg1.unregister();
    assertEquals("Check the number of unregistration", 1, all.unregistration);
   
    reg2.setProperties(props);
    assertEquals("Check the number of modification", 2, all.modification);
   
    reg2.unregister();
    assertEquals("Check the number of unregistration", 2, all.unregistration);
   
    registry.removeServiceListener(all);
  }
View Full Code Here

Examples of org.apache.felix.ipojo.context.ServiceRegistry

  }
 
  public void testRegistrationAndFilter() {
    ComponentInstance im = new FakeComponent();
    ComponentInstance im2 = new FakeComponent();
    ServiceRegistry registry = new ServiceRegistry(getContext());
    svcListener filtered = new svcListener();
   
    try {
      assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
     
    registry.addServiceListener(filtered, "(foo=bar)");
   
    Properties props = new Properties();
    props.put("foo", "bar");
    ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);
   
    try {
      assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
     
    ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);
     
     try {
      assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);
    } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
       
    assertEquals("Check the number of registration", 1, filtered.registration);
   
    reg2.setProperties(props);
    assertEquals("Check the number of modification", 1, filtered.modification);
    // Follow the OSGi semantics of filters
   
    reg1.unregister();
    reg2.unregister();
    assertEquals("Check the number of unregistration", 2, filtered.unregistration);
    registry.removeServiceListener(filtered);
  }
View Full Code Here

Examples of org.apache.felix.ipojo.context.ServiceRegistry

     * given bundle context.
     *
     * @param context : the bundle context
     */
    public CompositeServiceContext(BundleContext context) {
        m_registry = new ServiceRegistry(context);
        if (context instanceof IPojoContext) {
            m_global = ((IPojoContext) context).getGlobalContext();
        } else {
            m_global = context; // the parent context is the global context
        }
View Full Code Here

Examples of org.apache.hadoop.gateway.services.registry.ServiceRegistry

      ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), null );
      if( contributor != null ) {
        try {
          contributor.contributeService( context, service );
          if (gatewayServices != null) {
            ServiceRegistry sr = (ServiceRegistry) gatewayServices.getService(GatewayServices.SERVICE_REGISTRY_SERVICE);
            if (sr != null) {
              String regCode = sr.getRegistrationCode(topology.getName());
              sr.registerService(regCode, topology.getName(), service.getRole(), service.getUrl() );
            }
          }
        } catch( Exception e ) {
          // Maybe it makes sense to throw exception
          log.failedToContributeService( service.getName(), service.getRole(), e );
View Full Code Here

Examples of org.apache.mina.registry.ServiceRegistry

public class Main
{

    public static void main( String[] args ) throws Exception
    {
        ServiceRegistry registry = new SimpleServiceRegistry();

        VmPipeAddress address = new VmPipeAddress( 8080 );

        // Set up server
        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
        registry.bind( service, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ProtocolSession session = connector.connect( address,
                                                     new TennisPlayer() );

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }
       
        registry.unbind( service );
    }
View Full Code Here

Examples of org.codehaus.wadi.servicespace.ServiceRegistry

        deploymentIdToManager.put(deploymentId, manager);
 

        ServiceSpace serviceSpace = wadiSessionManager.getServiceSpace();
        ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
        NetworkConnectorTracker networkConnectorTracker;
        try {
            networkConnectorTracker = (NetworkConnectorTracker) serviceRegistry.getStartedService(NetworkConnectorTracker.NAME);
        } catch (Exception e) {
            throw new IllegalStateException("Should never occur" ,e);
        }

        deploymentIdToNetworkConnectorTracker.put(deploymentId, networkConnectorTracker);  
View Full Code Here

Examples of org.codehaus.xfire.service.ServiceRegistry

                new ConstructorInjectionComponentAdapter(DummyServiceThatCounts.class,
                        DummyServiceThatCounts.class)));
        getPico().registerComponentInstance(this);

        // Execute it 3 times.
        ServiceRegistry sr = (ServiceRegistry) getPico()
                .getComponentInstance(ServiceRegistry.class);
        assertNotNull(sr);

        Service endpoint = sr.getService("test");
        assertNotNull(endpoint);

        Invoker invoker = endpoint.getInvoker();
        assertNotNull(invoker);
View Full Code Here

Examples of org.codehaus.xfire.service.ServiceRegistry

        getPico().registerComponent(new ConstructorInjectionComponentAdapter(
                DummyServiceThatCounts.class, DummyServiceThatCounts.class));
        getPico().registerComponentInstance(this);

        // Execute it 3 times.
        ServiceRegistry sr = (ServiceRegistry) getPico()
                .getComponentInstance(ServiceRegistry.class);
        assertNotNull(sr);

        Service endpoint = sr.getService("test");
        assertNotNull(endpoint);

        Invoker invoker = endpoint.getInvoker();
        assertNotNull(invoker);
View Full Code Here

Examples of org.codehaus.xfire.service.ServiceRegistry

        ClassPathXmlApplicationContext context =
            new ClassPathXmlApplicationContext(new String[] {
                "/org/codehaus/xfire/spring/examples/simple.xml",
                "/org/codehaus/xfire/spring/xfire.xml" });

        ServiceRegistry reg = (ServiceRegistry) context.getBean("xfire.serviceRegistry");
        assertTrue(reg.hasService("Echo"));
    }
View Full Code Here

Examples of org.codehaus.xfire.service.ServiceRegistry

{
 
    public void testNoAnnotation()
            throws Exception
    {
        ServiceRegistry reg =getXFire().getServiceRegistry();
        assertEquals(1, reg.getServices().size());
        assertTrue(reg.hasService("EchoImpl"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.