Coverage Report - net.admin4j.ui.filters.BaseNotificationFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseNotificationFilter
66%
8/12
50%
1/2
5
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  * 
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  * 
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.ui.filters;
 15  
 
 16  
 import javax.servlet.Filter;
 17  
 import javax.servlet.FilterConfig;
 18  
 import javax.servlet.ServletException;
 19  
 
 20  
 import net.admin4j.config.Admin4JConfiguration;
 21  
 import net.admin4j.util.Admin4jRuntimeException;
 22  
 import net.admin4j.util.notify.Notifier;
 23  
 import net.admin4j.util.notify.NotifierUtils;
 24  
 
 25  
 
 26  
 /**
 27  
  * Base filter that accepts a configured notifier.
 28  
  * 
 29  
  * <p>Init parameters for this filter are as follows:</p>
 30  
  * <li>notifier -- Required.  Handles admin notification.  See documentation for the Notifier you're using
 31  
  * for any additional configuration requirements.  For example, 'net.admin4j.util.notify.EmailNotifier'.</li>
 32  
  * 
 33  
  * @author D. Ashmore
 34  
  * @since 1.0
 35  
  */
 36  33
 public abstract class BaseNotificationFilter extends BaseFilter implements Filter {
 37  
 
 38  
     protected Notifier notifier;
 39  
     public void init(FilterConfig config) throws ServletException {
 40  
         try {
 41  24
             new Admin4JConfiguration();
 42  24
             String notifierClassName = config.getInitParameter("notifier");
 43  
             
 44  24
             this.notifier = NotifierUtils.configure(config, notifierClassName);
 45  24
             if (this.notifier == null) {
 46  0
                 throw new Admin4jRuntimeException("Neither default notifier provided nor notifier parameter for Filter specified.");
 47  
             }
 48  
             
 49  0
         } catch (Throwable e) {
 50  0
             logger.error("Error in boot sequence", e);
 51  0
             throw new ServletException(e);
 52  24
         } 
 53  
         
 54  24
         Admin4JStandardFilterChain.registerFilter(this);
 55  
     
 56  24
     }
 57  
 
 58  
 }