sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Help
HEAD
Rev: 53043 - http://anonsvn.icesoft.org/repo / icenotify / tags / vras-1.3.1 / icenotify / cloud / src / main / java / org / icesoft / notify / cloud / core / email / EmailNotificationProvider.java
Unified Diff View - EmailNotificationProvider.java
/icenotify/tags/vras-1.3.1/icenotify/cloud/src/main/java/org/icesoft/notify/cloud/core/email/EmailNotificationProvider.java @ revision 53042
/icenotify/tags/vras-1.3.1/icenotify/cloud/src/main/java/org/icesoft/notify/cloud/core/email/EmailNotificationProvider.java @ revision 53043
@@ -70,11 +70,13 @@ import org.icesoft.notify.cloud.core.CloudNotificationEndpoint; import org.icesoft.notify.cloud.core.NotificationEvent; import org.icesoft.notify.cloud.core.NotificationProvider; +import org.icesoft.notify.cloud.core.NotificationProviderBlockingQueueListener; import org.icesoft.util.Configuration; import org.icesoft.util.NameValuePair; import org.icesoft.util.SystemConfiguration; import org.icesoft.util.SystemEnvironmentConfiguration; import org.icesoft.util.ThreadFactory; +import org.icesoft.util.concurrent.BlockingQueueActivityReporter; import org.icesoft.util.servlet.ServletContextConfiguration; public class EmailNotificationProvider @@ -157,12 +159,12 @@     }     private final Set<ScheduledFuture<?>> notificationConsumerSet = new HashSet<ScheduledFuture<?>>(); -    private final BlockingQueue<EmailNotification> notificationQueue = new DelayQueue<EmailNotification>();     private final ScheduledThreadPoolExecutor executor;     private final InternetAddress from;     private final String host;     private final int maxConnections; +    private final BlockingQueue<EmailNotification> notificationQueue;     private final String password;     private final int port;     private final String scheme; @@ -195,6 +197,13 @@                     ")"             );         } +        this.servletContext = +            // throws NullPointerException +            checkIfIsNotNull( +                servletContext, +                "Illegal argument servletContext: '" + servletContext + "'. " + +                    "Argument cannot be null." +            );         if (isNotNullAndIsNotEmpty(personal)) {             try {                 this.from = new InternetAddress(from, personal); @@ -267,6 +276,11 @@             _properties.setProperty("mail.smtps.socketFactory.fallback", "false");         }         session = Session.getInstance(_properties); +        this.notificationQueue = +            new BlockingQueueActivityReporter<EmailNotification>( +                new DelayQueue<EmailNotification>() +            ). +            withListener(new NotificationProviderBlockingQueueListener(getName(), getServletContext()));         this.maxConnections =             // throws IllegalArgumentException             checkIfIsGreaterThan( @@ -275,13 +289,6 @@                 "Illegal argument maxConnections: '" + maxConnections + "'. " +                     "Argument cannot be lesser than or equal to 0."             ); -        this.servletContext = -            // throws NullPointerException -            checkIfIsNotNull( -                servletContext, -                "Illegal argument servletContext: '" + servletContext + "'. " + -                    "Argument cannot be null." -            );         this.executor =             new ScheduledThreadPoolExecutor(                 maxConnections + 2, new ThreadFactory("APNS Notification Provider Thread", true) @@ -352,6 +359,14 @@         final Map<Category, Map<String, Object>> categoryToPropertyMap,         final Set<CloudNotificationEndpoint> cloudNotificationEndpointSet) { +        if (LOGGER.isLoggable(Level.FINE)) { +            LOGGER.log( +                Level.FINE, +                "Sending E-mail Notification with " + +                    "Properties '" + categoryToPropertyMap + "' to " + +                    "Cloud Notification Endpoints '" + cloudNotificationEndpointSet + "'." +            ); +        }         EmailNotification _notification = constructNotification(categoryToPropertyMap, cloudNotificationEndpointSet);         if (isNotNull(_notification)) {             try { @@ -361,9 +376,8 @@                 if (LOGGER.isLoggable(Level.FINE)) {                     LOGGER.log(                         Level.FINE, -                        "Successfully put E-mail Notification on the queue with " + -                            "Properties '" + categoryToPropertyMap + "' to " + -                            "Cloud Notification Endpoints '" + _notification.getNotifyBackURIList() + "'." +                        "Successfully put E-mail Notification '" + _notification + " onto the Queue. " + +                            "(Queue size: '" + getModifiableNotificationQueue().size() + "')"                     );                 }             } catch (final InterruptedException exception) {


feed icon

sventon 2.5.1