Return-Path: X-Original-To: apmail-stratos-dev-archive@minotaur.apache.org Delivered-To: apmail-stratos-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F2F5810BB5 for ; Fri, 18 Oct 2013 13:20:07 +0000 (UTC) Received: (qmail 41621 invoked by uid 500); 18 Oct 2013 13:20:07 -0000 Delivered-To: apmail-stratos-dev-archive@stratos.apache.org Received: (qmail 41590 invoked by uid 500); 18 Oct 2013 13:20:07 -0000 Mailing-List: contact dev-help@stratos.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stratos.incubator.apache.org Delivered-To: mailing list dev@stratos.incubator.apache.org Received: (qmail 41577 invoked by uid 99); 18 Oct 2013 13:20:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Oct 2013 13:20:07 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 18 Oct 2013 13:20:04 +0000 Received: (qmail 41429 invoked by uid 99); 18 Oct 2013 13:19:42 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Oct 2013 13:19:42 +0000 Date: Fri, 18 Oct 2013 13:19:42 +0000 (UTC) From: "Nirmal Fernando (JIRA)" To: dev@stratos.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (STRATOS-110) Topology Event Message Processors should follow 'chain of responsibility' design pattern MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STRATOS-110?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D137= 99082#comment-13799082 ]=20 Nirmal Fernando commented on STRATOS-110: ----------------------------------------- Fixed in commits: a7645cd4e60ff8e555fde141fdacf43a39fffc0c 779fa8312434d64813c012270c269c899c9da0d6 ea592fd39f62f822086c3dfeb1ea5eda6add29e8 f2960914f2d3e513ca831d6d8574ae72db8ea7ab 5f9e5a1fb8c48ac291dc9d9e565dd7d5081f6864 6c6cc07a6c727fe3a9f7a3760cac209e54865fb8 06755880ca12a4f9d8c07150209049fe734c729e > Topology Event Message Processors should follow 'chain of responsibility'= design pattern > -------------------------------------------------------------------------= --------------- > > Key: STRATOS-110 > URL: https://issues.apache.org/jira/browse/STRATOS-110 > Project: Stratos > Issue Type: Improvement > Affects Versions: 4.0.0 M1 > Reporter: Nirmal Fernando > Assignee: Nirmal Fernando > Priority: Critical > Fix For: 4.0.0 M1 > > > Following is the MessageProcessor interface with this change. > package org.apache.stratos.messaging.message.processor; > import org.apache.stratos.messaging.domain.topology.Topology; > /** > * Message processor interface. Every Message Processor should implement = this. > */ > public interface MessageProcessor { > =20 > /** > * Link a message processor and its successor, if there's any. > * @param nextProcessor > */ > public abstract void setNext(MessageProcessor nextProcessor); > /** > * Message processing and delegating logic. > * @param type type of the message. > * @param message real message body. > * @param topology Topology that will get updated. > * @return whether the processing was successful or not. > */ > public abstract boolean process(String type, String message, Topology= topology); > } > I've implemented initial Message Processors: > =E2=94=9C=E2=94=80=E2=94=80 ClusterCreatedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 ClusterRemovedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 CompleteTopologyEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 MemberActivatedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 MemberStartedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 MemberSuspendedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 MemberTerminatedEventProcessor.java > =E2=94=9C=E2=94=80=E2=94=80 ServiceCreatedEventProcessor.java > =E2=94=94=E2=94=80=E2=94=80 ServiceRemovedEventProcessor.java > Now, it is up to the Message Processor Delegator to build the Message pro= cessor chain. > // instantiate all the relevant processors > ServiceCreatedEventProcessor processor1 =3D new ServiceCreatedEve= ntProcessor(); > ServiceRemovedEventProcessor processor2 =3D new ServiceRemovedEve= ntProcessor(); > ClusterCreatedEventProcessor processor3 =3D new ClusterCreatedEve= ntProcessor(); > =20 > =20 > // link all the relevant processors in the required order > processor1.setNext(processor2); > processor2.setNext(processor3); > processor3.setNext(processor4); > and also it's a duty of the deligator to start the flow: > boolean hasProcessed =3D processor1.process(type, json, TopologyManager.g= etTopology()); > After the flow started, Processor who is capable of handling the message = would eventually receive it and will process the message and other Processo= rs will simply delegate the message to its successor. -- This message was sent by Atlassian JIRA (v6.1#6144)