Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 48856 invoked from network); 18 Jan 2011 18:02:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2011 18:02:27 -0000 Received: (qmail 90736 invoked by uid 500); 18 Jan 2011 18:02:27 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 90678 invoked by uid 500); 18 Jan 2011 18:02:26 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 90671 invoked by uid 99); 18 Jan 2011 18:02:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jan 2011 18:02:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jan 2011 18:02:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BC4F723889E1; Tue, 18 Jan 2011 18:02:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1060490 - in /sling/trunk/bundles/extensions/bundleresource: ./ src/main/java/org/apache/sling/bundleresource/impl/ Date: Tue, 18 Jan 2011 18:02:03 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110118180203.BC4F723889E1@eris.apache.org> Author: cziegeler Date: Tue Jan 18 18:02:03 2011 New Revision: 1060490 URL: http://svn.apache.org/viewvc?rev=1060490&view=rev Log: SLING-1935 : Remove dependency to web console Modified: sling/trunk/bundles/extensions/bundleresource/pom.xml sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java Modified: sling/trunk/bundles/extensions/bundleresource/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/pom.xml?rev=1060490&r1=1060489&r2=1060490&view=diff ============================================================================== --- sling/trunk/bundles/extensions/bundleresource/pom.xml (original) +++ sling/trunk/bundles/extensions/bundleresource/pom.xml Tue Jan 18 18:02:03 2011 @@ -67,9 +67,6 @@ org.apache.sling.api.resource;version="[$(version;==;$(@)),$(version;=+;$(@)))", * - - org.apache.felix.webconsole - @@ -101,15 +98,18 @@ org.apache.sling - org.apache.sling.jcr.resource + org.apache.sling.commons.osgi 2.0.6 provided - org.apache.felix - org.apache.felix.webconsole - 1.2.0 - provided + org.osgi + org.osgi.core + + + org.osgi + org.osgi.compendium + compile org.apache.jackrabbit @@ -118,13 +118,8 @@ provided - org.osgi - org.osgi.core - - - org.osgi - org.osgi.compendium - compile + javax.jcr + jcr org.slf4j Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java?rev=1060490&r1=1060489&r2=1060490&view=diff ============================================================================== --- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java (original) +++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java Tue Jan 18 18:02:03 2011 @@ -18,7 +18,6 @@ */ package org.apache.sling.bundleresource.impl; -import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -38,26 +37,6 @@ public class Activator implements Bundle */ public static final String BUNDLE_RESOURCE_ROOTS = "Sling-Bundle-Resources"; - /** - * Fully qualified name of the Web Console Plugin class. This class will be - * loaded dynamically to prevent issues if the Felix Web Console is not - * installed in the system (value is - * "org.apache.sling.bundleresource.impl.BundleResourceWebConsolePlugin"). - */ - private static final String CONSOLE_PLUGIN_CLASS = "org.apache.sling.bundleresource.impl.BundleResourceWebConsolePlugin"; - - /** - * Name of the initialization method to call on the Web Console Plugin class - * (value is "initPlugin"). - */ - private static final String METHOD_INIT = "initPlugin"; - - /** - * Name of the shutdown method to call on the Web Console Plugin class - * (value is "destroyPlugin"). - */ - private static final String METHOD_DESTROY = "destroyPlugin"; - /** default log */ private final Logger log = LoggerFactory.getLogger(getClass()); @@ -65,7 +44,10 @@ public class Activator implements Bundle private BundleContext bundleContext; - public void start(BundleContext context) throws Exception { + /** + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(final BundleContext context) throws Exception { this.bundleContext = context; @@ -85,15 +67,14 @@ public class Activator implements Bundle t); } - // hackery thing to prevent problems if the web console is not present - callMethod(CONSOLE_PLUGIN_CLASS, METHOD_INIT, - new Class[] { BundleContext.class }, new Object[] { context }); - + BundleResourceWebConsolePlugin.initPlugin(context); } - public void stop(BundleContext context) throws Exception { - // hackery thing to prevent problems if the web console is not present - callMethod(CONSOLE_PLUGIN_CLASS, METHOD_DESTROY, null, null); + /** + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(final BundleContext context) throws Exception { + BundleResourceWebConsolePlugin.destroyPlugin(); context.removeBundleListener(this); this.bundleContext = null; @@ -103,7 +84,7 @@ public class Activator implements Bundle * Loads and unloads any components provided by the bundle whose state * changed. If the bundle has been started, the components are loaded. If * the bundle is about to stop, the components are unloaded. - * + * * @param event The BundleEvent representing the bundle state * change. */ @@ -150,37 +131,4 @@ public class Activator implements Bundle brp.unregisterService(); } } - - /** - * Helper method to call the static method methodName on the - * class clazzName with the given args. This - * method operates exclusively using reflection to prevent any issues if the - * class cannot be loaded. - *

