Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * 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.internal.servlet;
  
  import java.net.URL;
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  import java.util.Set;
  
  
The OSGi Manager is the actual Web Console Servlet which is registered with the OSGi Http Service and which maintains registered console plugins.
  
  public class OsgiManager extends GenericServlet
  {

    
Pseudo class version ID to keep the IDE quite.
  
      private static final long serialVersionUID = 1L;

    
Old name of the request attribute providing the root to the web console. This attribute is no deprecated and replaced by org.apache.felix.webconsole.WebConsoleConstants.ATTR_APP_ROOT.

  
      private static final String ATTR_APP_ROOT_OLD = OsgiManager.class.getName()
          + ".appRoot";

    
Old name of the request attribute providing the mappings from label to page title. This attribute is now deprecated and replaced by org.apache.felix.webconsole.WebConsoleConstants.ATTR_LABEL_MAP.

 
     private static final String ATTR_LABEL_MAP_OLD = OsgiManager.class.getName()
         + ".labelMap";

    
The name of the (internal) request attribute providing the categorized label map structure.
 
     public static final String ATTR_LABEL_MAP_CATEGORIZED = . + ".categorized";

    
The name and value of a parameter which will prevent redirection to a render after the action has been executed (value is "_noredir_"). This may be used by programmatic action submissions.
 
     public static final String PARAM_NO_REDIRECT_AFTER_ACTION = "_noredir_";

    
The name of the cookie storing user-configured locale See https://issues.apache.org/jira/browse/FELIX-2267
 
     private static final String COOKIE_LOCALE = "felix-webconsole-locale"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_MANAGER_ROOT = "felix.webconsole.manager.root"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_REALM = "felix.webconsole.realm"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_USER_NAME = "felix.webconsole.username"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_PASSWORD = "felix.webconsole.password"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_LOG_LEVEL = "felix.webconsole.loglevel"//$NON-NLS-1$
 
     private static final String FRAMEWORK_PROP_LOCALE = "felix.webconsole.locale"//$NON-NLS-1$
 
     static final String PROP_MANAGER_ROOT = "manager.root"//$NON-NLS-1$
 
     static final String PROP_DEFAULT_RENDER = "default.render"//$NON-NLS-1$
 
     static final String PROP_REALM = "realm"//$NON-NLS-1$
 
     static final String PROP_USER_NAME = "username"//$NON-NLS-1$
 
     static final String PROP_PASSWORD = "password"//$NON-NLS-1$
 
     static final String PROP_CATEGORY = "category"//$NON-NLS-1$
 
     static final String PROP_ENABLED_PLUGINS = "plugins"//$NON-NLS-1$
 
     static final String PROP_LOG_LEVEL = "loglevel"//$NON-NLS-1$
 
     static final String PROP_LOCALE = "locale"//$NON-NLS-1$
 
     static final String PROP_HTTP_SERVICE_SELECTOR = "http.service.filter"//$NON-NLS-1$
 
     public static final int DEFAULT_LOG_LEVEL = .;
 
     static final String DEFAULT_PAGE = .;
 
     static final String DEFAULT_REALM = "OSGi Management Console"//$NON-NLS-1$
 
     static final String DEFAULT_USER_NAME = "admin"//$NON-NLS-1$
 
     static final String DEFAULT_PASSWORD = "{sha-256}jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="//$NON-NLS-1$
 
     static final String DEFAULT_CATEGORY = "Main"//$NON-NLS-1$
 
     static final String DEFAULT_HTTP_SERVICE_SELECTOR = ""//$NON-NLS-1$
 
    
The default value for the PROP_MANAGER_ROOT configuration property (value is "/system/console").
 
     static final String DEFAULT_MANAGER_ROOT = "/system/console"//$NON-NLS-1$
 
     private static final String OLD_CONFIG_MANAGER_CLASS = "org.apache.felix.webconsole.internal.compendium.ConfigManager"//$NON-NLS-1$
     private static final String NEW_CONFIG_MANAGER_CLASS = "org.apache.felix.webconsole.internal.configuration.ConfigManager"//$NON-NLS-1$
 
     static final String[] PLUGIN_CLASSES = {
             "org.apache.felix.webconsole.internal.configuration.ConfigurationAdminConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.compendium.PreferencesConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.compendium.WireAdminConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.core.BundlesConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.core.PermissionsConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.core.ServicesConfigurationPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.misc.SystemPropertiesPrinter"//$NON-NLS-1$
             "org.apache.felix.webconsole.internal.misc.ThreadPrinter", }; //$NON-NLS-1$
 
     static final String[] PLUGIN_MAP = {
             "configMgr"//$NON-NLS-1$ //$NON-NLS-2$
             "org.apache.felix.webconsole.internal.compendium.LogServlet""logs"//$NON-NLS-1$ //$NON-NLS-2$
             "org.apache.felix.webconsole.internal.core.BundlesServlet""bundles"//$NON-NLS-1$ //$NON-NLS-2$
             "org.apache.felix.webconsole.internal.core.ServicesServlet""services"//$NON-NLS-1$ //$NON-NLS-2$
             "org.apache.felix.webconsole.internal.misc.LicenseServlet""licenses"//$NON-NLS-1$ //$NON-NLS-2$
             "org.apache.felix.webconsole.internal.system.VMStatPlugin""vmstat"//$NON-NLS-1$ //$NON-NLS-2$
     };
 
     private BundleContext bundleContext;
 
 
     private HttpService httpService;
 
     private PluginHolder holder;
 
     private ServiceTracker brandingTracker;
 
 
 
     // list of OsgiManagerPlugin instances activated during init. All these
     // instances will have to be deactivated during destroy
     private List osgiManagerPlugins = new ArrayList();
 
     private String webManagerRoot;
 
     // true if the OsgiManager is registered as a Servlet with the HttpService
     private boolean httpServletRegistered;
 
     // true if the resources have been registered with the HttpService
     private boolean httpResourcesRegistered;
 
     // default configuration from framework properties
     private HashMap defaultConfiguration;
 
     // configuration from Configuration Admin
     private HashMap configuration;
 
     // See https://issues.apache.org/jira/browse/FELIX-2267
     private Locale configuredLocale;
 
     private Set enabledPlugins;
 
 
     private int logLevel = ;
 
     private String defaultCategory = ;
 
     public OsgiManager(BundleContext bundleContext)
     {
         this. = bundleContext;
         this. = new PluginHolder(bundleContext);
 
         // new plugins setup
         for (int i = 0; i < .i++)
         {
             final String pluginClassName = [i++];
             final String label = [i];
             .addInternalPlugin(thispluginClassNamelabel);
         }
 
         // setup the included plugins
         ClassLoader classLoader = getClass().getClassLoader();
         for (int i = 0; i < .i++)
         {
             String pluginClassName = [i];
 
             try
             {
                 Class pluginClass = classLoader.loadClass(pluginClassName);
                 Object plugin = pluginClass.newInstance();
 
                 if (plugin instanceof OsgiManagerPlugin)
                 {
                     ((OsgiManagerPluginplugin).activate(bundleContext);
                     .add(plugin);
                 }
                 if (plugin instanceof BrandingPlugin)
                 {
                     AbstractWebConsolePlugin.setBrandingPlugin((BrandingPluginplugin);
                 }
             }
             catch (NoClassDefFoundError ncdfe)
             {
                 String message = ncdfe.getMessage();
                 if (message == null)
                 {
                     // no message, construct it
                     message = "Class definition not found (NoClassDefFoundError)";
                 }
                 else if (message.indexOf(' ') < 0)
                 {
                     // message is just a class name, try to be more descriptive
                     message = "Class " + message + " missing";
                 }
                 log(.pluginClassName + " not enabled. Reason: "
                     + message);
             }
             catch (Throwable t)
             {
                 log(."Failed to instantiate plugin "
                     + pluginClassName + ". Reason: " + t);
             }
         }
 
         // the resource bundle manager
 
         // start the configuration render, providing the resource bundle manager
         //ConfigurationRender cr = new ConfigurationRender(resourceBundleManager);
         //cr.activate(bundleContext);
         //osgiManagerPlugins.add(cr);
         //holder.addOsgiManagerPlugin(cr);
 
         // start tracking external plugins after setting up our own plugins
         .open();
 
         // accept new console branding service
          = new BrandingServiceTracker(this);
         .open();
 
         // add support for pluggable security
          = new ServiceTracker(bundleContext,
             WebConsoleSecurityProvider.class.getName(), null);
         .open();
 
         // load the default configuration from the framework
         this. = new HashMap();
             ConfigurationUtil.getPropertybundleContext ) );
         this..put,
             ConfigurationUtil.getPropertybundleContext ) );
         this..put,
             ConfigurationUtil.getPropertybundleContext ) );
         this..put,
             ConfigurationUtil.getPropertybundleContext ) );
         this..put,
             new Integer( ConfigurationUtil.getPropertybundleContext ) ) );
         this..put,
             ConfigurationUtil.getPropertybundleContextnull ) );
 
         // configure and start listening for configuration
         updateConfiguration(null);
 
         // register managed service as a service factory
         this. = bundleContext.registerService"org.osgi.service.cm.ManagedService"//$NON-NLS-1$
             new ServiceFactory()
             {
                 public Object getServiceBundle bundleServiceRegistration registration )
                 {
                     /*
                      * Explicitly load the class through the class loader to dynamically
                      * wire the API if not wired yet. Implicit loading by creating a
                      * class instance does not seem to properly work wiring the API
                      * in time.
                      */
                     try
                     {
                         OsgiManager.this.getClass().getClassLoader()
                             .loadClass"org.osgi.service.metatype.MetaTypeProvider" );
                         return new ConfigurationMetatypeSupportOsgiManager.this );
                     }
                     catch ( ClassNotFoundException cnfe )
                     {
                         // ignore
                     }
 
                     return new ConfigurationSupportOsgiManager.this );
                 }
 
 
                 public void ungetServiceBundle bundleServiceRegistration registrationObject service )
                 {
                     // do nothing
                 }
             }, new Hashtable()
             {
                 {
                     put."The Apache Software Foundation" ); //$NON-NLS-1$
                     put."OSGi Management Console Configuration Receiver" ); //$NON-NLS-1$
                     put.getConfigurationPid() );
                 }
             } );
     }
 
     public void dispose()
     {
         // dispose off held plugins
         .close();
 
         // dispose off the resource bundle manager
         if ( != null)
         {
             .dispose();
              = null;
         }
 
         // stop listening for brandings
         if ( != null)
         {
             .close();
              = null;
         }
 
         // deactivate any remaining plugins
         for (Iterator pi = .iterator(); pi.hasNext();)
         {
             Object plugin = pi.next();
             ((OsgiManagerPluginplugin).deactivate();
         }
 
         // simply remove all operations, we should not be used anymore
         this..clear();
 
         // now drop the HttpService and continue with further destroyals
         if ( != null)
         {
             .close();
              = null;
         }
 
         // stop listening for configuration
         if ( != null)
         {
             .unregister();
              = null;
         }
 
         // stop tracking security provider
         if ( != null)
         {
             .close();
              = null;
         }
 
         this. = null;
     }
 
     //---------- Servlet API
 
    
 
     public void init()
     {
         // base class initialization not needed, since the GenericServlet.init
         // is an empty method
 
 
     }

    
 
     public void service(final ServletRequest reqfinal ServletResponse res)
         throws ServletExceptionIOException
     {
         // don't really expect to be called within a non-HTTP environment
         try
         {
             AccessController.doPrivileged(new PrivilegedExceptionAction()
             {
                 public Object run() throws Exception
                 {
                     service((HttpServletRequestreq, (HttpServletResponseres);
                     return null;
                 }
             });
         }
         catch (PrivilegedActionException e)
         {
             Exception x = e.getException();
             if (x instanceof IOException)
             {
                 throw (IOExceptionx;
             }
             else if (x instanceof ServletException)
             {
                 throw (ServletExceptionx;
             }
             else
             {
                 throw new IOException(x.toString());
             }
         }
 
         // ensure response has been sent back and response is committed
         // (we are authorative for our URL space and no other servlet should interfere)
         res.flushBuffer();
     }
 
     private void ensureLocaleCookieSet(HttpServletRequest requestHttpServletResponse responseLocale locale) {
         Cookie[] cookies = request.getCookies();
         boolean hasCookie = false;
         for(int i=0; cookies != null && i<cookies.length;i++) {
             if (.equals(cookies[i].getName()) ) {
                 hasCookie = true;
                 break;
             }
         }
         if (!hasCookie) {
             Cookie cookie = new Cookie(locale.toString());
             cookie.setPath((String)request.getAttribute(.));
             cookie.setMaxAge(20 * 365 * 24 * 60 * 60); // 20 years
             response.addCookie(cookie);
         }
     }
 
     void service(HttpServletRequest requestHttpServletResponse response)
         throws ServletExceptionIOException
     {
         // check whether we are not at .../{webManagerRoot}
         final String pathInfo = request.getPathInfo();
         if (pathInfo == null || pathInfo.equals("/")) //$NON-NLS-1$
         {
             String path = request.getRequestURI();
             if (!path.endsWith("/")) //$NON-NLS-1$
             {
                 path = path.concat("/"); //$NON-NLS-1$
             }
             path = path.concat(.getDefaultPluginLabel());
             response.sendRedirect(path);
             return;
         }
 
         int slash = pathInfo.indexOf("/", 1);
         if (slash < 2)
         {
             slash = pathInfo.length();
         }
 
         final Locale locale = getConfiguredLocale(request);
         final String label = pathInfo.substring(1, slash);
         AbstractWebConsolePlugin plugin = getConsolePlugin(label);
         if (plugin != null)
         {
             final Map labelMap = .getLocalizedLabelMaplocalethis. );
             final Object flatLabelMap = labelMap.remove. );
 
             // the official request attributes
             request.setAttribute(.getLangMap());
             request.setAttribute(.flatLabelMap);
             request.setAttributelabelMap );
             request.setAttribute(.,
                 request.getContextPath() + request.getServletPath());
             request.setAttribute(.,
                 request.getContextPath() + request.getServletPath() + '/' + label);
 
             // deprecated request attributes
             request.setAttribute(flatLabelMap);
             request.setAttribute(,
                 request.getContextPath() + request.getServletPath());
 
             // fix for https://issues.apache.org/jira/browse/FELIX-3408
             ensureLocaleCookieSet(requestresponselocale);
 
             // wrap the response for localization and template variable replacement
             request = wrapRequest(requestlocale);
             response = wrapResponse(requestresponseplugin);
 
             plugin.service(requestresponse);
         }
         else
         {
             final String body404 = MessageFormat.format(
                 .getResourceBundle(.getBundle(), locale).getString(
                     "404"), //$NON-NLS-1$
                 new Object[] { request.getContextPath() + request.getServletPath() + '/'
                     + . });
             response.setCharacterEncoding("utf-8"); //$NON-NLS-1$
             response.setContentType("text/html"); //$NON-NLS-1$
             response.setStatus(.);
             response.getWriter().println(body404);
         }
     }
 
     private final AbstractWebConsolePlugin getConsolePlugin(final String label)
     {
         // backwards compatibility for the former "install" action which is
         // used by the Maven Sling Plugin
         if ("install".equals(label)) //$NON-NLS-1$
         {
             return .getPlugin(.);
         }
 
         AbstractWebConsolePlugin plugin = .getPluginlabel );
         if ( plugin == null && label.indexOf'.' ) > 0 )
         {
             int last = 0;
             for ( int dot = label.indexOf'.'last ); plugin == null && dot > lastlast = dot + 1, dot = label
                 .indexOf'.'last ) )
             {
                 final String pluginLabel = label.substring( 0, dot );
                 plugin = .getPluginpluginLabel );
             }
         }
         return plugin;
     }
 
     // See https://issues.apache.org/jira/browse/FELIX-2267
     private final Locale getConfiguredLocale(HttpServletRequest request)
     {
         Locale locale = null;
 
         Cookie[] cookies = request.getCookies();
         for (int i = 0; cookies != null && i < cookies.lengthi++)
         {
             if (.equals(cookies[i].getName()))
             {
                 locale = Util.parseLocaleString(cookies[i].getValue());
                 break;
             }
         }
 
         // TODO: check UserAdmin ?
 
         if (locale == null)
             locale = ;
         if (locale == null)
             locale = request.getLocale();
 
         return locale;
     }

    
 
     public void destroy()
     {
         // base class destroy not needed, since the GenericServlet.destroy
         // is an empty method
 
         .setServletContext(null);
     }
 
     //---------- internal
 
     {
         return ;
     }

    
