Package org.apache.synapse.registry

Examples of org.apache.synapse.registry.Registry


                }
            }

            if (value.getType() == Property.DYNAMIC_TYPE) {

                Registry registry = getRegistry(value.getRegistryName());

                if (registry == null) {
                    handleException("Registry not available.");
                }

                OMNode node = null;
                try {
                    node = registry.lookup(value.getKey());
                    if (node == null) {
                        handleException("Registry key should map to a XML resource.");
                    }
                } catch (Exception e) {
                    handleException("Registry key should map to a XML resource.");
View Full Code Here


     */
    public Registry getRegistry(String name) {
        if (name == null) {
            name = "DEFAULT";
        }
        Registry reg = (Registry) registryMap.get(name);
        if (reg == null) {
            handleException("Reference to non-existing registry named : " + name);
        }
        return reg;
    }
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");
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey(FILE);

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

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

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

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

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

                    "repository at : " + configFile);
        }

        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 repository 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

            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

    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

                String endpointName = "dynamicEndpoint";
                if (log.isDebugEnabled()) {
                    log.debug("Updating endpoint : " + endpointName + " in the Synapse registry");
                }

                Registry registry = getSynapseConfiguration().getRegistry();
                if (registry != null) {
                    if (registry.getRegistryEntry(key).getType() == null) {
                        handleFault("No resource exists by the key '" + key + "'", null);
                    }

                    registry.updateResource(key, endpointElement);

                    if (log.isDebugEnabled()) {
                        log.debug("Updated endpoint : " + endpointName + " in the Synapse registry");
                    }
                    return true;
View Full Code Here

    public boolean deleteDynamicEndpoint(String key) throws EndpointAdminException {
        Lock lock = getLock();
        try {
            lock.lock();
            Registry registry = getSynapseConfiguration().getRegistry();
            if (registry != null) {
                if (registry.getRegistryEntry(key).getType() == null) {
                    handleFault("The key '" + key +
                            "' cannot be found within the configuration", null);
                }
                registry.delete(key);

                if (log.isDebugEnabled()) {
                    log.debug("Deleted endpoint with key: " + key + " from the Synapse registry");
                }
                return true;
View Full Code Here

        }
    }

    public void deleteDynamicEndpointTemplate(String key) throws AxisFault {
        SynapseConfiguration synConfig = getSynapseConfiguration();
        Registry registry = synConfig.getRegistry();
        if (registry != null) {
            if (registry.getRegistryEntry(key).getType() == null) {
                handleException("The key '" + key +
                        "' cannot be found within the configuration");
            } else {
                registry.delete(key);
            }
        } else {
            handleException("Unable to access the registry instance for the ESB");
        }
    }
View Full Code Here

    public String getDynamicEndpoint(String key) throws Exception {
        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration synConfig = getSynapseConfiguration();
            Registry registry = synConfig.getRegistry();
            if (registry != null) {
                if (registry.getRegistryEntry(key).getType() == null) {
                    handleFault("No resource is available by the key '" + key + "'", null);
                }
            } else {
                handleFault("Unable to access the registry instance for the ESB", null);
            }
            OMElement e = null;
            if (registry != null) {
                e = (OMElement) registry.getResource(new Entry(key), synConfig.getProperties());
            }
            if (e != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Found dynamic endpoint " + key);
                }
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.