Package org.apache.synapse.registry

Examples of org.apache.synapse.registry.Registry


            if (propEntry == null) {
                propEntry = new Entry();
                propEntry.setType(Entry.REMOTE_ENTRY);
                propEntry.setKey(key);
            }
            Registry registry = synCtx.getConfiguration().getRegistry();
            if (registry != null) {
                registry.getResource(propEntry, new Properties());
                if (propName != null) {
                    Properties reqProperties = propEntry.getEntryProperties();
                    if (reqProperties != null) {
                        if (reqProperties.get(propName) != null) {
                            return reqProperties.getProperty(propName);
View Full Code Here


        SynapseConfiguration initialSynCfg = SynapseConfigurationBuilder.getDefaultConfiguration();
        SequenceMediator mainSequence = (SequenceMediator) initialSynCfg.getMainSequence();
        SequenceMediator faultSequence = (SequenceMediator) initialSynCfg.getFaultSequence();
        mainSequence.setFileName(SynapseConstants.MAIN_SEQUENCE_KEY + ".xml");
        faultSequence.setFileName(SynapseConstants.FAULT_SEQUENCE_KEY + ".xml");
        Registry registry = new WSO2Registry();
        initialSynCfg.setRegistry(registry);

        MultiXMLConfigurationSerializer serializer
                = new MultiXMLConfigurationSerializer(synapseConfigDir.getAbsolutePath());
        try {
View Full Code Here

    public void setUp() throws Exception {
        writeToFile(TEXT_1);
    }

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

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

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

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

        // the renewed cache should be valid for another 1.5 secs
        // change the file now and change next cache duration
        writeToFile(TEXT_2);
        reg.addConfigProperty("cachableDuration", "100");

        // still cached content should be available and valid
        assertEquals(TEXT_1, reg.getResource(prop).toString());

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

        // sleep another 1 sec.. cache should expire and new content should be loaded
        Thread.sleep(1000);
        assertEquals(TEXT_2, reg.getResource(prop).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).toString());
    }
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);
                return registry;

            } catch (ClassNotFoundException e) {
                handleException("Cannot locate registry provider class : " +
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);
                return registry;

            } catch (ClassNotFoundException e) {
                handleException("Cannot locate registry provider class : " +
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);
        OMElement serializedElement = RegistrySerializer.serializeRegistry(null, registry);
        try {
            assertTrue(compare(registryElement, serializedElement));
        } catch (Exception e) {
            fail("Exception in test.");
View Full Code Here

    public void setUp() throws Exception {
        writeToFile(TEXT_1);
    }

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

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

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

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

        // the renewed cache should be valid for another 1.5 secs
        // change the file now and change next cache duration
        writeToFile(TEXT_2);
        reg.addConfigProperty("cachableDuration", "100");

        // still cached content should be available and valid
        assertEquals(TEXT_1, reg.getResource(prop).toString());

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

        // sleep another 1 sec.. cache should expire and new content should be loaded
        Thread.sleep(1000);
        assertEquals(TEXT_2, reg.getResource(prop).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).toString());
    }
View Full Code Here

    public void setUp() throws Exception {
        writeToFile(TEXT_1);
    }

    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).toString());

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

        // sleep another 1 sec, has expired in cache, but content hasnt changed
        Thread.sleep(1000);
        assertEquals(TEXT_1, reg.getResource(prop).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).toString());

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

        // sleep another 1 sec.. cache should expire and new content should be loaded
        Thread.sleep(1000);
        assertEquals(TEXT_2, reg.getResource(prop).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).toString());
    }
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));
                return registry;

            } catch (ClassNotFoundException e) {
                handleException("Cannot locate registry provider class : " +
                    prov.getAttributeValue(), e);
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.