Coverage Report - org.mule.module.ibeans.config.IBeanHolder
 
Classes in this File Line Coverage Branch Coverage Complexity
IBeanHolder
0%
0/17
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: IBeanHolder.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 package org.mule.module.ibeans.config;
 11  
 
 12  
 import org.mule.api.MuleContext;
 13  
 import org.mule.api.MuleException;
 14  
 import org.mule.api.construct.FlowConstruct;
 15  
 import org.mule.module.ibeans.spi.MuleIBeansPlugin;
 16  
 
 17  
 import org.ibeans.impl.IBeansNotationHelper;
 18  
 import org.ibeans.impl.view.TextView;
 19  
 
 20  
 /**
 21  
  * Holds a reference to an iBeans class in the registry. An iBean instance can be created from this object as well as reporting
 22  
  * its usage and short ID.
 23  
  */
 24  
 public class IBeanHolder implements Comparable
 25  
 {
 26  
     private Class ibean;
 27  
     private String usage;
 28  
 
 29  
     public IBeanHolder(Class ibean)
 30  0
     {
 31  0
         this.ibean = ibean;
 32  0
     }
 33  
 
 34  
     public int compareTo(Object o)
 35  
     {
 36  0
         IBeanHolder to = (IBeanHolder) o;
 37  0
         return getId().compareTo(to.getId());
 38  
     }
 39  
 
 40  
     public Class getIbeanClass()
 41  
     {
 42  0
         return ibean;
 43  
     }
 44  
 
 45  
     public Object create(MuleContext context, MuleIBeansPlugin plugin) throws MuleException
 46  
     {
 47  0
         IBeanFlowConstruct flow = new IBeanFlowConstruct(ibean.getSimpleName() + "." + System.identityHashCode(this), context);
 48  0
         context.getRegistry().registerObject(flow.getName(), flow, FlowConstruct.class);
 49  
 
 50  0
         IBeanBinding router = new IBeanBinding(flow, plugin);
 51  0
         router.setInterface(ibean);
 52  0
         return router.createProxy(new Object());
 53  
     }
 54  
 
 55  
     public String getId()
 56  
     {
 57  0
         return IBeansNotationHelper.getIBeanShortID(ibean);
 58  
     }
 59  
 
 60  
     public String getUsage()
 61  
     {
 62  0
         if (usage == null)
 63  
         {
 64  0
             TextView view = new TextView();
 65  0
             usage = view.createView(ibean);
 66  
         }
 67  0
         return usage;
 68  
     }
 69  
 
 70  
     @Override
 71  
     public String toString()
 72  
     {
 73  0
         return "IBean: " + getId() + " : " + ibean.getName();
 74  
     }
 75  
 }