You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/03/04 15:29:15 UTC

[1/2] stratos git commit: moving application policy to global level

Repository: stratos
Updated Branches:
  refs/heads/master 6dfbea5b3 -> 9d4f85ba1


http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
index 70d79a4..f0a324d 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl
@@ -1,1270 +1,1415 @@
-<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax27="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax25="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax21="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax22="http://common.stratos.apache.org/xsd" xmlns:ax216="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax213="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax211="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/
 soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax29="http://common.stratos.apache.org/xsd" xmlns:ax27="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ns="http://impl.services.autoscaler.stratos.apache.org" xmlns:ax25="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax23="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax219="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax215="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax212="http://io.java/xsd" xmlns:ax222="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ax211="http://rmi.java/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="ht
 tp://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+    <wsdl:documentation>AutoscalerService</wsdl:documentation>
     <wsdl:types>
+        <xs:schema xmlns:ax213="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://rmi.java/xsd">
+            <xs:import namespace="http://io.java/xsd"></xs:import>
+            <xs:complexType name="RemoteException">
+                <xs:complexContent>
+                    <xs:extension base="ax212:IOException">
+                        <xs:sequence>
+                            <xs:element minOccurs="0" name="cause" nillable="true" type="xs:anyType"></xs:element>
+                            <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
+                        </xs:sequence>
+                    </xs:extension>
+                </xs:complexContent>
+            </xs:complexType>
+        </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="AutoscalePolicy">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"/>
-                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax29:LoadThresholds"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="displayName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="id" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="instanceRoundingFactor" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="isPublic" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="loadThresholds" nillable="true" type="ax23:LoadThresholds"></xs:element>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="LoadThresholds">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="loadAverageThreshold" type="xs:float"/>
-                    <xs:element minOccurs="0" name="memoryConsumptionThreshold" type="xs:float"/>
-                    <xs:element minOccurs="0" name="requestsInFlightThreshold" type="xs:float"/>
+                    <xs:element minOccurs="0" name="loadAverageThreshold" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="memoryConsumptionThreshold" type="xs:float"></xs:element>
+                    <xs:element minOccurs="0" name="requestsInFlightThreshold" type="xs:float"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax23="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
-            <xs:import namespace="http://common.stratos.apache.org/xsd"/>
+        <xs:schema xmlns:ax220="http://common.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd">
+            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
             <xs:complexType name="ApplicationContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="components" nillable="true" type="ax21:ComponentContext"/>
-                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax23:Properties"/>
-                    <xs:element minOccurs="0" name="status" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="tenantAdminUsername" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="components" nillable="true" type="ax219:ComponentContext"></xs:element>
+                    <xs:element minOccurs="0" name="description" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="multiTenant" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="status" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="tenantAdminUsername" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="tenantDomain" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ComponentContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax21:ApplicationClusterContext"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax21:CartridgeContext"/>
-                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax21:DependencyContext"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax21:GroupContext"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="applicationClusterContexts" nillable="true" type="ax219:ApplicationClusterContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax219:CartridgeContext"></xs:element>
+                    <xs:element minOccurs="0" name="dependencyContext" nillable="true" type="ax219:DependencyContext"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax219:GroupContext"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ApplicationClusterContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="autoscalePolicyName" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyClusterIds" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="lbCluster" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax23:Properties"/>
-                    <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="textPayload" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="autoscalePolicyName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyClusterIds" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicyName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="hostName" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="lbCluster" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"></xs:element>
+                    <xs:element minOccurs="0" name="tenantRange" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="textPayload" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="CartridgeContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="cartridgeMax" type="xs:int"/>
-                    <xs:element minOccurs="0" name="cartridgeMin" type="xs:int"/>
-                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax21:SubscribableInfoContext"/>
-                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="cartridgeMax" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="cartridgeMin" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="subscribableInfoContext" nillable="true" type="ax219:SubscribableInfoContext"></xs:element>
+                    <xs:element minOccurs="0" name="type" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="SubscribableInfoContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax21:ArtifactRepositoryContext"/>
-                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="maxMembers" type="xs:int"/>
-                    <xs:element minOccurs="0" name="minMembers" type="xs:int"/>
-                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax23:Properties"/>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="artifactRepositoryContext" nillable="true" type="ax219:ArtifactRepositoryContext"></xs:element>
+                    <xs:element minOccurs="0" name="autoscalingPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="dependencyAliases" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="maxMembers" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="minMembers" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="ArtifactRepositoryContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="privateRepo" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="repoPassword" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="repoUrl" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="repoUsername" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="DependencyContext">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependents" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependents" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrdersContexts" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="GroupContext">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax21:CartridgeContext"/>
-                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax21:GroupContext"/>
-                    <xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"/>
-                    <xs:element minOccurs="0" name="groupMinInstances" type="xs:int"/>
-                    <xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridgeContexts" nillable="true" type="ax219:CartridgeContext"></xs:element>
+                    <xs:element minOccurs="0" name="deploymentPolicy" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groupContexts" nillable="true" type="ax219:GroupContext"></xs:element>
+                    <xs:element minOccurs="0" name="groupMaxInstances" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="groupMinInstances" type="xs:int"></xs:element>
+                    <xs:element minOccurs="0" name="groupScalingEnabled" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="ServiceGroup">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax216:Dependencies"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax216:ServiceGroup"/>
-                    <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="cartridges" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="dependencies" nillable="true" type="ax222:Dependencies"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="groups" nillable="true" type="ax222:ServiceGroup"></xs:element>
+                    <xs:element minOccurs="0" name="groupscalingEnabled" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Dependencies">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependants" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="scalingDependants" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="startupOrders" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="terminationBehaviour" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
-        <xs:schema xmlns:ax28="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax217="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax214="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax215="http://common.stratos.apache.org/xsd" xmlns:ax212="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
-            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://common.stratos.apache.org/xsd"/>
-            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"/>
-            <xs:element name="getApplications">
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="ApplicationPolicy">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="algorithm" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitionReferences" nillable="true" type="ax217:ApplicationPolicyNetworkPartitionReference"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="ApplicationPolicyNetworkPartitionReference">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"></xs:element>
+                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"></xs:element>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema xmlns:ax214="http://rmi.java/xsd" xmlns:ax221="http://pojo.applications.autoscaler.stratos.apache.org/xsd" xmlns:ax28="http://exception.autoscaler.stratos.apache.org/xsd" xmlns:ax210="http://common.stratos.apache.org/xsd" xmlns:ax223="http://pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax26="http://policy.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax24="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd" xmlns:ax216="http://application.exception.autoscaler.stratos.apache.org/xsd" xmlns:ax218="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.services.autoscaler.stratos.apache.org">
+            <xs:import namespace="http://autoscale.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://policy.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://common.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://rmi.java/xsd"></xs:import>
+            <xs:import namespace="http://application.exception.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.applications.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:import namespace="http://pojo.autoscaler.stratos.apache.org/xsd"></xs:import>
+            <xs:element name="getAutoScalingPolicies">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationsResponse">
+            <xs:element name="getAutoScalingPoliciesResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax24:ApplicationContext"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceApplicationDefinitionException">
+            <xs:element name="AutoscalerServiceInvalidPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax25:ApplicationDefinitionException"/>
+                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax25:InvalidPolicyException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addApplication">
+            <xs:element name="addAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax24:ApplicationContext"/>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceInvalidPolicyException">
+            <xs:element name="addAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidPolicyException" nillable="true" type="ax27:InvalidPolicyException"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addAutoScalingPolicy">
+            <xs:element name="updateAutoScalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addAutoScalingPolicyResponse">
+            <xs:element name="updateAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAutoScalingPolicies">
+            <xs:element name="removeAutoScalingPolicy">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="autoscalePolicyId" nillable="true" type="xs:string"></xs:element>
+                    </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getAutoScalingPoliciesResponse">
+            <xs:element name="removeAutoScalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateAutoScalingPolicy">
+            <xs:element name="AutoscalerServiceInvalidArgumentException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicy" nillable="true" type="ax29:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax27:InvalidArgumentException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateAutoScalingPolicyResponse">
+            <xs:element name="updateClusterMonitor">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="properties" nillable="true" type="ax29:Properties"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="removeAutoScalingPolicy">
+            <xs:element name="findClusterId">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalePolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="removeAutoScalingPolicyResponse">
+            <xs:element name="findClusterIdResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplication">
+            <xs:element name="serviceGroupExist">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax212:ApplicationPolicy"/>
+                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deployApplicationResponse">
+            <xs:element name="serviceGroupExistResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="undeployApplication">
+            <xs:element name="AutoscalerServiceAutoScalerException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax27:AutoScalerException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceInvalidArgumentException">
+            <xs:element name="undeployServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidArgumentException" nillable="true" type="ax214:InvalidArgumentException"/>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="updateClusterMonitor">
+            <xs:element name="AutoscalerServiceRemoteException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="properties" nillable="true" type="ax22:Properties"/>
+                        <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ax214:RemoteException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceInvalidServiceGroupException">
+            <xs:element name="AutoscalerServiceInvalidApplicationPolicyException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax25:InvalidServiceGroupException"/>
+                        <xs:element minOccurs="0" name="InvalidApplicationPolicyException" nillable="true" type="ax216:InvalidApplicationPolicyException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="addServiceGroup">
+            <xs:element name="addApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax217:ServiceGroup"/>
+                        <xs:element minOccurs="0" name="applicationPolicy" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="findClusterId">
+            <xs:element name="removeApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
-                        <xs:element minOccurs="0" name="alias" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="findClusterIdResponse">
+            <xs:element name="AutoscalerServiceApplicationDefinitionException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="ApplicationDefinitionException" nillable="true" type="ax216:ApplicationDefinitionException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="AutoscalerServiceAutoScalerException">
+            <xs:element name="addApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="AutoScalerException" nillable="true" type="ax214:AutoScalerException"/>
+                        <xs:element minOccurs="0" name="applicationContext" nillable="true" type="ax219:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationNetworkPartitions">
+            <xs:element name="getApplications">
+                <xs:complexType>
+                    <xs:sequence></xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax219:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationNetworkPartitionsResponse">
+            <xs:element name="deployApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                        <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="undeployServiceGroup">
+            <xs:element name="deployApplicationResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="return" type="xs:boolean"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroup">
+            <xs:element name="getApplicationPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="applicationPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getServiceGroupResponse">
+            <xs:element name="getApplicationPolicyResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax217:ApplicationPolicy"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationNetworkPartitions">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax217:ServiceGroup"/>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getApplicationNetworkPartitionsResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="undeployApplication">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicy">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="autoscalingPolicyId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getAutoscalingPolicyResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax29:AutoscalePolicy"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax23:AutoscalePolicy"></xs:element>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="deleteApplication">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getApplication">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getApplicationResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax24:ApplicationContext"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax219:ApplicationContext"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPolicy">
+            <xs:element name="AutoscalerServiceInvalidServiceGroupException">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="InvalidServiceGroupException" nillable="true" type="ax216:InvalidServiceGroupException"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="getApplicationPolicyResponse">
+            <xs:element name="addServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true" type="ax212:ApplicationPolicy"/>
+                        <xs:element minOccurs="0" name="servicegroup" nillable="true" type="ax222:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="deleteApplication">
+            <xs:element name="removeServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="groupName" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="serviceGroupExist">
+            <xs:element name="getServiceGroup">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
-            <xs:element name="serviceGroupExistResponse">
+            <xs:element name="getServiceGroupResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceGroups">
                 <xs:complexType>
