Sergey Shepelevich pushed to branch feature/msdts at cms-community / hippo-services-api
Commits: 42c00018 by Sergey Shepelevich at 2018-03-12T12:02:22+01:00 CMS-11102 Store ExtensionEvent in ExtensionRegistry instead of just Classloader - - - - - 2 changed files: - src/main/java/org/onehippo/cms7/services/extension/ExtensionEvent.java - src/main/java/org/onehippo/cms7/services/extension/ExtensionRegistry.java Changes: ===================================== src/main/java/org/onehippo/cms7/services/extension/ExtensionEvent.java ===================================== --- a/src/main/java/org/onehippo/cms7/services/extension/ExtensionEvent.java +++ b/src/main/java/org/onehippo/cms7/services/extension/ExtensionEvent.java @@ -26,6 +26,10 @@ public class ExtensionEvent extends HippoEvent<ExtensionEvent> { this.classLoader = classLoader; } + public String getExtensionName() { + return (String) getValues().get("application"); + } + public ClassLoader getClassLoader() { return classLoader; } ===================================== src/main/java/org/onehippo/cms7/services/extension/ExtensionRegistry.java ===================================== --- a/src/main/java/org/onehippo/cms7/services/extension/ExtensionRegistry.java +++ b/src/main/java/org/onehippo/cms7/services/extension/ExtensionRegistry.java @@ -27,7 +27,7 @@ public class ExtensionRegistry { HST, OTHER } - private static Map<String, ClassLoader> registry = new HashMap<>(); + private static Map<String, ExtensionEvent> registry = new HashMap<>(); /** * Register a site's classloader @@ -35,15 +35,15 @@ public class ExtensionRegistry { * @param ctx the servletContext to register * @param type the <code>WebAppType</code> to which the <code>ctx</code> belongs. Not allowed to be <code>null</code> */ - public synchronized static void register(final ServletContext ctx, final ExtensionType type) { + public synchronized static void register(final ServletContext ctx, final ExtensionEvent extensionEvent, final ExtensionType type) { if (registry.containsKey(ctx.getContextPath())) { throw new IllegalStateException("ServletContext "+ctx.getContextPath()+" already registered"); } if (type == null) { throw new IllegalArgumentException("ExtensionType argument is not allowed to be null."); } - Map<String, ClassLoader> newMap = new HashMap<>(registry); - newMap.put(ctx.getContextPath(), Thread.currentThread().getContextClassLoader()); + Map<String, ExtensionEvent> newMap = new HashMap<>(registry); + newMap.put(ctx.getContextPath(), extensionEvent); registry = Collections.unmodifiableMap(newMap); } @@ -56,7 +56,7 @@ public class ExtensionRegistry { if (!registry.containsKey(ctx.getContextPath())) { throw new IllegalStateException("ServletContext "+ctx.getContextPath()+" not registered"); } - Map<String, ClassLoader> newMap = new HashMap<>(registry); + Map<String, ExtensionEvent> newMap = new HashMap<>(registry); newMap.remove(ctx.getContextPath()); registry = Collections.unmodifiableMap(newMap); } @@ -65,14 +65,14 @@ public class ExtensionRegistry { * @param contextPath The contextPath for which to lookup the site * @return the site's Classloader registered under the parameter contextPath */ - public static ClassLoader getContext(final String contextPath) { + public static ExtensionEvent getContext(final String contextPath) { return registry.get(contextPath); } /** * @return unmodifiable map of all currently registered site's classloaders mapped by their contextPath */ - public static Map<String, ClassLoader> getContexts() { + public static Map<String, ExtensionEvent> getContexts() { return registry; } } \ No newline at end of file View it on GitLab: https://code.onehippo.org/cms-community/hippo-services-api/commit/42c00018e314516b39548644e99ef8fbf3dc340e --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-services-api/commit/42c00018e314516b39548644e99ef8fbf3dc340e You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn