Examples of AssociationDescriptor


Examples of org.rioproject.associations.AssociationDescriptor

            injectedCount++;
        }
    }

    private AssociationDescriptor createAssociationDescriptor(String name) {
        AssociationDescriptor ad = new AssociationDescriptor();
        ad.setName(name);
        ad.setInterfaceNames(Dummy.class.getName());
        ad.setPropertyName("dummy");
        return ad;
    }
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

        }
        return new ServiceItem(sid, new Object(), attributes.toArray(new Entry[attributes.size()]));
    }

    AssociationDescriptor makeAssociationDescriptor(String version) {
        AssociationDescriptor descriptor = new AssociationDescriptor();
        descriptor.setVersion(version);
        return descriptor;
    }
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

        Object result = null;
        long stopTime = 0;
        while (!terminated) {
            T service = getServiceSelectionStrategy().getService();
            if(service==null) {
                AssociationDescriptor aDesc = a.getAssociationDescriptor();
                if(aDesc.getServiceDiscoveryTimeout()>0) {
                    stopTime = (stopTime==0?
                                System.currentTimeMillis()+
                                aDesc.getServiceDiscoveryTimeUnits().toMillis(aDesc.getServiceDiscoveryTimeout()): stopTime);
                    if(System.currentTimeMillis()<stopTime) {
                        if(logger.isTraceEnabled()) {
                            logger.trace("The association proxy for {} is not available. A service discovery timeout of " +
                                         "[{} {}], has been configured, and the computed stop time is: {}, sleep for one " +
                                         "second and re-evaluate",
                                         formatAssociationService(a),
                                         aDesc.getServiceDiscoveryTimeout(),
                                         aDesc.getServiceDiscoveryTimeUnits().name(),
                                         new Date(stopTime));
                        }
                        Thread.sleep(1000);
                        continue;
                    } else {
                        String s = formatAssociationService(a);
                        throw new RemoteException("No services available for associated service " +
                                                  s+", "+formatDiscoveryAttributes(a)+". "+
                                                  "A timeout of "+aDesc.getServiceDiscoveryTimeout()+" "+
                                                  aDesc.getServiceDiscoveryTimeUnits()+" expired. Check network " +
                                                  "connections and ensure that the "+s+" service is deployed");
                    }
                } else {
                    String s = formatAssociationService(a);
                    throw new RemoteException("No services available for service association " +
                                              s+", "+formatDiscoveryAttributes(a)+". Check network " +
                                              "connections and ensure that the ["+s+"] service is deployed. " +
                                              "You may also want to check the service discovery timeout property, " +
                                              "it is set to ["+aDesc.getServiceDiscoveryTimeout()+"]. Changing this " +
                                              "value will allow Rio to wait the specified amount of time for a service " +
                                              "to become available.");
                }
            }
            try {
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

        }
        return result;
    }

    private String formatAssociationService(Association<T> a) {
        AssociationDescriptor aDesc = a.getAssociationDescriptor();
        StringBuilder sb = new StringBuilder();
        String[] names = aDesc.getInterfaceNames();
        sb.append("[");
        for(int i=0; i<names.length; i++) {
            if(i>0)
                sb.append(", ");
            sb.append(names[i]);
        }
        sb.append("]");
        if(!aDesc.getName().equals(AssociationDescriptor.NO_NAME)) {
            sb.append(", name [");
            sb.append(aDesc.getName());
            sb.append("]");
        }
        sb.append(", ");
        sb.append("strategy=[");
        String strategy = a.getAssociationDescriptor().getServiceSelectionStrategy();
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

            }
        }

        private List<ServiceElement> getMatchingServiceElements(final DeploymentMap dMap) {
            List<ServiceElement> matching = new ArrayList<ServiceElement>();
            AssociationDescriptor ad = association.getAssociationDescriptor();
            String[] adInterfaces = ad.getInterfaceNames();
            Arrays.sort(adInterfaces);
            for(ServiceElement elem : dMap.getServiceElements()) {
                List<String> list = new ArrayList<String>();
                for(ClassBundle cb : elem.getExportBundles()) {
                    list.add(cb.getClassName());
                }
                String[] cbInterfaces = list.toArray(new String[list.size()]);
                if(Arrays.equals(adInterfaces, cbInterfaces)) {
                    if(ad.matchOnName()) {
                        if(ad.getName().equals(elem.getName())) {
                            matching.add(elem);
                        }
                    } else {
                        matching.add(elem);
                    }
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

    @Test
    public void testEagerInjection() {
        DefaultAssociationManagement aMgr = new DefaultAssociationManagement();
        Target5 target = new Target5();
        aMgr.setBackend(target);
        AssociationDescriptor descriptor = createAssociationDescriptor();
        descriptor.setLazyInject(false);
        Association<Dummy> a = aMgr.addAssociationDescriptor(descriptor);
        Assert.assertTrue(target.injectedCount==1);
        Assert.assertNotNull(target.dummy);
        Assert.assertEquals(Association.State.PENDING, target.dummy.getState());
    }
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

    private AssociationDescriptor createAssociationDescriptor() {
        return createAssociationDescriptor(null);
    }

    private AssociationDescriptor createAssociationDescriptor(String name) {
        AssociationDescriptor ad = new AssociationDescriptor();
        ad.setName(name);
        ad.setInterfaceNames(Dummy.class.getName());
        ad.setPropertyName("dummy");
        return ad;
    }
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

*/
public class AssociationCollectionTest {

    @Test
    public void testAdd() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());

View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

        }
    }

    @Test
    public void testAddRemove() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        ServiceItem[] items = a.getServiceItems();
View Full Code Here

Examples of org.rioproject.associations.AssociationDescriptor

        Assert.assertEquals("Should have 0 associated services", 0, a.getServiceCount());
    }

    @Test
    public void testNext() {
        Association<Dummy> a = new DefaultAssociation<Dummy>(new AssociationDescriptor());
        for(int i=0; i<10; i++)
            a.addServiceItem(AssociationUtils.makeServiceItem(i));

        Assert.assertEquals("Should have 10 associated services", 10, a.getServiceCount());
        for(int i=0; i<a.getServiceCount(); i++) {
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.