Repository: stratos
Updated Branches:
  refs/heads/master 159f1c766 -> ee57e3174


refactoring packages for instance context


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

Branch: refs/heads/master
Commit: ee57e31748755f46286a206c2aaef203d45c4cbe
Parents: 159f1c7
Author: Isuru Haththotuwa <[email protected]>
Authored: Fri Nov 21 16:35:51 2014 +0530
Committer: Isuru Haththotuwa <[email protected]>
Committed: Fri Nov 21 16:35:51 2014 +0530

----------------------------------------------------------------------
 .../domain/applications/Application.java        |  4 +-
 .../messaging/domain/applications/Group.java    |  3 +-
 .../domain/applications/ParentComponent.java    |  2 +-
 .../context/ApplicationInstanceContext.java     | 56 ---------------
 .../context/ClusterInstanceContext.java         | 58 ---------------
 .../instance/context/GroupInstanceContext.java  | 58 ---------------
 .../instance/context/InstanceContext.java       | 74 --------------------
 .../context/ApplicationInstanceContext.java     | 56 +++++++++++++++
 .../context/ClusterInstanceContext.java         | 58 +++++++++++++++
 .../instance/context/GroupInstanceContext.java  | 58 +++++++++++++++
 .../instance/context/InstanceContext.java       | 74 ++++++++++++++++++++
 11 files changed, 249 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
index 1579bc1..4ffc182 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java
@@ -19,10 +19,8 @@
 
 package org.apache.stratos.messaging.domain.applications;
 
-import org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder;
 import org.apache.commons.lang3.RandomStringUtils;
-import 
org.apache.stratos.messaging.domain.applications.scaling.instance.context.ApplicationInstanceContext;
-import 
org.apache.stratos.messaging.domain.applications.scaling.instance.context.InstanceContext;
+import 
org.apache.stratos.messaging.domain.instance.context.ApplicationInstanceContext;
 
 import java.util.*;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
index 6990572..814b54a 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java
@@ -19,8 +19,7 @@
 
 package org.apache.stratos.messaging.domain.applications;
 
-import 
org.apache.stratos.messaging.domain.applications.scaling.instance.context.ApplicationInstanceContext;
-import 
org.apache.stratos.messaging.domain.applications.scaling.instance.context.GroupInstanceContext;
+import 
org.apache.stratos.messaging.domain.instance.context.GroupInstanceContext;
 
 import java.util.*;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
