View Javadoc
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.ibeans.config;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.MuleRuntimeException;
11  import org.mule.api.config.ConfigurationException;
12  import org.mule.api.context.MuleContextAware;
13  
14  /**
15   * Responsible for discovering and loading available iBeans into the registry.
16   */
17  public class IBeansLoader implements MuleContextAware
18  {
19      public static final String SCAN_PACKAGES_PROPERTY = "org.mule.scan";
20  
21      //Note that the space after the comma denotes that the classes path itself should be scanned.  I don't know what this is
22      //required when scanning for resources
23      private static final String DEFAULT_BASEPATH = "org.mule, ";
24  
25      public void setMuleContext(MuleContext context)
26      {
27          //Don't like this but without it the user must explicitly configure this builder at start up
28          String scanPackages = System.getProperty(SCAN_PACKAGES_PROPERTY, DEFAULT_BASEPATH);
29          String[] paths = scanPackages.split(",");
30          IBeanHolderConfigurationBuilder builder = new IBeanHolderConfigurationBuilder(paths);
31          try
32          {
33              builder.configure(context);
34          }
35          catch (ConfigurationException e)
36          {
37              throw new MuleRuntimeException(e);
38          }
39      }
40  }