You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by vv...@apache.org on 2011/09/12 16:45:57 UTC

svn commit: r1169777 [2/4] - in /felix/trunk: webconsole-plugins/deppack/ webconsole-plugins/deppack/src/ webconsole-plugins/deppack/src/main/ webconsole-plugins/deppack/src/main/java/ webconsole-plugins/deppack/src/main/java/org/ webconsole-plugins/de...

Added: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java Mon Sep 12 14:45:53 2011
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.webconsole.plugins.ds.internal;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.Reference;
+import org.apache.felix.scr.ScrService;
+import org.apache.felix.webconsole.ConfigurationPrinter;
+import org.apache.felix.webconsole.WebConsoleUtil;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentConstants;
+
+/**
+ * ComponentConfigurationPrinter prints the available SCR services. 
+ */
+class ComponentConfigurationPrinter implements ConfigurationPrinter
+{
+
+    private final ScrService scrService;
+
+    ComponentConfigurationPrinter(Object scrService)
+    {
+        this.scrService = (ScrService)scrService;
+    }
+
+    /**
+     * @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
+     */
+    public String getTitle()
+    {
+        return "Declarative Services Components";
+    }
+
+    /**
+     * @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
+     */
+    public void printConfiguration(PrintWriter pw)
+    {
+        printComponents(pw, scrService.getComponents());
+    }
+
+    private static final void printComponents(final PrintWriter pw,
+        final Component[] components)
+    {
+        if (components == null || components.length == 0)
+        {
+            pw.println("  No Components Registered");
+        }
+        else
+        {
+            // order components by id
+            TreeMap componentMap = new TreeMap();
+            for (int i = 0; i < components.length; i++)
+            {
+                Component component = components[i];
+                componentMap.put(new Long(component.getId()), component);
+            }
+
+            // render components
+            for (Iterator ci = componentMap.values().iterator(); ci.hasNext();)
+            {
+                Component component = (Component) ci.next();
+                component(pw, component);
+            }
+        }
+    }
+
+    private static final void component(PrintWriter pw, Component component)
+    {
+
+        pw.print(component.getId());
+        pw.print("=[");
+        pw.print(component.getName());
+        pw.println("]");
+
+        pw.println("  Bundle" + component.getBundle().getSymbolicName() + " ("
+            + component.getBundle().getBundleId() + ")");
+        pw.println("  State=" + toStateString(component.getState()));
+        pw.println("  DefaultState="
+            + (component.isDefaultEnabled() ? "enabled" : "disabled"));
+        pw.println("  Activation=" + (component.isImmediate() ? "immediate" : "delayed"));
+
+        listServices(pw, component);
+        listReferences(pw, component);
+        listProperties(pw, component);
+
+        pw.println();
+    }
+
+    private static void listServices(PrintWriter pw, Component component)
+    {
+        String[] services = component.getServices();
+        if (services == null)
+        {
+            return;
+        }
+
+        pw.println("  ServiceType="
+            + (component.isServiceFactory() ? "service factory" : "service"));
+
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < services.length; i++)
+        {
+            if (i > 0)
+            {
+                buf.append(", ");
+            }
+            buf.append(services[i]);
+        }
+
+        pw.println("  Services=" + buf);
+    }
+
+    private static final void listReferences(PrintWriter pw, Component component)
+    {
+        Reference[] refs = component.getReferences();
+        if (refs != null)
+        {
+            for (int i = 0; i < refs.length; i++)
+            {
+
+                pw.println("  Reference=" + refs[i].getName() + ", "
+                    + (refs[i].isSatisfied() ? "Satisfied" : "Unsatisfied"));
+
+                pw.println("    Service Name: " + refs[i].getServiceName());
+
+                if (refs[i].getTarget() != null)
+                {
+                    pw.println("  Target Filter: " + refs[i].getTarget());
+                }
+
+                pw.println("    Multiple: "
+                    + (refs[i].isMultiple() ? "multiple" : "single"));
+                pw.println("    Optional: "
+                    + (refs[i].isOptional() ? "optional" : "mandatory"));
+                pw.println("    Policy: " + (refs[i].isStatic() ? "static" : "dynamic"));
+
+                // list bound services
+                ServiceReference[] boundRefs = refs[i].getServiceReferences();
+                if (boundRefs != null && boundRefs.length > 0)
+                {
+                    for (int j = 0; j < boundRefs.length; j++)
+                    {
+                        pw.print("    Bound Service: ID ");
+                        pw.print(boundRefs[j].getProperty(Constants.SERVICE_ID));
+
+                        String name = (String) boundRefs[j].getProperty(ComponentConstants.COMPONENT_NAME);
+                        if (name == null)
+                        {
+                            name = (String) boundRefs[j].getProperty(Constants.SERVICE_PID);
+                            if (name == null)
+                            {
+                                name = (String) boundRefs[j].getProperty(Constants.SERVICE_DESCRIPTION);
+                            }
+                        }
+                        if (name != null)
+                        {
+                            pw.print(" (");
+                            pw.print(name);
+                            pw.print(")");
+                        }
+                        pw.println();
+                    }
+                }
+                else
+                {
+                    pw.println("    No Services bound");
+                }
+            }
+        }
+    }
+
+    private static final void listProperties(PrintWriter pw, Component component)
+    {
+        Dictionary props = component.getProperties();
+        if (props != null)
+        {
+
+            pw.println("  Properties=");
+            TreeSet keys = new TreeSet(Util.list(props.keys()));
+            for (Iterator ki = keys.iterator(); ki.hasNext();)
+            {
+                String key = (String) ki.next();
+                Object value = props.get(key);
+                value = WebConsoleUtil.toString(value);
+                if (value.getClass().isArray())
+                {
+                    value = Arrays.asList((Object[]) value);
+                }
+                pw.println("    " + key + "=" + value);
+            }
+        }
+    }
+
+    static final String toStateString(int state)
+    {
+        switch (state)
+        {
+            case Component.STATE_DISABLED:
+                return "disabled";
+            case Component.STATE_ENABLED:
+                return "enabled";
+            case Component.STATE_UNSATISFIED:
+                return "unsatisfied";
+            case Component.STATE_ACTIVATING:
+                return "activating";
+            case Component.STATE_ACTIVE:
+                return "active";
+            case Component.STATE_REGISTERED:
+                return "registered";
+            case Component.STATE_FACTORY:
+                return "factory";
+            case Component.STATE_DEACTIVATING:
+                return "deactivating";
+            case Component.STATE_DESTROYED:
+                return "destroyed";
+            default:
+                return String.valueOf(state);
+        }
+    }
+}