- * The goal is to enable running the bundle resource provider without a hard - * dependency on the Felix Web Console. - * - * @param clazzName The fully qualified name of the class whose static - * method is to be called. - * @param methodName The name of the method to call. This method must be - * declared in the given class. - * @param argTypes The types of arguments of the methods to be able to find - * the method. This may be null if the method has - * no arguments. - * @param args The actual arguments to the method. This may be - * null if the method has no arguments. - */ - private void callMethod(String clazzName, String methodName, - Class[] argTypes, Object[] args) { - try { - Class clazz = getClass().getClassLoader().loadClass(clazzName); - Method method = clazz.getDeclaredMethod(methodName, argTypes); - if (!method.isAccessible()) { - method.setAccessible(true); - } - method.invoke(null, args); - } catch (Throwable t) { - // ignore anything - } - } } Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java?rev=1060490&r1=1060489&r2=1060490&view=diff ============================================================================== --- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java (original) +++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java Tue Jan 18 18:02:03 2011 @@ -232,6 +232,8 @@ class BundleResourceCache { private static class BundleResourceMap extends LinkedHashMap { + private static final long serialVersionUID = 7455098291380945276L; + /** * The default size of a bundle resource cache (value is 20). */ Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java?rev=1060490&r1=1060489&r2=1060490&view=diff ============================================================================== --- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java (original) +++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java Tue Jan 18 18:02:03 2011 @@ -25,11 +25,12 @@ import java.util.Dictionary; import java.util.Hashtable; import java.util.List; +import javax.servlet.Servlet; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.felix.webconsole.AbstractWebConsolePlugin; -import org.apache.felix.webconsole.WebConsoleConstants; import org.apache.sling.api.resource.ResourceProvider; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -38,7 +39,9 @@ import org.osgi.framework.ServiceReferen import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.ServiceTracker; -class BundleResourceWebConsolePlugin extends AbstractWebConsolePlugin { +class BundleResourceWebConsolePlugin extends HttpServlet { + + private static final long serialVersionUID = 566337139719695235L; private static final String LABEL = "bundleresources"; @@ -51,7 +54,7 @@ class BundleResourceWebConsolePlugin ext //--------- setup and shutdown private static BundleResourceWebConsolePlugin INSTANCE; - + static void initPlugin(BundleContext context) { if (INSTANCE == null) { BundleResourceWebConsolePlugin tmp = new BundleResourceWebConsolePlugin(); @@ -59,7 +62,7 @@ class BundleResourceWebConsolePlugin ext INSTANCE = tmp; } } - + static void destroyPlugin() { if (INSTANCE != null) { try { @@ -69,27 +72,14 @@ class BundleResourceWebConsolePlugin ext } } } - + // private constructor to force using static setup and shutdown private BundleResourceWebConsolePlugin() { } - //---------- AbstractWebConsolePlugin implementation - - @Override - public String getLabel() { - return LABEL; - } - @Override - public String getTitle() { - return "Bundle Resource Provider"; - } - - @Override - protected void renderContent(HttpServletRequest req, HttpServletResponse res) - throws IOException { - + protected void doGet(final HttpServletRequest req, final HttpServletResponse res) + throws ServletException, IOException { PrintWriter pw = res.getWriter(); pw.println(""); @@ -160,8 +150,6 @@ class BundleResourceWebConsolePlugin ext } public void activate(BundleContext context) { - super.activate(context); - providerTracker = new ServiceTracker(context, ResourceProvider.SERVICE_NAME, null) { @Override @@ -189,10 +177,11 @@ class BundleResourceWebConsolePlugin ext "Web Console Plugin for Bundle Resource Providers"); props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); props.put(Constants.SERVICE_PID, getClass().getName()); - props.put(WebConsoleConstants.PLUGIN_LABEL, LABEL); + props.put("felix.webconsole.label", LABEL); + props.put("felix.webconsole.title", "Bundle Resource Provider"); serviceRegistration = context.registerService( - WebConsoleConstants.SERVICE_NAME, this, props); + Servlet.class.getName(), this, props); } public void deactivate() { @@ -205,8 +194,6 @@ class BundleResourceWebConsolePlugin ext providerTracker.close(); providerTracker = null; } - - super.deactivate(); } private String getName(Bundle bundle) {