You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2013/10/14 12:50:45 UTC

git commit: Implemented topology domain model, events and message processing functionality

Updated Branches:
  refs/heads/master 63cc70c76 -> 37c0d7a09


Implemented topology domain model, events and message processing functionality


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/37c0d7a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/37c0d7a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/37c0d7a0

Branch: refs/heads/master
Commit: 37c0d7a09e041fbcef6bc5db8c0f07f1038806cb
Parents: 63cc70c
Author: Imesh Gunaratne <im...@apache.org>
Authored: Mon Oct 14 16:20:23 2013 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Mon Oct 14 16:20:23 2013 +0530

----------------------------------------------------------------------
 components/org.apache.stratos.messaging/pom.xml |  34 +++---
 .../broker/connect/TopicConnector.java          | 104 +++++++++----------
 .../broker/heartbeat/TopicHealthChecker.java    |  14 +--
 .../broker/publish/TopicPublisher.java          |  14 +--
 .../broker/subscribe/TopicSubscriber.java       |  24 ++---
 .../messaging/message/EventMessageHeader.java   |  39 +++++++
 .../stratos/messaging/message/JsonMessage.java  |  23 ++--
 .../messaging/message/MessageProcessor.java     |  71 +++++++++++++
 .../messaging/publish/MessagePublisher.java     |  16 +--
 .../stratos/messaging/util/Constants.java       |  14 +--
 .../org/apache/stratos/messaging/util/Util.java |  44 +++++++-
 11 files changed, 273 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/pom.xml b/components/org.apache.stratos.messaging/pom.xml
index ddd4f60..70e1528 100644
--- a/components/org.apache.stratos.messaging/pom.xml
+++ b/components/org.apache.stratos.messaging/pom.xml
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--->
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/connect/TopicConnector.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/connect/TopicConnector.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/connect/TopicConnector.java
index 9f0d5a1..ed262ba 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/connect/TopicConnector.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/connect/TopicConnector.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -38,62 +38,58 @@ import org.apache.stratos.messaging.util.Util;
  * classpath
  * and initialize the topic connection. Later if some other object needs a topic
  * session, this object is capable of providing one.
- * 
+ *
  * @author nirmal
