|
From: <mol...@us...> - 2008-12-16 14:16:30
|
Revision: 957
http://openutils.svn.sourceforge.net/openutils/?rev=957&view=rev
Author: molaschi
Date: 2008-12-16 14:16:26 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
add openutils small notification manager lib
Added Paths:
-----------
trunk/openutils-notifications/
trunk/openutils-notifications/pom.xml
trunk/openutils-notifications/src/
trunk/openutils-notifications/src/main/
trunk/openutils-notifications/src/main/java/
trunk/openutils-notifications/src/main/java/net/
trunk/openutils-notifications/src/main/java/net/sourceforge/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/Notification.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/NotificationException.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/EmailNotification.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/FreemarkerEmailNotification.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/SmsNotification.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/EmailNotifier.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/FreemarkerEmailNotifier.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/Notifier.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/SMSNotifier.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/DefaultNotificationManagerImpl.java
trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/NotificationManager.java
trunk/openutils-notifications/src/main/resources/
trunk/openutils-notifications/src/test/
trunk/openutils-notifications/src/test/java/
trunk/openutils-notifications/src/test/resources/
Added: trunk/openutils-notifications/pom.xml
===================================================================
--- trunk/openutils-notifications/pom.xml (rev 0)
+++ trunk/openutils-notifications/pom.xml 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,47 @@
+<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>
+ <parent>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils</artifactId>
+ <version>10</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>openutils-notifications</artifactId>
+ <name>Openutils Notifications</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <description>openutils spring notification manager (plain text mails, freemarker mails, ...)</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.13</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.5.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/Notification.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/Notification.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/Notification.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,30 @@
+package net.sourceforge.openutils.notifications;
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public interface Notification
+{
+
+ /**
+ * Get the notifier bean
+ *
+ * @return notifier
+ */
+ String getNotifierBeanName();
+
+ /**
+ * Get message body
+ *
+ * @return message body
+ */
+ String getMessageBody() throws NotificationException;
+
+ /**
+ * Get message subject
+ *
+ * @return message subject
+ */
+ String getMessageSubject();
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/NotificationException.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/NotificationException.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/NotificationException.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,32 @@
+package net.sourceforge.openutils.notifications;
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public class NotificationException extends Exception
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public NotificationException(String arg0, Throwable arg1)
+ {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public NotificationException(Throwable arg0)
+ {
+ super(arg0);
+ }
+
+}
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/EmailNotification.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/EmailNotification.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/EmailNotification.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,35 @@
+package net.sourceforge.openutils.notifications.messages;
+
+import java.util.List;
+
+import javax.mail.internet.MimeBodyPart;
+
+import net.sourceforge.openutils.notifications.Notification;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public abstract class EmailNotification implements Notification
+{
+
+ /**
+ * Default property name for email sender
+ */
+ public static String DEFAULT_SENDER = "mail.defaultSender";
+
+ public static String BEAN_NAME = "emailNotifier";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final String getNotifierBeanName()
+ {
+ return BEAN_NAME;
+ }
+
+ public abstract List<MimeBodyPart> getAttachments();
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/FreemarkerEmailNotification.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/FreemarkerEmailNotification.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/FreemarkerEmailNotification.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,182 @@
+package net.sourceforge.openutils.notifications.messages;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.mail.internet.MimeBodyPart;
+
+import net.sourceforge.openutils.notifications.NotificationException;
+
+import org.apache.commons.lang.StringUtils;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.ext.beans.BeanModel;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import freemarker.template.TemplateMethodModelEx;
+import freemarker.template.TemplateModelException;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public abstract class FreemarkerEmailNotification extends EmailNotification
+{
+
+ private Configuration configuration;
+
+ private Map<String, Object> data;
+
+ protected String body;
+
+ public Locale getLocale()
+ {
+ return Locale.ENGLISH;
+ }
+
+ /**
+ * Sets the configuration.
+ * @param configuration the configuration to set
+ */
+ public void setConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getMessageBody() throws NotificationException
+ {
+ if (body == null)
+ {
+ if (data == null)
+ {
+ data = new HashMap<String, Object>();
+ }
+ for (Method m : this.getClass().getDeclaredMethods())
+ {
+ if ((m.getModifiers() & Method.PUBLIC) == Method.PUBLIC)
+ {
+ data.put(m.getName(), new ExecuteMethod(m, this));
+ }
+ }
+ String templateName = StringUtils.replace(this.getClass().getName(), ".", "/") + ".html";
+ data.put("this", this);
+ try
+ {
+ this.configuration.setTemplateLoader(new ClassTemplateLoader(this.getClass(), "/"));
+ Template t = this.configuration.getTemplate(templateName, getLocale());
+ StringWriter out = new StringWriter();
+ t.process(data, out);
+ body = out.toString();
+ }
+ catch (TemplateException e)
+ {
+ throw new NotificationException(e);
+ }
+ catch (IOException e)
+ {
+ throw new NotificationException(e);
+ }
+
+ }
+ return body;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public abstract String getMessageSubject();
+
+ public class ExecuteMethod implements TemplateMethodModelEx
+ {
+
+ private Method method;
+
+ private Object parent;
+
+ public ExecuteMethod(Method method, Object parent)
+ {
+ this.method = method;
+ this.parent = parent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object exec(List arguments) throws TemplateModelException
+ {
+ try
+ {
+ if (arguments == null || arguments.size() == 0)
+ {
+ return method.invoke(parent);
+ }
+ else
+ {
+ List unwrappedArgs = new ArrayList();
+ for (Object o : arguments)
+ {
+ unwrappedArgs.add(((BeanModel) o).getWrappedObject());
+ }
+
+ if (unwrappedArgs.size() == 1)
+ {
+ return method.invoke(parent, unwrappedArgs.iterator().next());
+
+ }
+ else
+ {
+ return method.invoke(parent, unwrappedArgs.toArray(new Object[unwrappedArgs.size()]));
+ }
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ throw new TemplateModelException(ex);
+ }
+ catch (IllegalArgumentException ex)
+ {
+ throw new TemplateModelException(ex);
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw new TemplateModelException(ex);
+ }
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<MimeBodyPart> getAttachments()
+ {
+ return null;
+ }
+
+ /**
+ * Sets the data.
+ * @param data the data to set
+ */
+ public void setData(Map<String, Object> data)
+ {
+ this.data = data;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/SmsNotification.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/SmsNotification.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/messages/SmsNotification.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,33 @@
+package net.sourceforge.openutils.notifications.messages;
+
+import net.sourceforge.openutils.notifications.Notification;
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public abstract class SmsNotification implements Notification
+{
+
+ public static String BEAN_NAME = "smsNotifier";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final String getNotifierBeanName()
+ {
+ return BEAN_NAME;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final String getMessageSubject()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/EmailNotifier.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/EmailNotifier.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/EmailNotifier.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,186 @@
+package net.sourceforge.openutils.notifications.notifiers;
+
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import net.sourceforge.openutils.notifications.Notification;
+import net.sourceforge.openutils.notifications.NotificationException;
+import net.sourceforge.openutils.notifications.messages.EmailNotification;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public class EmailNotifier implements Notifier
+{
+
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(EmailNotifier.class);
+
+ private String mailHost;
+
+ private String mailPort;
+
+ private boolean async = false;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean send(String from, List<String> toAddresses, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException
+ {
+ if (log.isDebugEnabled() && notification != null)
+ {
+ log.debug("Subject: {}", notification.getMessageSubject());
+ log.debug("Body: {}", notification.getMessageBody());
+ }
+
+ Properties props = new Properties(); // System.getProperties(); should I try to use the system properties ?
+ props.put("mail.smtp.host", this.mailHost);
+ props.put("mail.smtp.port", this.mailPort);
+
+ Session smtpSession = Session.getInstance(props);
+ MimeMessage message = new MimeMessage(smtpSession);
+
+ List<MimeBodyPart> attachments = ((EmailNotification) notification).getAttachments();
+ try
+ {
+ message.addFrom(new Address[]{new InternetAddress(from) });
+ message.setSubject(notification.getMessageSubject());
+ if (attachments == null || attachments.size() == 0)
+ {
+ message.setContent(notification.getMessageBody(), "text/html; charset=UTF-8");
+ }
+ else
+ {
+ MimeMultipart multiPart = new MimeMultipart();
+
+ MimeBodyPart text = new MimeBodyPart();
+ text.setContent(notification.getMessageBody(), "text/html; charset=UTF-8");
+
+ multiPart.addBodyPart(text);
+
+ for (MimeBodyPart mbp : attachments)
+ {
+ multiPart.addBodyPart(mbp);
+ }
+
+ message.setContent(multiPart);
+ }
+ }
+ catch (MessagingException ex)
+ {
+ throw new NotificationException(ex);
+ }
+
+ for (String to : toAddresses)
+ {
+ try
+ {
+ message.setRecipient(RecipientType.TO, new InternetAddress(to));
+
+ if (ccAddresses != null)
+ {
+ for (String address : ccAddresses)
+ {
+ if (StringUtils.isNotEmpty(address))
+ {
+ message.addRecipient(RecipientType.CC, new InternetAddress(address));
+ }
+ }
+ }
+ if (ccnAddresses != null)
+ {
+ for (String address : ccnAddresses)
+ {
+ if (StringUtils.isNotEmpty(address))
+ {
+ message.addRecipient(RecipientType.BCC, new InternetAddress(address));
+ }
+ }
+ }
+ Transport.send(message);
+ }
+ catch (MessagingException ex)
+ {
+ throw new NotificationException(ex);
+ }
+
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the mailHost.
+ * @return the mailHost
+ */
+ public String getMailHost()
+ {
+ return mailHost;
+ }
+
+ /**
+ * Sets the mailHost.
+ * @param mailHost the mailHost to set
+ */
+ public void setMailHost(String mailHost)
+ {
+ this.mailHost = mailHost;
+ }
+
+ /**
+ * Returns the mailPort.
+ * @return the mailPort
+ */
+ public String getMailPort()
+ {
+ return mailPort;
+ }
+
+ /**
+ * Sets the mailPort.
+ * @param mailPort the mailPort to set
+ */
+ public void setMailPort(String mailPort)
+ {
+ this.mailPort = mailPort;
+ }
+
+ /**
+ * Returns the async.
+ * @return the async
+ */
+ public boolean isAsync()
+ {
+ return async;
+ }
+
+ /**
+ * Sets the async.
+ * @param async the async to set
+ */
+ public void setAsync(boolean async)
+ {
+ this.async = async;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/FreemarkerEmailNotifier.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/FreemarkerEmailNotifier.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/FreemarkerEmailNotifier.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,56 @@
+package net.sourceforge.openutils.notifications.notifiers;
+
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.openutils.notifications.Notification;
+import net.sourceforge.openutils.notifications.NotificationException;
+import net.sourceforge.openutils.notifications.messages.FreemarkerEmailNotification;
+import freemarker.template.Configuration;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public class FreemarkerEmailNotifier extends EmailNotifier
+{
+
+ Configuration configuration;
+
+ Map<String, Object> data;
+
+ /**
+ * Sets the data.
+ * @param data the data to set
+ */
+ public void setData(Map<String, Object> data)
+ {
+ this.data = data;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean send(String from, List<String> toAddresses, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException
+ {
+ if (notification instanceof FreemarkerEmailNotification)
+ {
+ ((FreemarkerEmailNotification) notification).setConfiguration(configuration);
+ ((FreemarkerEmailNotification) notification).setData(data);
+ }
+ return super.send(from, toAddresses, ccAddresses, ccnAddresses, notification);
+ }
+
+ /**
+ * Sets the configuration.
+ * @param configuration the configuration to set
+ */
+ public void setConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/Notifier.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/Notifier.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/Notifier.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,27 @@
+package net.sourceforge.openutils.notifications.notifiers;
+
+import java.util.List;
+
+import net.sourceforge.openutils.notifications.Notification;
+import net.sourceforge.openutils.notifications.NotificationException;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public interface Notifier
+{
+
+ /**
+ * Send method
+ * @param from sender
+ * @param toAddresses list of receivers
+ * @param ccAddresses list of cc addresses
+ * @param ccnAddresses list of ccn addresses
+ * @param notification notification class
+ * @return true if send succeed
+ */
+ boolean send(String from, List<String> toAddresses, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException;
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/SMSNotifier.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/SMSNotifier.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/notifiers/SMSNotifier.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,194 @@
+package net.sourceforge.openutils.notifications.notifiers;
+
+import java.util.List;
+
+import net.sourceforge.openutils.notifications.Notification;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public class SMSNotifier implements Notifier
+{
+
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(SMSNotifier.class);
+
+ private String smsGateway;
+
+ private String userId;
+
+ private String password;
+
+ private String passwordProperty;
+
+ private String userIdProperty;
+
+ private String cellNumProperty;
+
+ private String textProperty;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean send(String from, List<String> toAddresses, List<String> ccAddress, List<String> ccnAddresses,
+ Notification notification)
+ {
+ String url = smsGateway;
+ if (url.indexOf("?") < 0)
+ {
+ url += "?";
+ }
+ else
+ {
+ url += "&";
+ }
+
+ for (String to : toAddresses)
+ {
+ /*
+ * GetMethod request = new GetMethod(smsGateway); request.setQueryString(new NameValuePair[]{ new
+ * NameValuePair(userIdProperty, userId), new NameValuePair(passwordProperty, password), new
+ * NameValuePair(cellNumProperty, to), new NameValuePair(textProperty, notification.getMessageBody()) });
+ * HttpClient client = new HttpClient(); try { client.executeMethod(request); } catch (HttpException ex) {
+ * log.error("Exception sending sms", ex); } catch (IOException ex) { log.error("Exception sending sms",
+ * ex); }
+ */
+ }
+ return true;
+ }
+
+ /**
+ * Returns the smsGateway.
+ * @return the smsGateway
+ */
+ public String getSmsGateway()
+ {
+ return smsGateway;
+ }
+
+ /**
+ * Sets the smsGateway.
+ * @param smsGateway the smsGateway to set
+ */
+ public void setSmsGateway(String smsGateway)
+ {
+ this.smsGateway = smsGateway;
+ }
+
+ /**
+ * Returns the userId.
+ * @return the userId
+ */
+ public String getUserId()
+ {
+ return userId;
+ }
+
+ /**
+ * Sets the userId.
+ * @param userId the userId to set
+ */
+ public void setUserId(String userId)
+ {
+ this.userId = userId;
+ }
+
+ /**
+ * Returns the password.
+ * @return the password
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Sets the password.
+ * @param password the password to set
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * Returns the passwordProperty.
+ * @return the passwordProperty
+ */
+ public String getPasswordProperty()
+ {
+ return passwordProperty;
+ }
+
+ /**
+ * Sets the passwordProperty.
+ * @param passwordProperty the passwordProperty to set
+ */
+ public void setPasswordProperty(String passwordProperty)
+ {
+ this.passwordProperty = passwordProperty;
+ }
+
+ /**
+ * Returns the userIdProperty.
+ * @return the userIdProperty
+ */
+ public String getUserIdProperty()
+ {
+ return userIdProperty;
+ }
+
+ /**
+ * Sets the userIdProperty.
+ * @param userIdProperty the userIdProperty to set
+ */
+ public void setUserIdProperty(String userIdProperty)
+ {
+ this.userIdProperty = userIdProperty;
+ }
+
+ /**
+ * Returns the cellNumProperty.
+ * @return the cellNumProperty
+ */
+ public String getCellNumProperty()
+ {
+ return cellNumProperty;
+ }
+
+ /**
+ * Sets the cellNumProperty.
+ * @param cellNumProperty the cellNumProperty to set
+ */
+ public void setCellNumProperty(String cellNumProperty)
+ {
+ this.cellNumProperty = cellNumProperty;
+ }
+
+ /**
+ * Returns the textProperty.
+ * @return the textProperty
+ */
+ public String getTextProperty()
+ {
+ return textProperty;
+ }
+
+ /**
+ * Sets the textProperty.
+ * @param textProperty the textProperty to set
+ */
+ public void setTextProperty(String textProperty)
+ {
+ this.textProperty = textProperty;
+ }
+
+}
\ No newline at end of file
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/DefaultNotificationManagerImpl.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/DefaultNotificationManagerImpl.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/DefaultNotificationManagerImpl.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,90 @@
+package net.sourceforge.openutils.notifications.services;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.openutils.notifications.Notification;
+import net.sourceforge.openutils.notifications.NotificationException;
+import net.sourceforge.openutils.notifications.notifiers.Notifier;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public class DefaultNotificationManagerImpl implements ApplicationContextAware, NotificationManager
+{
+
+ private ApplicationContext context;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
+ {
+ this.context = applicationContext;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, List<String> toAddresses, List<String> ccAddresses, Notification notification)
+ throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, toAddresses, ccAddresses, null, notification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, List<String> toAddresses, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, toAddresses, ccAddresses, ccnAddresses, notification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, String toAddress, List<String> ccAddresses, Notification notification)
+ throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, Arrays.asList(toAddress), ccAddresses, null, notification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, String toAddress, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, Arrays.asList(toAddress), ccAddresses, ccnAddresses, notification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, String toAddress, Notification notification) throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, Arrays.asList(toAddress), null, null, notification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean send(String from, List<String> toAddresses, Notification notification) throws NotificationException
+ {
+ Notifier notifier = (Notifier) context.getBean(notification.getNotifierBeanName());
+ return notifier.send(from, toAddresses, null, null, notification);
+ }
+}
Added: trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/NotificationManager.java
===================================================================
--- trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/NotificationManager.java (rev 0)
+++ trunk/openutils-notifications/src/main/java/net/sourceforge/openutils/notifications/services/NotificationManager.java 2008-12-16 14:16:26 UTC (rev 957)
@@ -0,0 +1,86 @@
+package net.sourceforge.openutils.notifications.services;
+
+import java.util.List;
+
+import net.sourceforge.openutils.notifications.Notification;
+import net.sourceforge.openutils.notifications.NotificationException;
+
+
+/**
+ * @author molaschi
+ * @version $Id: $
+ */
+public interface NotificationManager
+{
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddresses list of receivers
+ * @param ccAddresses list of cc
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, List<String> toAddresses, List<String> ccAddresses, Notification notification)
+ throws NotificationException;
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddresses list of receivers
+ * @param ccAddresses list of cc
+ * @param ccnAddresses list of ccn
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, List<String> toAddresses, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException;
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddress receiver
+ * @param ccAddresses list of cc
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, String toAddress, List<String> ccAddresses, Notification notification)
+ throws NotificationException;
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddress receiver
+ * @param ccAddresses list of cc
+ * @param ccnAddresses list of ccn
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, String toAddress, List<String> ccAddresses, List<String> ccnAddresses,
+ Notification notification) throws NotificationException;
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddress receiver
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, String toAddress, Notification notification) throws NotificationException;
+
+ /**
+ * Send notification
+ * @param from sender
+ * @param toAddresses list of receivers
+ * @param notification notification
+ * @param <T> Class that extends Notification interface
+ * @return true if mail is sent
+ */
+ boolean send(String from, List<String> toAddresses, Notification notification) throws NotificationException;
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|