improve synchronization of plugin handler

This commit is contained in:
Sebastian Sdorra
2013-05-23 19:40:27 +02:00
parent 3a9c66db25
commit 5af724326b

View File

@@ -77,6 +77,9 @@ public class AetherPluginHandler
private static final Logger logger = private static final Logger logger =
LoggerFactory.getLogger(AetherPluginHandler.class); LoggerFactory.getLogger(AetherPluginHandler.class);
/** Field description */
private static final Object LOCK = new Object();
//~--- constructors --------------------------------------------------------- //~--- constructors ---------------------------------------------------------
/** /**
@@ -137,15 +140,10 @@ public class AetherPluginHandler
*/ */
public void install(String gav) public void install(String gav)
{ {
if (logger.isInfoEnabled()) synchronized (LOCK)
{ {
logger.info("try to install plugin with gav: {}", gav); doInstall(gav);
} }
Dependency dependency = Aether.createDependency(gav);
List<Dependency> dependencies = getInstalledDependencies(null);
collectDependencies(dependency, dependencies);
} }
/** /**
@@ -157,19 +155,9 @@ public class AetherPluginHandler
*/ */
public void uninstall(String id) public void uninstall(String id)
{ {
if (logger.isInfoEnabled()) synchronized (LOCK)
{ {
logger.info("try to uninstall plugin: {}", id); doUninstall(id);
}
if (classpath != null)
{
synchronized (Classpath.class)
{
List<Dependency> dependencies = getInstalledDependencies(id);
collectDependencies(null, dependencies);
}
} }
} }
@@ -223,15 +211,10 @@ public class AetherPluginHandler
classpath = new Classpath(); classpath = new Classpath();
} }
synchronized (Classpath.class) Set<String> classpathSet = createClasspathSet(resolver.createClassPath());
{
Set<String> classpathSet = classpath.setPathSet(classpathSet);
createClasspathSet(resolver.createClassPath()); storeClasspath();
classpath.setPathSet(classpathSet);
storeClasspath();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -271,6 +254,46 @@ public class AetherPluginHandler
return classpathSet; return classpathSet;
} }
/**
* Method description
*
*
* @param gav
*/
private void doInstall(String gav)
{
if (logger.isInfoEnabled())
{
logger.info("try to install plugin with gav: {}", gav);
}
Dependency dependency = Aether.createDependency(gav);
List<Dependency> dependencies = getInstalledDependencies(null);
collectDependencies(dependency, dependencies);
}
/**
* Method description
*
*
* @param id
*/
private void doUninstall(String id)
{
if (logger.isInfoEnabled())
{
logger.info("try to uninstall plugin: {}", id);
}
if (classpath != null)
{
List<Dependency> dependencies = getInstalledDependencies(id);
collectDependencies(null, dependencies);
}
}
/** /**
* Method description * Method description
* *