Commit afb26086 authored by Christophe Demarey's avatar Christophe Demarey
Browse files

Move communication code in a separate module.

parent b03e6b40
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<modelVersion>4.0.0</modelVersion>
<name>Home Automation Demonstration Orange Communication module</name>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-comm-orange</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- ===== -->
<!-- Build -->
<!-- ===== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- ============= -->
<!-- Properties -->
<!-- ============= -->
<properties>
</properties>
<!-- ============ -->
<!-- Dependencies -->
<!-- ============ -->
<dependencies>
<dependency>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/***
* OW2 FraSCAti: Home Automation demonstration
* Copyright (C) 2010 INRIA, IRISA, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Grégory Nain, Mahmoud Ben Hassine
*
* Contributor(s): Christophe Demarey
*/
package org.ow2.frascati.demo.homeautomation.comm;
/**
* Communication service using Orange API
*
* @author Mahmoud Ben Hassine
* @version 1.0
*
*/
public interface OrangeService {
/**
* Send a short message to a phone number
* @param number the phone number to send the short message to
* @param sms the short message to send
*/
void sendSMS(String number,String sms);
}
\ No newline at end of file
/***
* OW2 FraSCAti: Home Automation demonstration
* Copyright (C) 2010 INRIA, IRISA, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author(s): Grégory Nain, Mahmoud Ben Hassine
*
* Contributor(s): Christophe Demarey
*/
package org.ow2.frascati.demo.homeautomation.comm;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ow2.frascati.demo.homeautomation.api.SkypeService;
/**
* Implementation of {@link org.ow2.frascati.demo.homeautomation.api.OrangeService} interface
*
* @author Mahmoud Ben Hassine
* @version 1.0
*
*/
public class OrangeServiceImpl implements OrangeService {
public OrangeServiceImpl() {
}
@Override
public void sendSMS(String number, String sms) {
// TODO add orange implementation
Logger.getLogger(SkypeService.class.getName()).log(Level.INFO," [Communication service] sms '" + sms + "' sent to " + number + " using Orange API");
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<modelVersion>4.0.0</modelVersion>
<name>Home Automation Demonstration Skype Communication Mock module</name>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-comm-skype-mock</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- ===== -->
<!-- Build -->
<!-- ===== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- ============= -->
<!-- Properties -->
<!-- ============= -->
<properties>
</properties>
<!-- ============ -->
<!-- Dependencies -->
<!-- ============ -->
<dependencies>
<dependency>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......@@ -23,22 +23,22 @@
* Contributor(s):
*/
package org.ow2.frascati.demo.homeautomation.lib;
package org.ow2.frascati.demo.homeautomation.comm;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.skype.SkypeException;
import org.ow2.frascati.demo.homeautomation.api.CommunicationService;
import org.ow2.frascati.demo.homeautomation.api.SkypeService;
/**
* Mock implementation of {@link CommunicationService} interface
* Mock implementation of {@link org.ow2.frascati.demo.homeautomation.api.SkypeService} interface
*
* @author Mahmoud Ben Hassine
*
*/
public class CommunicationServiceMockImpl implements CommunicationService {
public class SkypeMockServiceImpl implements SkypeService {
@Override
public void call(String skypeId) throws SkypeException {
......@@ -52,13 +52,8 @@ public class CommunicationServiceMockImpl implements CommunicationService {
}
@Override
public void sendSMS(String number, String sms) {
}
@Override
public void sendSkypeSMS(String number, String sms) throws SkypeException {
Logger.getLogger(CommunicationService.class.getName()).log(Level.INFO," [Communication mock service] sms '" + sms + "' sent to " + number + " using skype API");
public void sendSMS(String number, String sms) throws SkypeException {
Logger.getLogger(SkypeService.class.getName()).log(Level.INFO," [Communication mock service] sms '" + sms + "' sent to " + number + " using skype API");
}
}
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="home-automation">
<component name="skypeCommunicationMockComponent">
<implementation.java class="org.ow2.frascati.demo.homeautomation.comm.SkypeMockServiceImpl"/>
<service name="skypeCommunicationMockService" requires="qos">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.SkypeService"/>
</service>
</component>
<wire source="Mediator/communicationService" target="skypeCommunicationMockComponent/skypeCommunicationMockService"/>
</composite>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<modelVersion>4.0.0</modelVersion>
<name>Home Automation Demonstration Skype Communication module</name>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-comm-skype</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- ===== -->
<!-- Build -->
<!-- ===== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- ============= -->
<!-- Properties -->
<!-- ============= -->
<properties>
</properties>
<!-- ============ -->
<!-- Dependencies -->
<!-- ============ -->
<dependencies>
<dependency>
<groupId>org.ow2.frascati.demo</groupId>
<artifactId>home-automation-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>tmp.demo.homeautomation</groupId>
<artifactId>skype</artifactId>
</dependency>
</dependencies>
</project>
......@@ -23,7 +23,7 @@
* Contributor(s):
*/
package org.ow2.frascati.demo.homeautomation.lib;
package org.ow2.frascati.demo.homeautomation.comm;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -31,18 +31,18 @@ import java.util.logging.Logger;
import com.skype.SkypeException;
import com.skype.Skype;
import org.ow2.frascati.demo.homeautomation.api.CommunicationService;
import org.ow2.frascati.demo.homeautomation.api.SkypeService;
/**
* Implementation of {@link CommunicationService} interface
* Implementation of {@link org.ow2.frascati.demo.homeautomation.api.SkypeService} interface
*
* @author Mahmoud Ben Hassine
* @version 1.0
*
*/
public class CommunicationServiceImpl implements CommunicationService {
public class SkypeServiceImpl implements SkypeService {
public CommunicationServiceImpl() {
public SkypeServiceImpl() {
}
@Override
......@@ -57,18 +57,9 @@ public class CommunicationServiceImpl implements CommunicationService {
}
@Override
public void sendSkypeSMS(String number, String sms) throws SkypeException {
public void sendSMS(String number, String sms) throws SkypeException {
Skype.sendSMS(number, sms);
Logger.getLogger(CommunicationService.class.getName()).log(Level.INFO," [Communication service] sms '" + sms + "' sent to " + number + " using Skype API");
Logger.getLogger(SkypeService.class.getName()).log(Level.INFO," [Communication service] sms '" + sms + "' sent to " + number + " using Skype API");
}
@Override
public void sendSMS(String number, String sms) {
// TODO add orange implementation
Logger.getLogger(CommunicationService.class.getName()).log(Level.INFO," [Communication service] sms '" + sms + "' sent to " + number + " using Orange API");
}
}
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="home-automation">
<component name="skypeCommunicationComponent">
<implementation.java class="org.ow2.frascati.demo.homeautomation.comm.SkypeServiceImpl"/>
<service name="skypeCommunicationService" requires="qos">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.SkypeService"/>
</service>
</component>
<wire source="Mediator/communicationService" target="skypeCommunicationComponent/skypeCommunicationService"/>
</composite>
\ No newline at end of file
......@@ -189,7 +189,6 @@
<dependency>
<groupId>tmp.demo.homeautomation</groupId>
<artifactId>skype</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>tmp.demo.homeautomation</groupId>
......
......@@ -41,7 +41,7 @@ import com.google.gdata.util.ServiceException;
* @version 1.0
*/
public interface GoogleService {
public interface GcalService {
//Calendar related services
......
......@@ -81,7 +81,7 @@ public interface IMediator {
public void switchLightOFF(String lightId);
/**
* Send a short message using {@link CommunicationService}
* Send a short message using {@link SkypeService}
* @param number the phone number to send the message to
* @param sms the short message to send
*/
......
......@@ -20,50 +20,38 @@
*
* Author(s): Grégory Nain, Mahmoud Ben Hassine
*
* Contributor(s):
* Contributor(s): Christophe Demarey
*/
package org.ow2.frascati.demo.homeautomation.api;
import com.skype.SkypeException;
/**
* Communication service
* Communication service using Skype API
*
* @author Mahmoud Ben Hassine
* @version 1.0
*
*/
public interface CommunicationService {
//Orange services
/**
* Send a short message to a phone number
* @param number the phone number to send the short message to
* @param sms the short message to send
*/
void sendSMS(String number,String sms);
// Skype services
/**
* Send a chat message to a skype user
* @param skypeId the user identifier
* @param message the chat message to send
*/
void sendChatMessage(String skypeId,String message) throws SkypeException;
/**
* Send a short message to a phone number using the skype4java API
* @param number the phone number to send the short message to
* @param sms the short message to send
*/
void sendSkypeSMS(String number,String sms) throws SkypeException;
/**
* call a skype user
* @param skypeId the user identifier
*/
void call(String skypeId) throws SkypeException;
public interface SkypeService {
/**
* Send a chat message to a skype user
* @param skypeId the user identifier
* @param message the chat message to send
*/
void sendChatMessage(String skypeId,String message) throws SkypeException;
/**
* Send a short message to a phone number using the skype4java API
* @param number the phone number to send the short message to
* @param sms the short message to send
*/
void sendSMS(String number,String sms) throws SkypeException;
/**
* call a skype user
* @param skypeId the user identifier
*/
void call(String skypeId) throws SkypeException;
}
......@@ -44,7 +44,7 @@ import com.google.gdata.util.ServiceException;
import com.skype.SkypeException;
import org.ow2.frascati.demo.homeautomation.api.AccessCodeService;
import org.ow2.frascati.demo.homeautomation.api.CommunicationService;
import org.ow2.frascati.demo.homeautomation.api.SkypeService;
import org.ow2.frascati.demo.homeautomation.api.GUIService;
import org.ow2.frascati.demo.homeautomation.api.GcalService;
import org.ow2.frascati.demo.homeautomation.api.IMediator;
......@@ -83,7 +83,7 @@ public class Mediator implements IMediator {
private TTSService ttsService;
@Reference
private CommunicationService communicationService;
private SkypeService communicationService;
@Reference
private KnxService knxService;
......@@ -165,7 +165,7 @@ public class Mediator implements IMediator {
public void sendSMS(String number,String sms){
try {
communicationService.sendSkypeSMS(number, sms);
communicationService.sendSMS(number, sms);
} catch (SkypeException e) {
Logger.getLogger(Mediator.class.getName()).log(Level.WARNING," [ Mediator ] skype exception for communication service");
}
......
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="communication">
<component name="communicationComponent">
<implementation.java class="org.ow2.frascati.demo.homeautomation.lib.CommunicationServiceImpl"/>
<service name="communicationService" requires="qos">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.CommunicationService"/>
</service>
</component>
<component name="communicationMockComponent">
<implementation.java class="org.ow2.frascati.demo.homeautomation.lib.CommunicationServiceMockImpl"/>
<service name="communicationMockService" requires="qos">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.CommunicationService"/>
</service>
</component>
</composite>
\ No newline at end of file
......@@ -6,12 +6,11 @@
<include name="map"/>
<include name="tts"/>
<include name="weather"/>
<include name="communication"/>
<include name="gui"/>
<include name="patientDAO"/>
<include name="accesscode"/>
<include name="sunspot"/>
<component name="Mediator">
<property name="mode">no-tts</property>
......@@ -19,7 +18,7 @@
<implementation.java class="org.ow2.frascati.demo.homeautomation.lib.Mediator"/>
<service name="mediatorService">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.IMediator"/>
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.IMediator"/>
</service>
<reference name="guiService" target="userUIComponent/GUIService">
......@@ -34,8 +33,8 @@
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.TTSService"/>
</reference>
<reference name="communicationService" target="communicationMockComponent/communicationMockService">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.CommunicationService"/>
<reference name="communicationService">
<interface.java interface="org.ow2.frascati.demo.homeautomation.api.SkypeService"/>
</reference>
<reference name="calendarService">
......