add http pushnotification

revert-70aa11f8
ayyoob 8 years ago
parent f3393080ba
commit 7ab52af66e

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - HTTP Based Push Notification Provider Implementation</name>
<description>WSO2 Carbon - HTTP Based Push Notification Provider Implementation</description>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.scannotation</groupId>
<artifactId>scannotation</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</dependency>
<dependency>
<groupId>commons-lang.wso2</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>MQTT Based Push Notification Provider Bundle</Bundle-Description>
<Export-Package>
!org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal,
org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.*
</Export-Package>
<Import-Package>
org.apache.commons.logging,
org.osgi.service.component,
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.core.service,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core,
com.google.gson,
org.apache.commons.httpclient.*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,37 @@
/*
* 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
public class HTTPBasedPushNotificationProvider implements PushNotificationProvider {
@Override
public String getType() {
return "HTTP";
}
@Override
public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) {
return new HTTPNotificationStrategy(config);
}
}

@ -0,0 +1,91 @@
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
import com.google.gson.Gson;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import java.net.UnknownHostException;
public class HTTPMessageExecutor implements Runnable {
private String url;
private String authorizationHeader;
private String payload;
private HostConfiguration hostConfiguration;
private HttpClient httpClient;
private static final String APPLIATION_JSON = "application/json";
private static final String AUTHORIZATION_HEADER = "Authorization";
private static final Log log = LogFactory.getLog(HTTPMessageExecutor.class);
public HTTPMessageExecutor(NotificationContext notificationContext, String authorizationHeader, String url
, HostConfiguration hostConfiguration, HttpClient httpClient) {
this.url = url;
this.authorizationHeader = authorizationHeader;
Gson gson = new Gson();
this.payload = gson.toJson(notificationContext);
this.hostConfiguration = hostConfiguration;
this.httpClient = httpClient;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuthorizationHeader() {
return authorizationHeader;
}
public void setAuthorizationHeader(String authorizationHeader) {
this.authorizationHeader = authorizationHeader;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public HttpClient getHttpClient() {
return httpClient;
}
public void setHttpClient(HttpClient httpClient) {
this.httpClient = httpClient;
}
@Override
public void run() {
EntityEnclosingMethod method = null;
try {
method = new PostMethod(this.getUrl());
method.setRequestEntity(new StringRequestEntity(this.getPayload(), APPLIATION_JSON, "UTF-8"));
if (authorizationHeader != null && authorizationHeader.isEmpty()) {
method.setRequestHeader(AUTHORIZATION_HEADER, authorizationHeader);
}
this.getHttpClient().executeMethod(hostConfiguration, method);
} catch (UnknownHostException e) {
log.error("Push Notification message dropped " + url, e);
} catch (Throwable e) {
log.error("Push Notification message dropped ", e);
} finally {
if (method != null) {
method.releaseConnection();
}
}
}
}

@ -0,0 +1,98 @@
/*
* 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
public class HTTPNotificationStrategy implements NotificationStrategy {
private static final Log log = LogFactory.getLog(HTTPNotificationStrategy.class);
private final PushNotificationConfig config;
private static final String URL_PROPERTY = "url";
private static final String AUTHORIZATION_HEADER_PROPERTY = "authorization";
private String endpoint;
private static ExecutorService executorService;
private HttpClient httpClient = null;
private HostConfiguration hostConfiguration;
private String authorizationHeaderValue;
private String uri;
public HTTPNotificationStrategy(PushNotificationConfig config) {
this.config = config;
}
@Override
public void init() {
endpoint = config.getProperties().get(URL_PROPERTY);
if (endpoint == null || endpoint.isEmpty()) {
throw new InvalidConfigurationException("Property - 'url' cannot be found");
}
try {
this.uri = endpoint;
URL url = new URL(endpoint);
hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(url.getHost(), url.getPort(), url.getProtocol());
this.authorizationHeaderValue = config.getProperties().get(AUTHORIZATION_HEADER_PROPERTY);
executorService = Executors.newFixedThreadPool(1);
httpClient = new HttpClient();
} catch (MalformedURLException e) {
throw new InvalidConfigurationException("Property - 'url' is malformed.", e);
}
}
@Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
try {
executorService.submit(new HTTPMessageExecutor(ctx, authorizationHeaderValue, uri, hostConfiguration
, httpClient));
} catch (RejectedExecutionException e) {
log.error("Failed to publish to external endpoint url: " + endpoint, e);
}
}
@Override
public NotificationContext buildContext() {
return null;
}
@Override
public void undeploy() {
executorService.shutdown();
}
@Override
public PushNotificationConfig getConfig() {
return config;
}
}

@ -0,0 +1,46 @@
/*
* 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
/**
* This exception is thrown whether the http configured with invalid configuration.
*/
public class InvalidConfigurationException extends RuntimeException {
public InvalidConfigurationException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public InvalidConfigurationException(String message, Throwable cause) {
super(message, cause);
}
public InvalidConfigurationException(String msg) {
super(msg);
}
public InvalidConfigurationException() {
super();
}
public InvalidConfigurationException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,49 @@
/*
* 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
/**
* @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal.HTTPPushNotificationServiceComponent" immediate="true"
*/
public class HTTPPushNotificationServiceComponent {
private static final Log log = LogFactory.getLog(HTTPPushNotificationServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
try {
if (log.isDebugEnabled()) {
log.debug("Initializing HTTP based push notification provider implementation bundle");
}
//Do nothing
if (log.isDebugEnabled()) {
log.debug("HTTP based push notification provider implementation bundle has been successfully " +
"initialized");
}
} catch (Throwable e) {
log.error("Error occurred while initializing HTTP based push notification provider " +
"implementation bundle", e);
}
}
}

@ -34,6 +34,7 @@
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</module>

@ -21,16 +21,15 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.extensions.device.type.template.HTTPDeviceTypeManagerService;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypeManagementAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@ -69,8 +68,8 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen
String msg = "Device type already available, " + deviceType.getName();
return Response.status(Response.Status.CONFLICT).entity(msg).build();
}
HTTPDeviceTypeManagerService httpDeviceTypeManagerService = new HTTPDeviceTypeManagerService
(deviceType.getName(), deviceType.getDeviceTypeMetaDefinition());
DeviceManagementService httpDeviceTypeManagerService = DeviceMgtAPIUtils.getDeviceTypeGeneratorService()
.populateDeviceManagementService(deviceType.getName(), deviceType.getDeviceTypeMetaDefinition());
DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService);
return Response.status(Response.Status.OK).build();
} catch (DeviceManagementException e) {
@ -92,8 +91,8 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen
String msg = "Device type does not exist, " + deviceType.getName();
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}
HTTPDeviceTypeManagerService httpDeviceTypeManagerService = new HTTPDeviceTypeManagerService
(deviceType.getName(), deviceType.getDeviceTypeMetaDefinition());
DeviceManagementService httpDeviceTypeManagerService = DeviceMgtAPIUtils.getDeviceTypeGeneratorService()
.populateDeviceManagementService(deviceType.getName(), deviceType.getDeviceTypeMetaDefinition());
DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService);
return Response.status(Response.Status.OK).build();
} catch (DeviceManagementException e) {

@ -44,6 +44,7 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
@ -193,6 +194,18 @@ public class DeviceMgtAPIUtils {
return deviceManagementProviderService;
}
public static DeviceTypeGeneratorService getDeviceTypeGeneratorService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceTypeGeneratorService deviceTypeGeneratorService =
(DeviceTypeGeneratorService) ctx.getOSGiService(DeviceTypeGeneratorService.class, null);
if (deviceTypeGeneratorService == null) {
String msg = "DeviceTypeGeneratorService service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return deviceTypeGeneratorService;
}
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
Device device = getDeviceManagementService().getDevice(deviceIdentifier);
if (device == null || device.getDeviceIdentifier() == null ||

@ -0,0 +1,13 @@
package org.wso2.carbon.device.mgt.common.spi;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
/**
* This implementation populates device management service.
*/
public interface DeviceTypeGeneratorService {
DeviceManagementService populateDeviceManagementService(String deviceTypeName
, DeviceTypeMetaDefinition deviceTypeMetaDefinition);
}

@ -133,10 +133,6 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>

@ -50,7 +50,6 @@ import org.wso2.carbon.device.mgt.core.status.task.impl.DeviceStatusTaskManagerS
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.extensions.device.type.template.HTTPDeviceTypeManagerService;
import java.util.Collections;
import java.util.HashMap;
@ -179,8 +178,12 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
}
DeviceTypeMetaDefinition deviceTypeMetaDefinition = deviceType.getDeviceTypeMetaDefinition();
if (deviceTypeMetaDefinition != null) {
HTTPDeviceTypeManagerService deviceTypeManagerService = new HTTPDeviceTypeManagerService
(type, deviceTypeMetaDefinition);
DeviceManagementService deviceTypeManagerService = DeviceManagementDataHolder.getInstance()
.getDeviceTypeGeneratorService().populateDeviceManagementService(type, deviceTypeMetaDefinition);
if (deviceTypeManagerService == null) {
log.error("Failing to retrieve the device type service for " + type);
return null;
}
addDeviceManagementProvider(deviceTypeManagerService);
deviceTypeIdentifier = new DeviceTypeServiceIdentifier(type, tenantId);
provider = providers.get(deviceTypeIdentifier);
@ -210,8 +213,12 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
provider.getDeviceManagementService()).getDeviceTypeMetaDefinition();
String cachedDefinition = gson.toJson(deviceTypeMetaDefinition);
if (!cachedDefinition.equals(dbStoredDefinition)) {
HTTPDeviceTypeManagerService deviceTypeManagerService = new HTTPDeviceTypeManagerService
(type, deviceTypeMetaDefinition);
DeviceManagementService deviceTypeManagerService = DeviceManagementDataHolder.getInstance()
.getDeviceTypeGeneratorService().populateDeviceManagementService(type, deviceTypeMetaDefinition);
if (deviceTypeManagerService == null) {
log.error("Failing to retrieve the device type service for " + type);
return null;
}
addDeviceManagementProvider(deviceTypeManagerService);
deviceTypeIdentifier = new DeviceTypeServiceIdentifier(type, tenantId);
provider = providers.get(deviceTypeIdentifier);

@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@ -65,6 +66,7 @@ public class DeviceManagementDataHolder {
private PushNotificationProviderRepository pushNotificationProviderRepository;
private DeviceTaskManagerService deviceTaskManagerService;
private DeviceStatusTaskManagerService deviceStatusTaskManagerService;
private DeviceTypeGeneratorService deviceTypeGeneratorService;
private Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<DeviceType, DeviceStatusTaskPluginConfig>());
@ -255,4 +257,13 @@ public class DeviceManagementDataHolder {
public void removeDeviceStatusTaskPluginConfig(DeviceType deviceType) {
this.deviceStatusTaskPluginConfigs.remove(deviceType);
}
public DeviceTypeGeneratorService getDeviceTypeGeneratorService() {
return deviceTypeGeneratorService;
}
public void setDeviceTypeGeneratorService(
DeviceTypeGeneratorService deviceTypeGeneratorService) {
this.deviceTypeGeneratorService = deviceTypeGeneratorService;
}
}

@ -30,6 +30,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagerProviderServiceImpl;
@ -105,6 +106,12 @@ import java.util.concurrent.TimeUnit;
* policy="dynamic"
* bind="setEmailSenderService"
* unbind="unsetEmailSenderService"
* @scr.reference name="device.type.generator.service"
* interface="org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService"
* cardinality="0..1"
* policy="dynamic"
* bind="setDeviceTypeGeneratorService"
* unbind="unsetDeviceTypeGeneratorService"
*/
public class DeviceManagementServiceComponent {
@ -304,7 +311,7 @@ public class DeviceManagementServiceComponent {
try {
if (log.isDebugEnabled()) {
log.debug("Setting Device Management Service Provider: '" +
deviceManagementService.getType() + "'");
deviceManagementService.getType() + "'");
}
synchronized (LOCK) {
deviceManagers.add(deviceManagementService);
@ -435,6 +442,30 @@ public class DeviceManagementServiceComponent {
}
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null);
}
/**
* sets DeviceTypeGeneratorService.
*
* @param deviceTypeGeneratorService An Instance of DeviceTypeGeneratorService
*/
protected void setDeviceTypeGeneratorService(DeviceTypeGeneratorService deviceTypeGeneratorService) {
if (log.isDebugEnabled()) {
log.debug("Un setting Device DeviceTypeGeneratorService");
}
DeviceManagementDataHolder.getInstance().setDeviceTypeGeneratorService(deviceTypeGeneratorService);
}
/**
* sets DeviceTypeGeneratorService.
*
* @param deviceTypeGeneratorService An Instance of DeviceTypeGeneratorService
*/
protected void unsetDeviceTypeGeneratorService(DeviceTypeGeneratorService deviceTypeGeneratorService) {
if (log.isDebugEnabled()) {
log.debug("Un setting Device DeviceTypeGeneratorService");
}
DeviceManagementDataHolder.getInstance().setDeviceTypeGeneratorService(null);
}
}

@ -110,6 +110,7 @@
org.wso2.carbon.registry.core.service,
org.wso2.carbon.utils.dbcreator,
org.wso2.carbon.utils.multitenancy,
org.osgi.framework
</Import-Package>
<DynamicImport-Package>org.wso2.carbon.device.mgt.extensions.pull.notification,
org.wso2.carbon.device.mgt.extensions.pull.notification.*</DynamicImport-Package>

@ -0,0 +1,14 @@
package org.wso2.carbon.device.mgt.extensions.device.type.template;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
public class DeviceTypeGeneratorServiceImpl implements DeviceTypeGeneratorService {
@Override
public DeviceManagementService populateDeviceManagementService(String deviceTypeName
, DeviceTypeMetaDefinition deviceTypeMetaDefinition) {
return new HTTPDeviceTypeManagerService(deviceTypeName, deviceTypeMetaDefinition);
}
}

@ -21,6 +21,8 @@ package org.wso2.carbon.device.mgt.extensions.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.extensions.device.type.template.DeviceTypeGeneratorServiceImpl;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.registry.core.service.RegistryService;
@ -45,6 +47,8 @@ public class DeviceTypeExtensionServiceComponent {
if (log.isDebugEnabled()) {
log.debug("Activating DeviceType Deployer Service Component");
}
ctx.getBundleContext().registerService(DeviceTypeGeneratorService.class, new DeviceTypeGeneratorServiceImpl()
, null);
}
protected void deactivate(ComponentContext ctx) {

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.72-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature</artifactId>
<packaging>pom</packaging>
<version>2.0.72-SNAPSHOT</version>
<name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name>
<url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>src/main/resources</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
<includes>
<include>build.properties</include>
<include>p2.inf</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>${carbon.p2.plugin.version}</version>
<executions>
<execution>
<id>p2-feature-generation</id>
<phase>package</phase>
<goals>
<goal>p2-feature-gen</goal>
</goals>
<configuration>
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</id>
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
<adviceFile>
<properties>
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.extensions.push.notification.provider.http:${carbon.device.mgt.version}
</bundleDef>
</bundles>
<importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}</importFeatureDef>
</importFeatures>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -37,6 +37,7 @@
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</module>
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature</module>
</modules>
</project>

@ -34,6 +34,7 @@
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider</Provider>
<!--<Provider>org.wso2.carbon.device.mgt.mobile.impl.ios.apns.APNSBasedPushNotificationProvider</Provider>-->
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider>
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider</Provider>
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider>
</PushNotificationProviders>
</PushNotificationConfiguration>

@ -1446,6 +1446,11 @@
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</artifactId>

Loading…
Cancel
Save