Package org.apache.synapse.config

Examples of org.apache.synapse.config.Entry


        }
    }

    private synchronized void cleanupSequenceMap() {
        for (String key : sequenceMap.keySet()) {
            Entry sequenceEntry = sequenceMap.get(key);
            if (sequenceEntry.isExpired()) {
                sequenceMap.remove(key);
            }
        }
    }
View Full Code Here


            }
            File[] entryDefinitions = localEntriesDir.listFiles(filter);
            for (File file : entryDefinitions) {
                try {
                    OMElement document = parseFile(file);
                    Entry entry = SynapseXMLConfigurationFactory.defineEntry(
                            synapseConfig, document, properties);
                    entry.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(
                            file.getAbsolutePath(), entry.getKey());
                } catch (FileNotFoundException ignored) {}
            }
        }
    }
View Full Code Here

            handleException("The 'key' attribute is required for a local registry entry");
            return null;

        } else {

            Entry entry = new Entry(key.getAttributeValue());

            OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
            if (descriptionElem != null) {
                entry.setDescription(descriptionElem.getText());
                descriptionElem.detach();
            }

            String src  = elem.getAttributeValue(
                    new QName(XMLConfigConstants.NULL_NAMESPACE, "src"));

            // if a src attribute is present, this is a URL source resource,
            // it would now be loaded from the URL source, as all static properties
            // are initialized at startup
            if (src != null) {
                try {
                    entry.setSrc(new URL(src.trim()));
                    entry.setType(Entry.URL_SRC);
                    entry.setValue(SynapseConfigUtils.getObject(entry.getSrc(), properties));
                } catch (MalformedURLException e) {
                    handleException("The entry with key : " + key + " refers to an invalid URL");
                }

            } else {
                OMNode    nodeValue = elem.getFirstOMChild();
                OMElement elemValue = elem.getFirstElement();

                if (elemValue != null) {
                    entry.setType(Entry.INLINE_XML);
                    entry.setValue(elemValue);
                } else if (nodeValue != null && nodeValue instanceof OMText) {
                    entry.setType(Entry.INLINE_TEXT);
                  entry.setValue(elem.getText());
        }
            }

            return entry;
        }
View Full Code Here

        return proxy;
    }

   public static Entry defineEntry(SynapseConfiguration config, OMElement elem,
                                   Properties properties) {
        Entry entry = EntryFactory.createEntry(elem, properties);
        config.addEntry(entry.getKey(), entry);
        return entry;
    }
View Full Code Here

                if (endpoint.getFileName() == null) {
                    OMElement endpointElem = EndpointSerializer.getElementFromEndpoint(endpoint);
                    definitions.addChild(endpointElem);
                }
            } else if (o instanceof Entry) {
                Entry entry = (Entry) o;
                if (entry.getFileName() == null) {
                    if ((SynapseConstants.SERVER_HOST.equals(entry.getKey())
                            || SynapseConstants.SERVER_IP.equals(entry.getKey()))
                            || entry.getType() == Entry.REMOTE_ENTRY) {
                        continue;
                    }

                    EntrySerializer.serializeEntry(entry, definitions);
                }
View Full Code Here

        if (o instanceof SequenceMediator) {
            return serializeSequence((SequenceMediator) o, synapseConfig, parent);
        } else if (o instanceof Endpoint) {
            return serializeEndpoint((Endpoint) o, synapseConfig, parent);
        } else if (o instanceof Entry) {
            Entry entry = (Entry) o;
            if ((SynapseConstants.SERVER_HOST.equals(entry.getKey())
                    || SynapseConstants.SERVER_IP.equals(entry.getKey()))
                    || entry.getType() == Entry.REMOTE_ENTRY) {
                return null;
            }

            File entriesDir = createDirectory(currentDirectory,
                    MultiXMLConfigurationBuilder.LOCAL_ENTRY_DIR);
            OMElement entryElem = EntrySerializer.serializeEntry(entry, null);

            String fileName = entry.getFileName();
            if (fileName != null) {
                handleDeployment(entriesDir, fileName, entry.getKey(),
                        synapseConfig.getArtifactDeploymentStore());
                File entryFile  = new File(entriesDir, fileName);
                writeToFile(entryElem, entryFile);
            } else if (parent != null) {
                parent.addChild(entryElem);
View Full Code Here

            return true;
        } else {
            //Load the XML document from the registry
            boolean reLoad = false;
            boolean hasValueChanged = false;
            Entry dp = synCtx.getConfiguration().getEntryDefinition(this.regKey);
            // if the key refers to a dynamic resource
            if (dp != null && dp.isDynamic()) {
                if (!dp.isCached() || dp.isExpired()) {
                    reLoad = true;
                }
            }
            synchronized (resourceLock) {
                if (reLoad || this.value == null) {
View Full Code Here

        // flag to check if we need to initialize/re-initialize the schema
        boolean reCreate = false;
        // if any of the schemas are not loaded, or have expired, load or re-load them
        for (Iterator iter = schemaKeys.iterator(); iter.hasNext();) {
            String propKey = (String) iter.next();
            Entry dp = synCtx.getConfiguration().getEntryDefinition(propKey);
            if (dp != null && dp.isDynamic()) {
                if (!dp.isCached() || dp.isExpired()) {
                    reCreate = true;       // request re-initialization of Validator
                }
            }
        }
View Full Code Here

        }
        config.addProxyService(proxy.getName(), proxy);
    }

    private static void defineEntry(SynapseConfiguration config, OMElement elem) {
        Entry entry = EntryFactory.createEntry(elem);
        if (config.getLocalRegistry().get(entry.getKey()) != null) {
            handleException("Duplicate registry entry definition for key : " + entry.getKey());
        }
        config.addEntry(entry.getKey(), entry);
    }
View Full Code Here

        // TODO: only need this synchronized method for dynamic registry entries. If there was a way
        // to access the registry entry during mediator initialization then for non-dynamic entries
        // this could be done just the once during mediator initialization.

        Entry entry = synCtx.getConfiguration().getEntryDefinition(key);
        boolean needsReload = (entry != null) && entry.isDynamic() && (!entry.isCached() || entry.isExpired());
        synchronized (resourceLock) {
            if (scriptSourceCode == null || needsReload) {
                Object o = synCtx.getEntry(key);
                if (o instanceof OMElement) {
                    scriptSourceCode = ((OMElement) (o)).getText();
                } else if (o instanceof String) {
                    scriptSourceCode = (String) o;
                }

                scriptEngine.eval(scriptSourceCode);
            }
        }

        // load <include /> scripts; reload each script if needed
      for(Iterator iter = includes.keySet().iterator(); iter.hasNext();) {
        String includeKey = (String) iter.next();
        String includeSourceCode = (String) includes.get(includeKey);
            Entry includeEntry = synCtx.getConfiguration().getEntryDefinition(includeKey);
            boolean includeEntryNeedsReload = (entry != null) && entry.isDynamic()
                  && (!entry.isCached() || entry.isExpired());
            synchronized (resourceLock) {
                if (includeSourceCode == null || needsReload) {
                    Object o = synCtx.getEntry(includeKey);
View Full Code Here

TOP

Related Classes of org.apache.synapse.config.Entry

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.