Package org.apache.synapse.registry

Examples of org.apache.synapse.registry.Registry


    public static Registry defineRegistry(SynapseConfiguration config, OMElement elem,
                                          Properties properties) {
        if (config.getRegistry() != null) {
            handleException("Only one remote registry can be defined within a configuration");
        }
        Registry registry = RegistryFactory.createRegistry(elem, properties);
        config.setRegistry(registry);
        return registry;
    }
View Full Code Here


        root.serialize(out);
        out.close();
    }

    public void testRegistry() throws Exception {
        Registry reg = new SimpleURLRegistry();
        Properties props = new Properties();
        props.put("root", "file:./");
        props.put("cachableDuration", "1500");
        reg.init(props);
        Entry prop = new Entry();
        prop.setType(Entry.REMOTE_ENTRY);
        prop.setKey(FILE);

        // initial load of file from registry
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());

        // sleep 1 sec
        Thread.sleep(1000);
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());

        // sleep another 1 sec, has expired in cache, but content hasnt changed
        Thread.sleep(1000);
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());

        // the renewed cache should be valid for another 1.5 secs
        // change the file now and change next cache duration
        writeToFile(TEXT_2);
        props.put("cachableDuration", "100");
        reg.init(props);
        // still cached content should be available and valid
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());

        // now sleep ~1 sec, still cache should be valid
        Thread.sleep(800);
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());

        // sleep another 1 sec.. cache should expire and new content should be loaded
        Thread.sleep(1000);
        assertEquals(TEXT_2, reg.getResource(prop, new Properties()).toString());

        // change content back to original
        writeToFile(TEXT_1);

        // sleep for .5 sec, now the new content should be loaded as new expiry time
        // is .1 sec
        Thread.sleep(500);
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());
    }
View Full Code Here

        Thread.sleep(500);
        assertEquals(TEXT_1, reg.getResource(prop, new Properties()).toString());
    }
   
    public void testLargeFile() throws Exception {
        Registry reg = new SimpleURLRegistry();
        Properties props = new Properties();
        props.put("root", "file:./");
        props.put("cachableDuration", "1500");
        reg.init(props);
       
        OMNode node = reg.lookup(FILE2);
        node.serialize(new NullOutputStream());
    }
View Full Code Here

                "<syn:parameter name=\"root\">file:./../../repository/</syn:parameter>" +
                "<syn:parameter name=\"cachableDuration\">15000</syn:parameter>" +
                "</syn:registry>";

        OMElement registryElement = createOMElement(regitryConfiguration);
        Registry registry = RegistryFactory.createRegistry(registryElement, new Properties());
        OMElement serializedElement = RegistrySerializer.serializeRegistry(null, registry);
        try {
            assertTrue(compare(registryElement, serializedElement));
        } catch (Exception e) {
            fail("Exception in test.");
View Full Code Here

            }
        }

        assert synCfg != null;
        synCfg.setPathToConfigFile(new File(configFile).getAbsolutePath());
        Registry localConfigReg = synCfg.getRegistry();
        if (synCfg.getLocalRegistry().isEmpty() && synCfg.getProxyServices().isEmpty()
                && localConfigReg != null) {
            if (log.isDebugEnabled()) {
                log.debug("Only the registry is defined in the synapse configuration, trying " +
                        "to fetch a configuration from the registry");
            }
            // TODO: support a artifact repo for registry as well instead of just the synapse.xml
            OMNode remoteConfigNode = localConfigReg.lookup("synapse.xml");
            if (remoteConfigNode != null) {
                try {
                    synCfg = XMLConfigurationBuilder.getConfiguration(SynapseConfigUtils
                            .getStreamSource(remoteConfigNode).getInputStream(), properties);
                    // TODO: when you fetch the configuration and serialize the config in any case
View Full Code Here

        OMAttribute prov = elem.getAttribute(PROVIDER_Q);
        if (prov != null) {
            try {
                Class provider = Class.forName(prov.getAttributeValue());
                Registry registry = (Registry) provider.newInstance();
                registry.init(getProperties(elem, properties));
                return registry;

            } catch (ClassNotFoundException e) {
                handleException("Cannot locate registry provider class : " +
                    prov.getAttributeValue(), e);
View Full Code Here

    public static Registry defineRegistry(SynapseConfiguration config, OMElement elem,
                                          Properties properties) {
        if (config.getRegistry() != null) {
            handleException("Only one remote registry can be defined within a configuration");
        }
        Registry registry = RegistryFactory.createRegistry(elem, properties);
        config.setRegistry(registry);
        return registry;
    }
View Full Code Here

                "<syn:property name=\"root\" value=\"file:./../../repository/\"/>" +
                "<syn:property name=\"cachableDuration\" value=\"15000\"/>" +
                "</syn:registry>";

        OMElement registryElement = createOMElement(regitryConfiguration);
        Registry registry = RegistryFactory.createRegistry(registryElement);
        OMElement serializedElement = RegistrySerializer.serializeRegistry(null, registry);

        try {
            assertTrue(compare(registryElement, serializedElement));
        } catch (XMLComparisonException e) {
View Full Code Here

        OMAttribute prov = elem.getAttribute(PROVIDER_Q);
        if (prov != null) {
            try {
                Class provider = Class.forName(prov.getAttributeValue());
                Registry registry = (Registry) provider.newInstance();
                setProperties(registry, elem);

                OMAttribute name = elem.getAttribute(NAME_Q);
                if (name != null) {
                    registry.setRegistryName(name.getAttributeValue());
                }
                return registry;

            } catch (ClassNotFoundException e) {
                handleException("Cannot locate registry provider class : " +
View Full Code Here

        Iterator regs = root.getChildrenWithName(Constants.REGISTRY_ELT);
        if (regs != null) {
            while (regs.hasNext()) {
                Object o = regs.next();
                if (o instanceof OMElement) {
                    Registry reg = RegistryFactory.createRegistry((OMElement) o);
                    config.addRegistry(reg.getRegistryName(), reg);
                } else {
                    handleException("Invalid registry declaration in configuration");
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.synapse.registry.Registry

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.