Returns the Service PID used to retrieve configuration and to describe the configuration properties.
 
     {
         return getClass().getName();
     }


    
Calls the ServletContext.log(String) method if the configured log level is less than or equal to the given level.

Note, that the level parameter is only used to decide whether the GenericServlet.log(String) method is called or not. The actual implementation of the GenericServlet.log method is outside of the control of this method.

If the servlet has not been initialized yet or has already been destroyed the message is printed to stderr.

Parameters:
level The log level at which to log the message
message The message to log
 
     void log(int levelString message)
     {
         if ( >= level)
         {
             ServletConfig config = getServletConfig();
             if ( config != null )
             {
                 ServletContext context = config.getServletContext();
                 if ( context != null )
                 {
                     context.logmessage );
                     return;
                 }
             }
 
             ..printlnmessage );
         }
     }

    
Calls the ServletContext.log(String, Throwable) method if the configured log level is less than or equal to the given level.

Note, that the level parameter is only used to decide whether the GenericServlet.log(String, Throwable) method is called or not. The actual implementation of the GenericServlet.log method is outside of the control of this method.

If the servlet has not been initialized yet or has already been destroyed the message is printed to stderr.

Parameters:
level The log level at which to log the message
message The message to log
t The Throwable to log with the message
 
     void log(int levelString messageThrowable t)
     {
         if ( >= level)
         {
             ServletConfig config = getServletConfig();
             if ( config != null )
             {
                 ServletContext context = config.getServletContext();
                 if ( context != null )
                 {
                     context.logmessaget );
                     return;
                 }
             }
 
             ..printlnmessage );
             if ( t != null )
             {
                 t.printStackTrace. );
             }
         }
     }
 
     private HttpServletRequest wrapRequest(final HttpServletRequest request,
         final Locale locale)
     {
         return new HttpServletRequestWrapper(request)
         {
            
 
             public Locale getLocale()
             {
                 return locale;
             }
         };
     }
 
     private HttpServletResponse wrapResponse(final HttpServletRequest request,
         final HttpServletResponse responsefinal AbstractWebConsolePlugin plugin)
     {
         final Locale locale = request.getLocale();
         final ResourceBundle resourceBundle = .getResourceBundle(
             plugin.getBundle(), locale);
         return new FilteringResponseWrapper(responseresourceBundlerequest);
     }
 
     private static class HttpServiceTracker extends ServiceTracker
     {
 
         private static final String HTTP_SERVICE = "org.osgi.service.http.HttpService"//$NON-NLS-1$
 
         private final OsgiManager osgiManager;
 
         private final String httpServiceSelector;
 
         static HttpServiceTracker create(OsgiManager osgiManager,
             String httpServiceSelector)
         {
             // got a service selector filter
             if (httpServiceSelector != null && httpServiceSelector.length() > 0)
             {
                 try
                 {
                     final String filterString = "(&(" + . + "=" //$NON-NLS-1$ //$NON-NLS-2$
                         +  + ")(" + httpServiceSelector + "))"//$NON-NLS-1$ //$NON-NLS-2$
                     Filter filter = osgiManager.getBundleContext().createFilter(
                         filterString);
                     return new HttpServiceTracker(osgiManagerhttpServiceSelector,
                         filter);
                 }
                 catch (InvalidSyntaxException ise)
                 {
                     // TODO: log or throw or ignore ....
                 }
             }
 
             // no filter or illegal filter string
             return new HttpServiceTracker(osgiManager);
         }
 
         private HttpServiceTracker(final OsgiManager osgiManager)
         {
             super(osgiManager.getBundleContext(), null);
             this. = osgiManager;
             this. = null;
         }
 
         private HttpServiceTracker(final OsgiManager osgiManagerfinal String httpServiceSelectorfinal Filter httpServiceFilter)
         {
             super(osgiManager.getBundleContext(), httpServiceFilternull);
             this. = osgiManager;
             this. = httpServiceSelector;
         }
 
         boolean isSameSelector(final String newHttpServiceSelector)
         {
             if (newHttpServiceSelector != null)
             {
                 return newHttpServiceSelector.equals();
             }
             return  == null;
         }
 
         public Object addingService(ServiceReference reference)
         {
             Object service = super.addingService(reference);
             if (service instanceof HttpService)
             {
                 .bindHttpService((HttpServiceservice);
             }
             return service;
         }
 
         public void removedService(ServiceReference referenceObject service)
         {
             if (service instanceof HttpService)
             {
                 .unbindHttpService((HttpServiceservice);
             }
 
             super.removedService(referenceservice);
         }
     }
 
     private static class BrandingServiceTracker extends ServiceTracker
     {
         BrandingServiceTracker(OsgiManager osgiManager)
         {
             super(osgiManager.getBundleContext(), BrandingPlugin.class.getName(), null);
         }
 
         public Object addingService(ServiceReference reference)
         {
             Object plugin = super.addingService(reference);
             if (plugin instanceof BrandingPlugin)
             {
                 AbstractWebConsolePlugin.setBrandingPlugin((BrandingPluginplugin);
             }
             return plugin;
         }
 
         public void removedService(ServiceReference referenceObject service)
         {
             if (service instanceof BrandingPlugin)
             {
                 AbstractWebConsolePlugin.setBrandingPlugin(null);
             }
             super.removedService(referenceservice);
         }
 
     }
 
     protected synchronized void bindHttpService(HttpService httpService)
     {
         // do not bind service, when we are already bound
         if (this. != null)
         {
             log(.,
                 "bindHttpService: Already bound to an HTTP Service, ignoring further services");
             return;
         }
 
         Map config = getConfiguration();
 
         // get authentication details
         String realm = ConfigurationUtil.getProperty(config);
         String userId = ConfigurationUtil.getProperty(config);
         String password = ConfigurationUtil.getProperty(config);
 
         // register the servlet and resources
         try
         {
             HttpContext httpContext = new OsgiManagerHttpContext(httpService,
                 userIdpasswordrealm);
 
             Dictionary servletConfig = toStringConfig(config);
 
             // register this servlet and take note of this
             httpService.registerServlet(this.thisservletConfig,
                 httpContext);
              = true;
 
             // register resources and take of this
             httpService.registerResources(this. + "/res""/res",
                 httpContext);
              = true;
 
         }
         catch (Exception e)
         {
             log(."bindHttpService: Problem setting up"e);
         }
 
         this. = httpService;
     }
 
     protected synchronized void unbindHttpService(HttpService httpService)
     {
         if (this. != httpService)
         {
             log(.,
                 "unbindHttpService: Ignoring unbind of an HttpService to which we are not registered");
             return;
         }
 
         // drop the service reference
         this. = null;
 
         if ()
         {
             try
             {
                 httpService.unregister(this. + "/res");
             }
             catch (Throwable t)
             {
                 log(.,
                     "unbindHttpService: Failed unregistering Resources"t);
             }
              = false;
         }
 
         if ()
         {
             try
             {
                 httpService.unregister(this.);
             }
             catch (Throwable t)
             {
                 log(.,
                     "unbindHttpService: Failed unregistering Servlet"t);
             }
              = false;
         }
     }
 
 
     private Map getConfiguration()
     {
         return ;
     }
 
 
     {
         return ;
     }
 
 
     synchronized void updateConfigurationDictionary osgiConfig )
     {
         HashMap config = new HashMapthis. );
 
         if ( osgiConfig != null )
         {
             for ( Enumeration keys = osgiConfig.keys(); keys.hasMoreElements(); )
             {
                 final Object key = keys.nextElement();
                 config.putkeyosgiConfig.getkey ) );
             }
         }
 
          = config;
 
         final Object locale = config.get();
          = locale == null || locale.toString().trim().length() == 0 //
         ? null : Util.parseLocaleString(locale.toString().trim());
 
          = ConfigurationUtil.getProperty(config);
         AbstractWebConsolePlugin.setLogLevel();
 
         // default plugin page configuration
         .setDefaultPluginLabel(ConfigurationUtil.getProperty(config));
 
         // get the web manager root path
         String newWebManagerRoot = ConfigurationUtil.getProperty(config);
         if (!newWebManagerRoot.startsWith("/")) //$NON-NLS-1$
         {
             newWebManagerRoot = "/" + newWebManagerRoot//$NON-NLS-1$
         }
 
         // default category
         this. = ConfigurationUtil.getPropertyconfig );
 
         // get the HTTP Service selector (and dispose tracker for later
         // recreation)
         final String newHttpServiceSelector = ConfigurationUtil.getProperty(config,
         if ( != null
             && !.isSameSelector(newHttpServiceSelector))
         {
             .close();
              = null;
         }
 
         // get enabled plugins
         String[] plugins = ConfigurationUtil.getStringArrayProperty(config);
          = null == plugins ? null : new HashSet(Arrays.asList(plugins));
         // check for moved config manager class (see FELIX-4074)
         if (  != null )
        {
            if ( .remove() )
            {
                .add();
            }
        }
        initInternalPlugins();
        // might update HTTP service registration
        HttpService httpService = this.;
        if (httpService != null)
        {
            // unbind old location first
            unbindHttpService(httpService);
            // switch location
            this. = newWebManagerRoot;
            // bind new location now
            bindHttpService(httpService);
        }
        else
        {
            // just set the configured location (FELIX-2034)
            this. = newWebManagerRoot;
        }
        // create or recreate the HTTP service tracker with the new selector
        if ( == null)
        {
             = HttpServiceTracker.create(thisnewHttpServiceSelector);
            .open();
        }
    }
    private void initInternalPlugins()
    {
        for (int i = 0; i < .i++)
        {
            final String pluginClassName = [i++];
            final String label = [i];
            boolean active = .getPlugin(label) != null;
            boolean disabled = isPluginDisabled(pluginClassName);
            if (disabled)
            {
                if (active)
                {
                    .removeOsgiManagerPlugin(label);
                }
            }
            else
            {
                if (!active)
                {
                    .addInternalPlugin(thispluginClassNamelabel);
                }
            }
        }
    }

    
