From 9343032c88a69b3d9cbff569270e2539e5db4091 Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Mon, 29 May 2017 18:35:37 +0530 Subject: [PATCH] Changes to App Management Externsions Framework --- .../pom.xml | 5 ++ .../impl/ApplicationManagementAPIImpl.java | 7 +++ .../ApplicationManagementExtension.java | 36 +++++++++++ .../ApplicationConfigurationManager.java | 1 + .../ApplicationManagementConfigurations.java | 13 ++++ .../datasource/JNDILookupDefinition.java | 4 +- .../mgt/core/config/extensions/Extension.java | 63 +++++++++++++++++++ .../core/config/extensions/Extensions.java | 49 +++++++++++++++ .../config/extensions/ExtensionsConfig.java | 37 +++++++++++ .../mgt/core/config/extensions/Parameter.java | 56 +++++++++++++++++ .../config/extensions/ParameterAdapter.java | 50 +++++++++++++++ .../core/config/extensions/Parameters.java | 45 +++++++++++++ .../ApplicationManagementServiceFactory.java | 40 +++++++++--- .../pom.xml | 8 +-- .../appupload/AppUploadManager.java} | 6 +- .../appupload/AppUploadManagerImpl.java} | 9 +-- .../main/resources/conf/application-mgt.xml | 12 ++++ 17 files changed, 416 insertions(+), 25 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtension.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extension.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extensions.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ExtensionsConfig.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameter.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ParameterAdapter.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameters.java rename components/application-mgt/{org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtensionsService.java => org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManager.java} (78%) rename components/application-mgt/{org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementExtensionsFactory.java => org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManagerImpl.java} (68%) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml index dbf36b10b03..0fe45329a3e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml @@ -166,6 +166,11 @@ org.wso2.carbon.device.application.mgt.common provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.extensions + provided + io.swagger swagger-annotations diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java index e17a2985e6f..777820efa7d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.device.application.mgt.common.ApplicationList; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.api.util.ApplicationMgtAPIUtil; import org.wso2.carbon.device.application.mgt.core.services.impl.ApplicationManagementServiceFactory; +import org.wso2.carbon.device.application.mgt.extensions.appupload.AppUploadManager; import javax.ws.rs.*; import javax.ws.rs.core.Response; @@ -39,6 +40,8 @@ public class ApplicationManagementAPIImpl { public static final int DEFAULT_LIMIT = 20; + public static final String APPLICATION_UPLOAD_EXTENSION = "ApplicationUploadExtension"; + private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class); @@ -50,6 +53,10 @@ public class ApplicationManagementAPIImpl { ApplicationManagementServiceFactory serviceFactory = ApplicationMgtAPIUtil.getApplicationManagementServiceFactory(); ApplicationManager applicationManager = (ApplicationManager) serviceFactory .getApplicationManagementService(APPLICATION_MANAGER); + + AppUploadManager appUploadManager = (AppUploadManager) serviceFactory + .applicationManagementExtensionsService(APPLICATION_UPLOAD_EXTENSION); + try { if (limit == 0) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtension.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtension.java new file mode 100644 index 00000000000..df281eb991b --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtension.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.common.services; + +import java.util.List; +import java.util.Map; + +public abstract class ApplicationManagementExtension { + + private Map parameters; + + + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationConfigurationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationConfigurationManager.java index 046f2ed6b34..4485b8470d3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationConfigurationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationConfigurationManager.java @@ -70,6 +70,7 @@ public class ApplicationConfigurationManager { Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); this.applicationManagerConfiguration = (ApplicationManagementConfigurations) unmarshaller.unmarshal(doc); } catch (Exception e) { + log.error(e); throw new ApplicationManagerException("Error occurred while initializing application config", e); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationManagementConfigurations.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationManagementConfigurations.java index b56d8f206a7..58f103c2c8f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationManagementConfigurations.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/ApplicationManagementConfigurations.java @@ -18,6 +18,8 @@ */ package org.wso2.carbon.device.application.mgt.core.config; +import org.wso2.carbon.device.application.mgt.core.config.extensions.ExtensionsConfig; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -26,6 +28,8 @@ public class ApplicationManagementConfigurations { private ApplicationManagementRepository applicationManagerRepository; + private ExtensionsConfig extensionsConfig; + @XmlElement(name = "ManagementRepository", required = true) public ApplicationManagementRepository getApplicationManagerRepository() { return applicationManagerRepository; @@ -34,6 +38,15 @@ public class ApplicationManagementConfigurations { public void setApplicationManagerRepository(ApplicationManagementRepository applicationManagerRepository) { this.applicationManagerRepository = applicationManagerRepository; } + + @XmlElement(name = "ExtensionsConfig", required = false) + public ExtensionsConfig getExtensionsConfig() { + return extensionsConfig; + } + + public void setExtensionsConfig(ExtensionsConfig extensionsConfig) { + this.extensionsConfig = extensionsConfig; + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/datasource/JNDILookupDefinition.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/datasource/JNDILookupDefinition.java index 600c9f1dafd..2ae8125c798 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/datasource/JNDILookupDefinition.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/datasource/JNDILookupDefinition.java @@ -40,7 +40,7 @@ public class JNDILookupDefinition { } @XmlElementWrapper(name = "Environment", nillable = false) - @XmlElement(name = "Property", nillable = false) + @XmlElement(name = "Parameters", nillable = false) public List getJndiProperties() { return jndiProperties; } @@ -49,7 +49,7 @@ public class JNDILookupDefinition { this.jndiProperties = jndiProperties; } - @XmlRootElement(name = "Property") + @XmlRootElement(name = "Parameters") public static class JNDIProperty { private String name; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extension.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extension.java new file mode 100644 index 00000000000..862f2130f8c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extension.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Map; + +@XmlRootElement(name = "Extension") +public class Extension { + + private String name; + + private String className; + + private Map parameters; + + @XmlAttribute(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElement(name = "ClassName", nillable = true) + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + @XmlElement(name = "Parameters", nillable = true) + @XmlJavaTypeAdapter(ParameterAdapter.class) + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extensions.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extensions.java new file mode 100644 index 00000000000..e686e8b9b4b --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Extensions.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.*; +import java.util.List; + +@XmlRootElement(name = "Extensions") +public class Extensions { + + private List extensions; + + + @XmlElement(name = "Extension") + public List getExtensions() { + return extensions; + } + + public void setExtensions(List extensions) { + this.extensions = extensions; + } + + public Extension getExtensionByName(String extensionName) { + if (extensions != null) { + for (Extension extension : extensions) { + if(extension.getName().equals(extensionName)) { + return extension; + } + } + } + return null; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ExtensionsConfig.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ExtensionsConfig.java new file mode 100644 index 00000000000..75be478f2e8 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ExtensionsConfig.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "ExtensionsConfig") +public class ExtensionsConfig { + + private Extensions extensions; + + @XmlElement(name = "Extensions", nillable = true) + public Extensions getExtensions() { + return extensions; + } + + public void setExtensions(Extensions extensions) { + this.extensions = extensions; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameter.java new file mode 100644 index 00000000000..db3d22b8d85 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameter.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlValue; + +public class Parameter { + + private String name; + + private String value; + + Parameter(String name, String value) { + this.name = name; + this.value = value; + } + + Parameter(){ + + } + + @XmlAttribute(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlValue + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ParameterAdapter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ParameterAdapter.java new file mode 100644 index 00000000000..ff0a4b2ac3a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/ParameterAdapter.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class ParameterAdapter extends XmlAdapter> { + + @Override + public Map unmarshal(Parameters in) throws Exception { + HashMap hashMap = new HashMap<>(); + for (Parameter parameter : in.getParameters()) { + hashMap.put(parameter.getName(), parameter.getValue()); + } + return hashMap; + } + + @Override + public Parameters marshal(Map map) throws Exception { + Parameters parameters = new Parameters(); + for (Map.Entry entry : map.entrySet()) { + parameters.addEntry(new Parameter(entry.getKey(), entry.getValue())); + } + return parameters; + } + +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameters.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameters.java new file mode 100644 index 00000000000..280b9d516d8 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/config/extensions/Parameters.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, 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.device.application.mgt.core.config.extensions; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "Parameters") +public class Parameters { + + private List parameters = new ArrayList<>();; + + @XmlElement(name = "Parameter", nillable = true) + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + void addEntry(Parameter parameter) { + parameters.add(parameter); + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceFactory.java index 1de229058c4..6715fab1171 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceFactory.java @@ -20,19 +20,15 @@ package org.wso2.carbon.device.application.mgt.core.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; -import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagerException; -import org.wso2.carbon.device.application.mgt.common.Application; -import org.wso2.carbon.device.application.mgt.common.ApplicationList; -import org.wso2.carbon.device.application.mgt.common.Filter; import org.wso2.carbon.device.application.mgt.common.services.*; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO; -import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOException; -import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; +import org.wso2.carbon.device.application.mgt.core.config.ApplicationConfigurationManager; +import org.wso2.carbon.device.application.mgt.core.config.extensions.Extension; +import org.wso2.carbon.device.application.mgt.core.config.extensions.ExtensionsConfig; public class ApplicationManagementServiceFactory { + private static Log log = LogFactory.getLog(ApplicationManagementServiceFactory.class); + public enum ManagerService { APPLICATION_MANAGER, APPLICATION_RELEASE_MANAGER, @@ -55,4 +51,30 @@ public class ApplicationManagementServiceFactory { return null; } } + + public ApplicationManagementExtension applicationManagementExtensionsService(String extensionName) { + ApplicationConfigurationManager applicationConfigurationManager = ApplicationConfigurationManager.getInstance(); + + ExtensionsConfig extensionConfig = applicationConfigurationManager + .getApplicationManagerConfiguration().getExtensionsConfig(); + + Extension extension = extensionConfig.getExtensions().getExtensionByName(extensionName); + + try { + Class theClass = Class.forName(extension.getClassName()); + ApplicationManagementExtension appManagementExtension = (ApplicationManagementExtension) theClass.newInstance(); + appManagementExtension.setParameters(extension.getParameters()); + return appManagementExtension; + } catch (ClassNotFoundException e) { + log.error("Class not Found", e); + } catch (IllegalAccessException e) { + log.error("Illegal Access of Class", e); + } catch (InstantiationException e) { + log.error("Class instantiation exception", e); + } + + + return null; + + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/pom.xml index 591dd295057..11a0a9f9e2a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/pom.xml @@ -49,10 +49,7 @@ ${project.artifactId} ${project.artifactId} ${carbon.device.mgt.version} - Application Management Core Bundle - - org.wso2.carbon.device.application.mgt.core.internal - + Application Management Extensions Bundle org.osgi.framework, org.osgi.service.component, @@ -73,8 +70,7 @@ org.wso2.carbon.device.mgt.common.*, - !org.wso2.carbon.device.application.mgt.core.internal.*, - org.wso2.carbon.device.application.mgt.core.* + org.wso2.carbon.device.application.mgt.extensions.* diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtensionsService.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManager.java similarity index 78% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtensionsService.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManager.java index 770940c7aaa..c813a6af12f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManagementExtensionsService.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManager.java @@ -16,8 +16,10 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.common.services; +package org.wso2.carbon.device.application.mgt.extensions.appupload; -public interface ApplicationManagementExtensionsService { +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManagementService; + +public interface AppUploadManager { } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementExtensionsFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManagerImpl.java similarity index 68% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementExtensionsFactory.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManagerImpl.java index fb5ec65dc95..cd935e95d81 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementExtensionsFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.extensions/src/main/java/org/wso2/carbon/device/application/mgt/extensions/appupload/AppUploadManagerImpl.java @@ -16,13 +16,10 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.core.dao.common; +package org.wso2.carbon.device.application.mgt.extensions.appupload; -import org.wso2.carbon.device.application.mgt.common.services.ApplicationManagementExtensionsService; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManagementExtension; -public class ApplicationManagementExtensionsFactory { +public class AppUploadManagerImpl extends ApplicationManagementExtension implements AppUploadManager { - public ApplicationManagementExtensionsService getExtensionsService(Class managerClass) throws Exception { - return (ApplicationManagementExtensionsService) managerClass.newInstance(); - } } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 8bdf6b95e65..539b5af3d5c 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -10,4 +10,16 @@ + + + + + org.wso2.carbon.device.application.mgt.extensions.appupload.AppUploadManagerImpl + + repository/resources/mobileapps + + + + + \ No newline at end of file