-                    <xs:sequence/>
+                    <xs:sequence></xs:sequence>
                 </xs:complexType>
             </xs:element>
             <xs:element name="getServiceGroupsResponse">
                 <xs:complexType>
                     <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax217:ServiceGroup"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="removeServiceGroup">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="groupName" nillable="true" type="xs:string"/>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="ax222:ServiceGroup"></xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
         </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://deployment.policy.pojo.autoscaler.stratos.apache.org/xsd">
-            <xs:complexType name="ApplicationPolicy">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="applicationId" nillable="true" type="xs:string"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="networkPartitionReferences" nillable="true" type="ax211:ApplicationPolicyNetworkPartitionReference"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="ApplicationPolicyNetworkPartitionReference">
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://application.exception.autoscaler.stratos.apache.org/xsd">
+            <xs:complexType name="InvalidApplicationPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="activeByDefault" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="networkPartitionId" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
-        </xs:schema>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://application.exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="ApplicationDefinitionException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="InvalidServiceGroupException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.stratos.apache.org/xsd">
             <xs:complexType name="Properties">
                 <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax22:Property"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax29:Property"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="Property">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"></xs:element>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://policy.exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="InvalidPolicyException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
         </xs:schema>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://io.java/xsd">
+            <xs:complexType name="IOException">
+                <xs:sequence></xs:sequence>
+            </xs:complexType>
+        </xs:schema>
         <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exception.autoscaler.stratos.apache.org/xsd">
             <xs:complexType name="InvalidArgumentException">
                 <xs:sequence>
-                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="message" nillable="true" type="xs:string"></xs:element>
                 </xs:sequence>
             </xs:complexType>
             <xs:complexType name="AutoScalerException">
                 <xs:complexContent>
                     <xs:extension base="xs:RuntimeException">
-                        <xs:sequence/>
+                        <xs:sequence></xs:sequence>
                     </xs:extension>
                 </xs:complexContent>
             </xs:complexType>
         </xs:schema>
     </wsdl:types>
-    <wsdl:message name="removeAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:removeAutoScalingPolicy"/>
+    <wsdl:message name="addApplicationPolicyRequest">
+        <wsdl:part name="parameters" element="ns:addApplicationPolicy"></wsdl:part>
     </wsdl:message>
-    <wsdl:message name="removeAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:removeAutoScalingPolicyResponse"/>
+    <wsdl:message name="AutoscalerServiceRemoteException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceRemoteException"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="AutoscalerServiceInvalidApplicationPolicyException">
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidApplicationPolicyException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceInvalidPolicyException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidPolicyException"/>
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidPolicyException"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="removeAutoScalingPolicyRequest">
+        <wsdl:part name="parameters" element="ns:removeAutoScalingPolicy"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="removeAutoScalingPolicyResponse">
+        <wsdl:part name="parameters" element="ns:removeAutoScalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoScalingPoliciesRequest">
-        <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"/>
+        <wsdl:part name="parameters" element="ns:getAutoScalingPolicies"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoScalingPoliciesResponse">
-        <wsdl:part name="parameters" element="ns:getAutoScalingPoliciesResponse"/>
+        <wsdl:part name="parameters" element="ns:getAutoScalingPoliciesResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupsRequest">
-        <wsdl:part name="parameters" element="ns:getServiceGroups"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroups"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupsResponse">
-        <wsdl:part name="parameters" element="ns:getServiceGroupsResponse"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroupsResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceAutoScalerException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceAutoScalerException"/>
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceAutoScalerException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationRequest">
-        <wsdl:part name="parameters" element="ns:getApplication"/>
+        <wsdl:part name="parameters" element="ns:getApplication"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationResponse">
-        <wsdl:part name="parameters" element="ns:getApplicationResponse"/>
+        <wsdl:part name="parameters" element="ns:getApplicationResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="deployApplicationRequest">
-        <wsdl:part name="parameters" element="ns:deployApplication"/>
+        <wsdl:part name="parameters" element="ns:deployApplication"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="deployApplicationResponse">
-        <wsdl:part name="parameters" element="ns:deployApplicationResponse"/>
+        <wsdl:part name="parameters" element="ns:deployApplicationResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceApplicationDefinitionException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceApplicationDefinitionException"/>
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceApplicationDefinitionException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationNetworkPartitionsRequest">
-        <wsdl:part name="parameters" element="ns:getApplicationNetworkPartitions"/>
+        <wsdl:part name="parameters" element="ns:getApplicationNetworkPartitions"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationNetworkPartitionsResponse">
-        <wsdl:part name="parameters" element="ns:getApplicationNetworkPartitionsResponse"/>
+        <wsdl:part name="parameters" element="ns:getApplicationNetworkPartitionsResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistRequest">
-        <wsdl:part name="parameters" element="ns:serviceGroupExist"/>
+        <wsdl:part name="parameters" element="ns:serviceGroupExist"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="serviceGroupExistResponse">
-        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"/>
+        <wsdl:part name="parameters" element="ns:serviceGroupExistResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:addAutoScalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:addServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:addServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceInvalidServiceGroupException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidServiceGroupException"/>
-    </wsdl:message>
-    <wsdl:message name="deleteApplicationRequest">
-        <wsdl:part name="parameters" element="ns:deleteApplication"/>
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidServiceGroupException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:getServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getServiceGroupResponse">
-        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"/>
+        <wsdl:part name="parameters" element="ns:getServiceGroupResponse"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="deleteApplicationRequest">
+        <wsdl:part name="parameters" element="ns:deleteApplication"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="undeployServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:undeployServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:undeployServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getAutoscalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getAutoscalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="updateAutoScalingPolicyRequest">
-        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicy"/>
+        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="updateAutoScalingPolicyResponse">
-        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:updateAutoScalingPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="findClusterIdRequest">
-        <wsdl:part name="parameters" element="ns:findClusterId"/>
+        <wsdl:part name="parameters" element="ns:findClusterId"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="findClusterIdResponse">
-        <wsdl:part name="parameters" element="ns:findClusterIdResponse"/>
+        <wsdl:part name="parameters" element="ns:findClusterIdResponse"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="removeApplicationPolicyRequest">
+        <wsdl:part name="parameters" element="ns:removeApplicationPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationsRequest">
-        <wsdl:part name="parameters" element="ns:getApplications"/>
+        <wsdl:part name="parameters" element="ns:getApplications"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationsResponse">
-        <wsdl:part name="parameters" element="ns:getApplicationsResponse"/>
+        <wsdl:part name="parameters" element="ns:getApplicationsResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="addApplicationRequest">
-        <wsdl:part name="parameters" element="ns:addApplication"/>
+        <wsdl:part name="parameters" element="ns:addApplication"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="updateClusterMonitorRequest">
-        <wsdl:part name="parameters" element="ns:updateClusterMonitor"/>
+        <wsdl:part name="parameters" element="ns:updateClusterMonitor"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="AutoscalerServiceInvalidArgumentException">
-        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidArgumentException"/>
+        <wsdl:part name="parameters" element="ns:AutoscalerServiceInvalidArgumentException"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="undeployApplicationRequest">
-        <wsdl:part name="parameters" element="ns:undeployApplication"/>
+        <wsdl:part name="parameters" element="ns:undeployApplication"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="removeServiceGroupRequest">
-        <wsdl:part name="parameters" element="ns:removeServiceGroup"/>
+        <wsdl:part name="parameters" element="ns:removeServiceGroup"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationPolicyRequest">
-        <wsdl:part name="parameters" element="ns:getApplicationPolicy"/>
+        <wsdl:part name="parameters" element="ns:getApplicationPolicy"></wsdl:part>
     </wsdl:message>
     <wsdl:message name="getApplicationPolicyResponse">
-        <wsdl:part name="parameters" element="ns:getApplicationPolicyResponse"/>
+        <wsdl:part name="parameters" element="ns:getApplicationPolicyResponse"></wsdl:part>
     </wsdl:message>
     <wsdl:portType name="AutoscalerServicePortType">
