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.boot;
8   
9   import java.net.URL;
10  import java.net.URLClassLoader;
11  import java.util.List;
12  
13  import org.apache.commons.logging.Log;
14  import org.apache.commons.logging.LogFactory;
15  
16  /**
17   * Loads a standard $MULE_HOME/lib/* hierarchy.
18   */
19  public class MuleSystemClassLoader extends URLClassLoader
20  {
21  
22      protected transient Log logger = LogFactory.getLog(getClass());
23  
24      public MuleSystemClassLoader()
25      {
26          super(new URL[0]);
27          try
28          {
29              DefaultMuleClassPathConfig classPath = new DefaultMuleClassPathConfig(MuleBootstrap.lookupMuleHome(),
30                                                                                    MuleBootstrap.lookupMuleBase());
31  
32              final List<URL> urlsList = classPath.getURLs();
33              for (URL url : urlsList)
34              {
35                  addURL(url);
36              }
37          }
38          catch (Exception e)
39          {
40              if (logger.isDebugEnabled())
41              {
42                  logger.debug(e);
43              }
44          }
45      }
46  }