Package org.apache.synapse.config

Examples of org.apache.synapse.config.Entry


                } else if (policyKey != null) {

                    // If the policy has specified as a registry key.
                    // load or re-load policy from registry or local entry if not already available

                    Entry entry = synCtx.getConfiguration().getEntryDefinition(policyKey);
                    if (entry == null) {
                        handleException("Cannot find throttling policy using key : "
                                + policyKey, synCtx);

                    } else {
                        boolean reCreate = false;
                        // if the key refers to a dynamic resource
                        if (entry.isDynamic()) {
                            if (!entry.isCached() || entry.isExpired()) {
                                reCreate = true;
                            }
                        }
                        if (reCreate || throttle == null) {
                            Object entryValue = synCtx.getEntry(policyKey);
View Full Code Here


        entries.put(key, entry);
        return this;
    }
   
    public TestMessageContextBuilder addEntry(String key, URL url) {
        Entry entry = new Entry();
        entry.setType(Entry.URL_SRC);
        entry.setSrc(url);
        entries.put(key, entry);
        return this;
    }
View Full Code Here

        boolean needBind = false;
        XQResultSequence resultSequence;

        if (queryKey != null && !"".equals(queryKey)) {

            Entry dp = synCtx.getConfiguration().getEntryDefinition(queryKey);
            // if the queryKey refers to a dynamic resource
            if (dp != null && dp.isDynamic()) {
                if (!dp.isCached() || dp.isExpired()) {
                    reLoad = true;
                }
            }
        }
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();
                    scriptEngine.eval(scriptSourceCode);
                } else if (o instanceof String) {
                    scriptSourceCode = (String) o;
                    scriptEngine.eval(scriptSourceCode);
                } else if (o instanceof OMText) {

                    DataHandler dataHandler = (DataHandler) ((OMText) o).getDataHandler();
                    if (dataHandler != null) {
                        BufferedReader reader = null;
                        try {
                            reader = new BufferedReader(
                                    new InputStreamReader(dataHandler.getInputStream()));
                            scriptEngine.eval(reader);

                        } catch (IOException e) {
                            handleException("Error in reading script as a stream ", e, synCtx);
                        } finally {

                            if (reader != null) {
                                try {
                                    reader.close();
                                } catch (IOException e) {
                                    handleException("Error in closing input stream ", e, synCtx);
                                }
                            }

                        }
                    }
                }

            }
        }

        // load <include /> scripts; reload each script if needed
        for (String includeKey : includes.keySet()) {
            String includeSourceCode = (String) includes.get(includeKey);
            Entry includeEntry = synCtx.getConfiguration().getEntryDefinition(includeKey);
            boolean includeEntryNeedsReload = (includeEntry != null) && includeEntry.isDynamic()
                    && (!includeEntry.isCached() || includeEntry.isExpired());
            synchronized (resourceLock) {
                if (includeSourceCode == null || includeEntryNeedsReload) {
                    log.debug("Re-/Loading the include script with key " + includeKey);
                    Object o = synCtx.getEntry(includeKey);
                    if (o instanceof OMElement) {
View Full Code Here

    public void testEntrySerializationScenarioOne() throws Exception {
        String inputXml = "<localEntry xmlns=\"http://ws.apache.org/ns/synapse\" key=\"key\" " +
            "><description>description</description><foo/></localEntry>";
        OMElement inputOM = createOMElement(inputXml);
        Entry entry = EntryFactory.createEntry(inputOM.cloneOMElement(), new Properties());
        OMElement resultOM = EntrySerializer.serializeEntry(entry, null);
        assertTrue(compare(resultOM, inputOM));
    }
View Full Code Here

    public void testEntrySerializationScenarioTwo() throws Exception {
        String inputXml = "<localEntry xmlns=\"http://ws.apache.org/ns/synapse\" key=\"key\"" +
            "><description>description</description></localEntry>";
        OMElement inputOM = createOMElement(inputXml);
        Entry entry = EntryFactory.createEntry(inputOM.cloneOMElement(), new Properties());
        OMElement resultOM = EntrySerializer.serializeEntry(entry, null);
        assertTrue(compare(resultOM, inputOM));
    }
View Full Code Here

   
    public void testEntrySerializationScenarioThree() throws Exception {
        String inputXml = "<localEntry xmlns=\"http://ws.apache.org/ns/synapse\" key=\"key\" " +
            "/>";
        OMElement inputOM = createOMElement(inputXml);
        Entry entry = EntryFactory.createEntry(inputOM.cloneOMElement(), new Properties());
        OMElement resultOM = EntrySerializer.serializeEntry(entry, null);
        assertTrue(compare(resultOM, inputOM));
    }
View Full Code Here

    private void addServerIPAndHostEnrties() {
        String hostName = serverConfigurationInformation.getHostName();
        String ipAddress = serverConfigurationInformation.getIpAddress();
        if (hostName != null && !"".equals(hostName)) {
            Entry entry = new Entry(SynapseConstants.SERVER_HOST);
            entry.setValue(hostName);
            synapseConfiguration.addEntry(SynapseConstants.SERVER_HOST, entry);
        }

        if (ipAddress != null && !"".equals(ipAddress)) {
            Entry entry = new Entry(SynapseConstants.SERVER_IP);
            entry.setValue(ipAddress);
            if (synapseConfiguration.getAxisConfiguration().getTransportsIn() != null) {
                Map<String, TransportInDescription> transportInConfigMap = synapseConfiguration.getAxisConfiguration().getTransportsIn();
                if (transportInConfigMap != null) {
                    TransportInDescription transportInDescription = transportInConfigMap.get("http");
                    if (transportInDescription != null) {
                        Parameter bindAddressParam = transportInDescription.getParameter("bind-address");
                        if (bindAddressParam != null) {
                            entry.setValue(bindAddressParam.getValue());
                        }
                    }
                }
            }
            synapseConfiguration.addEntry(SynapseConstants.SERVER_IP, entry);
View Full Code Here

     */
    public void testWSDLWithPublishWSDLAndRecursiveImports() throws Exception {
        SynapseConfiguration synCfg = new SynapseConfiguration();
        AxisConfiguration axisCfg = new AxisConfiguration();
        // Add local entries
        Entry entry = new Entry();
        entry.setType(Entry.URL_SRC);
        entry.setSrc(getClass().getResource("root.wsdl"));
        synCfg.addEntry("root_wsdl", entry);
        entry = new Entry();
        entry.setType(Entry.URL_SRC);
        entry.setSrc(getClass().getResource("imported.xsd"));
        synCfg.addEntry("imported_xsd", entry);
        entry = new Entry();
        entry.setType(Entry.URL_SRC);
        entry.setSrc(getClass().getResource("imported.wsdl"));
        synCfg.addEntry("imported_wsdl", entry);
        // Build the proxy service
        ProxyService proxyService = new ProxyService("Test");
        proxyService.setWSDLKey("root_wsdl");
        ResourceMap resourceMap = new ResourceMap();
View Full Code Here

        ThrottleTestMediator throttleMediator = new ThrottleTestMediator();
        throttleMediator.setPolicyKey("throttlepolicy");
        MessageContext synCtx = createLightweightSynapseMessageContext("<empty/>");
        synCtx.setProperty(REMOTE_ADDR, "192.168.8.212");
        SynapseConfiguration synCfg = new SynapseConfiguration();
        Entry prop = new Entry();
        prop.setKey("throttlepolicy");
        prop.setType(Entry.INLINE_XML);
        prop.setValue(builde.getDocumentElement());
        synCfg.addEntry("throttlepolicy", prop);
        synCtx.setConfiguration(synCfg);
        for (int i = 0; i < 6; i++) {
            try {
                throttleMediator.mediate(synCtx);
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.