+        <wsdl:operation name="addApplicationPolicy">
+            <wsdl:input message="ns:addApplicationPolicyRequest" wsaw:Action="urn:addApplicationPolicy"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceRemoteException" name="AutoscalerServiceRemoteException" wsaw:Action="urn:addApplicationPolicyAutoscalerServiceRemoteException"></wsdl:fault>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidApplicationPolicyException" name="AutoscalerServiceInvalidApplicationPolicyException" wsaw:Action="urn:addApplicationPolicyAutoscalerServiceInvalidApplicationPolicyException"></wsdl:fault>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:addApplicationPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="removeAutoScalingPolicy">
-            <wsdl:input message="ns:removeAutoScalingPolicyRequest" wsaw:Action="urn:removeAutoScalingPolicy"/>
-            <wsdl:output message="ns:removeAutoScalingPolicyResponse" wsaw:Action="urn:removeAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServiceInvalidPolicyException"/>
+            <wsdl:input message="ns:removeAutoScalingPolicyRequest" wsaw:Action="urn:removeAutoScalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:removeAutoScalingPolicyResponse" wsaw:Action="urn:removeAutoScalingPolicyResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:removeAutoScalingPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getAutoScalingPolicies">
-            <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"/>
-            <wsdl:output message="ns:getAutoScalingPoliciesResponse" wsaw:Action="urn:getAutoScalingPoliciesResponse"/>
+            <wsdl:input message="ns:getAutoScalingPoliciesRequest" wsaw:Action="urn:getAutoScalingPolicies"></wsdl:input>
+            <wsdl:output message="ns:getAutoScalingPoliciesResponse" wsaw:Action="urn:getAutoScalingPoliciesResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
-            <wsdl:input message="ns:getServiceGroupsRequest" wsaw:Action="urn:getServiceGroups"/>
-            <wsdl:output message="ns:getServiceGroupsResponse" wsaw:Action="urn:getServiceGroupsResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:getServiceGroupsAutoscalerServiceAutoScalerException"/>
+            <wsdl:input message="ns:getServiceGroupsRequest" wsaw:Action="urn:getServiceGroups"></wsdl:input>
+            <wsdl:output message="ns:getServiceGroupsResponse" wsaw:Action="urn:getServiceGroupsResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:getServiceGroupsAutoscalerServiceAutoScalerException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getApplication">
-            <wsdl:input message="ns:getApplicationRequest" wsaw:Action="urn:getApplication"/>
-            <wsdl:output message="ns:getApplicationResponse" wsaw:Action="urn:getApplicationResponse"/>
+            <wsdl:input message="ns:getApplicationRequest" wsaw:Action="urn:getApplication"></wsdl:input>
+            <wsdl:output message="ns:getApplicationResponse" wsaw:Action="urn:getApplicationResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="deployApplication">
-            <wsdl:input message="ns:deployApplicationRequest" wsaw:Action="urn:deployApplication"/>
-            <wsdl:output message="ns:deployApplicationResponse" wsaw:Action="urn:deployApplicationResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceApplicationDefinitionException" name="AutoscalerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationAutoscalerServiceApplicationDefinitionException"/>
+            <wsdl:input message="ns:deployApplicationRequest" wsaw:Action="urn:deployApplication"></wsdl:input>
+            <wsdl:output message="ns:deployApplicationResponse" wsaw:Action="urn:deployApplicationResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceApplicationDefinitionException" name="AutoscalerServiceApplicationDefinitionException" wsaw:Action="urn:deployApplicationAutoscalerServiceApplicationDefinitionException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getApplicationNetworkPartitions">
-            <wsdl:input message="ns:getApplicationNetworkPartitionsRequest" wsaw:Action="urn:getApplicationNetworkPartitions"/>
-            <wsdl:output message="ns:getApplicationNetworkPartitionsResponse" wsaw:Action="urn:getApplicationNetworkPartitionsResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:getApplicationNetworkPartitionsAutoscalerServiceAutoScalerException"/>
+            <wsdl:input message="ns:getApplicationNetworkPartitionsRequest" wsaw:Action="urn:getApplicationNetworkPartitions"></wsdl:input>
+            <wsdl:output message="ns:getApplicationNetworkPartitionsResponse" wsaw:Action="urn:getApplicationNetworkPartitionsResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:getApplicationNetworkPartitionsAutoscalerServiceAutoScalerException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"/>
-            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"/>
+            <wsdl:input message="ns:serviceGroupExistRequest" wsaw:Action="urn:serviceGroupExist"></wsdl:input>
+            <wsdl:output message="ns:serviceGroupExistResponse" wsaw:Action="urn:serviceGroupExistResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"/>
-            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoscalerServiceInvalidPolicyException"/>
+            <wsdl:input message="ns:addAutoScalingPolicyRequest" wsaw:Action="urn:addAutoScalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:addAutoScalingPolicyResponse" wsaw:Action="urn:addAutoScalingPolicyResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:addAutoScalingPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="addServiceGroup">
-            <wsdl:input message="ns:addServiceGroupRequest" wsaw:Action="urn:addServiceGroup"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidServiceGroupException" name="AutoscalerServiceInvalidServiceGroupException" wsaw:Action="urn:addServiceGroupAutoscalerServiceInvalidServiceGroupException"/>
-        </wsdl:operation>
-        <wsdl:operation name="deleteApplication">
-            <wsdl:input message="ns:deleteApplicationRequest" wsaw:Action="urn:deleteApplication"/>
+            <wsdl:input message="ns:addServiceGroupRequest" wsaw:Action="urn:addServiceGroup"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidServiceGroupException" name="AutoscalerServiceInvalidServiceGroupException" wsaw:Action="urn:addServiceGroupAutoscalerServiceInvalidServiceGroupException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroup">
-            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"/>
-            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"/>
+            <wsdl:input message="ns:getServiceGroupRequest" wsaw:Action="urn:getServiceGroup"></wsdl:input>
+            <wsdl:output message="ns:getServiceGroupResponse" wsaw:Action="urn:getServiceGroupResponse"></wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="deleteApplication">
+            <wsdl:input message="ns:deleteApplicationRequest" wsaw:Action="urn:deleteApplication"></wsdl:input>
         </wsdl:operation>
         <wsdl:operation name="undeployServiceGroup">
-            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"/>
-            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:undeployServiceGroupAutoscalerServiceAutoScalerException"/>
+            <wsdl:input message="ns:undeployServiceGroupRequest" wsaw:Action="urn:undeployServiceGroup"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceAutoScalerException" name="AutoscalerServiceAutoScalerException" wsaw:Action="urn:undeployServiceGroupAutoscalerServiceAutoScalerException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getAutoscalingPolicy">
-            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"/>
-            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"/>
+            <wsdl:input message="ns:getAutoscalingPolicyRequest" wsaw:Action="urn:getAutoscalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:getAutoscalingPolicyResponse" wsaw:Action="urn:getAutoscalingPolicyResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="updateAutoScalingPolicy">
-            <wsdl:input message="ns:updateAutoScalingPolicyRequest" wsaw:Action="urn:updateAutoScalingPolicy"/>
-            <wsdl:output message="ns:updateAutoScalingPolicyResponse" wsaw:Action="urn:updateAutoScalingPolicyResponse"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:updateAutoScalingPolicyAutoscalerServiceInvalidPolicyException"/>
+            <wsdl:input message="ns:updateAutoScalingPolicyRequest" wsaw:Action="urn:updateAutoScalingPolicy"></wsdl:input>
+            <wsdl:output message="ns:updateAutoScalingPolicyResponse" wsaw:Action="urn:updateAutoScalingPolicyResponse"></wsdl:output>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:updateAutoScalingPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="findClusterId">
-            <wsdl:input message="ns:findClusterIdRequest" wsaw:Action="urn:findClusterId"/>
-            <wsdl:output message="ns:findClusterIdResponse" wsaw:Action="urn:findClusterIdResponse"/>
+            <wsdl:input message="ns:findClusterIdRequest" wsaw:Action="urn:findClusterId"></wsdl:input>
+            <wsdl:output message="ns:findClusterIdResponse" wsaw:Action="urn:findClusterIdResponse"></wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="removeApplicationPolicy">
+            <wsdl:input message="ns:removeApplicationPolicyRequest" wsaw:Action="urn:removeApplicationPolicy"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidPolicyException" name="AutoscalerServiceInvalidPolicyException" wsaw:Action="urn:removeApplicationPolicyAutoscalerServiceInvalidPolicyException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getApplications">
-            <wsdl:input message="ns:getApplicationsRequest" wsaw:Action="urn:getApplications"/>
-            <wsdl:output message="ns:getApplicationsResponse" wsaw:Action="urn:getApplicationsResponse"/>
+            <wsdl:input message="ns:getApplicationsRequest" wsaw:Action="urn:getApplications"></wsdl:input>
+            <wsdl:output message="ns:getApplicationsResponse" wsaw:Action="urn:getApplicationsResponse"></wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addApplication">
-            <wsdl:input message="ns:addApplicationRequest" wsaw:Action="urn:addApplication"/>
-            <wsdl:fault message="ns:AutoscalerServiceApplicationDefinitionException" name="AutoscalerServiceApplicationDefinitionException" wsaw:Action="urn:addApplicationAutoscalerServiceApplicationDefinitionException"/>
+            <wsdl:input message="ns:addApplicationRequest" wsaw:Action="urn:addApplication"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceApplicationDefinitionException" name="AutoscalerServiceApplicationDefinitionException" wsaw:Action="urn:addApplicationAutoscalerServiceApplicationDefinitionException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="updateClusterMonitor">
-            <wsdl:input message="ns:updateClusterMonitorRequest" wsaw:Action="urn:updateClusterMonitor"/>
-            <wsdl:fault message="ns:AutoscalerServiceInvalidArgumentException" name="AutoscalerServiceInvalidArgumentException" wsaw:Action="urn:updateClusterMonitorAutoscalerServiceInvalidArgumentException"/>
+            <wsdl:input message="ns:updateClusterMonitorRequest" wsaw:Action="urn:updateClusterMonitor"></wsdl:input>
+            <wsdl:fault message="ns:AutoscalerServiceInvalidArgumentException" name="AutoscalerServiceInvalidArgumentException" wsaw:Action="urn:updateClusterMonitorAutoscalerServiceInvalidArgumentException"></wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="undeployApplication">
-            <wsdl:input message="ns:undeployApplicationRequest" wsaw:Action="urn:undeployApplication"/>
+            <wsdl:input message="ns:undeployApplicationRequest" wsaw:Action="urn:undeployApplication"></wsdl:input>
         </wsdl:operation>
         <wsdl:operation name="removeServiceGroup">
