Coverage Report - org.jtheque.core.spring.factory.ActivableManagerFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
ActivableManagerFactoryBean
0 %
0/8
0 %
0/2
1.667
 
 1  
 package org.jtheque.core.spring.factory;
 2  
 
 3  
 import org.apache.commons.logging.LogFactory;
 4  
 import org.jtheque.core.managers.ActivableManager;
 5  
 import org.springframework.beans.factory.config.AbstractFactoryBean;
 6  
 
 7  
 import java.lang.reflect.Proxy;
 8  
 
 9  
 /*
 10  
  * This file is part of JTheque.
 11  
  *
 12  
  * JTheque is free software: you can redistribute it and/or modify
 13  
  * it under the terms of the GNU General Public License as published by
 14  
  * the Free Software Foundation, either version 3 of the License.
 15  
  *
 16  
  * JTheque is distributed in the hope that it will be useful,
 17  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 19  
  * GNU General Public License for more details.
 20  
  *
 21  
  * You should have received a copy of the GNU General Public License
 22  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 23  
  */
 24  
 
 25  
 /**
 26  
  * A factory bean for activable managers.
 27  
  *
 28  
  * @author Baptiste Wicht
 29  
  */
 30  0
 public final class ActivableManagerFactoryBean extends AbstractFactoryBean {
 31  
     private ActivableManager manager;
 32  
 
 33  
     /**
 34  
      * Set the manager to factor.
 35  
      *
 36  
      * @param manager The activable manager to factor.
 37  
      */
 38  
     public void setManager(ActivableManager manager) {
 39  0
         this.manager = manager;
 40  0
     }
 41  
 
 42  
     @Override
 43  
     public Class<?> getObjectType() {
 44  0
         if (manager == null) { //Property not already set by Spring
 45  0
             LogFactory.getLog(getClass()).error("Manager is null");
 46  
 
 47  0
             return null;
 48  
         }
 49  
 
 50  0
         return manager.getClass();
 51  
     }
 52  
 
 53  
     @Override
 54  
     protected Object createInstance() {
 55  0
         return Proxy.newProxyInstance(
 56  
                 ClassLoader.getSystemClassLoader(),
 57  
                 manager.getClass().getInterfaces(),
 58  
                 new ActivableManagerHandler(manager));
 59  
     }
 60  
 }