diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
index d66e9ff997e..5b9b7deb789 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
@@ -83,6 +83,28 @@
org.wso2.carbon
org.wso2.carbon.logging
+
+
+ org.wso2.carbon
+ org.wso2.carbon.policy.mgt.common
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.ndatasource.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.ndatasource.rdbms
+
org.wso2.carbon
org.wso2.carbon.logging
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java
new file mode 100644
index 00000000000..944bf89a9ef
--- /dev/null
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. 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.wso2.carbon.policy.mgt.core.dao;
+
+import org.wso2.carbon.policy.mgt.common.Policy;
+
+public interface PolicyDAO {
+
+ int addPolicy(Policy policy) throws PolicyManagerDAOException;
+
+ int addPolicy(String deviceType, Policy policy) throws PolicyManagerDAOException;
+
+ int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException;
+
+ void updatePolicy(int id) throws PolicyManagerDAOException;
+
+ Policy getPolicy() throws PolicyManagerDAOException;
+
+ Policy getPolicy(String deviceType) throws PolicyManagerDAOException;
+
+ Policy getPolicy(String deviceID, String deviceType) throws PolicyManagerDAOException;
+}
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java
index 0e2b1c91a51..f1d9cf56cab 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyManagementDAOFactory.java
@@ -18,5 +18,63 @@
package org.wso2.carbon.policy.mgt.core.dao;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
+import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition;
+import org.wso2.carbon.policy.mgt.core.dao.impl.PolicyDAOImpl;
+import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
+
+import javax.sql.DataSource;
+import java.util.Hashtable;
+import java.util.List;
+
public class PolicyManagementDAOFactory {
+
+ private static DataSource dataSource;
+ private static final Log log = LogFactory.getLog(PolicyManagementDAOFactory.class);
+
+
+ public static PolicyDAO getDeviceTypeDAO() {
+ return new PolicyDAOImpl(dataSource);
+ }
+
+ public static void init(DataSourceConfig config) {
+ dataSource = resolveDataSource(config);
+ }
+
+ /**
+ * Resolve data source from the data source definition
+ *
+ * @param config data source configuration
+ * @return data source resolved from the data source definition
+ */
+ private static DataSource resolveDataSource(DataSourceConfig config) {
+ DataSource dataSource = null;
+ if (config == null) {
+ throw new RuntimeException("Device Management Repository data source configuration " +
+ "is null and thus, is not initialized");
+ }
+ JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
+ if (jndiConfig != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing Device Management Repository data source using the JNDI " +
+ "Lookup Definition");
+ }
+ List jndiPropertyList =
+ jndiConfig.getJndiProperties();
+ if (jndiPropertyList != null) {
+ Hashtable
-
+
+ org.wso2.carbon
+ org.wso2.carbon.policy.mgt.common
+ ${project.version}
+
+
+
+
org.eclipse.osgi
org.eclipse.osgi