-            <wsdl:input message="ns:removeServiceGroupRequest" wsaw:Action="urn:removeServiceGroup"/>
+            <wsdl:input message="ns:removeServiceGroupRequest" wsaw:Action="urn:removeServiceGroup"></wsdl:input>
         </wsdl:operation>
         <wsdl:operation name="getApplicationPolicy">
-            <wsdl:input message="ns:getApplicationPolicyRequest" wsaw:Action="urn:getApplicationPolicy"/>
-            <wsdl:output message="ns:getApplicationPolicyResponse" wsaw:Action="urn:getApplicationPolicyResponse"/>
+            <wsdl:input message="ns:getApplicationPolicyRequest" wsaw:Action="urn:getApplicationPolicy"></wsdl:input>
+            <wsdl:output message="ns:getApplicationPolicyResponse" wsaw:Action="urn:getApplicationPolicyResponse"></wsdl:output>
         </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="AutoscalerServiceSoap11Binding" type="ns:AutoscalerServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
+        <wsdl:operation name="addApplicationPolicy">
+            <soap:operation soapAction="urn:addApplicationPolicy" style="document"></soap:operation>
+            <wsdl:input>
+                <soap:body use="literal"></soap:body>
+            </wsdl:input>
+            <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
+                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"></soap:fault>
+            </wsdl:fault>
+            <wsdl:fault name="AutoscalerServiceRemoteException">
+                <soap:fault use="literal" name="AutoscalerServiceRemoteException"></soap:fault>
+            </wsdl:fault>
+            <wsdl:fault name="AutoscalerServiceInvalidApplicationPolicyException">
+                <soap:fault use="literal" name="AutoscalerServiceInvalidApplicationPolicyException"></soap:fault>
+            </wsdl:fault>
+        </wsdl:operation>
         <wsdl:operation name="getAutoScalingPolicies">
-            <soap:operation soapAction="urn:getAutoScalingPolicies" style="document"/>
+            <soap:operation soapAction="urn:getAutoScalingPolicies" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="removeAutoScalingPolicy">
-            <soap:operation soapAction="urn:removeAutoScalingPolicy" style="document"/>
+            <soap:operation soapAction="urn:removeAutoScalingPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getServiceGroups">
-            <soap:operation soapAction="urn:getServiceGroups" style="document"/>
+            <soap:operation soapAction="urn:getServiceGroups" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoscalerServiceAutoScalerException">
-                <soap:fault use="literal" name="AutoscalerServiceAutoScalerException"/>
+                <soap:fault use="literal" name="AutoscalerServiceAutoScalerException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getApplication">
-            <soap:operation soapAction="urn:getApplication" style="document"/>
+            <soap:operation soapAction="urn:getApplication" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="deployApplication">
-            <soap:operation soapAction="urn:deployApplication" style="document"/>
+            <soap:operation soapAction="urn:deployApplication" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoscalerServiceApplicationDefinitionException">
-                <soap:fault use="literal" name="AutoscalerServiceApplicationDefinitionException"/>
+                <soap:fault use="literal" name="AutoscalerServiceApplicationDefinitionException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="getApplicationNetworkPartitions">
-            <soap:operation soapAction="urn:getApplicationNetworkPartitions" style="document"/>
+            <soap:operation soapAction="urn:getApplicationNetworkPartitions" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoscalerServiceAutoScalerException">
-                <soap:fault use="literal" name="AutoscalerServiceAutoScalerException"/>
+                <soap:fault use="literal" name="AutoscalerServiceAutoScalerException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="serviceGroupExist">
-            <soap:operation soapAction="urn:serviceGroupExist" style="document"/>
+            <soap:operation soapAction="urn:serviceGroupExist" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="addAutoScalingPolicy">
-            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"/>
+            <soap:operation soapAction="urn:addAutoScalingPolicy" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:output>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:output>
             <wsdl:fault name="AutoscalerServiceInvalidPolicyException">
-                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"/>
+                <soap:fault use="literal" name="AutoscalerServiceInvalidPolicyException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
         <wsdl:operation name="addServiceGroup">
-            <soap:operation soapAction="urn:addServiceGroup" style="document"/>
+            <soap:operation soapAction="urn:addServiceGroup" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
             <wsdl:fault name="AutoscalerServiceInvalidServiceGroupException">
-                <soap:fault use="literal" name="AutoscalerServiceInvalidServiceGroupException"/>
+                <soap:fault use="literal" name="AutoscalerServiceInvalidServiceGroupException"></soap:fault>
             </wsdl:fault>
         </wsdl:operation>
-        <wsdl:operation name="getServiceGroup">
-            <soap:operation soapAction="urn:getServiceGroup" style="document"/>
+        <wsdl:operation name="deleteApplication">
+            <soap:operation soapAction="urn:deleteApplication" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
         </wsdl:operation>
-        <wsdl:operation name="deleteApplication">
-            <soap:operation soapAction="urn:deleteApplication" style="document"/>
+        <wsdl:operation name="getServiceGroup">
+            <soap:operation soapAction="urn:getServiceGroup" style="document"></soap:operation>
             <wsdl:input>
-                <soap:body use="literal"/>
+                <soap:body use="literal"></soap:body>
             </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"></soap:body>
+            </wsdl:output>
         </wsdl:operation>
         <wsdl:operation name="undeployServiceGroup">
-            <soap:operation soapAction="urn:undeployServiceGroup" style="document"/>
+            <soap:operation soapAction="urn:undeployServiceGroup" style="

<TRUNCATED>

[2/2] stratos git commit: moving application policy to global level

Posted by ra...@apache.org.
moving application policy to global level


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

Branch: refs/heads/master
Commit: 9d4f85ba1566089691547aa7d50e1a795c5c65d1
Parents: 6dfbea5
Author: R-Rajkumar <rr...@gmail.com>
Authored: Wed Mar 4 19:58:45 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Wed Mar 4 19:58:45 2015 +0530

----------------------------------------------------------------------
 .../applications/topic/ApplicationBuilder.java  |   28 +-
 .../AutoscalerTopologyEventReceiver.java        |   26 +-
 .../ApplicatioinPolicyNotExistsException.java   |   46 +
 .../monitor/component/ApplicationMonitor.java   |   14 +-
 .../autoscaler/pojo/policy/PolicyManager.java   |   34 +-
 .../policy/deployment/ApplicationPolicy.java    |   19 +-
 .../autoscaler/registry/RegistryManager.java    |   10 +-
 .../autoscaler/services/AutoscalerService.java  |   37 +-
 .../services/impl/AutoscalerServiceImpl.java    |   56 +-
 .../stratos/autoscaler/util/AutoscalerUtil.java |   51 +-
 .../deployment/ApplicationPolicyBean.java       |   10 +-
 .../common/client/AutoscalerServiceClient.java  |   19 +-
 .../domain/application/Application.java         |   11 +
 .../rest/endpoint/api/StratosApiV41.java        |   48 +-
 .../rest/endpoint/api/StratosApiV41Utils.java   |  112 +-
 .../util/converter/ObjectConverter.java         |    6 +
 .../application-policy.json                     |    9 +
 .../artifacts/application-policy.json           |    8 -
 .../artifacts/application-policy.json           |    8 -
 .../single-cartridge/scripts/common/deploy.sh   |    6 +-
 .../single-cartridge/scripts/common/undeploy.sh |    4 +
 .../artifacts/application-policy.json           |   12 -
 .../src/main/resources/AutoscalerService.wsdl   | 1111 ++++++++++--------
 23 files changed, 1031 insertions(+), 654 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index df23277..1cb1a6e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.client.CloudControllerClient;
 import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.context.partition.network.GroupLevelNetworkPartitionContext;
@@ -241,15 +242,14 @@ public class ApplicationBuilder {
                 return;
             } else {
                 // Check whether given application is deployed
-            	// if there is an application policy with appId, it means application is deployed
-            	ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(appId);
-                if (applicationPolicy != null) {
-                    log.warn(String.format("Application has been found in the ApplicationsTopology" +
-                                    ": [application-id] %s, Please unDeploy the Application Policy " +
-                                    "before deleting the Application definition.",
-                            appId));
-                    return;
-                }
+            	ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(appId);
+            	if (applicationContext != null && applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
+            		log.warn(String.format("Application has been found in the ApplicationsTopology" +
+            				": [application-id] %s, Please unDeploy the Application Policy " +
+            				"before deleting the Application definition.",
+            				appId));
+            		return;
+				}
             }
 
             //get cluster data to send in event before deleting the application
