Examples of TargetService


Examples of org.wso2.carbon.discovery.messages.TargetService

import javax.xml.namespace.QName;

public class MessageSerializerTest extends TestCase {

    public void testProbeMatchSerializer() {
        TargetService service = new TargetService(new EndpointReference("http://hello-world.com"));
        service.setMetadataVersion(5000);
        service.setTypes(getTypes());
        QueryMatch match = new QueryMatch(DiscoveryConstants.RESULT_TYPE_PROBE_MATCH,
                new TargetService[]{ service });
        try {
            OMElement matchElem = DiscoveryOMUtils.toOM(match, OMAbstractFactory.getSOAP11Factory());
            System.out.println(matchElem);
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

        String proxyURL = properties.getProperty(DISCOVERY_PROXY_URL);
        if (proxyURL == null) {
            throw new DiscoveryException("The discovery proxy URL is not specified");
        }
        DiscoveryClient client = new DiscoveryClient(cfgCtx, proxyURL);
        TargetService service = client.resolve(uuid);
        client.cleanup();
        return getEndpointFromService(service, protocol);
    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

public class SimpleDiscoveryRegistryExtension extends DiscoveryRegistryExtension {

    public OMNode findEndpoint(String uuid, String protocol) throws Exception {
        EndpointReference epr = new EndpointReference(uuid);
        TargetService service = DiscoveryServiceUtils.getService(epr);
        return getEndpointFromService(service, protocol);
    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

        if (proxy.getPolicy() != null) {
            client.engageModule("rampart");
            client.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
                    getPolicy(proxy.getPolicy(), registry));
        }
        TargetService service = client.resolve(id);
        client.cleanup();
        return service;
    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

                    service.getAxisConfiguration());

            // create the hello/bye message and send
            String uniqueID = getServiceID(config, service);
            EndpointReference endpointReference = new EndpointReference(uniqueID);
            TargetService targetService = new TargetService(endpointReference);

            targetService.setTypes(new QName[] { Util.getTypes(service) });

            URI[] scopes = new URI[config.getScopes().size()];
            for (int i = 0; i < config.getScopes().size(); i++) {
                scopes[i] = new URI(config.getScopes().get(i));
            }
            targetService.setScopes(scopes);

            String[] eprs = service.getEPRs();
            URI[] xAddres = new URI[eprs.length];
            for (int i = 0; i < eprs.length; i++) {
                String epr = eprs[i];
                if (epr.endsWith("/")) {
                    epr = epr.substring(0, epr.length() - 1);
                }
                xAddres[i] = new URI(epr);
            }
            targetService.setXAddresses(xAddres);
            targetService.setMetadataVersion(config.getMetadataVersion());

            Notification notification = new Notification(notificationType, targetService);
            serviceClient.fireAndForget(DiscoveryOMUtils.toOM(notification,
                    OMAbstractFactory.getOMFactory()));
            serviceClient.cleanup();
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

                    if ((targetServices[0].getXAddresses() != null) && (targetServices[0].getXAddresses().length > 0)) {
                        targetURI = getTargetURI(targetServices[0].getXAddresses(),
                                (String) messageContext.getProperty(DiscoveryConstants.DISCOVERY_SCHEME));
                    } else {
                        // get the epr using a resolve request
                        TargetService targetService = discoveryClient.resolve(targetServices[0].getEpr().getAddress());
                        if ((targetService.getXAddresses() != null) && (targetService.getXAddresses().length > 0)) {
                            targetURI = getTargetURI(targetService.getXAddresses(),
                                    (String) messageContext.getProperty(DiscoveryConstants.DISCOVERY_SCHEME));
                        } else {
                            throw new AxisFault("Resolve message did not return the service location");
                        }
                    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

                        "</wsd:Hello>";
        System.out.println(getURIList(xaddr));
        OMElement original = AXIOMUtil.stringToOM(input);
        Notification hello = DiscoveryOMUtils.getHelloFromOM(original);
        assertEquals(DiscoveryConstants.NOTIFICATION_TYPE_HELLO, hello.getType());
        TargetService service = hello.getTargetService();
        assertEquals(1, service.getMetadataVersion());
        assertEquals(uuid, service.getEpr().getAddress());
        assertURIArrayEquals(scopes, service.getScopes());
        assertURIArrayEquals(xaddr, service.getXAddresses());
        assertQNameArrayEquals(types, service.getTypes());

        OMElement serialization = DiscoveryOMUtils.toOM(hello, OMAbstractFactory.getSOAP11Factory());
        System.out.println(serialization.toString());
        assertXMLEquals(input, serialization);
    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

                        "</wsd:Bye>";

        OMElement original = AXIOMUtil.stringToOM(input);
        Notification bye = DiscoveryOMUtils.getByeFromOM(original);
        assertEquals(DiscoveryConstants.NOTIFICATION_TYPE_BYE, bye.getType());
        TargetService service = bye.getTargetService();
        assertEquals(1, service.getMetadataVersion());
        assertEquals(uuid, service.getEpr().getAddress());
        assertURIArrayEquals(scopes, service.getScopes());
        assertURIArrayEquals(xaddr, service.getXAddresses());
        assertQNameArrayEquals(types, service.getTypes());

        OMElement serialization = DiscoveryOMUtils.toOM(bye, OMAbstractFactory.getSOAP11Factory());
        System.out.println(serialization.toString());
        assertXMLEquals(input, serialization);
    }
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

     * @return a target service description or null
     * @throws Exception on error
     */
    public TargetServiceDetails resolveTargetService(String name,
                                                     String serviceId) throws Exception {
        TargetService service = DiscoveryMgtUtils.resolveService(name,
                serviceId, getConfigSystemRegistry());
        if (service != null) {
            return DiscoveryMgtUtils.getServiceDetails(service);
        }
        return null;
View Full Code Here

Examples of org.wso2.carbon.discovery.messages.TargetService

            newService.activate();
        }
    }   

    public static void removeServiceEndpoints(TargetService service) throws Exception {
        TargetService oldService = getService(service.getEpr());

        if (oldService == null) {
            throw new DiscoveryException("Error while updating discovery metadata. No service " +
                    "exists with the ID: " + service.getEpr().getAddress());
        }

        // When marking an existing service as inactive try to hold on to
        // the old metadata of the service
        if (service.getScopes() == null) {
            service.setScopes(oldService.getScopes());
        }
        if (service.getTypes() == null) {
            service.setTypes(oldService.getTypes());
        }
        if (service.getMetadataVersion() == -1) {
            service.setMetadataVersion(oldService.getMetadataVersion());
        }

        if (service.getXAddresses() != null && oldService.getXAddresses() != null) {
            // According to the spec this is the set of addresses on
            // which the service is NO LONGER AVAILABLE.
            // We should remove them from the registry.
            List<URI> existingAddresses = new ArrayList<URI>();
            for (URI xAddr : oldService.getXAddresses()) {
                existingAddresses.add(xAddr);
            }

            for (URI xAddr : service.getXAddresses()) {
                existingAddresses.remove(xAddr);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.