Propchange: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Util.java?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Util.java (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Util.java Mon Sep 12 14:45:53 2011
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.webconsole.plugins.ds.internal;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Enumeration;
+
+import org.apache.felix.scr.Component;
+
+class Util
+{
+
+    static final Comparator COMPONENT_COMPARATOR = new Comparator()
+    {
+        public int compare(Object o0, Object o1)
+        {
+            final Component c0 = (Component) o0;
+            final Component c1 = (Component) o1;
+            final int nameCmp = c0.getName().compareTo(c1.getName());
+            if (nameCmp != 0)
+            {
+                return nameCmp;
+            }
+            return (c0.getId() < c1.getId()) ? -1 : ((c0.getId() > c1.getId()) ? 1 : 0);
+        }
+    };
+
+    private Util()
+    {
+        // prevent instantiation
+    }
+
+    /**
+     * This method is the same as Collections#list(Enumeration). The reason to
+     * duplicate it here, is that it is missing in OSGi/Minimum execution
+     * environment.
+     *
+     * @param e the enumeration which to convert
+     * @return the list containing all enumeration entries.
+     */
+    public static final ArrayList list(Enumeration e)
+    {
+        ArrayList l = new ArrayList();
+        while (e.hasMoreElements())
+        {
+            l.add(e.nextElement());
+        }
+        return l;
+    }
+
+}

Propchange: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Util.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java Mon Sep 12 14:45:53 2011
@@ -0,0 +1,620 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.webconsole.plugins.ds.internal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.Reference;
+import org.apache.felix.scr.ScrService;
+import org.apache.felix.webconsole.DefaultVariableResolver;
+import org.apache.felix.webconsole.SimpleWebConsolePlugin;
+import org.apache.felix.webconsole.WebConsoleUtil;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONWriter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.component.ComponentConstants;
+import org.osgi.service.metatype.MetaTypeInformation;
+import org.osgi.service.metatype.MetaTypeService;
+
+/**
+ * ComponentsServlet provides a plugin for managing Service Components Runtime.
+ */
+class WebConsolePlugin extends SimpleWebConsolePlugin
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String LABEL = "components"; //$NON-NLS-1$
+    private static final String TITLE = "%components.pluginTitle"; //$NON-NLS-1$
+    private static final String CSS[] = { "/res/ui/bundles.css" }; // yes, it's correct! //$NON-NLS-1$
+    private static final String RES = "/" + LABEL + "/res/"; //$NON-NLS-1$ //$NON-NLS-2$
+
+    // actions
+    private static final String OPERATION = "action"; //$NON-NLS-1$
+    private static final String OPERATION_ENABLE = "enable"; //$NON-NLS-1$
+    private static final String OPERATION_DISABLE = "disable"; //$NON-NLS-1$
+    //private static final String OPERATION_CONFIGURE = "configure";
+
+    // needed services
+    static final String SCR_SERVICE = "org.apache.felix.scr.ScrService"; //$NON-NLS-1$
+    private static final String META_TYPE_NAME = "org.osgi.service.metatype.MetaTypeService"; //$NON-NLS-1$
+    private static final String CONFIGURATION_ADMIN_NAME = "org.osgi.service.cm.ConfigurationAdmin"; //$NON-NLS-1$
+
+    // templates
+    private final String TEMPLATE;
+
+    /** Default constructor */
+    WebConsolePlugin()
+    {
+        super(LABEL, TITLE, CSS);
+
+        // load templates
+        TEMPLATE = readTemplateFile("/res/plugin.html"); //$NON-NLS-1$
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+     */
+    protected void doPost(HttpServletRequest request, HttpServletResponse response)
+        throws IOException
+    {
+        final RequestInfo reqInfo = new RequestInfo(request);
+        if (reqInfo.component == null && reqInfo.componentRequested)
+        {
+            response.sendError(404);
+            return;
+        }
+        if (!reqInfo.componentRequested)
+        {
+            response.sendError(500);
+            return;
+        }
+        String op = request.getParameter(OPERATION);
+        if (OPERATION_ENABLE.equals(op))
+        {
+            reqInfo.component.enable();
+        }
+        else if (OPERATION_DISABLE.equals(op))
+        {
+            reqInfo.component.disable();
+        }
+
+        final PrintWriter pw = response.getWriter();
+        response.setContentType("application/json"); //$NON-NLS-1$
+        response.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
+        renderResult(pw, null);
+    }
+
+    /**
+     * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+     */
+    protected void doGet(HttpServletRequest request, HttpServletResponse response)
+        throws ServletException, IOException
+    {
+        String path = request.getPathInfo();
+        // don't process if this is request to load a resource
+        if (!path.startsWith(RES))
+        {
+            final RequestInfo reqInfo = new RequestInfo(request);
+            if (reqInfo.component == null && reqInfo.componentRequested)
+            {
+                response.sendError(404);
+                return;
+            }
+            if (reqInfo.extension.equals("json")) //$NON-NLS-1$
+            {
+                response.setContentType("application/json"); //$NON-NLS-1$
+                response.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
+
+                this.renderResult(response.getWriter(), reqInfo.component);
+
+                // nothing more to do
+                return;
+            }
+        }
+        super.doGet(request, response);
+    }
+
+    /**
+     * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+     */
+    protected void renderContent(HttpServletRequest request, HttpServletResponse response)
+        throws IOException
+    {
+        // get request info from request attribute
+        final RequestInfo reqInfo = getRequestInfo(request);
+
+        StringWriter w = new StringWriter();
+        PrintWriter w2 = new PrintWriter(w);
+        renderResult(w2, reqInfo.component);
+
+        // prepare variables
+        DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
+        vars.put("__drawDetails__", reqInfo.componentRequested ? Boolean.TRUE : Boolean.FALSE); //$NON-NLS-1$
+        vars.put("__data__", w.toString()); //$NON-NLS-1$
+
+        response.getWriter().print(TEMPLATE);
+
+    }
+
+    private void renderResult(final PrintWriter pw, final Component component)
+        throws IOException
+    {
+        final JSONWriter jw = new JSONWriter(pw);
+        try
+        {
+            jw.object();
+
+            final ScrService scrService = getScrService();
+            if (scrService == null)
+            {
+                jw.key("status"); //$NON-NLS-1$
+                jw.value(-1);
+            }
+            else
+            {
+                final Component[] components = scrService.getComponents();
+
+                if (components == null || components.length == 0)
+                {
+                    jw.key("status"); //$NON-NLS-1$
+                    jw.value(0);
+                }
+                else
+                {
+                    // order components by name
+                    sortComponents(components);
+
+                    final StringBuffer buffer = new StringBuffer();
+                    buffer.append(components.length);
+                    buffer.append(" component"); //$NON-NLS-1$
+                    if (components.length != 1)
+                    {
+                        buffer.append('s');
+                    }
+                    buffer.append(" installed."); //$NON-NLS-1$
+                    jw.key("status"); //$NON-NLS-1$
+                    jw.value(components.length);
+
+                    // render components
+                    jw.key("data"); //$NON-NLS-1$
+                    jw.array();
+                    if (component != null)
+                    {
+                        component(jw, component, true);
+                    }
+                    else
+                    {
+                        for (int i = 0; i < components.length; i++)
+                        {
+                            component(jw, components[i], false);
+                        }
+                    }
+                    jw.endArray();
+                }
+            }
+
+            jw.endObject();
+        }
+        catch (JSONException je)
+        {
+            throw new IOException(je.toString());
+        }
+    }
+
+    private void sortComponents(Component[] components)
+    {
+        Arrays.sort(components, Util.COMPONENT_COMPARATOR);
+    }
+
+    private void component(JSONWriter jw, Component component, boolean details)
+        throws JSONException
+    {
+        String id = String.valueOf(component.getId());
+        String name = component.getName();
+        int state = component.getState();
+
+        jw.object();
+
+        // component information
+        jw.key("id"); //$NON-NLS-1$
+        jw.value(id);
+        jw.key("name"); //$NON-NLS-1$
+        jw.value(name);
+        jw.key("state"); //$NON-NLS-1$
+        jw.value(ComponentConfigurationPrinter.toStateString(state));
+        jw.key("stateRaw"); //$NON-NLS-1$
+        jw.value(state);
+
+        final Dictionary props = component.getProperties();
+
+        final String pid = (String) (props != null ? props.get(Constants.SERVICE_PID)
+            : null);
+        if (pid != null)
+        {
+            jw.key("pid"); //$NON-NLS-1$
+            jw.value(pid);
+            if (isConfigurable(component.getBundle(), pid))
+            {
+                jw.key("configurable"); //$NON-NLS-1$
+                jw.value(pid);
+            }
+        }
+
+        // component details
+        if (details)
+        {
+            gatherComponentDetails(jw, component);
+        }
+
+        jw.endObject();
+    }
+
+    private void gatherComponentDetails(JSONWriter jw, Component component)
+        throws JSONException
+    {
+        jw.key("props"); //$NON-NLS-1$
+        jw.array();
+
+        keyVal(jw, "Bundle", component.getBundle().getSymbolicName() + " ("
+            + component.getBundle().getBundleId() + ")");
+        keyVal(jw, "Implementation Class", component.getClassName());
+        if (component.getFactory() != null)
+        {
+            keyVal(jw, "Component Factory Name", component.getFactory());
+        }
+        keyVal(jw, "Default State", component.isDefaultEnabled() ? "enabled" : "disabled");
+        keyVal(jw, "Activation", component.isImmediate() ? "immediate" : "delayed");
+
+        try
+        {
+            keyVal(jw, "Configuration Policy", component.getConfigurationPolicy());
+        }
+        catch (Throwable t)
+        {
+            // missing implementation of said method in the actually bound API
+            // ignore this and just don't display the information
+        }
+
+        listServices(jw, component);
+        listReferences(jw, component);
+        listProperties(jw, component);
+
+        jw.endArray();
+    }
+
+    private void listServices(JSONWriter jw, Component component)
+    {
+        String[] services = component.getServices();
+        if (services == null)
+        {
+            return;
+        }
+
+        keyVal(jw, "Service Type", component.isServiceFactory() ? "service factory"
+            : "service");
+
+        JSONArray buf = new JSONArray();
+        for (int i = 0; i < services.length; i++)
+        {
+            buf.put(services[i]);
+        }
+
+        keyVal(jw, "Services", buf);
+    }
+
+    private void listReferences(JSONWriter jw, Component component)
+    {
+        Reference[] refs = component.getReferences();
+        if (refs != null)
+        {
+            for (int i = 0; i < refs.length; i++)
+            {
+                JSONArray buf = new JSONArray();
+                buf.put(refs[i].isSatisfied() ? "Satisfied" : "Unsatisfied");
+                buf.put("Service Name: " + refs[i].getServiceName());
+                if (refs[i].getTarget() != null)
+                {
+                    buf.put("Target Filter: " + refs[i].getTarget());
+                }
+                buf.put("Multiple: " + (refs[i].isMultiple() ? "multiple" : "single"));
+                buf.put("Optional: " + (refs[i].isOptional() ? "optional" : "mandatory"));
+                buf.put("Policy: " + (refs[i].isStatic() ? "static" : "dynamic"));
+
+                // list bound services
+                ServiceReference[] boundRefs = refs[i].getServiceReferences();
+                if (boundRefs != null && boundRefs.length > 0)
+                {
+                    for (int j = 0; j < boundRefs.length; j++)
+                    {
+                        final StringBuffer b = new StringBuffer();
+                        b.append("Bound Service ID ");
+                        b.append(boundRefs[j].getProperty(Constants.SERVICE_ID));
+
+                        String name = (String) boundRefs[j].getProperty(ComponentConstants.COMPONENT_NAME);
+                        if (name == null)
+                        {
+                            name = (String) boundRefs[j].getProperty(Constants.SERVICE_PID);
+                            if (name == null)
+                            {
+                                name = (String) boundRefs[j].getProperty(Constants.SERVICE_DESCRIPTION);
+                            }
+                        }
+                        if (name != null)
+                        {
+                            b.append(" (");
+                            b.append(name);
+                            b.append(")");
+                        }
+                        buf.put(b.toString());
+                    }
+                }
+                else
+                {
+                    buf.put("No Services bound");
+                }
+
+                keyVal(jw, "Reference " + refs[i].getName(), buf.toString());
+            }
+        }
+    }
+
+    private void listProperties(JSONWriter jw, Component component)
+    {
+        Dictionary props = component.getProperties();
+        if (props != null)
+        {
+            JSONArray buf = new JSONArray();
+            TreeSet keys = new TreeSet(Util.list(props.keys()));
+            for (Iterator ki = keys.iterator(); ki.hasNext();)
+            {
+                final String key = (String) ki.next();
+                final StringBuffer b = new StringBuffer();
+                b.append(key).append(" = ");
+
+                Object prop = props.get(key);
+                prop = WebConsoleUtil.toString(prop);
+                b.append(prop);
+                buf.put(b.toString());
+            }
+
+            keyVal(jw, "Properties", buf);
+        }
+
+    }
+
+    private void keyVal(JSONWriter jw, String key, Object value)
+    {
+        try
+        {
+            WebConsoleUtil.keyVal(jw, key, value);
+        }
+        catch (JSONException je)
+        {
+            // don't care
+        }
+    }
+
+    /**
+     * Check if the component with the specified pid is
+     * configurable
+     * @param providingBundle The Bundle providing the component. This may be
+     *      theoretically be <code>null</code>.
+     * @param pid A non null pid
+     * @return <code>true</code> if the component is configurable.
+     */
+    private boolean isConfigurable(final Bundle providingBundle, final String pid)
+    {
+        // we first check if the config admin has something for this pid
+        final ConfigurationAdmin ca = this.getConfigurationAdmin();
+        if (ca != null)
+        {
+            try
+            {
+                // we use listConfigurations to not create configuration
+                // objects persistently without the user providing actual
+                // configuration
+                String filter = '(' + Constants.SERVICE_PID + '=' + pid + ')';
+                Configuration[] configs = ca.listConfigurations(filter);
+                if (configs != null && configs.length > 0)
+                {
+                    return true;
+                }
+            }
+            catch (InvalidSyntaxException ise)
+            {
+                // should print message
+            }
+            catch (IOException ioe)
+            {
+                // should print message
+            }
+        }
+        // second check is using the meta type service
+        if (providingBundle != null)
+        {
+            final MetaTypeService mts = this.getMetaTypeService();
+            if (mts != null)
+            {
+                final MetaTypeInformation mti = mts.getMetaTypeInformation(providingBundle);
+                if (mti != null)
+                {
+                    return mti.getObjectClassDefinition(pid, null) != null;
+                }
+            }
+        }
+        return false;
+    }
+
+    private final ConfigurationAdmin getConfigurationAdmin()
+    {
+        return (ConfigurationAdmin) getService(CONFIGURATION_ADMIN_NAME);
+    }
+
+    final ScrService getScrService()
+    {
+        return (ScrService) getService(SCR_SERVICE);
+    }
+
+    private final MetaTypeService getMetaTypeService()
+    {
+        return (MetaTypeService) getService(META_TYPE_NAME);
+    }
+
+    private final class RequestInfo
+    {
+        public final String extension;
+        public final Component component;
+        public final boolean componentRequested;
+
+        protected RequestInfo(final HttpServletRequest request)
+        {
+            String info = request.getPathInfo();
+            // remove label and starting slash
+            info = info.substring(getLabel().length() + 1);
+
+            // get extension
+            if (info.endsWith(".json")) //$NON-NLS-1$
+            {
+                extension = "json"; //$NON-NLS-1$
+                info = info.substring(0, info.length() - 5);
+            }
+            else
+            {
+                extension = "html"; //$NON-NLS-1$
+            }
+
+            if (info.length() > 1 && info.startsWith("/")) //$NON-NLS-1$
+            {
+                this.componentRequested = true;
+                info = info.substring(1);
+                Component component = getComponentId(info);
+                if (component == null)
+                {
+                    component = getComponentByName(info);
+                }
+                this.component = component;
+            }
+            else
+            {
+                this.componentRequested = false;
+                this.component = null;
+            }
+
+            request.setAttribute(WebConsolePlugin.this.getClass().getName(), this);
+        }
+
+        protected Component getComponentId(final String componentIdPar)
+        {
+            final ScrService scrService = getScrService();
+            if (scrService != null)
+            {
+                try
+                {
+                    final long componentId = Long.parseLong(componentIdPar);
+                    return scrService.getComponent(componentId);
+                }
+                catch (NumberFormatException nfe)
+                {
+                    // don't care
+                }
+            }
+
+            return null;
+        }
+
+        protected Component getComponentByName(final String names)
+        {
+            if (names.length() > 0)
+            {
+                final ScrService scrService = getScrService();
+                if (scrService != null)
+                {
+
+                    final int slash = names.lastIndexOf('/');
+                    final String componentName;
+                    final String pid;
+                    if (slash > 0)
+                    {
+                        componentName = names.substring(0, slash);
+                        pid = names.substring(slash + 1);
+                    }
+                    else
+                    {
+                        componentName = names;
+                        pid = null;
+                    }
+
+                    Component[] components;
+                    try
+                    {
+                        components = scrService.getComponents(componentName);
+                    }
+                    catch (Throwable t)
+                    {
+                        // not implemented in the used API version
+                        components = null;
+                    }
+
+                    if (components != null)
+                    {
+                        if (pid != null)
+                        {
+                            for (int i = 0; i < components.length; i++)
+                            {
+                                Component component = components[i];
+                                if (pid.equals(component.getProperties().get(
+                                    Constants.SERVICE_PID)))
+                                {
+                                    return component;
+                                }
+                            }
+                        }
+                        else if (components.length > 0)
+                        {
+                            return components[0];
+                        }
+                    }
+                }
+            }
+
+            return null;
+        }
+    }
+
+    static RequestInfo getRequestInfo(final HttpServletRequest request)
+    {
+        return (RequestInfo) request.getAttribute(WebConsolePlugin.class.getName());
+    }
+}

Propchange: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties Mon Sep 12 14:45:53 2011
@@ -0,0 +1,49 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+# native2ascii -encoding utf-8 bundle_bg.raw_properties bundle_bg.properties
+
+# Components plugin
+components.pluginTitle=Компоненти
+scr.status.no_service=Declarative Service не е наличен!
+scr.status.no_components=Няма инсталирани компонент в момента!
+scr.status.ok=Брой инсталирани компоненти: {0}
+scr.action.enable=Enable
+scr.action.disable=Disable
+scr.action.configure=Конфигуриране
+scr.prop.bundle=Бъндъл
+scr.prop.defstate=Статус по подразбиране
+scr.prop.activation=Активация
+scr.prop.properties=Конфигурации
+scr.prop.class=Implementation Class
+scr.prop.componentfactory=Component Factory име
+scr.prop.configurationpolicy=Конфигурационна политика
+scr.serv.type=Тип на услугата
+scr.serv=Услуги
+scr.title.actions=Действия
+scr.title.status=Статус
+scr.title.name=Име

Propchange: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties Mon Sep 12 14:45:53 2011
@@ -0,0 +1,49 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Components plugin
+components.pluginTitle=Komponenten
+scr.status.no_service=Declarative Service ist Voraussetzung für diese Funktionalität!
+scr.status.no_components=Zur Zeit sind keine Komponenten installiert!
+scr.status.ok=Anzahl installierter Komponenten: {0}
+scr.action.enable=Aktivieren
+scr.action.disable=Deaktivieren
+scr.action.configure=Konfigurieren
+scr.prop.bundle=Bundle
+scr.prop.defstate=Default Status
+scr.prop.activation=Aktivierung
+scr.prop.properties=Eigenschaften
+scr.prop.class=Implementationsklasse
+scr.prop.componentfactory=Komponenten Factory Name
+scr.prop.configurationpolicy=Konfigurations Policy
+scr.serv.type=Dienst Typ
+scr.serv=Dienste
+scr.title.actions=Aktionen
+scr.title.status=Status
+scr.title.name=Name

Propchange: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties Mon Sep 12 14:45:53 2011
@@ -0,0 +1,49 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Components plugin
+components.pluginTitle=Компоненты
+scr.status.no_service=Сервис Declarative Service не найден!
+scr.status.no_components=Нет установленных компонентов!
+scr.status.ok=Количество установленных компонентов: {0}
+scr.action.enable=Включить
+scr.action.disable=Выключить
+scr.action.configure=Конфигурировать
+scr.prop.bundle=Модуль
+scr.prop.defstate=Состояние по умолчанию
+scr.prop.activation=Активация
+scr.prop.properties=Конфигурации
+scr.prop.class=Класс реализации
+scr.prop.componentfactory=Имя фабрики компонентов
+scr.prop.configurationpolicy=Политика конфигурирования
+scr.serv.type=Тип сервиса
+scr.serv=Сервисы
+scr.title.actions=Действия
+scr.title.status=Состояние
+scr.title.name=Имя

Propchange: felix/trunk/webconsole-plugins/ds/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties Mon Sep 12 14:45:53 2011
@@ -0,0 +1,49 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Components plugin
+components.pluginTitle=Components
+scr.status.no_service=Declarative Service required for this function!
+scr.status.no_components=No components installed currently!
+scr.status.ok=Number of installed components: {0}
+scr.action.enable=Enable
+scr.action.disable=Disable
+scr.action.configure=Configure
+scr.prop.bundle=Bundle
+scr.prop.defstate=Default State
+scr.prop.activation=Activation
+scr.prop.properties=Properties
+scr.prop.class=Implementation Class
+scr.prop.componentfactory=Component Factory Name
+scr.prop.configurationpolicy=Configuration Policy
+scr.serv.type=Service Type
+scr.serv=Services
+scr.title.actions=Actions
+scr.title.status=Status
+scr.title.name=Name

Propchange: felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.html
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.html?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.html (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.html Mon Sep 12 14:45:53 2011
@@ -0,0 +1,67 @@
+<script type="text/javascript" src="${pluginRoot}/res/plugin.js"></script>
+<script type="text/javascript">
+// <![CDATA[
+var drawDetails = ${__drawDetails__};
+var scrData = ${__data__};
+// i18n
+var i18n = {
+	'Bundle'                 : '${scr.prop.bundle}',
+	'Default State'          : '${scr.prop.defstate}',
+	'Activation'             : '${scr.prop.activation}',
+	'Service Type'           : '${scr.serv.type}',
+	'Services'               : '${scr.serv}',
+	'Properties'             : '${scr.prop.properties}',
+	'Implementation Class'   : '${scr.prop.class}',
+	'Component Factory Name' : '${scr.prop.componentfactory}',
+	'Configuration Policy'   : '${scr.prop.configurationpolicy}',
+	stat_no_service          : "${scr.status.no_service}",
+	stat_no_components       : "${scr.status.no_components}",
+	stat_ok                  : "${scr.status.ok}"
+}
+// ]]>
+</script>
+<p class="statline">&nbsp;</p>
+
+
+<div id="scr"> <!-- data available -->
+	<!-- top header -->
+	<form method='post' enctype='multipart/form-data' action="${pluginRoot}">
+		<div class="ui-widget-header ui-corner-top buttonGroup">
+			<button class='reloadButton' type='button' name='reload'>${reload}</button>
+		</div>
+	</form>
+	
+	<table id="plugin_table" class="tablesorter nicetable noauto">
+	<thead>
+		<tr>
+			<th class="col_Id">${id}</th>
+			<th class="col_Name">${scr.title.name}</th>
+			<th class="col_Status">${scr.title.status}</th>
+			<th class="col_Actions">${scr.title.actions}</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr>
+			<td>&nbsp;</td> <!-- id -->
+			<td> <!-- name with arrow -->
+				<div class="bIcon ui-icon ui-icon-triangle-1-e" style="float:left" title="${scr.details.tip}">&nbsp;</div>
+			</td> 
+			<td>&nbsp;</td> <!-- status -->
+			<td>
+				<ul class="icons">
+					<li class="dynhover ui-helper-hidden" title="${scr.action.enable}"><span class="ui-icon ui-icon-play">&nbsp;</span></li>
+					<li class="dynhover ui-helper-hidden" title="${scr.action.disable}"><span class="ui-icon ui-icon-stop">&nbsp;</span></li>
+					<li class="dynhover ui-helper-hidden" title="${scr.action.configure}"><span class="ui-icon ui-icon-wrench">&nbsp;</span></li>
+				</ul>
+			</td>
+		</tr>
+	</tbody>
+	</table>
+</div> <!-- end data available -->
+
+<!-- bottom header -->
+<form method='post' enctype='multipart/form-data' action="${pluginRoot}">
+	<div class="ui-widget-header ui-corner-bottom buttonGroup">
+		<button class='reloadButton' type='button' name='reload'>${reload}</button>
+	</div>
+</form>

Propchange: felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js (added)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js Mon Sep 12 14:45:53 2011
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *	  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function renderData( eventData )  {
+	switch(eventData.status) {
+		case -1: // no event admin
+			$('.statline').html(i18n.stat_no_service);
+			$('#scr').addClass('ui-helper-hidden');
+			break;
+		case  0: // no components
+			$('.statline').html(i18n.stat_no_components);
+			$('#scr').addClass('ui-helper-hidden');
+			break;
+		default:
+			$('.statline').html(i18n.stat_ok.msgFormat(eventData.status));
+			$('#scr').removeClass('ui-helper-hidden');
+
+			tableBody.empty();
+			for ( var idx in eventData.data ) {
+				entry( eventData.data[idx] );
+			}
+			if ( drawDetails ) renderDetails(eventData);
+			initStaticWidgets();
+	}
+}
+
+function getEntryId(/* Object */ dataEntry) {
+    var id = dataEntry.id;
+    if (id < 0) {
+        id = dataEntry.name;
+        if (dataEntry.pid) {
+            id += '/' + dataEntry.pid;
+        }
+    }
+    return id;
+}
+
+function entry( /* Object */ dataEntry ) {
+	var idPath = getEntryId(dataEntry);
+	var id = idPath.replace(/[./-]/g, '_');
+	var name = dataEntry.name;
+	var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'entry' + id);
+
+	_.find('.bIcon').attr('id', 'img' + id).click(function() {
+		showDetails(idPath);
+	}).after(drawDetails ? name : ('<a href="' + pluginRoot + '/' + idPath + '">' + name + '</a>'));
+
+	_.find('td:eq(0)').text( dataEntry.id );
+	_.find('td:eq(2)').text( dataEntry.state );
+
+	// setup buttons
+	if ( dataEntry.stateRaw == 1 || dataEntry.stateRaw == 1024 ) { // disabled or disabling
+		_.find('li:eq(0)').removeClass('ui-helper-hidden').click(function() { changeDataEntryState(idPath, 'enable') });
+	} else {
+		_.find('li:eq(1)').removeClass('ui-helper-hidden').click(function() { changeDataEntryState(idPath, 'disable') });
+	}
+	if ( dataEntry.configurable ) _.find('li:eq(2)').removeClass('ui-helper-hidden').click(function() { // configure
+		changeDataEntryState(dataEntry.pid, 'configure');
+	});	
+}
+
+function changeDataEntryState(/* long */ id, /* String */ action) {
+	if ( action == 'configure') {
+		window.location = appRoot + '/configMgr/' + id;
+		return;
+	}
+	$.post(pluginRoot + '/' + id, {'action':action}, function(data) {
+		renderData(data);
+	}, 'json');	
+}
+
+function showDetails( id ) {
+	$.get(pluginRoot + '/' + id + '.json', null, function(data) {
+		renderDetails(data);
+	}, 'json');
+}
+
+function hideDetails( id ) {
+	var __test__ = $('#img' + id);
+	$('#img' + id).each(function() {
+		$('#pluginInlineDetails').remove();
+		$(this).
+			removeClass('ui-icon-triangle-1-w').//left
+			removeClass('ui-icon-triangle-1-s').//down
+			addClass('ui-icon-triangle-1-e').//right
+		    attr('title', 'Details').
+			unbind('click').click(function() {showDetails(id)});
+	});
+}
+
+function renderDetails( data ) {
+	data = data.data[0];
+	var id = getEntryId(data).replace(/[./-]/g, '_');
+	$('#pluginInlineDetails').remove();
+	var __test__ = $('#entry' + id);
+	$('#entry' + id + ' > td').eq(1).append('<div id="pluginInlineDetails"/>');
+	$('#img' + id).each(function() {
+		if ( drawDetails ) {
+			var ref = window.location.pathname;
+			ref = ref.substring(0, ref.lastIndexOf('/'));
+			$(this).
+				removeClass('ui-icon-triangle-1-e').//right
+				removeClass('ui-icon-triangle-1-s').//down
+				addClass('ui-icon-triangle-1-w').//left
+				attr('title', 'Back').
+				unbind('click').click(function() {window.location = ref});
+		} else {
+			$(this).
+				removeClass('ui-icon-triangle-1-w').//left
+				removeClass('ui-icon-triangle-1-e').//right
+				addClass('ui-icon-triangle-1-s').//down
+				attr('title', 'Hide Details').
+				unbind('click').click(function() {hideDetails(id)});
+		}
+	});
+	$('#pluginInlineDetails').append('<table border="0"><tbody></tbody></table>');
+	var details = data.props;
+	for (var idx in details) {
+		var prop = details[idx];
+		var key = i18n[prop.key] ? i18n[prop.key] : prop.key; // i18n
+
+		var txt = '<tr><td class="aligntop" noWrap="true" style="border:0px none">' + key + '</td><td class="aligntop" style="border:0px none">';
+		if (prop.value) {
+			if ( $.isArray(prop.value) ) {
+				var i = 0;
+				for(var pi in prop.value) {
+					var value = prop.value[pi];
+					if (i > 0) { txt = txt + '<br/>'; }
+					var span;
+					if (value.substring(0, 2) == '!!') {
+						txt = txt + '<span style="color: red;'> + value + '</span>';
+					} else {
+						txt = txt + value;
+					}
+					i++;
+				}
+			} else {
+				txt = txt + prop.value;
+			}
+		} else {
+			txt = txt + '\u00a0';
+		}
+		txt = txt + '</td></tr>';
+		$('#pluginInlineDetails > table > tbody').append(txt);
+	}
+}
+
+var tableBody = false;
+var tableEntryTemplate = false;
+var pluginTable = false;
+
+$(document).ready(function(){
+	pluginTable = $('#plugin_table');
+	tableBody = pluginTable.find('tbody');
+	tableEntryTemplate = tableBody.find('tr').clone();
+
+	renderData(scrData);
+
+	$('.reloadButton').click(document.location.reload);
+
+	pluginTable.tablesorter({
+		headers: {
+			0: { sorter:'digit'},
+			3: { sorter: false }
+		},
+		sortList: [[1,0]],
+		textExtraction:mixedLinksExtraction
+	});
+});
+

Propchange: felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/obr/LICENSE
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr/LICENSE?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/obr/LICENSE (added)
+++ felix/trunk/webconsole-plugins/obr/LICENSE Mon Sep 12 14:45:53 2011
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: felix/trunk/webconsole-plugins/obr/NOTICE
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr/NOTICE?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/obr/NOTICE (added)
+++ felix/trunk/webconsole-plugins/obr/NOTICE Mon Sep 12 14:45:53 2011
@@ -0,0 +1,21 @@
+Apache Felix OSGi Web Console Event Plugin
+Copyright 2007-2010 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0

Added: felix/trunk/webconsole-plugins/obr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr/pom.xml?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/obr/pom.xml (added)
+++ felix/trunk/webconsole-plugins/obr/pom.xml Mon Sep 12 14:45:53 2011
@@ -0,0 +1,127 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+	license agreements. See the NOTICE file distributed with this work for additional 
+	information regarding copyright ownership. The ASF licenses this file to 
+	you under the Apache License, Version 2.0 (the "License"); you may not use 
+	this file except in compliance with the License. You may obtain a copy of 
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+	by applicable law or agreed to in writing, software distributed under the 
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+	OF ANY KIND, either express or implied. See the License for the specific 
+	language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.felix</groupId>
+		<artifactId>felix-parent</artifactId>
+		<version>1.2.0</version>
+		<relativePath>../../../pom/pom.xml</relativePath>
+	</parent>
+
+	<artifactId>org.apache.felix.webconsole.plugins.obr</artifactId>
+	<packaging>bundle</packaging>
+	<version>1.0.0-SNAPSHOT</version>
+
+	<name>Apache Felix Web Console OBR Plugin</name>
+	<description>
+        This Apache Felix OSGi web console plugin provides method to install bundles from a bundle repository.
+    </description>
+
+	<scm>
+		<connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/obr</connection>
+		<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/obr</developerConnection>
+		<url>http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr</url>
+	</scm>
+
+	<build>
+		<plugins>
+			<!-- translate UTF-8 encoded properties files to ISO-8859-1 -->
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>native2ascii-maven-plugin</artifactId>
+				<version>1.0-alpha-1</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>native2ascii</goal>
+						</goals>
+						<configuration>
+							<encoding>UTF-8</encoding>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>2.0.1</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Bundle-SymbolicName>
+							${artifactId}
+                        </Bundle-SymbolicName>
+						<Bundle-Activator>
+							org.apache.felix.webconsole.plugins.obr.internal.Activator
+                        </Bundle-Activator>
+						<DynamicImport-Package>
+                            org.apache.felix.bundlerepository,
+                            org.osgi.service.obr
+                        </DynamicImport-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.4</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>4.0.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+			<version>4.1.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.json</groupId>
+			<artifactId>json</artifactId>
+			<version>20070829</version>
+			<scope>compile</scope>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.webconsole</artifactId>
+			<version>3.0.0</version>
+			<scope>provided</scope>
+		</dependency>
+
+        <!-- OSGi and Apache Felix OBR API -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.service.obr</artifactId>
+            <version>1.0.2</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.bundlerepository</artifactId>
+            <version>1.6.0</version>
+            <scope>provided</scope>
+            <optional>true</optional>
+        </dependency>
+	</dependencies>
+</project>

Propchange: felix/trunk/webconsole-plugins/obr/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/AbstractBundleRepositoryRenderHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/AbstractBundleRepositoryRenderHelper.java?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/AbstractBundleRepositoryRenderHelper.java (added)
+++ felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/AbstractBundleRepositoryRenderHelper.java Mon Sep 12 14:45:53 2011
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.webconsole.plugins.obr.internal;
+
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import org.apache.felix.webconsole.AbstractWebConsolePlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+abstract class AbstractBundleRepositoryRenderHelper
+{
+
+    protected final AbstractWebConsolePlugin logger;
+
+    private final ServiceTracker repositoryAdmin;
+
+
+    protected AbstractBundleRepositoryRenderHelper( final AbstractWebConsolePlugin logger,
+        final BundleContext bundleContext, final String serviceName )
+    {
+        this.logger = logger;
+        this.repositoryAdmin = new ServiceTracker( bundleContext, serviceName, null );
+        this.repositoryAdmin.open();
+    }
+
+
+    void dispose()
+    {
+        repositoryAdmin.close();
+    }
+
+
+    boolean hasRepositoryAdmin()
+    {
+        return getRepositoryAdmin() != null;
+    }
+
+
+    protected final Object getRepositoryAdmin()
+    {
+        return repositoryAdmin.getService();
+    }
+
+
+    abstract void doDeploy( String[] bundles, boolean start, boolean optional );
+
+
+    abstract void doAction( String action, String urlParam ) throws IOException, ServletException;
+
+
+    abstract String getData( final String filter, final boolean details, final Bundle[] bundles );
+
+}
\ No newline at end of file

Propchange: felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/AbstractBundleRepositoryRenderHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/Activator.java?rev=1169777&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/Activator.java (added)
+++ felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/Activator.java Mon Sep 12 14:45:53 2011
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.webconsole.plugins.obr.internal;
+
+import org.apache.felix.webconsole.SimpleWebConsolePlugin;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Activator is the main starting class.
+ */
+public class Activator implements BundleActivator, ServiceTrackerCustomizer, Constants
+{
+
+    private ServiceTracker tracker;
+    private BundleContext context;
+
+    private SimpleWebConsolePlugin plugin;
+
+    /**
+     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+     */
+    public final void start(BundleContext context) throws Exception
+    {
+        this.context = context;
+        Filter filter = context.createFilter("(|" //$NON-NLS-1$
+            + '(' + OBJECTCLASS + "=org.osgi.service.obr.RepositoryAdmin)" //$NON-NLS-1$
+            + '(' + OBJECTCLASS + "=org.apache.felix.bundlerepository.RepositoryAdmin)" //$NON-NLS-1$
+            + ')');
+        this.tracker = new ServiceTracker(context, filter, this);
+        this.tracker.open();
+    }
+
+    /**
+     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+     */
+    public final void stop(BundleContext context) throws Exception
+    {
+        if (tracker != null)
+        {
+            tracker.close();
+            tracker = null;
+        }
+    }
+
+    // - begin tracker
+    /**
+     * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference,
+     *      java.lang.Object)
+     */
+    public final void modifiedService(ServiceReference reference, Object service)
+    {/* unused */
+    }
+
+    /**
+     * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
+     */
+    public final Object addingService(ServiceReference reference)
+    {
+        SimpleWebConsolePlugin plugin = this.plugin;
+        if (plugin == null)
+        {
+            this.plugin = plugin = new WebConsolePlugin().register(context);
+        }
+
+        return context.getService(reference);
+    }
+
+    /**
+     * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference,
+     *      java.lang.Object)
+     */
+    public final void removedService(ServiceReference reference, Object service)
+    {
+        SimpleWebConsolePlugin plugin = this.plugin;
+
+        if (tracker.getTrackingCount() == 0 && plugin != null)
+        {
+            plugin.unregister();
+            this.plugin = null;
+        }
+
+    }
+}

Propchange: felix/trunk/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/Activator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain