diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
index 7da850e7a94..63176b19db8 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml
@@ -105,6 +105,10 @@
org.wso2.carbon.governance
org.wso2.carbon.governance.lcm
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.core
+
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java
index f3ecf346207..b04f2a5f599 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java
@@ -30,7 +30,8 @@ import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
-import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationUtil;
+import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor;
+import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import javax.servlet.ServletContext;
import java.io.IOException;
@@ -51,13 +52,16 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED);
boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param);
- if (isManagedApi) {
+ String profile = System.getProperty(DeviceManagementConstants.Common.PROPERTY_PROFILE);
+
+ if ((profile.equalsIgnoreCase(DeviceManagementConstants.Common.PROFILE_DT_GOVERN) ||
+ profile.equalsIgnoreCase(DeviceManagementConstants.Common.PROFILE_DEFAULT)) && isManagedApi) {
try {
- AnnotationUtil annotationUtil = new AnnotationUtil(context);
- Set annotatedAPIClasses = annotationUtil.
+ AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
+ Set annotatedAPIClasses = annotationProcessor.
scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName());
- List apiDefinitions = annotationUtil.extractAPIInfo(servletContext,
+ List apiDefinitions = annotationProcessor.extractAPIInfo(servletContext,
annotatedAPIClasses);
for (APIResourceConfiguration apiDefinition : apiDefinitions) {
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java
similarity index 96%
rename from components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationUtil.java
rename to components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java
index 4974a54c0eb..730c8c82dca 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationUtil.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java
@@ -32,6 +32,8 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.config.PermissionConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.config.PermissionManagementException;
+import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
+import org.wso2.carbon.device.mgt.core.config.deviceType.DTConfiguration;
import javax.servlet.ServletContext;
import javax.ws.rs.*;
@@ -47,9 +49,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-public class AnnotationUtil {
+public class AnnotationProcessor {
- private static final Log log = LogFactory.getLog(AnnotationUtil.class);
+ private static final Log log = LogFactory.getLog(AnnotationProcessor.class);
private static final String PACKAGE_ORG_APACHE = "org.apache";
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus";
@@ -70,7 +72,7 @@ public class AnnotationUtil {
private ServletContext servletContext;
- public AnnotationUtil(final StandardContext context) {
+ public AnnotationProcessor(final StandardContext context) {
this.context = context;
servletContext = context.getServletContext();
classLoader = servletContext.getClassLoader();
@@ -175,6 +177,7 @@ public class AnnotationUtil {
/**
* Iterate API annotation and build API Configuration
+ *
* @param apiAnno
* @return
* @throws Throwable
@@ -204,6 +207,7 @@ public class AnnotationUtil {
/**
* Get Resources for each API
+ *
* @param resourceRootContext
* @param apiRootContext
* @param annotatedMethods
@@ -221,8 +225,11 @@ public class AnnotationUtil {
APIResource resource = new APIResource();
resource.setUriTemplate(makeContextURLReady(apiRootContext + subCtx));
- String serverIP = System.getProperty(SERVER_HOST);
- String httpServerPort = System.getProperty(HTTP_PORT);
+ DTConfiguration deviceTypeConfig = DeviceConfigurationManager.getInstance().
+ getDeviceManagementConfig().getDTDeploymentConfiguration();
+
+ String serverIP = deviceTypeConfig.getDtHostAddress();
+ String httpServerPort = deviceTypeConfig.getDtHostPort();
resource.setUri(PROTOCOL_HTTP + "://" + serverIP + ":" + httpServerPort + makeContextURLReady(
resourceRootContext) + makeContextURLReady(subCtx));
@@ -266,6 +273,7 @@ public class AnnotationUtil {
/**
* Read Method annotations indicating HTTP Methods
+ *
* @param resource
* @param annotation
*/
@@ -289,6 +297,7 @@ public class AnnotationUtil {
/**
* Append '/' to the context and make it URL ready
+ *
* @param context
* @return
*/
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index 379ca8c3d6c..f4c2ba61f4a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -28,6 +28,9 @@ public final class DeviceManagementConstants {
public static final String PROPERTY_SETUP = "setup";
public static final String DEFAULT_LICENSE_CONFIG_XML_NAME = "license-config.xml";
+ public static final String PROPERTY_PROFILE = "profile";
+ public static final String PROFILE_DT_GOVERN = "deviceTypeGovern";
+ public static final String PROFILE_DEFAULT = "default";
}
public static final class AppManagement {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
index 31dc99187a0..ee11038ca47 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
@@ -17,6 +17,7 @@
*/
package org.wso2.carbon.device.mgt.core.config;
+import org.wso2.carbon.device.mgt.core.config.deviceType.DTConfiguration;
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
@@ -37,6 +38,7 @@ public final class DeviceManagementConfig {
private IdentityConfigurations identityConfigurations;
private PolicyConfiguration policyConfiguration;
//private List pushNotificationProviders;
+ private DTConfiguration dTDepyloymentConfiguration;
@XmlElement(name = "ManagementRepository", required = true)
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
@@ -75,6 +77,15 @@ public final class DeviceManagementConfig {
this.taskConfiguration = taskConfiguration;
}
+ @XmlElement(name = "DTDeploymentConfiguration", required = true)
+ public DTConfiguration getDTDeploymentConfiguration() {
+ return dTDepyloymentConfiguration;
+ }
+
+ public void setDTDeploymentConfiguration(DTConfiguration dTDeploymentConfiguration) {
+ this.dTDepyloymentConfiguration = dTDeploymentConfiguration;
+ }
+
// @XmlElementWrapper(name = "PushNotificationProviders", required = true)
// @XmlElement(name = "Provider", required = true)
// public List getPushNotificationProviders() {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/deviceType/DTConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/deviceType/DTConfiguration.java
new file mode 100644
index 00000000000..14a3af12748
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/deviceType/DTConfiguration.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+
+/**
+ * This class will read the configurations related to task. This task will be responsible for adding the operations.
+ */
+package org.wso2.carbon.device.mgt.core.config.deviceType;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "DTDepyloymentConfiguration")
+public class DTConfiguration {
+
+ private String dtHostAddress;
+ private String dtHostPort;
+
+ @XmlElement(name = "DTHostAddress", required = true)
+ public String getDtHostAddress() {
+ return dtHostAddress;
+ }
+
+ public void setDtHostAddress(String dtHostAddress) {
+ this.dtHostAddress = dtHostAddress;
+ }
+
+ @XmlElement(name = "DTHostPort", required = true)
+ public String getDtHostPort() {
+ return dtHostPort;
+ }
+
+ public void setDtHostPort(String dtHostPort) {
+ this.dtHostPort = dtHostPort;
+ }
+
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
index 6cb83f59746..41aa93f835e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
@@ -90,6 +90,10 @@
commons-lang.wso2
commons-lang
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.core
+
@@ -110,6 +114,7 @@
org.wso2.carbon.governance.api.*,
javax.xml.namespace;resolution:=optional,
+ org.wso2.carbon.device.mgt.core.*,
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.common.license.mgt,
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/lifecycle/listener/FeatureManagementLifecycleListener.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/lifecycle/listener/FeatureManagementLifecycleListener.java
index 57ae592ee65..fde55173369 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/lifecycle/listener/FeatureManagementLifecycleListener.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/lifecycle/listener/FeatureManagementLifecycleListener.java
@@ -24,9 +24,10 @@ import org.apache.catalina.core.StandardContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Feature;
+import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
-import org.wso2.carbon.device.mgt.extensions.feature.mgt.util.AnnotationUtil;
+import org.wso2.carbon.device.mgt.extensions.feature.mgt.util.AnnotationProcessor;
import javax.servlet.ServletContext;
import java.io.IOException;
@@ -51,11 +52,15 @@ public class FeatureManagementLifecycleListener implements LifecycleListener {
ServletContext servletContext = context.getServletContext();
String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED);
boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param);
- if (isManagedApi) {
+
+ String profile = System.getProperty(DeviceManagementConstants.Common.PROPERTY_PROFILE);
+
+ if ((profile.equalsIgnoreCase(DeviceManagementConstants.Common.PROFILE_DT_GOVERN) ||
+ profile.equalsIgnoreCase(DeviceManagementConstants.Common.PROFILE_DEFAULT)) && isManagedApi) {
try {
- AnnotationUtil annotationUtil = new AnnotationUtil(context);
- Set annotatedAPIClasses = annotationUtil.scanStandardContext(DeviceType.class.getName());
- Map> features = annotationUtil.extractFeatures(annotatedAPIClasses);
+ AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
+ Set annotatedAPIClasses = annotationProcessor.scanStandardContext(DeviceType.class.getName());
+ Map> features = annotationProcessor.extractFeatures(annotatedAPIClasses);
if (features != null && !features.isEmpty()) {
GenericFeatureManager.getInstance().addFeatures(features);
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationProcessor.java
similarity index 98%
rename from components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java
rename to components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationProcessor.java
index a70c9c5dc14..2819d47ee1f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationProcessor.java
@@ -55,9 +55,9 @@ import java.util.Set;
/**
* This has the utility function to extract feature information.
*/
-public class AnnotationUtil {
+public class AnnotationProcessor {
- private static final Log log = LogFactory.getLog(AnnotationUtil.class);
+ private static final Log log = LogFactory.getLog(AnnotationProcessor.class);
private static final String PACKAGE_ORG_APACHE = "org.apache";
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus";
@@ -71,7 +71,7 @@ public class AnnotationUtil {
private ServletContext servletContext;
- public AnnotationUtil(final StandardContext context) {
+ public AnnotationProcessor(final StandardContext context) {
servletContext = context.getServletContext();
classLoader = servletContext.getClassLoader();
}