http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/MockIaasApi.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/MockIaasApi.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/MockIaasApi.java
new file mode 100644
index 0000000..b1438f7
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/MockIaasApi.java
@@ -0,0 +1,154 @@
+/*
+ * 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.mock.iaas.api;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.mock.iaas.api.exception.MockIaasApiException;
+import org.apache.stratos.mock.iaas.domain.MockInstanceContext;
+import org.apache.stratos.mock.iaas.domain.MockInstanceMetadata;
+import org.apache.stratos.mock.iaas.services.MockIaasService;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+/**
+ * Mock IaaS API.
+ */
+@Path("/")
+public class MockIaasApi {
+
+    private static final Log log = LogFactory.getLog(MockIaasApi.class);
+
+    @Context
+    private HttpServletRequest httpServletRequest;
+    private MockIaasService mockIaasService;
+
+    public MockIaasApi() {
+        try {
+            mockIaasService = (MockIaasService) 
PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(MockIaasService.class);
+        } catch (Exception e) {
+            String message = "Could not initialize mock iaas service 
reference";
+            log.error(message, e);
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    @POST
+    @Path("/instances")
+    @Consumes("application/json")
+    @Produces("application/json")
+    public Response startInstance(MockInstanceContext mockInstanceContext) 
throws MockIaasApiException {
+        try {
+            log.info(String.format("Starting mock instance: [member-id] %s", 
mockInstanceContext.getMemberId()));
+
+            MockInstanceMetadata mockInstanceMetadata = 
mockIaasService.startInstance(mockInstanceContext);
+
+            log.info(String.format("Mock instance started successfully: 
[member-id] %s [instance-id] %s",
+                    mockInstanceContext.getMemberId(), 
mockInstanceContext.getInstanceId()));
+            return Response.ok(mockInstanceMetadata).build();
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            log.error(message, e);
+            throw new MockIaasApiException(message, e);
+        }
+    }
+
+    @GET
+    @Path("/instances")
+    @Produces("application/json")
+    public Response getInstances() throws MockIaasApiException {
+        try {
+            log.debug(String.format("Get mock instances"));
+
+            List<MockInstanceMetadata> mockInstanceMetadataList = 
mockIaasService.getInstances();
+            MockInstanceMetadata[] mockInstanceMetadataArray = 
mockInstanceMetadataList.toArray(
+                    new MockInstanceMetadata[mockInstanceMetadataList.size()]);
+            return Response.ok(mockInstanceMetadataArray).build();
+        } catch (Exception e) {
+            String message = "Could not get mock instances";
+            log.error(message, e);
+            throw new MockIaasApiException(message, e);
+        }
+    }
+
+    @GET
+    @Path("/instances/{instanceId}")
+    @Produces("application/json")
+    public Response getInstance(@PathParam("instanceId") String instanceId) 
throws MockIaasApiException {
+        try {
+            log.debug(String.format("Get mock instance: [instance-id] %s", 
instanceId));
+
+            MockInstanceMetadata mockInstanceMetadata = 
mockIaasService.getInstance(instanceId);
+            if(mockInstanceMetadata == null) {
+                return Response.status(Response.Status.NOT_FOUND).build();
+            }
+
+            log.debug(String.format("Mock instance found: [instance-id] %s", 
instanceId));
+            return Response.ok(mockInstanceMetadata).build();
+        } catch (Exception e) {
+            String message = "Could not get mock instance";
+            log.error(message, e);
+            throw new MockIaasApiException(message, e);
+        }
+    }
+
+    @POST
+    @Path("/instances/{instanceId}/allocateIpAddress")
+    @Produces("application/json")
+    public Response allocateIpAddress(@PathParam("instanceId") String 
instanceId) throws MockIaasApiException {
+        try {
+            log.info(String.format("Allocating ip addresses: [instance-id] 
%s", instanceId));
+
+            MockInstanceMetadata mockInstanceMetadata = 
mockIaasService.getInstance(instanceId);
+            if(mockInstanceMetadata == null) {
+                return Response.status(Response.Status.NOT_FOUND).build();
+            }
+            mockInstanceMetadata = 
mockIaasService.allocateIpAddress(instanceId);
+            log.info(String.format("IP addresses allocated: [instance-id] %s 
[default-private-ip] %s " +
+                    "[default-public-ip] %s", instanceId, 
mockInstanceMetadata.getDefaultPrivateIp(),
+                    mockInstanceMetadata.getDefaultPublicIp()));
+            return Response.ok(mockInstanceMetadata).build();
+        } catch (Exception e) {
+            String message = String.format("Could not allocate ip address: 
[instance-id] %s", instanceId);
+            log.error(message, e);
+            throw new MockIaasApiException(message, e);
+        }
+    }
+
+    @DELETE
+    @Path("/instances/{instanceId}")
+    public Response terminateInstance(@PathParam("instanceId") String 
instanceId) throws MockIaasApiException {
+        try {
+            log.info(String.format("Terminating mock instance: [instance-id] 
%s", instanceId));
+            mockIaasService.terminateInstance(instanceId);
+            log.info(String.format("Mock instance terminated successfully: 
[instance-id] %s", instanceId));
+            return Response.ok().build();
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            log.error(message, e);
+            throw new MockIaasApiException(message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/exception/MockIaasApiException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/exception/MockIaasApiException.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/exception/MockIaasApiException.java
new file mode 100644
index 0000000..80ae315
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/exception/MockIaasApiException.java
@@ -0,0 +1,70 @@
+/*
+ * 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.mock.iaas.api.exception;
+
+import javax.ws.rs.core.Response;
+
+public class MockIaasApiException extends Exception {
+
+    private static final long serialVersionUID = 1L;
+
+    private String message;
+    private Response.Status httpStatusCode;
+
+    public MockIaasApiException() {
+        super();
+    }
+
+    public MockIaasApiException(String message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public MockIaasApiException(Response.Status httpStatusCode, String 
message, Throwable cause) {
+        super(message, cause);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public MockIaasApiException(String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public MockIaasApiException(Response.Status httpStatusCode, String 
message) {
+        super(message);
+        this.message = message;
+        this.httpStatusCode = httpStatusCode;
+    }
+
+    public MockIaasApiException(Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Response.Status getHTTPStatusCode() {
+        return httpStatusCode;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/BadRequestExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/BadRequestExceptionMapper.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/BadRequestExceptionMapper.java
new file mode 100644
index 0000000..fd4f7a6
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/BadRequestExceptionMapper.java
@@ -0,0 +1,64 @@
+/*
+ * 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.mock.iaas.api.handlers;/*
+ * 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.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.mock.iaas.api.utils.MockIaasApiUtils;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/*
+*Converts the badRequestException errors to appropriate json output messages. 
Introduced to
+* converts the JAXBExceptions due to wrong input formats
+**/
+public class BadRequestExceptionMapper implements 
ExceptionMapper<BadRequestException> {
+    private static Log log = 
LogFactory.getLog(BadRequestExceptionMapper.class);
+
+    public Response toResponse(BadRequestException badRequestException) {
+        if(log.isDebugEnabled()){
+            log.debug("Error in input format", badRequestException);
+        }
+        String errorMsg = badRequestException.getMessage() != null ? 
badRequestException.getMessage() : "please check" +
+                "your input format";
+        return 
Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON).
+                
entity(MockIaasApiUtils.buildMessage(Response.Status.BAD_REQUEST.getStatusCode(),
 errorMsg)).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomExceptionMapper.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomExceptionMapper.java
new file mode 100644
index 0000000..af6d9f2
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomExceptionMapper.java
@@ -0,0 +1,52 @@
+/*
+ * 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.mock.iaas.api.handlers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.mock.iaas.api.utils.MockIaasApiUtils;
+import org.apache.stratos.mock.iaas.api.exception.MockIaasApiException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/*
+* Stratos admin APIs' throw {@link RestAPIException} upon failure. This Class
+* maps such exceptions to appropriate JSON output
+* */
+public class CustomExceptionMapper implements 
ExceptionMapper<MockIaasApiException> {
+    private static Log log = LogFactory.getLog(CustomExceptionMapper.class);
+
+    public Response toResponse(MockIaasApiException restAPIException) {
+        if(log.isDebugEnabled()){
+            log.debug("Error while invoking the admin rest api", 
restAPIException);
+        }
+        // if no specific error message specified, spitting out a generaic 
error message
+        String errorMessage = (restAPIException.getMessage() != null)?
+                restAPIException.getMessage():"Error while fulfilling the 
request";
+        // if no specific error specified we are throwing the bad request http 
status code by default
+        Response.Status httpStatus= (restAPIException.getHTTPStatusCode() != 
null)?
+                
restAPIException.getHTTPStatusCode():Response.Status.BAD_REQUEST;
+           
+        log.error(errorMessage, restAPIException);
+        return 
Response.status(httpStatus.getStatusCode()).type(MediaType.APPLICATION_JSON).
+                
entity(MockIaasApiUtils.buildMessage(httpStatus.getStatusCode(), 
errorMessage)).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomThrowableExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomThrowableExceptionMapper.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomThrowableExceptionMapper.java
new file mode 100644
index 0000000..eb77540
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/CustomThrowableExceptionMapper.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.mock.iaas.api.handlers;/*
+ * 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.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.mock.iaas.api.utils.MockIaasApiUtils;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+public class CustomThrowableExceptionMapper implements 
ExceptionMapper<Throwable> {
+    private static Log log = 
LogFactory.getLog(CustomThrowableExceptionMapper.class);
+
+    public Response toResponse(Throwable throwable) {
+        if(log.isErrorEnabled()){
+            log.error("Internal server error", throwable);
+        }
+
+        return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON).
+                
entity(MockIaasApiUtils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
 "Internal server error")).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/GenericExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/GenericExceptionMapper.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/GenericExceptionMapper.java
new file mode 100644
index 0000000..020101d
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/handlers/GenericExceptionMapper.java
@@ -0,0 +1,47 @@
+/*
+ * 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.mock.iaas.api.handlers;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.mock.iaas.api.utils.MockIaasApiUtils;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/*This class maps any exception thrown by the server, which is not mapped by a 
specifi exception mapper
+* in to an appropriate format
+* */
+public class GenericExceptionMapper implements 
ExceptionMapper<WebApplicationException> {
+    private static Log log = LogFactory.getLog(GenericExceptionMapper.class);
+
+    public Response toResponse(WebApplicationException 
webApplicationException) {
+        if(log.isDebugEnabled()){
+            log.debug("Internal server error", webApplicationException);
+        }
+        // if no specific error message specified, spitting out a generic 
error message
+        String errorMessage = (webApplicationException.getMessage() != null)?
+                webApplicationException.getMessage():"Internal server error";
+        return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON).
+                
entity(MockIaasApiUtils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
 errorMessage)).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/utils/MockIaasApiUtils.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/utils/MockIaasApiUtils.java
 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/utils/MockIaasApiUtils.java
new file mode 100644
index 0000000..e96cdb9
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.api/src/main/java/org/apache/stratos/mock/iaas/api/utils/MockIaasApiUtils.java
@@ -0,0 +1,37 @@
+/*
+ * 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.mock.iaas.api.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.stratos.mock.iaas.domain.ErrorResponse;
+
+public class MockIaasApiUtils {
+
+    private static String transformToJson(Object object) {
+        GsonBuilder gsonBuilder = new GsonBuilder();
+        Gson gson = gsonBuilder.create();
+        return gson.toJson(object);
+    }
+
+    public static String buildMessage(int errorCode, String errorMessage) {
+        ErrorResponse errorResponse = new ErrorResponse(errorCode, 
errorMessage);
+        return transformToJson(errorResponse);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.client/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mock.iaas.client/pom.xml 
b/components/org.apache.stratos.mock.iaas.client/pom.xml
new file mode 100644
index 0000000..4b8a49e
--- /dev/null
+++ b/components/org.apache.stratos.mock.iaas.client/pom.xml
@@ -0,0 +1,109 @@
+<?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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>stratos-components-parent</artifactId>
+        <groupId>org.apache.stratos</groupId>
+        <version>4.1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>org.apache.stratos.mock.iaas.client</artifactId>
+    <name>Apache Stratos - Mock IaaS API Client</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.3.0.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.2.5.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.mock.iaas</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.apache.stratos.mock.iaas.client.*,
+                        </Export-Package>
+                        <Private-Package>
+                               org.apache.stratos.mock.iaas.client.internal;
+                        </Private-Package>
+                        <Import-Package>
+                            !org.apache.commons.logging,
+                            org.apache.commons.logging; version=0.0.0,
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/MockIaasApiClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/MockIaasApiClient.java
 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/MockIaasApiClient.java
new file mode 100644
index 0000000..eec6783
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/MockIaasApiClient.java
@@ -0,0 +1,130 @@
+/*
+ * 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.mock.iaas.client;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.stratos.mock.iaas.domain.ErrorResponse;
+import org.apache.stratos.mock.iaas.domain.MockInstanceContext;
+import org.apache.stratos.mock.iaas.domain.MockInstanceMetadata;
+import org.apache.stratos.mock.iaas.client.rest.HttpResponse;
+import org.apache.stratos.mock.iaas.client.rest.RestClient;
+
+import java.net.URI;
+
+/**
+ * Mock iaas api client.
+ */
+public class MockIaasApiClient {
+
+    private static final Log log = LogFactory.getLog(MockIaasApiClient.class);
+    private static final String INSTANCES_CONTEXT = "/instances/";
+
+    private RestClient restClient;
+    private String endpoint;
+
+    public MockIaasApiClient(String endpoint) {
+        this.restClient = new RestClient();
+        this.endpoint = endpoint;
+    }
+
+    public MockInstanceMetadata startInstance(MockInstanceContext 
mockInstanceContext) {
+        try {
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            Gson gson = gsonBuilder.create();
+            String content = gson.toJson(mockInstanceContext);
+            if (log.isDebugEnabled()) {
+                log.debug("Start instance request body: " + content);
+            }
+            URI uri = new URIBuilder(endpoint + INSTANCES_CONTEXT).build();
+            HttpResponse response = restClient.doPost(uri, content);
+            if(response != null) {
+                if((response.getStatusCode() >= 200) && 
(response.getStatusCode() < 300)) {
+                    return gson.fromJson(response.getContent(), 
MockInstanceMetadata.class);
+                } else {
+                    ErrorResponse errorResponse = 
gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if(errorResponse != null) {
+                        throw new 
RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public void terminateInstance(String instanceId) {
+        try {
+            if (log.isDebugEnabled()) {
+                log.debug(String.format("Terminate instance: [instance-id] 
%s", instanceId));
+            }
+            URI uri = new URIBuilder(endpoint + INSTANCES_CONTEXT + 
instanceId).build();
+            HttpResponse response = restClient.doDelete(uri);
+            if(response != null) {
+                if((response.getStatusCode() >= 200) && 
(response.getStatusCode() < 300)) {
+                    return;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = 
gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if(errorResponse != null) {
+                        throw new 
RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public MockInstanceMetadata allocateIpAddress(String instanceId) {
+        try {
+            if (log.isDebugEnabled()) {
+                log.debug(String.format("Allocating ip address: [instance-id] 
%s", instanceId));
+            }
+            URI uri = new URIBuilder(endpoint + INSTANCES_CONTEXT + instanceId 
+ "/allocateIpAddress").build();
+            HttpResponse response = restClient.doPost(uri, new String());
+            if(response != null) {
+                GsonBuilder gsonBuilder = new GsonBuilder();
+                Gson gson = gsonBuilder.create();
+
+                if((response.getStatusCode() >= 200) && 
(response.getStatusCode() < 300)) {
+                    return gson.fromJson(response.getContent(), 
MockInstanceMetadata.class);
+                } else {
+                    ErrorResponse errorResponse = 
gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if(errorResponse != null) {
+                        throw new 
RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = String.format("Could not allocate ip address: 
[instance-id] ", instanceId);
+            throw new RuntimeException(message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponse.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponse.java
 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponse.java
new file mode 100644
index 0000000..db571bd
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponse.java
@@ -0,0 +1,54 @@
+/*
+ * 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.mock.iaas.client.rest;
+
+/**
+ * Holds the data extracted from a HttpResponse.
+ */
+public class HttpResponse {
+
+    private int statusCode;
+    private String content;
+    private String reason;
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+    public void setStatusCode(int statusCode) {
+        this.statusCode = statusCode;
+    }
+    public String getContent() {
+        return content;
+    }
+    public void setContent(String content) {
+        this.content = content;
+    }
+    public String getReason() {
+        return reason;
+    }
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    @Override
+    public String toString() {
+        return "HttpResponse [statusCode=" + statusCode + ", content=" + 
content
+                + ", reason=" + reason + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponseHandler.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponseHandler.java
 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponseHandler.java
new file mode 100644
index 0000000..0d554af
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/HttpResponseHandler.java
@@ -0,0 +1,69 @@
+/*
+ * 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.mock.iaas.client.rest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.ResponseHandler;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * Handles a HttpResponse and returns a {@link HttpResponse}
+ */
+public class HttpResponseHandler implements ResponseHandler<HttpResponse>{
+
+    private static final Log log = 
LogFactory.getLog(HttpResponseHandler.class);
+
+    @Override
+    public HttpResponse handleResponse(org.apache.http.HttpResponse response) 
throws ClientProtocolException,
+            IOException {
+        StatusLine statusLine = response.getStatusLine();
+        HttpEntity entity = response.getEntity();
+        if (entity == null) {
+            throw new ClientProtocolException("Response contains no content");
+        }
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                (response.getEntity().getContent())));
+
+        String output;
+        String result = "";
+
+        while ((output = reader.readLine()) != null) {
+            result += output;
+        }
+
+        HttpResponse httpResponse = new HttpResponse();
+        httpResponse.setStatusCode(statusLine.getStatusCode());
+        httpResponse.setContent(result);
+        httpResponse.setReason(statusLine.getReasonPhrase());
+
+        if (log.isDebugEnabled()) {
+            log.debug("Extracted Http Response: " + httpResponse.toString());
+        }
+
+        return httpResponse;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/RestClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/RestClient.java
 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/RestClient.java
new file mode 100644
index 0000000..ecc1f80
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas.client/src/main/java/org/apache/stratos/mock/iaas/client/rest/RestClient.java
@@ -0,0 +1,118 @@
+/*
+ * 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.mock.iaas.client.rest;
+
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+
+import java.net.URI;
+
+public class RestClient {
+
+    private DefaultHttpClient httpClient;
+
+    public RestClient() {
+        PoolingClientConnectionManager cm = new 
PoolingClientConnectionManager();
+        // Increase max total connection to 200
+        cm.setMaxTotal(200);
+        // Increase default max connection per route to 50
+        cm.setDefaultMaxPerRoute(50);
+
+        httpClient = new DefaultHttpClient(cm);
+    }
+
+    /**
+     * Handle http post request. Return String
+     *
+     * @param resourcePath    This should be REST endpoint
+     * @param jsonParamString The json string which should be executed from 
the post request
+     * @return The HttpResponse
+     * @throws Exception if any errors occur when executing the request
+     */
+    public HttpResponse doPost(URI resourcePath, String jsonParamString) 
throws Exception {
+        HttpPost postRequest = null;
+        try {
+            postRequest = new HttpPost(resourcePath);
+
+            StringEntity input = new StringEntity(jsonParamString);
+            input.setContentType("application/json");
+            postRequest.setEntity(input);
+
+            return httpClient.execute(postRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(postRequest);
+        }
+    }
+
+    /**
+     * Handle http get request. Return String
+     *
+     * @param resourcePath This should be REST endpoint
+     * @return The HttpResponse
+     * @throws org.apache.http.client.ClientProtocolException and IOException
+     *                                                        if any errors 
occur when executing the request
+     */
+    public HttpResponse doGet(URI resourcePath) throws Exception {
+        HttpGet getRequest = null;
+        try {
+            getRequest = new HttpGet(resourcePath);
+            getRequest.addHeader("Content-Type", "application/json");
+
+            return httpClient.execute(getRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(getRequest);
+        }
+    }
+
+    public HttpResponse doDelete(URI resourcePath) throws Exception {
+        HttpDelete httpDelete = null;
+        try {
+            httpDelete = new HttpDelete(resourcePath);
+            httpDelete.addHeader("Content-Type", "application/json");
+
+            return httpClient.execute(httpDelete, new HttpResponseHandler());
+        } finally {
+            releaseConnection(httpDelete);
+        }
+    }
+
+    public HttpResponse doPut(URI resourcePath, String jsonParamString) throws 
Exception {
+
+        HttpPut putRequest = null;
+        try {
+            putRequest = new HttpPut(resourcePath);
+
+            StringEntity input = new StringEntity(jsonParamString);
+            input.setContentType("application/json");
+            putRequest.setEntity(input);
+
+            return httpClient.execute(putRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(putRequest);
+        }
+    }
+
+    private void releaseConnection(HttpRequestBase request) {
+        if (request != null) {
+            request.releaseConnection();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mock.iaas/pom.xml 
b/components/org.apache.stratos.mock.iaas/pom.xml
new file mode 100644
index 0000000..9a0aed1
--- /dev/null
+++ b/components/org.apache.stratos.mock.iaas/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>stratos-components-parent</artifactId>
+        <groupId>org.apache.stratos</groupId>
+        <version>4.1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>org.apache.stratos.mock.iaas</artifactId>
+    <name>Apache Stratos - Mock IaaS</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.core</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.logging</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.databridge.commons</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${pom.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.apache.stratos.mock.iaas.*,
+                            org.apache.stratos.mock.iaas.domain.*,
+                            
org.apache.stratos.mock.iaas.services.MockIaasService,
+                        </Export-Package>
+                        <Private-Package>
+                            org.apache.stratos.mock.iaas.internal;
+                        </Private-Package>
+                        <Import-Package>
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockHealthStatisticsConfig.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockHealthStatisticsConfig.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockHealthStatisticsConfig.java
new file mode 100644
index 0000000..1980579
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockHealthStatisticsConfig.java
@@ -0,0 +1,44 @@
+/*
+ * 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.mock.iaas.config;
+
+import 
org.apache.stratos.mock.iaas.statistics.generator.MockHealthStatisticsPattern;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Mock health statistics configuration.
+ */
+public class MockHealthStatisticsConfig {
+    List<MockHealthStatisticsPattern> statisticsPatternList;
+
+    public MockHealthStatisticsConfig() {
+        statisticsPatternList = new ArrayList<MockHealthStatisticsPattern>();
+    }
+
+    public void addStatisticsPattern(MockHealthStatisticsPattern 
statisticsPattern) {
+        statisticsPatternList.add(statisticsPattern);
+    }
+
+    public List<MockHealthStatisticsPattern> getStatisticsPatterns() {
+        return statisticsPatternList;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfig.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfig.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfig.java
new file mode 100644
index 0000000..55d32ff
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfig.java
@@ -0,0 +1,70 @@
+/*
+ * 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.mock.iaas.config;
+
+/**
+ * Mock iaas configuration.
+ */
+public class MockIaasConfig {
+
+    public static final String MOCK_IAAS_CONFIG_FILE_PATH = 
"mock.iaas.config.file.path";
+    public static final String MOCK_IAAS_CONFIG_FILE_NAME = "mock-iaas.xml";
+
+    private static final String CARBON_HOME = "carbon.home";
+    private static final String REPOSITORY_CONF = "/repository/conf/";
+
+    private static volatile MockIaasConfig instance;
+
+    private boolean enabled;
+    private MockHealthStatisticsConfig mockHealthStatisticsConfig;
+    
+    public static MockIaasConfig getInstance() {
+        if (instance == null) {
+            synchronized (MockIaasConfig.class) {
+                if (instance == null) {
+                    String defaultConfigFilePath = 
System.getProperty(CARBON_HOME) + REPOSITORY_CONF +
+                            MOCK_IAAS_CONFIG_FILE_NAME;
+                    String configFilePath = 
System.getProperty(MOCK_IAAS_CONFIG_FILE_PATH, defaultConfigFilePath);
+                    instance = MockIaasConfigParser.parse(configFilePath);
+                }
+            }
+        }
+        return instance;
+    }
+
+    MockIaasConfig() {
+    }
+
+    void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    void setMockHealthStatisticsConfig(MockHealthStatisticsConfig 
mockHealthStatisticsConfig) {
+        this.mockHealthStatisticsConfig = mockHealthStatisticsConfig;
+    }
+
+    public MockHealthStatisticsConfig getMockHealthStatisticsConfig() {
+        return mockHealthStatisticsConfig;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfigParser.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfigParser.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfigParser.java
new file mode 100644
index 0000000..371d5e1
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/config/MockIaasConfigParser.java
@@ -0,0 +1,173 @@
+/*
+ * 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.mock.iaas.config;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.stratos.common.util.AxiomXpathParserUtil;
+import org.apache.stratos.mock.iaas.services.impl.MockAutoscalingFactor;
+import org.apache.stratos.mock.iaas.statistics.StatisticsPatternMode;
+import 
org.apache.stratos.mock.iaas.statistics.generator.MockHealthStatisticsPattern;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Mock health statistics configuration parser.
+ */
+public class MockIaasConfigParser {
+
+    private static final QName ENABLED_ATTRIBUTE = new QName("enabled");
+    private static final QName TYPE_ATTRIBUTE = new QName("type");
+    private static final QName FACTOR_ATTRIBUTE = new QName("factor");
+    private static final QName MODE_ATTRIBUTE = new QName("mode");
+    private static final String HEALTH_STATISTICS_ELEMENT = 
"health-statistics";
+    private static final String SAMPLE_VALUES_ELEMENT = "sampleValues";
+    private static final String SAMPLE_DURATION_ELEMENT = "sampleDuration";
+
+    /**
+     * Parse mock iaas configuration and return configuration object.
+     * @param filePath
+     * @return
+     */
+    public static MockIaasConfig parse(String filePath) {
+        try {
+            MockIaasConfig mockIaasConfig = new MockIaasConfig();
+            MockHealthStatisticsConfig mockHealthStatisticsConfig = new 
MockHealthStatisticsConfig();
+            
mockIaasConfig.setMockHealthStatisticsConfig(mockHealthStatisticsConfig);
+
+            OMElement document = AxiomXpathParserUtil.parse(new 
File(filePath));
+            String enabledStr = document.getAttributeValue(ENABLED_ATTRIBUTE);
+            if(StringUtils.isEmpty(enabledStr)) {
+                throw new RuntimeException("Enabled attribute not found in 
mock-iaas element");
+            }
+            mockIaasConfig.setEnabled(Boolean.parseBoolean(enabledStr));
+
+            Iterator statisticsIterator = document.getChildElements();
+
+            while (statisticsIterator.hasNext()) {
+                OMElement statisticsElement = (OMElement) 
statisticsIterator.next();
+
+                if 
(HEALTH_STATISTICS_ELEMENT.equals(statisticsElement.getQName().getLocalPart())) 
{
+                    Iterator cartridgeIterator = 
statisticsElement.getChildElements();
+
+                    while (cartridgeIterator.hasNext()) {
+                        OMElement cartridgeElement = (OMElement) 
cartridgeIterator.next();
+                        OMAttribute typeAttribute = 
cartridgeElement.getAttribute(TYPE_ATTRIBUTE);
+                        if (typeAttribute == null) {
+                            throw new RuntimeException("Type attribute not 
found in cartridge element");
+                        }
+                        String cartridgeType = 
typeAttribute.getAttributeValue();
+                        Iterator patternIterator = 
cartridgeElement.getChildElements();
+
+                        while (patternIterator.hasNext()) {
+                            OMElement patternElement = (OMElement) 
patternIterator.next();
+
+                            OMAttribute factorAttribute = 
patternElement.getAttribute(FACTOR_ATTRIBUTE);
+                            if (factorAttribute == null) {
+                                throw new RuntimeException("Factor attribute 
not found in pattern element: " +
+                                        "[cartridge-type] " + cartridgeType);
+                            }
+                            String factorStr = 
factorAttribute.getAttributeValue();
+                            MockAutoscalingFactor autoscalingFactor = 
convertAutoscalingFactor(factorStr);
+
+                            OMAttribute modeAttribute = 
patternElement.getAttribute(MODE_ATTRIBUTE);
+                            if(modeAttribute == null) {
+                                throw new RuntimeException("Mode attribute not 
found in pattern element: " +
+                                        "[cartridge-type] " + cartridgeType);
+                            }
+                            String modeStr = modeAttribute.getAttributeValue();
+                            StatisticsPatternMode mode = convertMode(modeStr);
+
+                            String sampleValuesStr = null;
+                            String sampleDurationStr = null;
+                            Iterator patternChildIterator = 
patternElement.getChildElements();
+
+                            while (patternChildIterator.hasNext()) {
+                                OMElement patternChild = (OMElement) 
patternChildIterator.next();
+                                if 
(SAMPLE_VALUES_ELEMENT.equals(patternChild.getQName().getLocalPart())) {
+                                    sampleValuesStr = patternChild.getText();
+                                } else if 
(SAMPLE_DURATION_ELEMENT.equals(patternChild.getQName().getLocalPart())) {
+                                    sampleDurationStr = patternChild.getText();
+                                }
+                            }
+
+                            if (sampleValuesStr == null) {
+                                throw new RuntimeException("Sample values not 
found in pattern [factor] " + factorStr);
+                            }
+                            if (sampleDurationStr == null) {
+                                throw new RuntimeException("Sample duration 
not found in pattern [factor] " + factorStr);
+                            }
+
+                            String[] sampleValuesArray = 
sampleValuesStr.split(",");
+                            List<Integer> sampleValues = 
convertStringArrayToIntegerList(sampleValuesArray);
+                            int sampleDuration = 
Integer.parseInt(sampleDurationStr);
+
+                            MockHealthStatisticsPattern 
mockHealthStatisticsPattern = new MockHealthStatisticsPattern
+                                    (cartridgeType, autoscalingFactor, mode, 
sampleValues, sampleDuration);
+                            
mockHealthStatisticsConfig.addStatisticsPattern(mockHealthStatisticsPattern);
+                        }
+                    }
+                }
+            }
+            return mockIaasConfig;
+        } catch (Exception e) {
+            throw new RuntimeException("Could not parse mock health statistics 
configuration", e);
+        }
+    }
+
+    private static StatisticsPatternMode convertMode(String modeStr) {
+        if("loop".equals(modeStr)) {
+            return StatisticsPatternMode.Loop;
+        }
+        else if("continue".equals(modeStr)) {
+            return StatisticsPatternMode.Continue;
+        }
+        else if("stop".equals(modeStr)) {
+            return StatisticsPatternMode.Stop;
+        }
+        throw new RuntimeException("An unknown statistics pattern mode found: 
" + modeStr);
+    }
+
+    private static MockAutoscalingFactor convertAutoscalingFactor(String 
factorStr) {
+        if("memory-consumption".equals(factorStr)) {
+            return MockAutoscalingFactor.MemoryConsumption;
+        }
+        else if("load-average".equals(factorStr)) {
+            return MockAutoscalingFactor.LoadAverage;
+        }
+        else if("request-in-flight".equals(factorStr)) {
+            return MockAutoscalingFactor.RequestInFlight;
+        }
+        throw new RuntimeException("An unknown autoscaling factor found: " + 
factorStr);
+    }
+
+    private static List<Integer> convertStringArrayToIntegerList(String[] 
stringArray) {
+        List<Integer> integerList = new ArrayList<Integer>();
+        for (String value : stringArray) {
+            integerList.add(Integer.parseInt(value));
+        }
+        return integerList;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/ErrorResponse.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/ErrorResponse.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/ErrorResponse.java
new file mode 100644
index 0000000..981fdc0
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/ErrorResponse.java
@@ -0,0 +1,57 @@
+/*
+ * 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.mock.iaas.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * Error response.
+ */
+@XmlRootElement(name = "errorResponse")
+public class ErrorResponse implements Serializable {
+
+    private int errorCode;
+    private String errorMessage;
+
+    public ErrorResponse(){
+    }
+
+    public ErrorResponse(int errorCode, String errorMessage) {
+        this.setErrorCode(errorCode);
+        this.setErrorMessage(errorMessage);
+    }
+
+    public int getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(int errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    public void setErrorMessage(String errorMessage) {
+        this.errorMessage = errorMessage;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceContext.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceContext.java
new file mode 100644
index 0000000..82bb606
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceContext.java
@@ -0,0 +1,141 @@
+/*
+ * 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.mock.iaas.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * Mock member context.
+ */
+@XmlRootElement(name = "mockInstanceContext")
+public class MockInstanceContext implements Serializable {
+
+    private static final long serialVersionUID = 5511318098405943180L;
+
+    private String applicationId;
+    private String serviceName;
+    private String clusterId;
+    private String memberId;
+    private String clusterInstanceId;
+    private String networkPartitionId;
+    private String partitionId;
+    private String defaultPrivateIP;
+    private String defaultPublicIP;
+    private String instanceId;
+
+    public MockInstanceContext(){
+    }
+
+    public MockInstanceContext(String applicationId, String serviceName, 
String clusterId, String memberId,
+                               String clusterInstanceId, String 
networkPartitionId, String partitionId) {
+        this.setApplicationId(applicationId);
+        this.setServiceName(serviceName);
+        this.setClusterId(clusterId);
+        this.setMemberId(memberId);
+        this.setClusterInstanceId(clusterInstanceId);
+        this.setNetworkPartitionId(networkPartitionId);
+        this.setPartitionId(partitionId);
+    }
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public String getApplicationId() {
+        return applicationId;
+    }
+
+    public void setApplicationId(String applicationId) {
+        this.applicationId = applicationId;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getMemberId() {
+        return memberId;
+    }
+
+    public void setMemberId(String memberId) {
+        this.memberId = memberId;
+    }
+
+    public String getClusterInstanceId() {
+        return clusterInstanceId;
+    }
+
+    public void setClusterInstanceId(String clusterInstanceId) {
+        this.clusterInstanceId = clusterInstanceId;
+    }
+
+    public String getNetworkPartitionId() {
+        return networkPartitionId;
+    }
+
+    public void setNetworkPartitionId(String networkPartitionId) {
+        this.networkPartitionId = networkPartitionId;
+    }
+
+    public String getPartitionId() {
+        return partitionId;
+    }
+
+    public void setPartitionId(String partitionId) {
+        this.partitionId = partitionId;
+    }
+
+    public String getDefaultPrivateIP() {
+        return defaultPrivateIP;
+    }
+
+    public void setDefaultPrivateIP(String defaultPrivateIP) {
+        this.defaultPrivateIP = defaultPrivateIP;
+    }
+
+    public String getDefaultPublicIP() {
+        return defaultPublicIP;
+    }
+
+    public void setDefaultPublicIP(String defaultPublicIP) {
+        this.defaultPublicIP = defaultPublicIP;
+    }
+
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public void setInstanceId(String instanceId) {
+        this.instanceId = instanceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceMetadata.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceMetadata.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceMetadata.java
new file mode 100644
index 0000000..1b67650
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/domain/MockInstanceMetadata.java
@@ -0,0 +1,69 @@
+/*
+ * 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.mock.iaas.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * Mock instance metadata.
+ */
+@XmlRootElement(name = "mockInstanceMetadata")
+public class MockInstanceMetadata implements Serializable {
+
+    private static final long serialVersionUID = -1323605022799409426L;
+
+    private String instanceId;
+    private String defaultPrivateIp;
+    private String defaultPublicIp;
+
+    public MockInstanceMetadata() {
+    }
+
+    public MockInstanceMetadata(MockInstanceContext mockInstanceContext) {
+        this.instanceId = mockInstanceContext.getInstanceId();
+        this.defaultPrivateIp = mockInstanceContext.getDefaultPrivateIP();
+        this.defaultPublicIp = mockInstanceContext.getDefaultPublicIP();
+    }
+
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public void setInstanceId(String instanceId) {
+        this.instanceId = instanceId;
+    }
+
+    public String getDefaultPrivateIp() {
+        return defaultPrivateIp;
+    }
+
+    public void setDefaultPrivateIp(String defaultPrivateIp) {
+        this.defaultPrivateIp = defaultPrivateIp;
+    }
+
+    public String getDefaultPublicIp() {
+        return defaultPublicIp;
+    }
+
+    public void setDefaultPublicIp(String defaultPublicIp) {
+        this.defaultPublicIp = defaultPublicIp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/event/publisher/MockMemberEventPublisher.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/event/publisher/MockMemberEventPublisher.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/event/publisher/MockMemberEventPublisher.java
new file mode 100644
index 0000000..4700355
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/event/publisher/MockMemberEventPublisher.java
@@ -0,0 +1,126 @@
+/*
+ * 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.mock.iaas.event.publisher;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import 
org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
+import 
org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
+import 
org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
+import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
+import org.apache.stratos.messaging.util.Util;
+import org.apache.stratos.mock.iaas.domain.MockInstanceContext;
+
+/**
+ * Mock member event publisher.
+ */
+public class MockMemberEventPublisher {
+
+    private static final Log log = 
LogFactory.getLog(MockMemberEventPublisher.class);
+
+    public static void publishInstanceStartedEvent(MockInstanceContext 
mockMemberContext) {
+        if (log.isInfoEnabled()) {
+            log.info("Publishing instance started event");
+        }
+        InstanceStartedEvent event = new InstanceStartedEvent(
+                mockMemberContext.getApplicationId(),
+                mockMemberContext.getServiceName(),
+                mockMemberContext.getClusterId(),
+                mockMemberContext.getMemberId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
+        String topic = Util.getMessageTopicName(event);
+        EventPublisher eventPublisher = EventPublisherPool
+                .getPublisher(topic);
+        eventPublisher.publish(event);
+        if (log.isInfoEnabled()) {
+            log.info("Instance started event published");
+        }
+    }
+
+    public static void publishInstanceActivatedEvent(MockInstanceContext 
mockMemberContext) {
+        if (log.isInfoEnabled()) {
+            log.info("Publishing instance activated event");
+        }
+        InstanceActivatedEvent event = new InstanceActivatedEvent(
+                mockMemberContext.getServiceName(),
+                mockMemberContext.getClusterId(),
+                mockMemberContext.getMemberId(),
+                mockMemberContext.getInstanceId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
+
+        // Event publisher connection will
+        String topic = Util.getMessageTopicName(event);
+        EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+        eventPublisher.publish(event);
+        if (log.isInfoEnabled()) {
+            log.info("Instance activated event published");
+        }
+    }
+
+    public static void publishInstanceReadyToShutdownEvent(MockInstanceContext 
mockMemberContext) {
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Publishing instance ready to shutdown 
event: [member-id] %s",
+                    mockMemberContext.getMemberId()));
+        }
+        InstanceReadyToShutdownEvent event = new InstanceReadyToShutdownEvent(
+                mockMemberContext.getServiceName(),
+                mockMemberContext.getClusterId(),
+                mockMemberContext.getMemberId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
+        String topic = Util.getMessageTopicName(event);
+        EventPublisher eventPublisher = EventPublisherPool
+                .getPublisher(topic);
+        eventPublisher.publish(event);
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Instance ready to shutDown event 
published: [member-id] %s",
+                    mockMemberContext.getMemberId()));
+        }
+    }
+
+    public static void publishMaintenanceModeEvent(MockInstanceContext 
mockMemberContext) {
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Publishing instance maintenance mode 
event: [member-id] %s",
+                    mockMemberContext.getMemberId()));
+        }
+        InstanceMaintenanceModeEvent event = new InstanceMaintenanceModeEvent(
+                mockMemberContext.getServiceName(),
+                mockMemberContext.getClusterId(),
+                mockMemberContext.getMemberId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
+        String topic = Util.getMessageTopicName(event);
+        EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+        eventPublisher.publish(event);
+
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Instance Maintenance mode event published: 
[member-id] %s",
+                    mockMemberContext.getMemberId()));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/ContinueLastSampleValueException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/ContinueLastSampleValueException.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/ContinueLastSampleValueException.java
new file mode 100644
index 0000000..1d3b5b1
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/ContinueLastSampleValueException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.mock.iaas.exceptions;
+
+/**
+ * Thrown when statistics pattern mode is set to continue and pattern reaches
+ * the last sample value.
+ */
+public class ContinueLastSampleValueException extends Exception {
+    private int lastSampleValue;
+
+    public ContinueLastSampleValueException(int lastSampleValue) {
+        this.lastSampleValue = lastSampleValue;
+    }
+
+    public int getLastSampleValue() {
+        return lastSampleValue;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/MockIaasException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/MockIaasException.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/MockIaasException.java
new file mode 100644
index 0000000..de304b0
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/MockIaasException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.mock.iaas.exceptions;
+
+/**
+ * Mock iaas exception.
+ */
+public class MockIaasException extends Exception {
+
+    public MockIaasException() {
+        super();
+    }
+
+    public MockIaasException(String message) {
+        super(message);
+    }
+
+    public MockIaasException(String message, Throwable throwable) {
+        super(message, throwable);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e16acd17/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/NoSampleValuesFoundException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/NoSampleValuesFoundException.java
 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/NoSampleValuesFoundException.java
new file mode 100644
index 0000000..65563e8
--- /dev/null
+++ 
b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/exceptions/NoSampleValuesFoundException.java
@@ -0,0 +1,26 @@
+/*
+ * 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.mock.iaas.exceptions;
+
+/**
+ * No sample values found exception.
+ */
+public class NoSampleValuesFoundException extends Exception {
+}

Reply via email to