You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZipPluginManager.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (C) 2012-present the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.pf4j;
  17. /**
  18. * It's a {@link PluginManager} that loads each plugin from a {@code zip} file.
  19. * The structure of the zip file is:
  20. * <ul>
  21. * <li>{@code lib} directory that contains all dependencies (as jar files); it's optional (no dependencies)
  22. * <li>{@code classes} directory that contains all plugin's classes
  23. * </ul>
  24. *
  25. * @author Decebal Suiu
  26. */
  27. public class ZipPluginManager extends DefaultPluginManager {
  28. @Override
  29. protected PluginDescriptorFinder createPluginDescriptorFinder() {
  30. return new PropertiesPluginDescriptorFinder();
  31. }
  32. @Override
  33. protected PluginLoader createPluginLoader() {
  34. return new CompoundPluginLoader()
  35. .add(new DevelopmentPluginLoader(this), this::isDevelopment)
  36. .add(new DefaultPluginLoader(this), this::isNotDevelopment);
  37. }
  38. @Override
  39. protected PluginRepository createPluginRepository() {
  40. return new CompoundPluginRepository()
  41. .add(new DevelopmentPluginRepository(getPluginsRoot()), this::isDevelopment)
  42. .add(new DefaultPluginRepository(getPluginsRoot()), this::isNotDevelopment);
  43. }
  44. }