Coverage report

  %line %branch
org.apache.commons.jelly.tags.bsf.BSFExpressionFactory
0% 
0% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (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
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.bsf;
 17  
 
 18  
 import org.apache.commons.jelly.JellyException;
 19  
 import org.apache.commons.jelly.expression.Expression;
 20  
 import org.apache.commons.jelly.expression.ExpressionFactory;
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 
 24  
 import org.apache.bsf.BSFEngine;
 25  
 import org.apache.bsf.BSFException;
 26  
 import org.apache.bsf.BSFManager;
 27  
 
 28  
 /** Represents a factory of BSF expressions
 29  
   *
 30  
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 31  
   * @version $Revision: 1.6 $
 32  
   */
 33  
 public class BSFExpressionFactory implements ExpressionFactory {
 34  
 
 35  
     /** The logger of messages */
 36  0
     private Log log = LogFactory.getLog( getClass() );
 37  
 
 38  0
     private String language = "javascript";
 39  
     private BSFManager manager;
 40  
     private BSFEngine engine;
 41  0
     private JellyContextRegistry registry = new JellyContextRegistry();
 42  
 
 43  0
     public BSFExpressionFactory() {
 44  0
     }
 45  
 
 46  
     // Properties
 47  
     //-------------------------------------------------------------------------
 48  
 
 49  
     /** @return the BSF language to be used */
 50  
     public String getLanguage() {
 51  0
         return language;
 52  
     }
 53  
 
 54  
     public void setLanguage(String language) {
 55  0
         this.language = language;
 56  0
     }
 57  
 
 58  
     /** @return the BSF Engine to be used by this expression factory */
 59  
     public BSFEngine getBSFEngine() throws BSFException {
 60  0
         if ( engine == null ) {
 61  0
             engine = createBSFEngine();
 62  
         }
 63  0
         return engine;
 64  
     }
 65  
 
 66  
     public void setBSFEngine(BSFEngine engine) {
 67  0
         this.engine = engine;
 68  0
     }
 69  
 
 70  
     public BSFManager getBSFManager() {
 71  0
         if ( manager == null ) {
 72  0
             manager = createBSFManager();
 73  0
             manager.setObjectRegistry( registry );
 74  
         }
 75  0
         return manager;
 76  
     }
 77  
 
 78  
     public void setBSFManager(BSFManager manager) {
 79  0
         this.manager = manager;
 80  0
         manager.setObjectRegistry( registry );
 81  0
     }
 82  
 
 83  
     // ExpressionFactory interface
 84  
     //-------------------------------------------------------------------------
 85  
     public Expression createExpression(String text) throws JellyException {
 86  
         try {
 87  0
             return new BSFExpression( text, getBSFEngine(), getBSFManager(), registry );
 88  
         } catch (BSFException e) {
 89  0
             throw new JellyException("Could not obtain BSF engine",e);
 90  
         }
 91  
     }
 92  
 
 93  
     // Implementation methods
 94  
     //-------------------------------------------------------------------------
 95  
 
 96  
     /** Factory method */
 97  
     protected BSFEngine createBSFEngine() throws BSFException {
 98  0
         return getBSFManager().loadScriptingEngine( getLanguage() );
 99  
     }
 100  
 
 101  
     /** Factory method */
 102  
     protected BSFManager createBSFManager() {
 103  0
         BSFManager answer = new BSFManager();
 104  0
         return answer;
 105  
     }
 106  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.