Package org.rioproject.associations

Examples of org.rioproject.associations.AssociationDescriptor


                                                     "DependsOn",
                                                     opStringName,
                                                     Boolean.FALSE.toString(),
                                                     Boolean.FALSE.toString(),
                                                     1);
        AssociationDescriptor descriptor = new AssociationDescriptor(AssociationType.REQUIRES, "DependsOn");
        descriptor.setMatchOnName(true);
        descriptor.setOperationalStringName(element2.getOperationalStringName());
        descriptor.setGroups(testManager.getGroups());
        element1.addAssociationDescriptors(descriptor);
        OpString opString = new OpString(opStringName, null);
        opString.addService(element1);
        opString.addService(element2);
        OperationalStringManager manager = testManager.deploy(opString, monitor);
View Full Code Here


                                                     "FooBar",
                                                     Boolean.FALSE.toString(),
                                                     Boolean.FALSE.toString(),
                                                     0);

        AssociationDescriptor descriptor = new AssociationDescriptor(AssociationType.REQUIRES, "DependsOn");
        descriptor.setMatchOnName(true);
        descriptor.setOperationalStringName(element2.getOperationalStringName());
        descriptor.setGroups(testManager.getGroups());
        element1.addAssociationDescriptors(descriptor);
        OpString opString = new OpString("FooBar", null);
        opString.addService(element1);
        opString.addService(element2);
        OperationalStringManager manager = testManager.deploy(opString, monitor);
View Full Code Here

public class AssociationVersionTest {

    @Test
    public void testVersionedAssociations() throws ExecutionException, InterruptedException, IOException {
        AssociationManagement aMgr = new DefaultAssociationManagement();
        AssociationDescriptor descriptor = AssociationDescriptor.create("Dummy", Dummy.class, System.getProperty("org.rioproject.groups"));
        descriptor.setMatchOnName(false);
        descriptor.setVersion("2.1");
        Association<Dummy> association = aMgr.addAssociationDescriptor(descriptor);
        Dummy dummy = association.getServiceFuture().get();
        Assert.assertNotNull(dummy);
        Assert.assertEquals("Expected 1 got " + association.getServiceCount(), 1, association.getServiceCount());
        Assert.assertTrue("Expected \'His Brother Darrel\', got " + dummy.getName(), "His Brother Darrel".equals(dummy.getName()));
View Full Code Here

    }

    @Test
    public void testVersionedAssociationRange() throws ExecutionException, InterruptedException, IOException {
        AssociationManagement aMgr = new DefaultAssociationManagement();
        AssociationDescriptor descriptor = AssociationDescriptor.create("Dummy", Dummy.class, System.getProperty("org.rioproject.groups"));
        descriptor.setMatchOnName(false);
        descriptor.setVersion("2.8");
        Association<Dummy> association = aMgr.addAssociationDescriptor(descriptor);
        Dummy dummy = association.getServiceFuture().get();
        Assert.assertNotNull(dummy);
        Assert.assertEquals("Expected 1 got "+association.getServiceCount(), 1, association.getServiceCount());
        Assert.assertTrue("Expected \'His Other Brother Darrel\', got "+dummy.getName(), "His Other Brother Darrel".equals(dummy.getName()));
View Full Code Here

    }

    @Test
    public void testVersionedAssociationNoMatches() throws ExecutionException, InterruptedException, IOException {
        AssociationManagement aMgr = new DefaultAssociationManagement();
        AssociationDescriptor descriptor = AssociationDescriptor.create("Dummy", Dummy.class, System.getProperty("org.rioproject.groups"));
        descriptor.setMatchOnName(false);
        descriptor.setVersion("1.0");
        Association<Dummy> association = aMgr.addAssociationDescriptor(descriptor);
        Dummy dummy = null;
        try {
            dummy = association.getServiceFuture().get(5, TimeUnit.SECONDS);
        } catch (TimeoutException e) {
View Full Code Here

    }

    @Test
    public void testVersionedAssociationMatchesAll() throws ExecutionException, InterruptedException, IOException {
        AssociationManagement aMgr = new DefaultAssociationManagement();
        AssociationDescriptor descriptor = AssociationDescriptor.create("Dummy", Dummy.class, System.getProperty("org.rioproject.groups"));
        descriptor.setMatchOnName(false);
        Association<Dummy> association = aMgr.addAssociationDescriptor(descriptor);
        Dummy dummy = null;
        TimeoutException timeoutException = null;
        try {
            dummy = association.getServiceFuture().get(5, TimeUnit.SECONDS);
View Full Code Here

            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

        }
        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

        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

        }
        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

TOP

Related Classes of org.rioproject.associations.AssociationDescriptor

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.