@@ -320,16 +320,6 @@ public class ApplicationBuilder {
                                 setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                         PrivilegedCarbonContext.getThreadLocalCarbonContext().
                                 setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-                        ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(appId);
-                        if (applicationPolicy != null) {
-                            try {
-                                PolicyManager.getInstance().removeApplicationPolicy(appId);
-                                log.info("Application policy for the [Application] " + appId +
-                                        "has been removed.");
-                            } catch (Exception e) {
-                                log.error("Error while removing the policy for [application] " + appId);
-                            }
-                        }
                     } finally {
                         PrivilegedCarbonContext.endTenantFlow();
                     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
index 7ecf923..d63cb4b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ExecutorService;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.context.cluster.ClusterContext;
 import org.apache.stratos.autoscaler.context.cluster.ClusterContextFactory;
@@ -115,13 +116,12 @@ public class AutoscalerTopologyEventReceiver {
                         if (applications != null) {
                             for (Application application : applications.getApplications().values()) {
                                 if (AutoscalerUtil.allClustersInitialized(application)) {
-                                	ApplicationPolicy applicationPolicy = 
-                                			PolicyManager.getInstance().getApplicationPolicy(application.getUniqueIdentifier());
-                                    if (applicationPolicy != null) {
-                                        AutoscalerUtil.getInstance().
-                                                startApplicationMonitor(application.getUniqueIdentifier());
-                                    } else {
-                                        log.info("The relevant application policy is not yet " +
+                                	ApplicationContext applicationContext = AutoscalerContext.getInstance().
+                                			getApplicationContext(application.getUniqueIdentifier());
+                                	if (applicationContext != null && applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
+                                		AutoscalerUtil.getInstance().startApplicationMonitor(application.getUniqueIdentifier());
+									} else {
+                                        log.info("The application is not yet " +
                                                 "deployed for this [application] " +
                                                 application.getUniqueIdentifier());
                                     }
@@ -155,11 +155,13 @@ public class AutoscalerTopologyEventReceiver {
                     try {
                         //acquire read lock
                         ApplicationHolder.acquireReadLock();
-                        //start the application monitor if the policy exists
-                        ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(appId);
-                        if (applicationPolicy != null && !AutoscalerContext.getInstance().containsApplicationPendingMonitor(appId)) {
-                            AutoscalerUtil.getInstance().startApplicationMonitor(appId);
-                        }
+                        //start the application monitor
+                        ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(appId);
+                        if (applicationContext != null && applicationContext.getStatus().equals(ApplicationContext.STATUS_DEPLOYED)) {
+                        	if (!AutoscalerContext.getInstance().containsApplicationPendingMonitor(appId)) {
+                        		AutoscalerUtil.getInstance().startApplicationMonitor(appId);
+                        	}
+						}
                     } catch (Exception e) {
                         String msg = "Error processing event " + e.getLocalizedMessage();
                         log.error(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/ApplicatioinPolicyNotExistsException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/ApplicatioinPolicyNotExistsException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/ApplicatioinPolicyNotExistsException.java
new file mode 100644
index 0000000..d8ffc21
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/policy/ApplicatioinPolicyNotExistsException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.autoscaler.exception.policy;
+
+public class ApplicatioinPolicyNotExistsException extends Exception {
+
+	private static final long serialVersionUID = -4326762495239318515L;
+	private String message;
+	
+	public ApplicatioinPolicyNotExistsException(String message) {
+		super(message);
+		this.message = message;
+	}
+	
+	public ApplicatioinPolicyNotExistsException(String message,Throwable e) {
+		super(message,e);
+		this.message = message;
+	}
+	
+	public ApplicatioinPolicyNotExistsException(Throwable e) {
+		super(e);
+	}
+	
+	@Override
+	public String getMessage() {
+		return message;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
index de70247..bb8905e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
@@ -316,7 +316,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
 //        } else {
         	
         	for (ApplicationPolicyNetworkPartitionReference 
-        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getUniqueIdentifier())) {
+        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
 	            if(appPolicyNetworkPartition.isActiveByDefault()) {
 	            	ApplicationLevelNetworkPartitionContext context =
                             new ApplicationLevelNetworkPartitionContext(appPolicyNetworkPartition.getNetworkPartitionId());
@@ -347,12 +347,12 @@ public class ApplicationMonitor extends ParentComponentMonitor {
     }
 
 	private ApplicationPolicyNetworkPartitionReference[] getNetworkPartitionReferences(
-            String applicationId) throws PolicyValidationException {
-	    ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationId);
+            String applicationPolicyId) throws PolicyValidationException {
+		
+	    ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
 	    
 	    if(applicationPolicy == null) {
-	    	String msg = "Application policy is not found "
-	    			+ "for application ["+ applicationId + "] ";
+	    	String msg = String.format("Application policy is not found [application-policy-id] %s [application-id] %s", applicationPolicyId, appId);
 	    	log.error(msg);
 	    	throw new PolicyValidationException(msg);        		
 	    }
@@ -360,7 +360,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
 	    
 	    if(npReference == null || npReference.length <= 0) {
 	    	String msg = "Network partition references cannot be found in application policy "+ applicationPolicy+ " is not found "
-	    			+ "for application ["+ applicationId + "] ";
+	    			+ "for application ["+ applicationPolicyId + "] ";
 	    	log.error(msg);        		
 	    	throw new PolicyValidationException(msg);  
 	    }
@@ -414,7 +414,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
 //
 //        } else {
             for (ApplicationPolicyNetworkPartitionReference 
-        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getUniqueIdentifier())) {
+        			appPolicyNetworkPartition : getNetworkPartitionReferences(application.getApplicationPolicyId())) {
                 //Checking whether any not active NP found
                 if (!appPolicyNetworkPartition.isActiveByDefault()) {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
index be1b01b..4b77764 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/PolicyManager.java
@@ -190,42 +190,42 @@ public class PolicyManager {
     }
 
 	public void addApplicationPolicy(ApplicationPolicy applicationPolicy) throws InvalidPolicyException {
-		String applicationId = applicationPolicy.getApplicationId();
+		String applicationPolicyId = applicationPolicy.getApplicationPolicyId();
 		if (log.isInfoEnabled()) {
-			log.info(String.format("Adding application policy for application: [id] %s", applicationId));
+			log.info(String.format("Adding application policy : [application-policy-id] %s", applicationPolicyId));
 		}
 		this.addApplicationPolicyToInformationModel(applicationPolicy);
 		RegistryManager.getInstance().persistApplicationPolicy(applicationPolicy);
 
 		if (log.isInfoEnabled()) {
 			log.info(String
-			        .format("Application policy is added successfully: [application-id] %s",
-			                applicationId));
+			        .format("Application policy is added successfully: [application-policy-id] %s",
+			                applicationPolicyId));
 		}
 
 	}
 	
-	public boolean removeApplicationPolicy(String applicationId) throws InvalidPolicyException {
-		if (StringUtils.isEmpty(applicationId)) {
+	public boolean removeApplicationPolicy(String applicationPolicyId) throws InvalidPolicyException {
+		if (StringUtils.isEmpty(applicationPolicyId)) {
 			throw new AutoScalerException("Application policy id cannot be empty");
 		}
-		this.removeApplicationPolicyInInformationModel(applicationId);
-		RegistryManager.getInstance().removeApplicationPolicy(applicationId);
+		this.removeApplicationPolicyInInformationModel(applicationPolicyId);
+		RegistryManager.getInstance().removeApplicationPolicy(applicationPolicyId);
 		if (log.isInfoEnabled()) {
-			log.info(String.format("Application policy is removed successfully: [id] %s", applicationId));
+			log.info(String.format("Application policy is removed successfully: [id] %s", applicationPolicyId));
 		}
 		return true;
 	}
 
 	public void addApplicationPolicyToInformationModel(ApplicationPolicy applicationPolicy) throws InvalidPolicyException {
-		String applicationId = applicationPolicy.getApplicationId();
-        if (!applicationPolicyListMap.containsKey(applicationId)) {
+		String applicationPolicyId = applicationPolicy.getApplicationPolicyId();
+        if (!applicationPolicyListMap.containsKey(applicationPolicyId)) {
             if (log.isDebugEnabled()) {
-                log.debug("Adding application policy for application Id: " + applicationId);
+                log.debug("Adding application policy : " + applicationPolicyId);
             }
-            applicationPolicyListMap.put(applicationId, applicationPolicy);
+            applicationPolicyListMap.put(applicationPolicyId, applicationPolicy);
         } else {
-        	String errMsg = "Application policy is already exists for appplication [" + applicationId + "] ";
+        	String errMsg = "Application policy already exists : " + applicationPolicyId;
         	log.error(errMsg);
             throw new InvalidPolicyException(errMsg);
         }
@@ -235,11 +235,11 @@ public class PolicyManager {
 	/**
 	 * Retruns an ApplicationPolicy of a given application
 	 * 
-	 * @param applicationId
+	 * @param applicationPolicyId
 	 * @return
 	 */
-    public ApplicationPolicy getApplicationPolicy(String applicationId) {
-        return applicationPolicyListMap.get(applicationId);
+    public ApplicationPolicy getApplicationPolicy(String applicationPolicyId) {
+        return applicationPolicyListMap.get(applicationPolicyId);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
index 38b100e..5bbf8bd 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/policy/deployment/ApplicationPolicy.java
@@ -23,17 +23,26 @@ import java.io.Serializable;
 public class ApplicationPolicy implements Serializable{
 
 	private static final long serialVersionUID = -2851334419121310395L;
-	private String applicationId;
+	private String applicationPolicyId;
+	private String algorithm;
 	private ApplicationPolicyNetworkPartitionReference[] networkPartitionReferences;
 	
-	public String getApplicationId() {
-		return applicationId;
+	public String getApplicationPolicyId() {
+		return applicationPolicyId;
 	}
 	
-	public void setApplicationId(String applicationId) {
-		this.applicationId = applicationId;
+	public void setApplicationPolicyId(String applicationPolicyId) {
+		this.applicationPolicyId = applicationPolicyId;
 	}
 	
+	public String getAlgorithm() {
+		return algorithm;
+	}
+	
+	public void setAlgorithm(String algorithm) {
+		this.algorithm = algorithm;
+	}
+
 	public ApplicationPolicyNetworkPartitionReference[] getNetworkPartitionReferences() {
 		return networkPartitionReferences;
 	}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 408f7f7..4ff777e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -531,12 +531,12 @@ public class RegistryManager {
 
     }
     
-    public void removeApplicationPolicy(String applicationId) {
+    public void removeApplicationPolicy(String applicationPolicyId) {
         String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" +
-        		applicationId;
+        		applicationPolicyId;
         this.delete(resourcePath);
         if (log.isDebugEnabled()) {
-            log.debug(String.format("Application policy deleted from registry [application-id] %s", applicationId));
+            log.debug(String.format("Application policy deleted from registry [application-policy-id] %s", applicationPolicyId));
         }
 
     }
@@ -563,10 +563,10 @@ public class RegistryManager {
 	public void persistApplicationPolicy(ApplicationPolicy applicationPolicy) {
 
 		String resourcePath = AutoscalerConstants.AUTOSCALER_RESOURCE + 
-				AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getApplicationId();
+				AutoscalerConstants.APPLICATION_POLICY_RESOURCE + "/" + applicationPolicy.getApplicationPolicyId();
         persist(applicationPolicy, resourcePath);
         if (log.isDebugEnabled()) {
-            log.debug(String.format("Application policy written to registry"));
+            log.debug(String.format("Application policy written to registry : %s", applicationPolicy.getApplicationPolicyId()));
         }
 	    
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
index fb9d85f..edc9004 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/AutoscalerService.java
@@ -21,10 +21,13 @@
 
 package org.apache.stratos.autoscaler.services;
 
+import java.rmi.RemoteException;
+
 import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.exception.application.ApplicationDefinitionException;
+import org.apache.stratos.autoscaler.exception.application.InvalidApplicationPolicyException;
 import org.apache.stratos.autoscaler.exception.application.InvalidServiceGroupException;
 import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
 import org.apache.stratos.autoscaler.pojo.ServiceGroup;
@@ -92,19 +95,12 @@ public interface AutoscalerService {
     /**
      * Deploy an application in created state
      * @param applicationId
-     * @param applicationPolicy
+     * @param applicationPolicyId
      * @return
      */
-    public boolean deployApplication(String applicationId, ApplicationPolicy applicationPolicy) throws ApplicationDefinitionException;
+    public boolean deployApplication(String applicationId, String applicationPolicyId) throws ApplicationDefinitionException;
     
     /**
-     * Get application policy by application id
-     * @param applicationId the application id
-     * @return {@link ApplicationPolicy} used by the given application
-     */
-    public ApplicationPolicy getApplicationPolicy(String applicationId);
-
-    /**
      * Undeploy an application in deployed state
      * @param applicationId
      * @return
@@ -116,6 +112,29 @@ public interface AutoscalerService {
      * @param applicationId
      */
     public void deleteApplication(String applicationId);
+    
+    /**
+     * Add application policy
+     * @param applicationPolicy the application policy to be added
+     * @throws InvalidApplicationPolicyException 
+     * @throws RemoteException 
+     * @throws InvalidPolicyException 
+     */
+    public void addApplicationPolicy(ApplicationPolicy applicationPolicy) throws RemoteException, InvalidApplicationPolicyException, InvalidPolicyException;
+    
+    /**
+     * Get application policy by application id
+     * @param applicationPolicyId the application policy id
+     * @return {@link ApplicationPolicy} used by the given application
+     */
+    public ApplicationPolicy getApplicationPolicy(String applicationPolicyId);
+    
+    /**
+     * Remove application policy
+     * @param applicationPolicyId the application policy id
+     * @throws InvalidPolicyException 
+     */
+    public void removeApplicationPolicy(String applicationPolicyId) throws InvalidPolicyException;
 
     /**
      * Dynamically update the properties of an Autoscaling Cluster Monitor

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index 9c9a728..f326605 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -18,6 +18,7 @@
  */
 package org.apache.stratos.autoscaler.services.impl;
 
+import java.rmi.RemoteException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -42,6 +43,7 @@ import org.apache.stratos.autoscaler.context.AutoscalerContext;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.exception.InvalidArgumentException;
 import org.apache.stratos.autoscaler.exception.application.ApplicationDefinitionException;
+import org.apache.stratos.autoscaler.exception.application.InvalidApplicationPolicyException;
 import org.apache.stratos.autoscaler.exception.application.InvalidServiceGroupException;
 import org.apache.stratos.autoscaler.exception.policy.InvalidPolicyException;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
@@ -161,7 +163,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
     }
 
     @Override
-    public boolean deployApplication(String applicationId, ApplicationPolicy applicationPolicy) throws ApplicationDefinitionException {
+    public boolean deployApplication(String applicationId, String applicationPolicyId) throws ApplicationDefinitionException {
         try {
             Application application = RegistryManager.getInstance().getApplication(applicationId);
             if (application == null) {
@@ -172,16 +174,24 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             if (applicationContext == null) {
                 throw new RuntimeException("Application context not found: " + applicationId);
             }
-
+            
             // Create application clusters in cloud controller and send application created event
             ApplicationBuilder.handleApplicationCreatedEvent(application, applicationContext.getComponents().getApplicationClusterContexts());
 
-			// validating application policy
-			AutoscalerUtil.validateApplicationPolicy(applicationId, applicationPolicy);
-			
-			// Add application policy
-			PolicyManager.getInstance().addApplicationPolicy(applicationPolicy);
-			if(!applicationContext.isMultiTenant()) {
+			// validating application policy against the application
+            AutoscalerUtil.validateApplicationPolicyAgainstApplication(applicationId, applicationPolicyId);
+
+            // setting application policy id in application object
+            try {
+            	ApplicationHolder.acquireWriteLock();
+            	application = ApplicationHolder.getApplications().getApplication(applicationId);
+            	application.setApplicationPolicyId(applicationPolicyId);
+            	ApplicationHolder.persistApplication(application);
+            } finally {
+            	ApplicationHolder.releaseWriteLock();
+            }
+
+            if(!applicationContext.isMultiTenant()) {
 			    // Add application signup for single tenant applications
 			    addApplicationSignUp(applicationContext, application.getKey());
 			}
@@ -199,7 +209,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             } finally {
                 ApplicationHolder.releaseReadLock();
             }
-
+            
             if (!AutoscalerContext.getInstance().containsApplicationPendingMonitor(applicationId)) {
                 if (allClusterInitialized) {
                     AutoscalerUtil.getInstance().startApplicationMonitor(applicationId);
@@ -364,9 +374,6 @@ public class AutoscalerServiceImpl implements AutoscalerService {
             // Remove Application SignUp(s) in stratos manager
             removeApplicationSignUp(application);
             
-            // Remove application policy
-            PolicyManager.getInstance().removeApplicationPolicy(applicationId);
-
             ApplicationBuilder.handleApplicationUndeployed(applicationId);
 
             ApplicationContext applicationContext = AutoscalerContext.getInstance().getApplicationContext(applicationId);
@@ -579,11 +586,6 @@ public class AutoscalerServiceImpl implements AutoscalerService {
     }
     
 	@Override
-	public ApplicationPolicy getApplicationPolicy(String applicationId) {
-		return PolicyManager.getInstance().getApplicationPolicy(applicationId);
-	}
-
-	@Override
 	public String[] getApplicationNetworkPartitions(String applicationId)
 			throws AutoScalerException {
 		List<String> networkPartitionIds = AutoscalerUtil.getNetworkPartitionIdsReferedInApplication(applicationId);
@@ -592,4 +594,24 @@ public class AutoscalerServiceImpl implements AutoscalerService {
 		}
 		return networkPartitionIds.toArray(new String[networkPartitionIds.size()]);
 	}
+
+	@Override
+	public void addApplicationPolicy(ApplicationPolicy applicationPolicy) 
+			throws RemoteException, InvalidApplicationPolicyException, InvalidPolicyException {
+		
+		// validating application policy
+		AutoscalerUtil.validateApplicationPolicy(applicationPolicy);
+		// Add application policy to the registry
+		PolicyManager.getInstance().addApplicationPolicy(applicationPolicy);
+	}
+	
+	@Override
+	public ApplicationPolicy getApplicationPolicy(String applicationPolicyId) {
+		return PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
+	}
+
+	@Override
+	public void removeApplicationPolicy(String applicationPolicyId) throws InvalidPolicyException {
+		PolicyManager.getInstance().removeApplicationPolicy(applicationPolicyId);
+	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
index 3851778..47090a9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
@@ -45,10 +45,12 @@ import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.exception.application.DependencyBuilderException;
 import org.apache.stratos.autoscaler.exception.application.InvalidApplicationPolicyException;
 import org.apache.stratos.autoscaler.exception.application.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.exception.policy.ApplicatioinPolicyNotExistsException;
 import org.apache.stratos.autoscaler.exception.policy.PolicyValidationException;
 import org.apache.stratos.autoscaler.monitor.Monitor;
 import org.apache.stratos.autoscaler.monitor.MonitorFactory;
 import org.apache.stratos.autoscaler.monitor.component.ApplicationMonitor;
+import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicy;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.ApplicationPolicyNetworkPartitionReference;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
@@ -575,12 +577,11 @@ public class AutoscalerUtil {
     
     /**
      * Validates Application Policy against the given application.
-     * @param applicationId the application id against which the application policy needs to be validated
      * @param applicationPolicy the application policy to be validated
      * @throws InvalidApplicationPolicyException if application policy is not valid
      * @throws RemoteException is anything went wrong while communicating with CC to validate network partitions
      */
-	public static void validateApplicationPolicy(String applicationId, ApplicationPolicy applicationPolicy) 
+	public static void validateApplicationPolicy(ApplicationPolicy applicationPolicy) 
     		throws InvalidApplicationPolicyException, RemoteException {
     	
     	// application policy can't be null
@@ -624,17 +625,6 @@ public class AutoscalerUtil {
 				throw new InvalidApplicationPolicyException(msg);
 			}
 			
-			// validate application policy against the given application
-			if (!isAppUsingNetworkPartitionId(applicationId, networkPartitionId)) {
-				String msg = String.format("Invalid Application Policy. "
-						+ "Cause -> Network partition [network-partition-id] %s is not used in application [application-id] %s. "
-						+ "Hence application bursting will fail. Either remove %s from application policy or make all the cartridges available in %s", 
-						networkPartitionId, applicationId, networkPartitionId, networkPartitionId);
-				log.error(msg);
-				throw new InvalidApplicationPolicyException(msg);
-			}
-			
-			
 			// counting number of network partitions which are active by default
 			if (true == applicationPolicyNetworkPartitionReference.isActiveByDefault()) {
 				activeByDefaultNetworkPartitionsCount++;
@@ -649,6 +639,41 @@ public class AutoscalerUtil {
 		}
     }
 	
+	
+	/**
+	 * Validates an application policy against the application
+	 * @param applicationId
+	 * @param applicationPolicyId
+	 * @throws ApplicatioinPolicyNotExistsException
+	 * @throws InvalidApplicationPolicyException
+	 */
+	public static void validateApplicationPolicyAgainstApplication(String applicationId, String applicationPolicyId) 
+			throws ApplicatioinPolicyNotExistsException, InvalidApplicationPolicyException {
+		
+		ApplicationPolicy applicationPolicy = PolicyManager.getInstance().getApplicationPolicy(applicationPolicyId);
+		if (applicationPolicy == null) {
+			String msg = String.format("Application Policy not exists for [application-policy-id] %s", applicationPolicyId);
+			log.error(msg);
+			throw new ApplicatioinPolicyNotExistsException(msg);
+		}
+		
+		ApplicationPolicyNetworkPartitionReference[] networkPartitionReferences = 
+				applicationPolicy.getNetworkPartitionReferences();
+    	
+		for (ApplicationPolicyNetworkPartitionReference applicationPolicyNetworkPartitionReference : networkPartitionReferences) {
+			String networkPartitionId = applicationPolicyNetworkPartitionReference.getNetworkPartitionId();
+    		// validate application policy against the given application
+    		if (!isAppUsingNetworkPartitionId(applicationId, networkPartitionId)) {
+    			String msg = String.format("Invalid Application Policy. "
+    					+ "Cause -> Network partition [network-partition-id] %s is not used in application [application-id] %s. "
+    					+ "Hence application bursting will fail. Either remove %s from application policy or make all the cartridges available in %s", 
+    					networkPartitionId, applicationId, networkPartitionId, networkPartitionId);
+    			log.error(msg);
+    			throw new InvalidApplicationPolicyException(msg);
+    		}
+    	}
+	}
+	
 	private static boolean isAppUsingNetworkPartitionId(String applicationId, String networkPartitionId) {
 		if (applicationId == null || StringUtils.isBlank(applicationId) 
 				|| networkPartitionId == null || StringUtils.isBlank(networkPartitionId)) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
index d2a9d31..0eb2551 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/policy/deployment/ApplicationPolicyBean.java
@@ -26,7 +26,16 @@ import org.apache.stratos.common.beans.partition.ApplicationPolicyNetworkPartiti
 @XmlRootElement
 public class ApplicationPolicyBean {
 
+	private String id;
     private ApplicationPolicyNetworkPartitionReferenceBean[] networkPartition;
+    
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
 
 	public ApplicationPolicyNetworkPartitionReferenceBean[] getNetworkPartition() {
 		return networkPartition;
@@ -35,5 +44,4 @@ public class ApplicationPolicyBean {
 	public void setNetworkPartition(ApplicationPolicyNetworkPartitionReferenceBean[] networkPartition) {
 		this.networkPartition = networkPartition;
 	}
-        
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
index 716f36e..2a187ee 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
@@ -101,13 +101,24 @@ public class AutoscalerServiceClient {
         return stub.getApplications();
     }
 
-    public boolean deployApplication(String applicationId, ApplicationPolicy ap) throws RemoteException,
+    public boolean deployApplication(String applicationId, String applicationPolicyId) throws RemoteException,
             AutoscalerServiceInvalidPolicyExceptionException, AutoscalerServiceApplicationDefinitionExceptionException {
-		return stub.deployApplication(applicationId, ap);
+		return stub.deployApplication(applicationId, applicationPolicyId);
     }
     
-    public ApplicationPolicy getApplicationPolicy(String applicationId) throws RemoteException {
-    	return stub.getApplicationPolicy(applicationId);
+    public void addApplicationPolicy(ApplicationPolicy applicationPolicy) 
+    		throws RemoteException, AutoscalerServiceInvalidPolicyExceptionException, 
+    AutoscalerServiceRemoteExceptionException, AutoscalerServiceInvalidApplicationPolicyExceptionException {
+    	stub.addApplicationPolicy(applicationPolicy);
+    }
+    
+    public ApplicationPolicy getApplicationPolicy(String applicationPolicyId) throws RemoteException {
+    	return stub.getApplicationPolicy(applicationPolicyId);
+    }
+    
+    public void removeApplicationPolicy(String applicationPolicyId) 
+    		throws RemoteException, AutoscalerServiceInvalidPolicyExceptionException {
+    	stub.removeApplicationPolicy(applicationPolicyId);
     }
     
     public String[] getApplicationNetworkPartitions(String applicationId) throws RemoteException, 

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
index 5453e23..7c68eac 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/application/Application.java
@@ -48,6 +48,9 @@ public class Application extends ParentComponent<ApplicationInstance> {
     private String tenantAdminUserName;
     // Life cycle state manager
     //protected LifeCycleStateManager<ApplicationStatus> applicationStateManager;
+    
+    // application policy id
+    private String applicationPolicyId;
 
     public Application(String id) {
         super();
@@ -169,4 +172,12 @@ public class Application extends ParentComponent<ApplicationInstance> {
     public void setDescription(String description) {
         this.description = description;
     }
+
+	public String getApplicationPolicyId() {
+		return applicationPolicyId;
+	}
+
+	public void setApplicationPolicyId(String applicationPolicyId) {
+		this.applicationPolicyId = applicationPolicyId;
+	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 907bcc5..15fd8f7 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -73,7 +73,6 @@ import javax.ws.rs.core.UriInfo;
 
 import java.net.URI;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -629,35 +628,58 @@ public class StratosApiV41 extends AbstractApi {
      * @throws RestAPIException the rest api exception
      */
     @POST
-    @Path("/applications/{applicationId}/deploy")
+    @Path("/applications/{applicationId}/deploy/{applicationPolicyId}")
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/deployApplication")
-    public Response deployApplication(@PathParam("applicationId") String applicationId, ApplicationPolicyBean
-		    applicationPolicy)
+    public Response deployApplication(@PathParam("applicationId") String applicationId, 
+    		@PathParam("applicationPolicyId") String applicationPolicyId)
             throws RestAPIException {
-        StratosApiV41Utils.deployApplication(applicationId, applicationPolicy);
+        StratosApiV41Utils.deployApplication(applicationId, applicationPolicyId);
         return Response.accepted().entity(
 		        new SuccessResponseBean(Response.Status.ACCEPTED.getStatusCode(),
 		                                String.format("Application deployed successfully: [application] %s",
 		                                              applicationId))).build();
     }
     
-    /**
-     * Get network partition by network partition id
-     * @return
-     * @throws RestAPIException
-     */
+    @POST
+    @Path("/applicationPolicies")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/admin/manage/addApplicationPolicy")
+    public Response addApplicationPolicy(ApplicationPolicyBean applicationPolicy)
+            throws RestAPIException {
+        StratosApiV41Utils.addApplicationPolicy(applicationPolicy);
+        URI url = uriInfo.getAbsolutePathBuilder().path(applicationPolicy.getId()).build();
+        return Response.created(url).entity(
+        		new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+        				String.format("Application policy added successfully: [application-policy] %s", applicationPolicy.getId() ))).build();
+    }
+
     @GET
-    @Path("/applications/{applicationId}/applicationPolicy")
+    @Path("/applicationPolicies/{applicationPolicyId}")
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/getApplicationPolicy")
-    public Response getApplicationPolicy(@PathParam("applicationId") String applicationId) throws RestAPIException {
-        ApplicationPolicyBean applicationPolicyBean = StratosApiV41Utils.getApplicationPolicy(applicationId);
+    public Response getApplicationPolicy(@PathParam("applicationPolicyId") String applicationPolicyId) throws RestAPIException {
+        ApplicationPolicyBean applicationPolicyBean = StratosApiV41Utils.getApplicationPolicy(applicationPolicyId);
         return Response.ok(applicationPolicyBean).build();
     }
     
+	@DELETE
+	@Path("/applicationPolicies/{applicationPolicyId}")
+	@Produces("application/json")
+	@Consumes("application/json")
+	@AuthorizationAction("/permission/admin/manage/removeApplicationPolicy")
+	public Response removeApplicationPolicy(@PathParam("applicationPolicyId") String applicationPolicyId)
+			throws RestAPIException {
+
+		StratosApiV41Utils.removeApplicationPolicy(applicationPolicyId);
+		return Response.ok().entity(
+        		new SuccessResponseBean(Response.Status.OK.getStatusCode(),
+        				String.format("Autoscaling policy deleted successfully: [autoscale-policy] %s", applicationPolicyId))).build();
+	}
+    
     /**
      * Get network partition ids used in an application
      * @return

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index c8f6337..bed4054 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -24,7 +24,9 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.stub.AutoscalerServiceApplicationDefinitionExceptionException;
+import org.apache.stratos.autoscaler.stub.AutoscalerServiceInvalidApplicationPolicyExceptionException;
 import org.apache.stratos.autoscaler.stub.AutoscalerServiceInvalidPolicyExceptionException;
+import org.apache.stratos.autoscaler.stub.AutoscalerServiceRemoteExceptionException;
 import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy;
 import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
@@ -557,6 +559,83 @@ public class StratosApiV41Utils {
             }
         }
     }
+    
+    public static void addApplicationPolicy(ApplicationPolicyBean applicationPolicyBean) throws RestAPIException {
+    	
+		if (applicationPolicyBean == null) {
+			String msg = "Application policy bean is null";
+			log.error(msg);
+			throw new RestAPIException(msg);
+		}
+    	
+    	AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
+    	try {
+			ApplicationPolicy applicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(applicationPolicyBean);
+			if (applicationPolicy == null) {
+				String msg = "Application policy is null";
+				log.error(msg);
+				throw new RestAPIException(msg);
+			}
+			serviceClient.addApplicationPolicy(applicationPolicy);
+		} catch (RemoteException e) {
+			throw new RestAPIException(e);
+		} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+			throw new RestAPIException(e);
+		} catch (AutoscalerServiceRemoteExceptionException e) {
+			throw new RestAPIException(e);
+		} catch (AutoscalerServiceInvalidApplicationPolicyExceptionException e) {
+			throw new RestAPIException(e);
+		}
+    }
+    
+    public static ApplicationPolicyBean getApplicationPolicy(String applicationPolicyId) throws RestAPIException {
+    	
+		if (applicationPolicyId == null) {
+			String msg = "Application policy bean id null";
+			log.error(msg);
+			throw new RestAPIException(msg);
+		}
+    	
+    	if (StringUtils.isBlank(applicationPolicyId)) {
+			String msg = "Application policy id is empty";
+			log.error(msg);
+			throw new RestAPIException(msg);
+    	}
+    	
+        try {
+            AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();
+            ApplicationPolicy applicationPolicy = serviceClient.getApplicationPolicy(applicationPolicyId);
+            return ObjectConverter.convertASStubApplicationPolicyToApplicationPolicy(applicationPolicy);
+        } catch (Exception e) {
+            String message = String.format("Could not get application policy [application-policy-id] %s", applicationPolicyId);
+            log.error(message);
+            throw new RuntimeException(message, e);
+        }
+    }
+    
+    public static void removeApplicationPolicy(String applicationPolicyId) throws RestAPIException {
+    	
+		if (applicationPolicyId == null) {
+			String msg = "Application policy bean id null";
+			log.error(msg);
+			throw new RestAPIException(msg);
+		}
+    	
+    	if (StringUtils.isBlank(applicationPolicyId)) {
+			String msg = "Application policy id is empty";
+			log.error(msg);
+			throw new RestAPIException(msg);
+    	}
+    	
+    	AutoscalerServiceClient serviceClient = getAutoscalerServiceClient();
+    	try {
+			serviceClient.removeApplicationPolicy(applicationPolicyId);
+		} catch (RemoteException e) {
+			throw new RestAPIException(e);
+		} catch (AutoscalerServiceInvalidPolicyExceptionException e) {
+			throw new RestAPIException(e);
+		}
+    }
 
     public static void updateAutoscalingPolicy(AutoscalePolicyBean autoscalePolicyBean) throws RestAPIException {
 
@@ -979,10 +1058,10 @@ public class StratosApiV41Utils {
 	 * Deploy application with an application policy.
 	 * 
 	 * @param applicationId
-	 * @param applicationPolicy
+	 * @param applicationPolicyId
 	 * @throws RestAPIException
 	 */
-    public static void deployApplication(String applicationId, ApplicationPolicyBean applicationPolicy)
+    public static void deployApplication(String applicationId, String applicationPolicyId)
             throws RestAPIException {
 
         try {
@@ -1008,9 +1087,14 @@ public class StratosApiV41Utils {
                 log.error(message);
                 throw new RestAPIException(message);
             }
-            if (applicationPolicy == null) {
-                String message = String.format("Application policy cannot be null : [application-id] %s. "
-                		+ "Are you passing application policy?", applicationId);
+            if(applicationPolicyId == null) {
+                String message = String.format("Application policy id is not found: [application-policy-id] %s", applicationPolicyId);
+                log.error(message);
+                throw new RestAPIException(message);
+            }
+            if (StringUtils.isBlank(applicationPolicyId)) {
+                String message = String.format("Application policy id cannot be null : [application-policy-id] %s. "
+                		+ "Are you passing application policy?", applicationPolicyId);
                 log.error(message);
                 throw new RestAPIException(message);
 			}
@@ -1023,11 +1107,11 @@ public class StratosApiV41Utils {
                 throw new RestAPIException(message);
             }
             
-            ApplicationPolicy ccStubApplicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(applicationPolicy);
+//            ApplicationPolicy ccStubApplicationPolicy = ObjectConverter.convertApplicationPolicyBeanToStubAppPolicy(applicationPolicy);
             // setting the application id since application-policy.json doesn't have this attribute explicitly
             // reason is deployApplication() api path is containing the application id
-            ccStubApplicationPolicy.setApplicationId(applicationId);
-			autoscalerServiceClient.deployApplication(applicationId, ccStubApplicationPolicy);
+//            ccStubApplicationPolicy.setApplicationId(applicationId);
+			autoscalerServiceClient.deployApplication(applicationId, applicationPolicyId);
             if (log.isInfoEnabled()) {
                 log.info(String.format("Application deployed successfully: [application-id] %s", applicationId));
             }
@@ -1045,18 +1129,6 @@ public class StratosApiV41Utils {
         }
     }
     
-    public static ApplicationPolicyBean getApplicationPolicy(String applicationId) {
-        try {
-            AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();
-            ApplicationPolicy applicationPolicy = serviceClient.getApplicationPolicy(applicationId);
-            return ObjectConverter.convertASStubApplicationPolicyToApplicationPolicy(applicationPolicy);
-        } catch (Exception e) {
-            String message = String.format("Could not get application policy [application-id] %s", applicationId);
-            log.error(message);
-            throw new RuntimeException(message, e);
-        }
-    }
-    
     public static ApplicationNetworkPartitionIdListBean getApplicationNetworkPartitions(String applicationId) {
         try {
             AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index 0f05e5a..a173f7a 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -1717,8 +1717,14 @@ public class ObjectConverter {
 	
 	public static ApplicationPolicy convertApplicationPolicyBeanToStubAppPolicy(
 	        ApplicationPolicyBean appPolicy) {
+		
+		if (appPolicy == null) {
+			return null;
+		}
+		
 		ApplicationPolicyNetworkPartitionReferenceBean[] nps = appPolicy.getNetworkPartition();
 		ApplicationPolicy applicationPolicy = new ApplicationPolicy();
+		applicationPolicy.setApplicationPolicyId(appPolicy.getId());
 		List<ApplicationPolicyNetworkPartitionReference> nprList = new ArrayList<ApplicationPolicyNetworkPartitionReference>();
 
 		for (ApplicationPolicyNetworkPartitionReferenceBean np : nps) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/application-policies/application-policy.json
----------------------------------------------------------------------
diff --git a/samples/application-policies/application-policy.json b/samples/application-policies/application-policy.json
new file mode 100644
index 0000000..2c24d46
--- /dev/null
+++ b/samples/application-policies/application-policy.json
@@ -0,0 +1,9 @@
+{
+   "id" : "application-policy-1",
+   "networkPartition":[
+      {
+         "id":"network-partition-1",
+         "activeByDefault":"true"
+      }
+   ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/applications/esb-php-nested-with-esb-php-nested-with-mysql-php-app/artifacts/application-policy.json
----------------------------------------------------------------------
diff --git a/samples/applications/esb-php-nested-with-esb-php-nested-with-mysql-php-app/artifacts/application-policy.json b/samples/applications/esb-php-nested-with-esb-php-nested-with-mysql-php-app/artifacts/application-policy.json
deleted file mode 100644
index 9d2c6a1..0000000
--- a/samples/applications/esb-php-nested-with-esb-php-nested-with-mysql-php-app/artifacts/application-policy.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-   "networkPartition":[
-      {
-         "id":"network-partition-1",
-         "activeByDefault":"true"
-      }
-   ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/applications/single-cartridge/artifacts/application-policy.json
----------------------------------------------------------------------
diff --git a/samples/applications/single-cartridge/artifacts/application-policy.json b/samples/applications/single-cartridge/artifacts/application-policy.json
deleted file mode 100644
index 9d2c6a1..0000000
--- a/samples/applications/single-cartridge/artifacts/application-policy.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-   "networkPartition":[
-      {
-         "id":"network-partition-1",
-         "activeByDefault":"true"
-      }
-   ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/applications/single-cartridge/scripts/common/deploy.sh
----------------------------------------------------------------------
diff --git a/samples/applications/single-cartridge/scripts/common/deploy.sh b/samples/applications/single-cartridge/scripts/common/deploy.sh
index ee56281..55595cc 100755
--- a/samples/applications/single-cartridge/scripts/common/deploy.sh
+++ b/samples/applications/single-cartridge/scripts/common/deploy.sh
@@ -13,6 +13,7 @@ cartridges_groups_path=`cd "${script_path}/../../../../cartridges-groups"; pwd`
 autoscaling_policies_path=`cd "${script_path}/../../../../autoscaling-policies"; pwd`
 network_partitions_path=`cd "${script_path}/../../../../network-partitions/${iaas}"; pwd`
 deployment_policies_path=`cd "${script_path}/../../../../deployment-policies"; pwd`
+application_policies_path=`cd "${script_path}/../../../../application-policies"; pwd`
 
 set -e
 
@@ -37,10 +38,13 @@ curl -X POST -H "Content-Type: application/json" -d "@${iaas_cartridges_path}/ph
 
 sleep 1
 
+echo "Adding application policy..."
+curl -X POST -H "Content-Type: application/json" -d "@${application_policies_path}/application-policy.json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies
+
 echo "Adding application..."
 curl -X POST -H "Content-Type: application/json" -d "@${artifacts_path}/application.json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applications
 
 sleep 1
 
 echo "Deploying application..."
-curl -X POST -H "Content-Type: application/json" -d "@${artifacts_path}/application-policy.json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applications/single-cartridge-app/deploy
+curl -X POST -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applications/single-cartridge-app/deploy/application-policy-1

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/applications/single-cartridge/scripts/common/undeploy.sh
----------------------------------------------------------------------
diff --git a/samples/applications/single-cartridge/scripts/common/undeploy.sh b/samples/applications/single-cartridge/scripts/common/undeploy.sh
index 65499db..b0174b8 100644
--- a/samples/applications/single-cartridge/scripts/common/undeploy.sh
+++ b/samples/applications/single-cartridge/scripts/common/undeploy.sh
@@ -25,3 +25,7 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://
 echo "Removing network partitions..."
 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1
 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2
+
+echo "Removing application policies..."
+curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/9d4f85ba/samples/applications/wordpress-extended-v2/artifacts/application-policy.json
----------------------------------------------------------------------
diff --git a/samples/applications/wordpress-extended-v2/artifacts/application-policy.json b/samples/applications/wordpress-extended-v2/artifacts/application-policy.json
deleted file mode 100644
index 5aa91dd..0000000
--- a/samples/applications/wordpress-extended-v2/artifacts/application-policy.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-   "networkPartition":[
-      {
-         "id":"network-partition-1",
-         "activeByDefault":"true"
-      },
-      {
-         "id":"network-partition-2",
-         "activeByDefault":"false"
-      }
-   ]
-}