Returns true if the list of enabled plugins is configured but the plugin is not contained in that list.

This method is intended to be used only for PluginHolder.InternalPlugin.isEnabled()

    boolean isPluginDisabled(String pluginClass)
    {
        return  != null && !.containspluginClass );
    }
    private Dictionary toStringConfigMap config )
    {
        Dictionary stringConfig = new Hashtable();
        for ( Iterator ei = config.entrySet().iterator(); ei.hasNext(); )
        {
            Entry entry = ( Entry ) ei.next();
            stringConfig.putentry.getKey(), String.valueOfentry.getValue() ) );
        }
        return stringConfig;
    }
    private Map langMap;
    private final Map getLangMap()
    {
        if (null != )
            return ;
        final Map map = new HashMap();
        final Bundle bundle = .getBundle();
        final Enumeration e = bundle.findEntries("res/flags"nullfalse); //$NON-NLS-1$
        while (e != null && e.hasMoreElements())
        {
            final URL img = (URLe.nextElement();
            final String name = FilenameUtils.getBaseName(img.getFile());
            try
            {
                final String locale = new Locale(name"").getDisplayLanguage(); //$NON-NLS-1$
                map.put(namenull != locale ? locale : name);
            }
            catch (Throwable t)
            {
                t.printStackTrace();
                /* ignore invalid locale? */
            }
        }
        return  = map;
    }