Package org.wso2.carbon.discovery.messages

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


                        "</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

                        "</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

     * @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

            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

            epr  = EndpointReferenceHelper.fromString(eprAttr);
        } else {
            epr = new EndpointReference(service.getId());
        }

        TargetService targetService = new TargetService(epr);
        String[] types = service.getAttributes(DiscoveryConstants.ATTR_TYPES);
        if (types != null) {
            targetService.setTypes(Util.toQNameArray(types));
        }

        String[] scopes = service.getAttributes(DiscoveryConstants.ATTR_SCOPES);
        if (scopes != null) {
            targetService.setScopes(Util.toURIArray(scopes));
        }

        String[] xAddresses = service.getAttributes(DiscoveryConstants.ATTR_XADDRESSES);
        if (xAddresses != null) {
            targetService.setXAddresses(Util.toURIArray(xAddresses));
        }

        String mdv = service.getAttribute(DiscoveryConstants.ATTR_METADATA_VERSION);
        if (mdv != null) {
            targetService.setMetadataVersion(Integer.valueOf(mdv));
        } else {
            // Set a default metadata version
            targetService.setMetadataVersion(1);
        }

        return targetService;
    }
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.discovery.messages.TargetService

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.