2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.examples.mailreaderjpa.Domains
 
Classes in this File Line Coverage Branch Coverage Complexity
Domains
0%
0/20
0%
0/1
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.shale.examples.mailreaderjpa;
 19  
 
 20  
 import java.util.ArrayList;
 21  
 import java.util.List;
 22  
 import javax.faces.model.SelectItem;
 23  
 import org.apache.mailreaderjpa.Protocol;
 24  
 import org.apache.mailreaderjpa.Subscription;
 25  
 import org.apache.mailreaderjpa.User;
 26  
 import org.apache.shale.view.AbstractApplicationBean;
 27  
 
 28  
 /**
 29  
  * <p>Application scope bean containing cached domain lists and other
 30  
  * application wide information.  In addition, it includes code to bootstrap
 31  
  * the database contents if this is the very first time that newly created
 32  
  * database tables are accessed.</p>
 33  
  */
 34  0
 public class Domains extends AbstractApplicationBean {
 35  
 
 36  
 
 37  
     // ------------------------------------------------------- Public Properties
 38  
 
 39  
 
 40  
     /**
 41  
      * <p>The business {@link Logic} for this application.  This value
 42  
      * will be injected, based on the managed bean configuration.</p>
 43  
      */
 44  0
     private Logic logic = null;
 45  
 
 46  
 
 47  
     /**
 48  
      * <p>Return the business {@link Logic} for this application.</p>
 49  
      */
 50  
     public Logic getLogic() {
 51  0
         return this.logic;
 52  
     }
 53  
 
 54  
 
 55  
     /**
 56  
      * <p>Set the business {@link Logic} for this application.</p>
 57  
      *
 58  
      * @param logic The new business logic instance
 59  
      */
 60  
     public void setLogic(Logic logic) {
 61  0
         this.logic = logic;
 62  0
     }
 63  
 
 64  
 
 65  
     /**
 66  
      * <p>The array of <code>SelectItem</code> instances identifying the valid
 67  
      * mail protocols for this application.</p>
 68  
      */
 69  
     private SelectItem[] protocols;
 70  
 
 71  
 
 72  
     /**
 73  
      * <p>Return an array of select items for valid protocols.</p>
 74  
      */
 75  
     public SelectItem[] getProtocols() {
 76  
 
 77  0
         return this.protocols;
 78  
 
 79  
     }
 80  
 
 81  
 
 82  
     // -------------------------------------------------------- Lifecycle Events
 83  
 
 84  
 
 85  
     /**
 86  
      * <p>Initialize the <code>profiles</codes> list from the database.  If
 87  
      * necessary, bootstrap the database content if it is completely empty.</p>
 88  
      */
 89  
     public void init() {
 90  
 
 91  0
         log("Caching application wide static data");
 92  
         try {
 93  
 
 94  
             // Ensure that the database content has been bootstrapped
 95  0
             getLogic().bootstrap();
 96  
 
 97  
             // Assemble the value of the "protocols" array
 98  0
             List<Protocol> items = getLogic().getProtocols();
 99  0
             protocols = new SelectItem[items.size()];
 100  0
             int n = 0;
 101  0
             for (Protocol item : items) {
 102  0
                 protocols[n++] = new SelectItem(item, item.getDescription());
 103  0
             }
 104  
 
 105  0
         } catch (Exception e) {
 106  
 
 107  0
             log("Exception acquiring domain data", e);
 108  0
             error("Exception acquiring domain data: " + e);
 109  0
             getFacesContext().responseComplete();
 110  
 
 111  0
         }
 112  
 
 113  
 
 114  0
     }
 115  
 
 116  
 
 117  
 }