View Javadoc

1   /*
2    * $Id: MulePluginsClassLoader.java 22153 2011-06-08 20:29:01Z aperepel $
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  
11  package org.mule.module.launcher.plugin;
12  
13  import org.mule.module.launcher.FineGrainedControlClassLoader;
14  
15  import java.net.URL;
16  import java.util.Arrays;
17  import java.util.Collection;
18  import java.util.Set;
19  
20  public class MulePluginsClassLoader extends FineGrainedControlClassLoader
21  {
22  
23      public MulePluginsClassLoader(ClassLoader parent, PluginDescriptor... plugins)
24      {
25          this(parent, Arrays.asList(plugins));
26      }
27  
28      public MulePluginsClassLoader(ClassLoader parent, Collection<PluginDescriptor> plugins)
29      {
30          super(new URL[0], parent);
31          for (PluginDescriptor plugin : plugins)
32          {
33              final URL[] pluginUrls = plugin.getClasspath().toURLs();
34              for (URL pluginUrl : pluginUrls)
35              {
36                  addURL(pluginUrl);
37              }
38  
39              final Set<String> override = plugin.getLoaderOverride();
40              processOverrides(override);
41          }
42      }
43  }