Coverage Report - org.equanda.tapestry5.services.EquandaModule
 
Classes in this File Line Coverage Branch Coverage Complexity
EquandaModule
0%
0/18
N/A
0
EquandaModule$1
0%
0/3
N/A
0
 
 1  
 /**
 2  
  * This file is part of the equanda project.
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 7  
  *
 8  
  * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
 9  
  * ANY KIND, either express or implied. See the License for the specific language governing rights and
 10  
  * limitations under the License.
 11  
  *
 12  
  * Alternatively, the contents of this file may be used under the terms of
 13  
  * either the GNU General Public License Version 2 or later (the "GPL"), or
 14  
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 15  
  * in which case the provisions of the GPL or the LGPL are applicable instead
 16  
  * of those above. If you wish to allow use of your version of this file only
 17  
  * under the terms of either the GPL or the LGPL, and not to allow others to
 18  
  * use your version of this file under the terms of the MPL, indicate your
 19  
  * decision by deleting the provisions above and replace them with the notice
 20  
  * and other provisions required by the GPL or the LGPL. If you do not delete
 21  
  * the provisions above, a recipient may use your version of this file under
 22  
  * the terms of any one of the MPL, the GPL or the LGPL.
 23  
  */
 24  
 
 25  
 package org.equanda.tapestry5.services;
 26  
 
 27  
 import org.apache.tapestry5.Translator;
 28  
 import org.apache.tapestry5.ioc.Configuration;
 29  
 import org.apache.tapestry5.ioc.MappedConfiguration;
 30  
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 31  
 import org.apache.tapestry5.ioc.annotations.InjectService;
 32  
 import org.apache.tapestry5.services.*;
 33  
 import org.equanda.tapestry5.bindings.ManifestBindingPrefixFactory;
 34  
 import org.equanda.tapestry5.translators.BooleanTranslator;
 35  
 import org.equanda.tapestry5.translators.DoubleTranslator;
 36  
 import org.equanda.tapestry5.translators.TimestampTranslator;
 37  
 
 38  
 import java.io.IOException;
 39  
 
 40  
 /**
 41  
  * Module definition
 42  
  *
 43  
  * @author <a href="mailto:joachim@progs.be">Joachim Van der Auwera</a>
 44  
  */
 45  0
 public class EquandaModule
 46  
 {
 47  
     // bind(MyServiceInterface.class, MyServiceImpl.class).scope("perthread");
 48  
     public static void contributeComponentClassResolver( Configuration<LibraryMapping> configuration )
 49  
     {
 50  0
         configuration.add( new LibraryMapping( "equanda", "org.equanda.tapestry5" ) );
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Contributes the following translators: <ul> <li>Double : which allows both both and comma as decimal
 55  
      * seperator</li> <li>Timestamp : translator for timestamp values</li> <li>Boolean : for boolean values</li> </ul>
 56  
      *
 57  
      * @param configuration configuration to add to
 58  
      */
 59  
     
 60  
     public static void contributeTranslatorSource( MappedConfiguration<String, Translator> configuration )
 61  
     {
 62  0
         configuration.add( "double", new DoubleTranslator() );
 63  0
         configuration.add( "timestamp", new TimestampTranslator() );
 64  0
         configuration.add( "boolean", new BooleanTranslator() );
 65  0
     }
 66  
 
 67  
 
 68  
     public static void contributeFactoryDefaults( MappedConfiguration<String, String> configuration )
 69  
     {
 70  0
         configuration.add( "equanda.truncate.default.length", "30" );
 71  0
         configuration.add( "equanda.truncate.default.suffix", "..." );
 72  0
         configuration.add( "equanda.inlinelinklist.additional.row.count", "5" );
 73  0
         configuration.add( "equanda.inlineprimitivelist.additional.row.count", "5" );
 74  0
         configuration.add( "equanda.select.rows.per.page", "25" );
 75  0
     }
 76  
 
 77  
     public RequestFilter buildUtf8Filter(
 78  
         @InjectService( "RequestGlobals" ) final RequestGlobals requestGlobals )
 79  
     {
 80  0
         return new RequestFilter()
 81  
         {
 82  0
             public boolean service( Request request, Response response, RequestHandler handler )
 83  
                 throws IOException
 84  
             {
 85  0
                 requestGlobals.getHTTPServletRequest().setCharacterEncoding( "UTF-8" );
 86  0
                 return handler.service( request, response );
 87  
             }
 88  
         };
 89  
     }
 90  
 
 91  
     public void contributeRequestHandler( OrderedConfiguration<RequestFilter> configuration,
 92  
                                           @InjectService( "Utf8Filter" ) final RequestFilter utf8Filter )
 93  
     {
 94  0
         configuration.add( "Utf8Filter", utf8Filter ); // handle UTF-8
 95  0
     }
 96  
 
 97  
     /**
 98  
      * Contributes the factory for equanda binding prefixes
 99  
      *
 100  
      * @param configuration configuration to add to
 101  
      */
 102  
     public static void contributeBindingSource( MappedConfiguration<String, BindingFactory> configuration )
 103  
     {
 104  0
         configuration.add( "manifest", new ManifestBindingPrefixFactory() );
 105  0
     }
 106  
 
 107  
 }