Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.Endpoint


    public static Endpoint defineEndpoint(SynapseConfiguration config, OMElement ele,
                                          Properties properties) {

        String name = ele.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
        Endpoint endpoint = null;
        if (name != null) {
            try {
                endpoint = EndpointFactory.getEndpointFromElement(ele, false, properties);
                if (endpoint != null) {
                    config.addEndpoint(name.trim(), endpoint);
View Full Code Here


                String targetEp =
                        (String) messageContext.getProperty(ForwardingProcessorConstants.TARGET_ENDPOINT);

                if (targetEp != null) {
                    Endpoint ep = messageContext.getEndpoint(targetEp);

                    if (ep instanceof AddressEndpoint) {
                        AddressEndpoint addEp = (AddressEndpoint) ep;
                        String addressUrl = addEp.getDefinition().getAddress();
View Full Code Here

        }

        endpointStates = new EndpointState[endpoints.size()];

        for (int i = 0; i < endpoints.size(); i++) {
            Endpoint endpoint = endpoints.get(i);
            if (!(endpoint instanceof PropertyInclude)) {
                EndpointState state = new EndpointState(i, DEFAULT_WEIGHT);
                endpointStates[i] = state;
            } else {
                MediatorProperty property =
View Full Code Here

        Map<String, Endpoint> definedEndpoints = new HashMap<String, Endpoint>();
        synchronized (this) {
            for (Object o : localRegistry.values()) {
                if (o instanceof Endpoint) {
                    Endpoint ep = (Endpoint) o;
                    definedEndpoints.put(ep.getName(), ep);
                }
            }
        }

        return definedEndpoints;
View Full Code Here

                o = registry.getResource(entry, getProperties());
                if (o != null && o instanceof Endpoint) {
                    localRegistry.put(key, entry);
                    return (Endpoint) o;
                } else if (o instanceof OMNode){
                    Endpoint e = (Endpoint) XMLToEndpointMapper.getInstance().
                            getObjectFromOMNode((OMNode) o, properties);
                    if (e != null) {
                        entry.setValue(e);
                        return e;
                    }
View Full Code Here

            Iterator endpoints = FileUtils.iterateFiles(endpointsDir, extensions, false);
            while (endpoints.hasNext()) {
                File file = (File) endpoints.next();
                OMElement document = getOMElement(file);
                Endpoint endpoint = SynapseXMLConfigurationFactory.defineEndpoint(
                        synapseConfig, document, properties);
                if (endpoint != null) {
                    endpoint.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(
                            file.getAbsolutePath(), endpoint.getName());
                }
            }
        }
    }
View Full Code Here

     * @return Endpoint implementation for the given configuration.
     */
    private Endpoint createEndpointWithName(OMElement epConfig, boolean anonymousEndpoint,
                                            Properties properties) {
       
        Endpoint ep = createEndpoint(epConfig, anonymousEndpoint, properties);
        OMElement descriptionElem = epConfig.getFirstChildWithName(DESCRIPTION_Q);
        if (descriptionElem != null) {
            ep.setDescription(descriptionElem.getText());
        }

        // if the endpoint doesn't have a name we will generate a unique name.
        if (anonymousEndpoint && ep.getName() == null) {
            String uuid = UIDGenerator.generateUID();
            uuid = uuid.replace(':', '_');
            ep.setName(ENDPOINT_NAME_PREFIX + uuid);
            if (ep instanceof AbstractEndpoint) {
                ((AbstractEndpoint) ep).setAnonymous(true);
            }
        }

        OMAttribute onFaultAtt = epConfig.getAttribute(ON_FAULT_Q);
        if (onFaultAtt != null) {
            ep.setErrorHandler(onFaultAtt.getAttributeValue());
        }
        return ep;
    }
View Full Code Here

        ArrayList<Endpoint> endpoints = new ArrayList<Endpoint>();
        ArrayList<String> keys = new ArrayList<String>();
        Iterator iter = listEndpointElement.getChildrenWithName(XMLConfigConstants.ENDPOINT_ELT);
        while (iter.hasNext()) {
            OMElement endptElem = (OMElement) iter.next();
            Endpoint endpoint = EndpointFactory.getEndpointFromElement(endptElem, true, properties);
            if (endpoint instanceof IndirectEndpoint) {
                String key = ((IndirectEndpoint) endpoint).getKey();
                if (!keys.contains(key)) {
                    keys.add(key);
                } else {
                    handleException("Same endpoint definition cannot be used with in the siblings");
                }
            }
            endpoint.setParentEndpoint(parent);
            endpoints.add(endpoint);
        }

        return endpoints;
    }
View Full Code Here

        Map<String, Endpoint> definedEndpoints = new HashMap<String, Endpoint>();
        synchronized (this) {
            for (Object o : localRegistry.values()) {
                if (o instanceof Endpoint) {
                    Endpoint ep = (Endpoint) o;
                    definedEndpoints.put(ep.getName(), ep);
                }
            }
        }

        return definedEndpoints;
View Full Code Here

        System.out.println("Testing dynamic endpoint lookup...");

        // Phase 1
        System.out.println("Testing basic registry lookup functionality...");
        MessageContext synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep1 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep1);
        assertTrue(ep1.isInitialized());
        assertEquals(1, registry.getHitCount());
        assertEquals("http://test.url", ((AddressEndpoint) ep1).getDefinition().getAddress());

        // Phase 2
        System.out.println("Testing basic endpoint caching...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep2 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep2);
        assertEquals(1, registry.getHitCount());
        assertTrue(ep1 == ep2);

        // Phase 3
        System.out.println("Testing advanced endpoint caching...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        System.out.println("Waiting for the cache to expire...");
        Thread.sleep(8500L);
        Endpoint ep3 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep3);
        assertEquals(1, registry.getHitCount());
        assertTrue(ep1 == ep3);

        // Phase 4
        System.out.println("Testing endpoint reloading...");
        registry.updateResource(KEY_DYNAMIC_ENDPOINT_1, TestUtils.createOMElement(DYNAMIC_ENDPOINT_2));
        System.out.println("Waiting for the cache to expire...");
        Thread.sleep(8500L);
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep4 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep4);
        assertTrue(ep4.isInitialized());
        assertEquals(2, registry.getHitCount());
        assertEquals("http://test2.url", ((AddressEndpoint) ep4).getDefinition().getAddress());
        assertTrue(ep1 != ep4);
        assertTrue(!ep1.isInitialized());

        // Phase 5
        System.out.println("Testing for non-existing endpoints...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep5 = synCtx.getEndpoint("non-existing-endpoint");
        assertNull(ep5);

        System.out.println("Dynamic endpoint lookup tests were successful...");
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.endpoints.Endpoint

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.