Package org.wso2.eventing

Examples of org.wso2.eventing.SubscriptionManager


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

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

     * @param eventSourceDTO Event source description to be built
     * @return a Synapse event source instance
     */
    private SynapseEventSource buildEventSource(EventSourceDTO eventSourceDTO) {
        SynapseEventSource synapseEventSource = new SynapseEventSource(eventSourceDTO.getName());
        SubscriptionManager subscriptionManager;
        try {
            if (eventSourceDTO.getType().equals("DefaultInMemory")) {
                subscriptionManager = new DefaultInMemorySubscriptionManager();
            }else  if (eventSourceDTO.getType().equals("EmbRegistry")) {
                subscriptionManager = (SubscriptionManager) Class.forName(
                        "org.wso2.carbon.eventing.impl.EmbeddedRegistryBasedSubscriptionManager")
                        .newInstance();
                subscriptionManager.init();
            } else {
                subscriptionManager = (SubscriptionManager) Class.forName(
                        "org.wso2.carbon.eventing.impl.RemoteRegistryBasedSubscriptionManager")
                        .newInstance();
            }
            subscriptionManager
                    .addProperty("topicHeaderName", eventSourceDTO.getTopicHeaderName());
            subscriptionManager
                    .addProperty("topicHeaderNS", eventSourceDTO.getTopicHeaderNS());
            //TODO this needs to be change to support any Subscription manager inherit from Subacription Manager
            if (eventSourceDTO.getType().equals("Registry")) {
                if (eventSourceDTO.getRegistryUrl() != null) {
                    subscriptionManager
                            .addProperty("registryURL", eventSourceDTO.getRegistryUrl());
                }
                if (eventSourceDTO.getUsername() != null) {
                    subscriptionManager
                            .addProperty("username", eventSourceDTO.getUsername());
                }
                if (eventSourceDTO.getRegistryUrl() != null) {
                    subscriptionManager
                            .addProperty("password", eventSourceDTO.getPassword());
                }
            }
            synapseEventSource.setSubscriptionManager(subscriptionManager);
        } catch (ClassNotFoundException e) {
View Full Code Here

   * @return
   * @throws AxisFault
   */
  public String[] getValidSubscriptions(String serviceName) throws AxisFault {
    AxisService service = null;
    SubscriptionManager manager = null;
    Parameter parameter = null;
    ArrayList<String> subscribers = null;

    service = getAxisService(serviceName);
    parameter = service.getParameter(SavanConstants.SUBSCRIBER_STORE);

    if (parameter == null) {
      parameter = service.getParameter(EventingConstants.SUBSCRIPTION_MANAGER);
    }

    subscribers = new ArrayList<String>();

    List<Subscription> list = null;
    Subscription subscription = null;

    if (parameter == null) {
      manager = new SubscriptionManagerAdapter(serviceName);
    } else {
      manager = (SubscriptionManager) parameter.getValue();
    }

    try {
      list = manager.getSubscriptions();
      for (Iterator<Subscription> iterator = list.iterator(); iterator.hasNext();) {
        subscription = iterator.next();
        if (!checkExpired(subscription)) {
          subscribers.add(subscription.getId());
        }
View Full Code Here

   * @return
   * @throws AxisFault
   */
  public String[] getExpiredSubscriptions(String serviceName) throws AxisFault {
    AxisService service = null;
    SubscriptionManager manager = null;
    Parameter parameter = null;
    ArrayList<String> subscribers = null;

    service = getAxisService(serviceName);
    parameter = service.getParameter(SavanConstants.SUBSCRIBER_STORE);

    if (parameter == null) {
      parameter = service.getParameter(EventingConstants.SUBSCRIPTION_MANAGER);
    }

    subscribers = new ArrayList<String>();

    List<Subscription> list = null;
    Subscription subscription = null;

    if (parameter == null) {
      manager = new SubscriptionManagerAdapter(serviceName);
    } else {
      manager = (SubscriptionManager) parameter.getValue();
    }

    try {
      list = manager.getSubscriptions();
      for (Iterator<Subscription> iterator = list.iterator(); iterator.hasNext();) {
        subscription = iterator.next();
        if (checkExpired(subscription)) {
          subscribers.add(subscription.getId());
        }
View Full Code Here

  public SubscriptionDTO getSubscriptionDetails(String serviceName, String subscriberId)
      throws AxisFault {
    AxisService service = null;
    Parameter parameter = null;
    SubscriptionDTO details = null;
    SubscriptionManager manager = null;

    service = getAxisService(serviceName);
    parameter = service.getParameter(SavanConstants.SUBSCRIBER_STORE);

    if (parameter == null) {
      parameter = service.getParameter(EventingConstants.SUBSCRIPTION_MANAGER);
    }

    Subscription subscription = null;

    if (parameter == null) {
      manager = new SubscriptionManagerAdapter(serviceName);
    } else {
      manager = (SubscriptionManager) parameter.getValue();
    }
   
    try {
      subscription = manager.getSubscription(subscriberId);
    } catch (EventException e) {
      String message = "Error while retrieving subscription details for " + subscriberId;
      log.error(message, e);
      throw new AxisFault(message, e);
    }
View Full Code Here

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private EventBrokerService buildEventSource(OMElement configElement)
            throws ClassNotFoundException {
        SubscriptionManager subscriptionManager;
        NotificationManager notificationManager;
        EventDispatcher eventDispatcher;

        String eventSourceName = null;
        OMAttribute eventSourceNameAttribute = configElement.getAttribute(
                new QName(ATTR_NAME)) ;
        if (eventSourceNameAttribute != null) {
            eventSourceName = eventSourceNameAttribute.getAttributeValue();
        }

        OMElement subscriptionManagerElement = configElement.getFirstChildWithName(new QName(
                BROKER_CONFIG_NAMESPACE, LOCAL_NAME_SUBSCRIPTION_MANAGER_CONFIG));

        String subscriptionManagerClass = subscriptionManagerElement.getAttribute(
                new QName(ATTR_CLASS)).getAttributeValue();

        try {
            subscriptionManager =
                    (SubscriptionManager) Class.forName(subscriptionManagerClass).newInstance();
        } catch(Exception e) {
            String message = "Error while creating Subscription Manager";
            log.error(message, e);
            if (e instanceof ClassNotFoundException) {
                throw (ClassNotFoundException)e;
            }
            throw new ActivationException(message, e);
        }

        Map<String, String> subscriptionManagerParameters = getParameters(
                subscriptionManagerElement.getChildrenWithName(new QName(
                        BROKER_CONFIG_NAMESPACE, LOCAL_NAME_PARAMETER)));
        Set<Map.Entry<String, String>> parameters = subscriptionManagerParameters.entrySet();
        for(Map.Entry<String, String> e : parameters) {
            subscriptionManager.addProperty(e.getKey(), e.getValue());
        }

        OMElement notificationManagerElement = configElement.getFirstChildWithName(new QName(
                BROKER_CONFIG_NAMESPACE, LOCAL_NAME_NOTIFICATION_MANAGER_CONFIG));

        String notificationManagerClass = notificationManagerElement.getAttribute(
                new QName(ATTR_CLASS)).getAttributeValue();

        try {
            notificationManager =
                    (NotificationManager) Class.forName(notificationManagerClass).newInstance();
            if (notificationManager instanceof CarbonNotificationManager) {
                Map<String, String> notificationManagerParameters = getParameters(
                        notificationManagerElement.getChildrenWithName(new QName(
                                BROKER_CONFIG_NAMESPACE, LOCAL_NAME_PARAMETER)));
                ((CarbonNotificationManager) notificationManager).init(
                        notificationManagerParameters);
            }
        } catch(Exception e) {
            String message = "Error while creating Notification Manager";
            log.error(message, e);
            if (e instanceof ClassNotFoundException) {
                throw (ClassNotFoundException)e;
            }
            throw new ActivationException(message, e);
        }

        String eventDispatcherName = configElement.getFirstChildWithName(new QName(
                BROKER_CONFIG_NAMESPACE, LOCAL_NAME_EVENT_DISPATCHER_CONFIG)).getText().trim();

        try {
            eventDispatcher = (EventDispatcher) Class.forName(eventDispatcherName).newInstance();
            if (eventDispatcher instanceof CarbonEventDispatcher) {
                ((CarbonEventDispatcher)eventDispatcher).init(serverConfigurationContext);
            }
        } catch(Exception e) {
            String message = "Error while creating Event Dispatcher";
            log.error(message, e);
            if (e instanceof ClassNotFoundException) {
                throw (ClassNotFoundException)e;
            }
            throw new ActivationException(message, e);
        }

        try {
            notificationManager.registerEventDispatcher(eventDispatcher);
            CarbonEventBroker broker;
            if (eventSourceName != null) {
                broker = (CarbonEventBroker)CarbonEventBroker.getInstance(eventSourceName);
            } else {
                broker = (CarbonEventBroker)CarbonEventBroker.getInstance();
            }
            broker.registerSubscriptionManager(subscriptionManager);
            broker.registerNotificationManager(notificationManager);
            subscriptionManager.init();
            if (eventSourceName != null) {
                dictionary.put(ATTR_NAME, eventSourceName);
            } else {
                dictionary.put(ATTR_NAME, DEFAULT_EVENT_SOURCE_NAME);
            }
View Full Code Here

TOP

Related Classes of org.wso2.eventing.SubscriptionManager

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.