- * 
  */
 public class TopicConnector {
 
-	private TopicConnection topicConnection;
-	private String jndiPropFileDir;
-	private Topic topic;
+    private TopicConnection topicConnection;
+    private String jndiPropFileDir;
+    private Topic topic;
 
-	public TopicConnector() {
-		jndiPropFileDir = System.getProperty("jndi.properties.dir");
-	}
+    public TopicConnector() {
+        jndiPropFileDir = System.getProperty("jndi.properties.dir");
+    }
 
-	public void init(String topicName) throws Exception {
-		InitialContext ctx;
-		Properties environment =
-		                         Util.getProperties(jndiPropFileDir + File.separator +
-		                                            "jndi.properties");
-		ctx = new InitialContext(environment);
-		// Lookup connection factory
-		TopicConnectionFactory connFactory =
-		                                     (TopicConnectionFactory) ctx.lookup("topicConnectionfactory");
-		// Lookup the topic
-		try {
-			setTopic((Topic) ctx.lookup(topicName));
-		} catch (NamingException e) {
-		}
-		topicConnection = connFactory.createTopicConnection();
-		topicConnection.start();
+    public void init(String topicName) throws Exception {
+        InitialContext ctx;
+        Properties environment = Util.getProperties(jndiPropFileDir + File.separator + "jndi.properties");
+        ctx = new InitialContext(environment);
+        // Lookup connection factory
+        String connectionFactoryName = environment.get("connectionfactoryName").toString();
+        TopicConnectionFactory connFactory = (TopicConnectionFactory) ctx.lookup(connectionFactoryName);
+        // Lookup the topic
+        try {
+            setTopic((Topic) ctx.lookup(topicName));
+        } catch (NamingException e) {
+        }
+        topicConnection = connFactory.createTopicConnection();
+        topicConnection.start();
 
-	}
+    }
 
-	/**
-	 * Provides a new topic session.
-	 * 
-	 * @return topic session instance
-	 * @throws JMSException
-	 *             if unable to create a topic session
-	 */
-	public TopicSession newSession() throws Exception {
-		return topicConnection.createTopicSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-	}
+    /**
+     * Provides a new topic session.
+     *
+     * @return topic session instance
+     * @throws JMSException if unable to create a topic session
+     */
+    public TopicSession newSession() throws Exception {
+        return topicConnection.createTopicSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+    }
 
-	public void close() throws JMSException {
-		if (topicConnection == null) {
-			return;
-		}
-		topicConnection.close();
-	}
+    public void close() throws JMSException {
+        if (topicConnection == null) {
+            return;
+        }
+        topicConnection.close();
+    }
 
-	public Topic getTopic() {
-		return topic;
-	}
+    public Topic getTopic() {
+        return topic;
+    }
 
-	public void setTopic(Topic topic) {
-		this.topic = topic;
-	}
+    public void setTopic(Topic topic) {
+        this.topic = topic;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/heartbeat/TopicHealthChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/heartbeat/TopicHealthChecker.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/heartbeat/TopicHealthChecker.java
index 67d5557..4d7638a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/heartbeat/TopicHealthChecker.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/heartbeat/TopicHealthChecker.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java
index aaa35fd..f26c3dd 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/TopicPublisher.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java
index fe316c2..577fee4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/subscribe/TopicSubscriber.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -39,8 +39,8 @@ public class TopicSubscriber implements Runnable {
 	private MessageListener messageListener;
 	private TopicSession topicSession;
 	private String topicName;
-	TopicConnector connector;
-	javax.jms.TopicSubscriber topicSubscriber = null;
+	private TopicConnector connector;
+	private javax.jms.TopicSubscriber topicSubscriber = null;
 
 	/**
 	 * @param aTopicName
@@ -67,13 +67,13 @@ public class TopicSubscriber implements Runnable {
 	}
 
 	/**
-	 * @param aMessageListener
+	 * @param messageListener
 	 *            this MessageListener will get triggered each time this
 	 *            subscription receives a message.
 	 */
-	public void setMessageListener(MessageListener aMessageListener) {
+	public void setMessageListener(MessageListener messageListener) {
 
-		messageListener = aMessageListener;
+		this.messageListener = messageListener;
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/EventMessageHeader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/EventMessageHeader.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/EventMessageHeader.java
new file mode 100644
index 0000000..b85d152
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/EventMessageHeader.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.message;
+
+/**
+ * Event message header definition.
+ */
+public class EventMessageHeader {
+    private String eventClassName;
+
+    public EventMessageHeader(String eventClassName) {
+        this.eventClassName = eventClassName;
+    }
+
+    public String getEventClassName() {
+        return eventClassName;
+    }
+
+    public void setEventClassName(String eventClassName) {
+        this.eventClassName = eventClassName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/JsonMessage.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/JsonMessage.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/JsonMessage.java
index 3009df7..39edb16 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/JsonMessage.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/JsonMessage.java
@@ -1,18 +1,18 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one 
+ * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -32,8 +32,17 @@ public class JsonMessage {
 	public JsonMessage(Object obj) {
 		object = obj;
 	}
-	
-	public String getMessage() {
+
+	public JsonMessage(String text, Class type) {
+		Gson gson = new Gson();
+		object = gson.fromJson(text, type);
+	}
+
+	public Object getObject() {
+		return this.object;
+	}
+
+	public String getText() {
 		Gson gson = new Gson();
 		return gson.toJson(object);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/MessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/MessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/MessageProcessor.java
new file mode 100644
index 0000000..8d36a16
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/MessageProcessor.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.message;
+
+import com.google.gson.stream.JsonReader;
+
+import java.io.*;
+
+/**
+ * Message processor generic implementation.
+ */
+public class MessageProcessor {
+    /**
+     * Transform json into an object of given type.
+     * @param json
+     * @param type
+     * @return
+     */
+    public Object jsonToObject(String json, Class type) {
+        return (new JsonMessage(json, type)).getObject();
+    }
+
+    /**
+     * Read message header and prepare an EventMessageHeader object.
+     * @param json
+     * @return
+     */
+    public EventMessageHeader readHeader(String json) {
+        try {
+            String eventClassName = null;
+            BufferedReader bufferedReader = new BufferedReader(new StringReader(json));
+            JsonReader reader = new JsonReader(bufferedReader);
+            reader.beginObject();
+            if(reader.hasNext()) {
+                if ("header".equals(reader.nextName())) {
+                    reader.beginObject();
+                    String name = reader.nextName();
+                    if("eventClassName".equals(name)) {
+                        eventClassName = reader.nextString();
+                    }
+                    // Add logic to read new header properties here
+                }
+            }
+            reader.close();
+
+            if(eventClassName != null) {
+                return new EventMessageHeader(eventClassName);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Could not extract message header", e);
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/publish/MessagePublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/publish/MessagePublisher.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/publish/MessagePublisher.java
index 5e05b8e..f64db31 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/publish/MessagePublisher.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/publish/MessagePublisher.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -20,7 +20,7 @@ package org.apache.stratos.messaging.publish;
 
 /**
  * Represents the template of a message publisher in Stratos.
- * All the message publisher should extend this class.
+ * All the message publishers should extend this class.
  * 
  * @author nirmal
  * 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
index 4abc8cd..b3ea650 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
@@ -1,18 +1,18 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one 
+ * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -20,6 +20,6 @@ package org.apache.stratos.messaging.util;
 
 public class Constants {
 	
-	public static final String TOPOLOGY_TOPIC = "topology_topic";
-
+	public static final String TOPOLOGY_TOPIC = "topology-topic";
+    public static final String TENANT_RANGE_DELIMITER = "-";
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/37c0d7a0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
index ca4966c..d373068 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
@@ -1,18 +1,18 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one 
+ * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -51,4 +51,38 @@ public class Util {
 		return props;
 	}
 
+    /**
+     * Validate tenant range.
+     * Valid formats: Integer-Integer, Integer-*
+     * Examples: 1-100, 101-200, 201-*
+     * @param tenantRange
+     */
+    public static void validateTenantRange(String tenantRange) {
+        boolean valid = false;
+        if(tenantRange != null) {
+            String[] array = tenantRange.split(Constants.TENANT_RANGE_DELIMITER);
+            if(array.length == 2) {
+                // Integer-Integer
+                if(isNumber(array[0]) && (isNumber(array[1]))){
+                    valid = true;
+                }
+                // Integer-*
+                else if(isNumber(array[0]) && "*".equals(array[1])) {
+                    valid = true;
+                }
+            }
+        }
+        if(!valid)
+            throw new RuntimeException(String.format("Tenant range %s is not valid", tenantRange));
+    }
+
+    public static boolean isNumber(String s) {
+        try {
+            Integer.parseInt(s);
+            return true;
+        }
+        catch (NumberFormatException e) {
+        }
+        return false;
+    }
 }