renamed PluginWrapper to InstalledPlugin

This commit is contained in:
Sebastian Sdorra
2019-08-20 07:54:00 +02:00
parent 056a81d9f9
commit ae19ad9327
20 changed files with 98 additions and 98 deletions

View File

@@ -7,7 +7,7 @@ import sonia.scm.plugin.Plugin;
import sonia.scm.plugin.PluginLoader;
import sonia.scm.plugin.PluginManager;
import sonia.scm.plugin.PluginPermissions;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import sonia.scm.web.VndMediaType;
import javax.inject.Inject;
@@ -53,7 +53,7 @@ public class InstalledPluginResource {
@Produces(VndMediaType.PLUGIN_COLLECTION)
public Response getInstalledPlugins() {
PluginPermissions.read().check();
List<PluginWrapper> plugins = new ArrayList<>(pluginLoader.getInstalledPlugins());
List<InstalledPlugin> plugins = new ArrayList<>(pluginLoader.getInstalledPlugins());
return Response.ok(collectionMapper.map(plugins)).build();
}

View File

@@ -5,7 +5,7 @@ import de.otto.edison.hal.Embedded;
import de.otto.edison.hal.HalRepresentation;
import de.otto.edison.hal.Links;
import sonia.scm.plugin.PluginInformation;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import java.util.Collection;
import java.util.List;
@@ -25,7 +25,7 @@ public class PluginDtoCollectionMapper {
this.mapper = mapper;
}
public HalRepresentation map(List<PluginWrapper> plugins) {
public HalRepresentation map(List<InstalledPlugin> plugins) {
List<PluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
return new HalRepresentation(createInstalledPluginsLinks(), embedDtos(dtos));
}

View File

@@ -7,7 +7,7 @@ import org.mapstruct.MappingTarget;
import org.mapstruct.ObjectFactory;
import sonia.scm.plugin.PluginInformation;
import sonia.scm.plugin.PluginState;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import javax.inject.Inject;
@@ -20,7 +20,7 @@ public abstract class PluginDtoMapper {
@Inject
private ResourceLinks resourceLinks;
public PluginDto map(PluginWrapper plugin) {
public PluginDto map(InstalledPlugin plugin) {
return map(plugin.getPlugin().getInformation());
}

View File

@@ -4,7 +4,7 @@ import com.google.inject.Inject;
import de.otto.edison.hal.Embedded;
import de.otto.edison.hal.HalRepresentation;
import de.otto.edison.hal.Links;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import java.util.Collection;
import java.util.List;
@@ -24,7 +24,7 @@ public class UIPluginDtoCollectionMapper {
this.mapper = mapper;
}
public HalRepresentation map(Collection<PluginWrapper> plugins) {
public HalRepresentation map(Collection<InstalledPlugin> plugins) {
List<UIPluginDto> dtos = plugins.stream().map(mapper::map).collect(toList());
return new HalRepresentation(createLinks(), embedDtos(dtos));
}

View File

@@ -2,7 +2,7 @@ package sonia.scm.api.v2.resources;
import com.google.common.base.Strings;
import de.otto.edison.hal.Links;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import sonia.scm.util.HttpUtil;
import javax.inject.Inject;
@@ -25,7 +25,7 @@ public class UIPluginDtoMapper {
this.request = request;
}
public UIPluginDto map(PluginWrapper plugin) {
public UIPluginDto map(InstalledPlugin plugin) {
UIPluginDto dto = new UIPluginDto(
plugin.getPlugin().getInformation().getName(),
getScriptResources(plugin)
@@ -40,7 +40,7 @@ public class UIPluginDtoMapper {
return dto;
}
private Set<String> getScriptResources(PluginWrapper wrapper) {
private Set<String> getScriptResources(InstalledPlugin wrapper) {
Set<String> scriptResources = wrapper.getPlugin().getResources().getScriptResources();
if (scriptResources != null) {
return scriptResources.stream()

View File

@@ -4,7 +4,7 @@ import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import com.webcohesion.enunciate.metadata.rs.TypeHint;
import sonia.scm.plugin.PluginLoader;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import sonia.scm.security.AllowAnonymousAccess;
import sonia.scm.web.VndMediaType;
@@ -46,7 +46,7 @@ public class UIPluginResource {
@TypeHint(CollectionDto.class)
@Produces(VndMediaType.UI_PLUGIN_COLLECTION)
public Response getInstalledPlugins() {
List<PluginWrapper> plugins = pluginLoader.getInstalledPlugins()
List<InstalledPlugin> plugins = pluginLoader.getInstalledPlugins()
.stream()
.filter(this::filter)
.collect(Collectors.toList());
@@ -85,7 +85,7 @@ public class UIPluginResource {
}
}
private boolean filter(PluginWrapper plugin) {
private boolean filter(InstalledPlugin plugin) {
return plugin.getPlugin().getResources() != null;
}

View File

@@ -13,7 +13,7 @@ import sonia.scm.plugin.Plugin;
import sonia.scm.plugin.PluginException;
import sonia.scm.plugin.PluginLoadException;
import sonia.scm.plugin.PluginLoader;
import sonia.scm.plugin.PluginWrapper;
import sonia.scm.plugin.InstalledPlugin;
import sonia.scm.plugin.PluginsInternal;
import sonia.scm.plugin.SmpArchive;
import sonia.scm.util.IOUtil;
@@ -43,7 +43,7 @@ public final class PluginBootstrap {
private final ClassLoaderLifeCycle classLoaderLifeCycle;
private final ServletContext servletContext;
private final Set<PluginWrapper> plugins;
private final Set<InstalledPlugin> plugins;
private final PluginLoader pluginLoader;
PluginBootstrap(ServletContext servletContext, ClassLoaderLifeCycle classLoaderLifeCycle) {
@@ -58,7 +58,7 @@ public final class PluginBootstrap {
return pluginLoader;
}
public Set<PluginWrapper> getPlugins() {
public Set<InstalledPlugin> getPlugins() {
return plugins;
}
@@ -66,7 +66,7 @@ public final class PluginBootstrap {
return new DefaultPluginLoader(servletContext, classLoaderLifeCycle.getBootstrapClassLoader(), plugins);
}
private Set<PluginWrapper> collectPlugins() {
private Set<InstalledPlugin> collectPlugins() {
try {
File pluginDirectory = getPluginDirectory();

View File

@@ -85,7 +85,7 @@ public class DefaultPluginLoader implements PluginLoader
* @param installedPlugins
*/
public DefaultPluginLoader(ServletContext servletContext, ClassLoader parent,
Set<PluginWrapper> installedPlugins)
Set<InstalledPlugin> installedPlugins)
{
this.installedPlugins = installedPlugins;
this.uberClassLoader = new UberClassLoader(parent, installedPlugins);
@@ -141,7 +141,7 @@ public class DefaultPluginLoader implements PluginLoader
* @return
*/
@Override
public Collection<PluginWrapper> getInstalledPlugins()
public Collection<InstalledPlugin> getInstalledPlugins()
{
return installedPlugins;
}
@@ -227,7 +227,7 @@ public class DefaultPluginLoader implements PluginLoader
private final ExtensionProcessor extensionProcessor;
/** Field description */
private final Set<PluginWrapper> installedPlugins;
private final Set<InstalledPlugin> installedPlugins;
/** Field description */
private final Set<ScmModule> modules;

View File

@@ -129,7 +129,7 @@ public class DefaultPluginManager implements PluginManager
this.httpClient = httpClient;
installedPlugins = new HashMap<>();
for (PluginWrapper wrapper : pluginLoader.getInstalledPlugins())
for (InstalledPlugin wrapper : pluginLoader.getInstalledPlugins())
{
Plugin plugin = wrapper.getPlugin();
PluginInformation info = plugin.getInformation();

View File

@@ -71,11 +71,11 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
//~--- constructors ---------------------------------------------------------
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<PluginWrapper> plugins) {
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<InstalledPlugin> plugins) {
this(servletContext, plugins, SCMContext.getContext().getStage());
}
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<PluginWrapper> plugins, Stage stage) {
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<InstalledPlugin> plugins, Stage stage) {
this.servletContext = servletContext;
this.plugins = plugins;
this.cache = createCache(stage);
@@ -153,7 +153,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
resources.add(ctxResource);
}
for (PluginWrapper wrapper : plugins)
for (InstalledPlugin wrapper : plugins)
{
URL resource = nonDirectory(wrapper.getWebResourceLoader().getResource(path));
@@ -205,7 +205,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
if (resource == null)
{
for (PluginWrapper wrapper : plugins)
for (InstalledPlugin wrapper : plugins)
{
resource = nonDirectory(wrapper.getWebResourceLoader().getResource(path));
@@ -259,7 +259,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
private final Cache<String, URL> cache;
/** Field description */
private final Iterable<PluginWrapper> plugins;
private final Iterable<InstalledPlugin> plugins;
/** Field description */
private final ServletContext servletContext;

View File

@@ -157,7 +157,7 @@ public final class PluginNode
*
* @return
*/
public PluginWrapper getWrapper()
public InstalledPlugin getWrapper()
{
return wrapper;
}
@@ -170,7 +170,7 @@ public final class PluginNode
*
* @param wrapper
*/
public void setWrapper(PluginWrapper wrapper)
public void setWrapper(InstalledPlugin wrapper)
{
this.wrapper = wrapper;
}
@@ -192,5 +192,5 @@ public final class PluginNode
private final ExplodedSmp plugin;
/** Field description */
private PluginWrapper wrapper;
private InstalledPlugin wrapper;
}

View File

@@ -160,7 +160,7 @@ public final class PluginProcessor
*
* @throws IOException
*/
public Set<PluginWrapper> collectPlugins(ClassLoader classLoader)
public Set<InstalledPlugin> collectPlugins(ClassLoader classLoader)
throws IOException
{
logger.info("collect plugins");
@@ -187,7 +187,7 @@ public final class PluginProcessor
logger.trace("create plugin wrappers and build classloaders");
Set<PluginWrapper> wrappers = createPluginWrappers(classLoader, rootNodes);
Set<InstalledPlugin> wrappers = createPluginWrappers(classLoader, rootNodes);
logger.debug("collected {} plugins", wrappers.size());
@@ -204,7 +204,7 @@ public final class PluginProcessor
*
* @throws IOException
*/
private void appendPluginWrapper(Set<PluginWrapper> plugins,
private void appendPluginWrapper(Set<InstalledPlugin> plugins,
ClassLoader classLoader, PluginNode node)
throws IOException
{
@@ -217,7 +217,7 @@ public final class PluginProcessor
for (PluginNode parent : node.getParents())
{
PluginWrapper wrapper = parent.getWrapper();
InstalledPlugin wrapper = parent.getWrapper();
if (wrapper != null)
{
@@ -236,7 +236,7 @@ public final class PluginProcessor
}
PluginWrapper plugin =
InstalledPlugin plugin =
createPluginWrapper(createParentPluginClassLoader(classLoader, parents),
smp);
@@ -257,7 +257,7 @@ public final class PluginProcessor
*
* @throws IOException
*/
private void appendPluginWrappers(Set<PluginWrapper> plugins,
private void appendPluginWrappers(Set<InstalledPlugin> plugins,
ClassLoader classLoader, List<PluginNode> nodes)
throws IOException
{
@@ -474,11 +474,11 @@ public final class PluginProcessor
*
* @throws IOException
*/
private PluginWrapper createPluginWrapper(ClassLoader classLoader,
ExplodedSmp smp)
private InstalledPlugin createPluginWrapper(ClassLoader classLoader,
ExplodedSmp smp)
throws IOException
{
PluginWrapper wrapper = null;
InstalledPlugin wrapper = null;
Path directory = smp.getPath();
Path descriptor = directory.resolve(PluginConstants.FILE_DESCRIPTOR);
@@ -490,7 +490,7 @@ public final class PluginProcessor
WebResourceLoader resourceLoader = createWebResourceLoader(directory);
wrapper = new PluginWrapper(plugin, cl, resourceLoader, directory);
wrapper = new InstalledPlugin(plugin, cl, resourceLoader, directory);
}
else
{
@@ -512,11 +512,11 @@ public final class PluginProcessor
*
* @throws IOException
*/
private Set<PluginWrapper> createPluginWrappers(ClassLoader classLoader,
List<PluginNode> rootNodes)
private Set<InstalledPlugin> createPluginWrappers(ClassLoader classLoader,
List<PluginNode> rootNodes)
throws IOException
{
Set<PluginWrapper> plugins = Sets.newHashSet();
Set<InstalledPlugin> plugins = Sets.newHashSet();
appendPluginWrappers(plugins, classLoader, rootNodes);

View File

@@ -87,8 +87,8 @@ public final class PluginsInternal
*
* @throws IOException
*/
public static Set<PluginWrapper> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle,
Path directory)
public static Set<InstalledPlugin> collectPlugins(ClassLoaderLifeCycle classLoaderLifeCycle,
Path directory)
throws IOException
{
PluginProcessor processor = new PluginProcessor(classLoaderLifeCycle, directory);
@@ -159,7 +159,7 @@ public final class PluginsInternal
*
* @return
*/
public static Iterable<Plugin> unwrap(Iterable<PluginWrapper> wrapped)
public static Iterable<Plugin> unwrap(Iterable<InstalledPlugin> wrapped)
{
return Iterables.transform(wrapped, new Unwrap());
}
@@ -188,7 +188,7 @@ public final class PluginsInternal
* @version Enter version here..., 14/06/05
* @author Enter your name here...
*/
private static class Unwrap implements Function<PluginWrapper, Plugin>
private static class Unwrap implements Function<InstalledPlugin, Plugin>
{
/**
@@ -200,7 +200,7 @@ public final class PluginsInternal
* @return
*/
@Override
public Plugin apply(PluginWrapper wrapper)
public Plugin apply(InstalledPlugin wrapper)
{
return wrapper.getPlugin();
}

View File

@@ -65,7 +65,7 @@ public final class UberClassLoader extends ClassLoader
* @param parent
* @param plugins
*/
public UberClassLoader(ClassLoader parent, Iterable<PluginWrapper> plugins)
public UberClassLoader(ClassLoader parent, Iterable<InstalledPlugin> plugins)
{
super(parent);
this.plugins = plugins;
@@ -87,7 +87,7 @@ public final class UberClassLoader extends ClassLoader
}
private Class<?> findClassInPlugins(String name) throws ClassNotFoundException {
for (PluginWrapper plugin : plugins) {
for (InstalledPlugin plugin : plugins) {
Class<?> clazz = findClass(plugin.getClassLoader(), name);
if (clazz != null) {
return clazz;
@@ -119,7 +119,7 @@ public final class UberClassLoader extends ClassLoader
{
URL url = null;
for (PluginWrapper plugin : plugins)
for (InstalledPlugin plugin : plugins)
{
ClassLoader cl = plugin.getClassLoader();
@@ -149,7 +149,7 @@ public final class UberClassLoader extends ClassLoader
{
List<URL> urls = Lists.newArrayList();
for (PluginWrapper plugin : plugins)
for (InstalledPlugin plugin : plugins)
{
ClassLoader cl = plugin.getClassLoader();
@@ -194,5 +194,5 @@ public final class UberClassLoader extends ClassLoader
Maps.newConcurrentMap();
/** Field description */
private final Iterable<PluginWrapper> plugins;
private final Iterable<InstalledPlugin> plugins;
}