Package org.impalaframework.service

Examples of org.impalaframework.service.ServiceRegistryEntry


    public void testClassMatching() throws Exception {
        final StringFactoryBean factoryBean = new StringFactoryBean();
        factoryBean.setValue("some service");
        registryaddService("bean1", "module1", factoryBean.getObject(), classLoader);

        ServiceRegistryEntry service = registry.getService("bean1", classes, false);
        assertEquals("some service", service.getServiceBeanReference().getService());

        //must match all classes provided
        assertNull(registry.getService("bean1", new Class<?>[]{String.class, Integer.class}, false));
        assertNull(registry.getService("bean1", new Class<?>[]{Integer.class}, false));
       
View Full Code Here


   
    public void testMultiExportTypes() throws Exception {
       
        classes = new Class[]{ ArrayList.class, List.class };
        ServiceRegistryEntry ref = registryaddService(null, "module1", new ArrayList<String>(), Arrays.asList(classes), null, classLoader);
       
        assertTrue(registry.getServices("bean1", new Class<?>[]{ String.class }, true).isEmpty());
        assertTrue(registry.getServices("bean1", classes, true).isEmpty());
        assertFalse(registry.getServices((String)null, classes, true).isEmpty());
       
View Full Code Here

   
    public void testGetServices() throws Exception {

        assertTrue(registry.getServices("bean1", new Class<?>[]{String.class}, false).isEmpty());
       
        final ServiceRegistryEntry ref1 = registryaddService("bean1", "module1", "some service 1", null, Collections.<String,Object>singletonMap("service.ranking", 100), classLoader);
        assertEquals(1, registry.getServices("bean1", new Class<?>[]{String.class}, false).size());
        assertEquals(0, registry.getServices("bean1", new Class<?>[]{Integer.class}, false).size());

        final ServiceRegistryEntry ref2 = registryaddService("bean1", "module2", "some service 2", null, Collections.<String,Object>singletonMap("service.ranking", 400), classLoader);
        List<ServiceRegistryEntry> services = registry.getServices("bean1", new Class<?>[]{ String.class }, false);
        assertEquals(2, services.size());
        assertEquals(ref2, services.get(0));
       
        assertEquals(0, registry.getServices("bean1", new Class<?>[]{Integer.class}, false).size());
View Full Code Here

        registry.remove(ref2);
        assertTrue(registry.getServices("bean1", new Class<?>[]{String.class}, false).isEmpty());
    }
   
    public void testDuplicateBean() throws Exception {
        final ServiceRegistryEntry ref1 = registryaddService("bean1", "module1", "some service", classLoader);
        final ServiceRegistryEntry ref2 = registryaddService("bean1", "module2", "some service", classLoader);
        assertEquals(2, entryDelegate.getBeanReferences("bean1").size());
        registry.remove(ref1);
        assertEquals(1, entryDelegate.getBeanReferences("bean1").size());
        registry.remove(ref2);
        assertEquals(0, entryDelegate.getBeanReferences("bean1").size());
View Full Code Here

        String service1 = "some service1";
        String service2 = "some service2";
       
        registryaddService("bean1", "module1", service1, classLoader);
        final ServiceRegistryEntry ref2 = registryaddService("bean2", "module2", service2, classLoader);
        registry.remove(ref2);
       
        assertEquals(3, listener1.getEvents().size());
        assertEquals(3, listener2.getEvents().size());
        assertTrue(listener1.getEvents().get(0) instanceof ServiceAddedEvent);
View Full Code Here

        final Method method = invocation.getMethod();
        final Object[] arguments = invocation.getArguments();
       
        final boolean setCCCL = optionsHelper.isSetContextClassLoader();

        ServiceRegistryEntry serviceReference = targetSource.getServiceRegistryReference();
       
        int retriesUsed = 0;
        while (serviceReference == null && retriesUsed < optionsHelper.getRetryCount()) {
            try {
                Thread.sleep(optionsHelper.getRetryInterval());
            }
            catch (InterruptedException e) {
            }
            serviceReference = targetSource.getServiceRegistryReference();
            retriesUsed++;
        }

        if (serviceReference != null) {
           
            final Thread currentThread;
            final ClassLoader existingClassLoader;
            if (setCCCL) {
                currentThread = Thread.currentThread()
                existingClassLoader= currentThread.getContextClassLoader();
            } else {
                currentThread = null;
                existingClassLoader = null;
            }
           
            try {
                if (setCCCL) {
                    currentThread.setContextClassLoader(serviceReference.getBeanClassLoader());
                }
               
                return AopUtils.invokeJoinpointUsingReflection(serviceReference.getServiceBeanReference().getService(), method, arguments);
               
            } finally {
                //reset the previous class loader
                if (setCCCL) {
                    Thread.currentThread().setContextClassLoader(existingClassLoader);
View Full Code Here

     *
     * Each time {@link #getTarget()} is called, the object is looked up from the service registry.
     * No cacheing is involved.
     */
    public Object getTarget() throws Exception {
        ServiceRegistryEntry reference = getServiceRegistryReference();
        if (reference != null) {
            return reference.getServiceBeanReference().getService();
        }
        return null;
    }
View Full Code Here

        if (moduleDefinition != null) {
            moduleName = moduleDefinition.getName();
        } else {
            moduleName = "internal";
        }
        ServiceRegistryEntry entry = new LocalOnlyServiceRegistryEntry(serviceBeanReference, getBeanNameToSearchFor(), moduleName, this.beanClassLoader);
       
        //no need to set context class loader as this is not being used to call across modules
        DefaultProxyFactoryCreator proxyFactoryCreator = new DefaultProxyFactoryCreator();
        proxyFactoryCreator.setSetContextClassLoader(false);
       
View Full Code Here

                NamedServiceEndpoint endPoint = SpringModuleServiceUtils.findServiceEndpoint(beanFactory, beanName);
                if (hasRegisterableEndpoint(beanName, endPoint)) {         
                    logger.info("Contributing bean " + beanName + " from module " + moduleName);
                   
                    final ServiceBeanReference service = new StaticSpringServiceBeanReference(bean);
                    final ServiceRegistryEntry serviceReference = serviceRegistry.addService(beanName, moduleName, service, beanClassLoader);
                    referenceMap.put(beanName, serviceReference);
                }  
            } else {
               
                if (logger.isDebugEnabled()) {
View Full Code Here

   
    /* *************** DestructionAwareBeanPostProcessor methods ************** */

    public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {

        final ServiceRegistryEntry serviceRegistryReference = referenceMap.get(beanName);
       
        //if we have reference for this bean
        if (serviceRegistryReference != null) {

            String moduleName = moduleName();
View Full Code Here

TOP

Related Classes of org.impalaframework.service.ServiceRegistryEntry

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.