index 2b3b64f..45e1366 100644
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java
@@ -21,7 +21,7 @@ package org.apache.stratos.messaging.domain.applications;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import 
org.apache.stratos.messaging.domain.applications.scaling.instance.context.InstanceContext;
+import org.apache.stratos.messaging.domain.instance.context.InstanceContext;
 
 import java.io.Serializable;
 import java.util.*;

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ApplicationInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ApplicationInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ApplicationInstanceContext.java
deleted file mode 100644
index 266b698..0000000
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ApplicationInstanceContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.domain.applications.scaling.instance.context;
-
-import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
-import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
-import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
-
-import java.util.Stack;
-
-public class ApplicationInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<ApplicationStatus> {
-
-    // Life cycle state manager
-    protected LifeCycleStateManager<ApplicationStatus> lifeCycleStateManager;
-
-    public ApplicationInstanceContext(String alias, String instanceId) {
-        super(alias, instanceId);
-    }
-
-    @Override
-    public boolean isStateTransitionValid(ApplicationStatus newState) {
-        return lifeCycleStateManager.isStateTransitionValid(newState);
-    }
-
-    @Override
-    public Stack<ApplicationStatus> getTransitionedStates() {
-        return lifeCycleStateManager.getStateStack();
-    }
-
-    @Override
-    public ApplicationStatus getStatus() {
-        return lifeCycleStateManager.getCurrentState();
-    }
-
-    @Override
-    public boolean setStatus(ApplicationStatus newState) {
-        return this.lifeCycleStateManager.changeState(newState);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ClusterInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ClusterInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ClusterInstanceContext.java
deleted file mode 100644
index dcaa201..0000000
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/ClusterInstanceContext.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.domain.applications.scaling.instance.context;
-
-import org.apache.stratos.messaging.domain.topology.ClusterStatus;
-import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
-import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
-
-import java.util.Stack;
-
-public class ClusterInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<ClusterStatus> {
-
-    // Life cycle state manager
-    protected LifeCycleStateManager<ClusterStatus> lifeCycleStateManager;
-
-    public ClusterInstanceContext(String alias, String instanceId) {
-        super(alias, instanceId);
-        this.lifeCycleStateManager = new 
LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created,
-                alias + "_" + instanceId);
-    }
-
-    @Override
-    public boolean isStateTransitionValid(ClusterStatus newState) {
-        return lifeCycleStateManager.isStateTransitionValid(newState);
-    }
-
-    @Override
-    public Stack<ClusterStatus> getTransitionedStates() {
-        return lifeCycleStateManager.getStateStack();
-    }
-
-    @Override
-    public ClusterStatus getStatus() {
-        return lifeCycleStateManager.getCurrentState();
-    }
-
-    @Override
-    public boolean setStatus(ClusterStatus newState) {
-        return this.lifeCycleStateManager.changeState(newState);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/GroupInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/GroupInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/GroupInstanceContext.java
deleted file mode 100644
index 7a99be5..0000000
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/GroupInstanceContext.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.domain.applications.scaling.instance.context;
-
-import org.apache.stratos.messaging.domain.applications.GroupStatus;
-import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
-import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
-
-import java.util.Stack;
-
-public class GroupInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<GroupStatus> {
-
-    // Life cycle state manager
-    protected LifeCycleStateManager<GroupStatus> lifeCycleStateManager;
-
-    public GroupInstanceContext(String alias, String instanceId) {
-        super(alias, instanceId);
-        this.lifeCycleStateManager = new 
LifeCycleStateManager<GroupStatus>(GroupStatus.Created,
-                alias + "_" + instanceId);
-    }
-
-    @Override
-    public boolean isStateTransitionValid(GroupStatus newState) {
-        return lifeCycleStateManager.isStateTransitionValid(newState);
-    }
-
-    @Override
-    public Stack<GroupStatus> getTransitionedStates() {
-        return lifeCycleStateManager.getStateStack();
-    }
-
-    @Override
-    public GroupStatus getStatus() {
-        return lifeCycleStateManager.getCurrentState();
-    }
-
-    @Override
-    public boolean setStatus(GroupStatus newState) {
-        return this.lifeCycleStateManager.changeState(newState);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/InstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/InstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/InstanceContext.java
deleted file mode 100644
index eba15c1..0000000
--- 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/scaling/instance/context/InstanceContext.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.domain.applications.scaling.instance.context;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-public abstract class InstanceContext implements Serializable {
-
-    // group/cluster level alias
-    protected String alias;
-    // instance id
-    protected String instanceId;
-
-    protected Properties instanceProperties;
-
-    public InstanceContext (String alias, String instanceId) {
-        this.alias = alias;
-        this.instanceId = instanceId;
-        this.instanceProperties = new Properties();
-    }
-
-    public void addProperty (String name, String value) {
-        instanceProperties.put(name, value);
-    }
-
-    public String getProperty (String name) {
-        return instanceProperties.getProperty(name);
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public String getInstanceId() {
-        return instanceId;
-    }
-
-    public boolean equals(Object other) {
-        if(other == null || !(other instanceof InstanceContext)) {
-            return false;
-        }
-
-        if(this == other) {
-            return true;
-        }
-
-        InstanceContext that = (InstanceContext)other;
-        return this.alias.equals(that.alias) &&
-                this.instanceId.equals(that.instanceId);
-    }
-
-    public int hashCode () {
-        return alias.hashCode() + instanceId.hashCode();
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ApplicationInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ApplicationInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ApplicationInstanceContext.java
new file mode 100644
index 0000000..df8e720
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ApplicationInstanceContext.java
@@ -0,0 +1,56 @@
+/*
+ * 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.domain.instance.context;
+
+import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
+import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
+
+import java.util.Stack;
+
+public class ApplicationInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<ApplicationStatus> {
+
+    // Life cycle state manager
+    protected LifeCycleStateManager<ApplicationStatus> lifeCycleStateManager;
+
+    public ApplicationInstanceContext(String alias, String instanceId) {
+        super(alias, instanceId);
+    }
+
+    @Override
+    public boolean isStateTransitionValid(ApplicationStatus newState) {
+        return lifeCycleStateManager.isStateTransitionValid(newState);
+    }
+
+    @Override
+    public Stack<ApplicationStatus> getTransitionedStates() {
+        return lifeCycleStateManager.getStateStack();
+    }
+
+    @Override
+    public ApplicationStatus getStatus() {
+        return lifeCycleStateManager.getCurrentState();
+    }
+
+    @Override
+    public boolean setStatus(ApplicationStatus newState) {
+        return this.lifeCycleStateManager.changeState(newState);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ClusterInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ClusterInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ClusterInstanceContext.java
new file mode 100644
index 0000000..069f545
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/ClusterInstanceContext.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain.instance.context;
+
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
+import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
+
+import java.util.Stack;
+
+public class ClusterInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<ClusterStatus> {
+
+    // Life cycle state manager
+    protected LifeCycleStateManager<ClusterStatus> lifeCycleStateManager;
+
+    public ClusterInstanceContext(String alias, String instanceId) {
+        super(alias, instanceId);
+        this.lifeCycleStateManager = new 
LifeCycleStateManager<ClusterStatus>(ClusterStatus.Created,
+                alias + "_" + instanceId);
+    }
+
+    @Override
+    public boolean isStateTransitionValid(ClusterStatus newState) {
+        return lifeCycleStateManager.isStateTransitionValid(newState);
+    }
+
+    @Override
+    public Stack<ClusterStatus> getTransitionedStates() {
+        return lifeCycleStateManager.getStateStack();
+    }
+
+    @Override
+    public ClusterStatus getStatus() {
+        return lifeCycleStateManager.getCurrentState();
+    }
+
+    @Override
+    public boolean setStatus(ClusterStatus newState) {
+        return this.lifeCycleStateManager.changeState(newState);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/GroupInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/GroupInstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/GroupInstanceContext.java
new file mode 100644
index 0000000..845015f
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/GroupInstanceContext.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain.instance.context;
+
+import org.apache.stratos.messaging.domain.applications.GroupStatus;
+import 
org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior;
+import 
org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager;
+
+import java.util.Stack;
+
+public class GroupInstanceContext extends InstanceContext implements 
LifeCycleStateTransitionBehavior<GroupStatus> {
+
+    // Life cycle state manager
+    protected LifeCycleStateManager<GroupStatus> lifeCycleStateManager;
+
+    public GroupInstanceContext(String alias, String instanceId) {
+        super(alias, instanceId);
+        this.lifeCycleStateManager = new 
LifeCycleStateManager<GroupStatus>(GroupStatus.Created,
+                alias + "_" + instanceId);
+    }
+
+    @Override
+    public boolean isStateTransitionValid(GroupStatus newState) {
+        return lifeCycleStateManager.isStateTransitionValid(newState);
+    }
+
+    @Override
+    public Stack<GroupStatus> getTransitionedStates() {
+        return lifeCycleStateManager.getStateStack();
+    }
+
+    @Override
+    public GroupStatus getStatus() {
+        return lifeCycleStateManager.getCurrentState();
+    }
+
+    @Override
+    public boolean setStatus(GroupStatus newState) {
+        return this.lifeCycleStateManager.changeState(newState);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee57e317/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/InstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/InstanceContext.java
 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/InstanceContext.java
new file mode 100644
index 0000000..c001d20
--- /dev/null
+++ 
b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/instance/context/InstanceContext.java
@@ -0,0 +1,74 @@
+/*
+ * 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.domain.instance.context;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+public abstract class InstanceContext implements Serializable {
+
+    // group/cluster level alias
+    protected String alias;
+    // instance id
+    protected String instanceId;
+
+    protected Properties instanceProperties;
+
+    public InstanceContext (String alias, String instanceId) {
+        this.alias = alias;
+        this.instanceId = instanceId;
+        this.instanceProperties = new Properties();
+    }
+
+    public void addProperty (String name, String value) {
+        instanceProperties.put(name, value);
+    }
+
+    public String getProperty (String name) {
+        return instanceProperties.getProperty(name);
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public boolean equals(Object other) {
+        if(other == null || !(other instanceof InstanceContext)) {
+            return false;
+        }
+
+        if(this == other) {
+            return true;
+        }
+
+        InstanceContext that = (InstanceContext)other;
+        return this.alias.equals(that.alias) &&
+                this.instanceId.equals(that.instanceId);
+    }
+
+    public int hashCode () {
+        return alias.hashCode() + instanceId.hashCode();
+    }
+}
+

Reply via email to