Coverage Report - org.mule.module.guice.AbstractMuleGuiceModule
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMuleGuiceModule
0%
0/8
N/A
1
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.guice;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.endpoint.EndpointBuilder;
 12  
 import org.mule.endpoint.DefaultEndpointFactory;
 13  
 
 14  
 import com.google.inject.AbstractModule;
 15  
 
 16  
 /**
 17  
  * A mule specific Guice module that allows users to override the {@link #configureMuleContext(org.mule.api.MuleContext)} method
 18  
  * to do any Mule configuration such as register notifications.  Most users will not need to override this method so the
 19  
  * {@link com.google.inject.AbstractModule} can be used.
 20  
  * <p/>
 21  
  * Note that Mule objects such as Connectors and Agents can be registered in a Guice module too.  To do this create provider methods
 22  
  * on a module and mark with the {@link com.google.inject.Provides} annotation.
 23  
  * <p/>
 24  
  * Its recommended that you put all your Mule configuration objects in a separate Guice module.
 25  
  */
 26  0
 public abstract class AbstractMuleGuiceModule extends AbstractModule
 27  
 {
 28  
     protected MuleContext muleContext;
 29  
 
 30  
     void setMuleContext(MuleContext context)
 31  
     {
 32  0
         muleContext = context;
 33  0
         configureMuleContext(muleContext);
 34  0
     }
 35  
 
 36  
     public void configureMuleContext(MuleContext muleContext)
 37  
     {
 38  
         // do nothing
 39  0
     }
 40  
 
 41  
     /**
 42  
      * Creates an {@link org.mule.api.endpoint.EndpointBuilder} instance for the endpoint uri.  The builder can be used to add
 43  
      * further configuration options and then used to create either {@link org.mule.api.endpoint.OutboundEndpoint} or
 44  
      * {@link org.mule.api.endpoint.InboundEndpoint} instances.
 45  
      *
 46  
      * @param uri the address URI for the endpoint
 47  
      * @return and EndpointBuilder instance that can be used to create endpoints
 48  
      * @throws MuleException if the builder cannot be created for any reason
 49  
      */
 50  
     protected EndpointBuilder createEndpointBuilder(String uri) throws MuleException
 51  
     {
 52  0
         DefaultEndpointFactory endpointFactory = new DefaultEndpointFactory();
 53  0
         endpointFactory.setMuleContext(muleContext);
 54  0
         return endpointFactory.getEndpointBuilder(uri);
 55  
     }
 56  
 }