You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2023/08/15 05:52:33 UTC
[felix-dev] branch jakarta-servlet-6 updated: Port webconsole changes from main branch. Could not build due to missing snapshot dependencies and java version
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch jakarta-servlet-6
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/jakarta-servlet-6 by this push:
new c239bfcd9f Port webconsole changes from main branch. Could not build due to missing snapshot dependencies and java version
c239bfcd9f is described below
commit c239bfcd9fa172c2446d8efb2184c2dc9273e921
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Aug 15 07:52:26 2023 +0200
Port webconsole changes from main branch. Could not build due to missing snapshot dependencies and java version
---
.../main/appended-resources/META-INF/DEPENDENCIES | 0
.../src/main/appended-resources/META-INF/LICENSE | 0
.../src/main/appended-resources/META-INF/NOTICE | 0
webconsole/src/main/compat/res/imgs/arrow_down.png | Bin
webconsole/src/main/compat/res/imgs/arrow_left.png | Bin
.../src/main/compat/res/imgs/arrow_right.png | Bin
webconsole/src/main/compat/res/imgs/asc.gif | Bin
webconsole/src/main/compat/res/imgs/bg.gif | Bin
.../src/main/compat/res/imgs/bundle_delete.png | Bin
.../src/main/compat/res/imgs/bundle_refresh.png | Bin
.../src/main/compat/res/imgs/bundle_start.png | Bin
.../src/main/compat/res/imgs/bundle_stop.png | Bin
.../src/main/compat/res/imgs/bundle_update.png | Bin
.../main/compat/res/imgs/component_configure.png | Bin
.../src/main/compat/res/imgs/component_disable.png | Bin
.../src/main/compat/res/imgs/component_enable.png | Bin
webconsole/src/main/compat/res/imgs/desc.gif | Bin
webconsole/src/main/compat/res/imgs/down.gif | Bin
.../src/main/compat/res/imgs/element_add.png | Bin
.../src/main/compat/res/imgs/element_delete.png | Bin
.../src/main/compat/res/imgs/element_run.png | Bin
.../src/main/compat/res/imgs/element_stop.png | Bin
webconsole/src/main/compat/res/imgs/left.gif | Bin
webconsole/src/main/compat/res/imgs/right.gif | Bin
.../res/imgs/ui-bg_glass_55_fbf9ee_1x400.png | Bin
webconsole/src/main/compat/res/ui/admin_compat.css | 0
.../res/lib/themes/base/jquery-ui.css | 0
.../res/lib/themes/base/jquery.ui.accordion.css | 0
.../res/lib/themes/base/jquery.ui.all.css | 0
.../res/lib/themes/base/jquery.ui.autocomplete.css | 0
.../res/lib/themes/base/jquery.ui.base.css | 0
.../res/lib/themes/base/jquery.ui.button.css | 0
.../res/lib/themes/base/jquery.ui.core.css | 0
.../res/lib/themes/base/jquery.ui.datepicker.css | 0
.../res/lib/themes/base/jquery.ui.dialog.css | 0
.../res/lib/themes/base/jquery.ui.menu.css | 0
.../res/lib/themes/base/jquery.ui.progressbar.css | 0
.../res/lib/themes/base/jquery.ui.resizable.css | 0
.../res/lib/themes/base/jquery.ui.selectable.css | 0
.../res/lib/themes/base/jquery.ui.slider.css | 0
.../res/lib/themes/base/jquery.ui.spinner.css | 0
.../res/lib/themes/base/jquery.ui.tabs.css | 0
.../res/lib/themes/base/jquery.ui.theme.css | 0
.../res/lib/themes/base/jquery.ui.tooltip.css | 0
.../felix/webconsole/AbstractWebConsolePlugin.java | 15 +-
.../felix/webconsole/AttachmentProvider.java | 0
.../apache/felix/webconsole/BrandingPlugin.java | 0
.../felix/webconsole/ConfigurationPrinter.java | 0
.../felix/webconsole/DefaultBrandingPlugin.java | 0
.../felix/webconsole/DefaultVariableResolver.java | 2 +
.../webconsole/ModeAwareConfigurationPrinter.java | 0
.../felix/webconsole/SimpleWebConsolePlugin.java | 57 +--
.../java/org/apache/felix/webconsole/User.java | 0
.../apache/felix/webconsole/VariableResolver.java | 0
.../felix/webconsole/WebConsoleConstants.java | 13 +
.../webconsole/WebConsoleSecurityProvider.java | 0
.../webconsole/WebConsoleSecurityProvider2.java | 0
.../webconsole/WebConsoleSecurityProvider3.java | 0
.../apache/felix/webconsole/WebConsoleUtil.java | 136 +++---
.../felix/webconsole/bundleinfo/BundleInfo.java | 0
.../webconsole/bundleinfo/BundleInfoProvider.java | 0
.../webconsole/bundleinfo/BundleInfoType.java | 0
.../felix/webconsole/bundleinfo/package-info.java | 0
.../felix/webconsole/i18n/LocalizationHelper.java | 0
.../apache/felix/webconsole/i18n/package-info.java | 0
.../internal/AbstractConfigurationPrinter.java | 6 +-
.../webconsole/internal/OsgiManagerActivator.java | 0
.../webconsole/internal/OsgiManagerPlugin.java | 0
.../org/apache/felix/webconsole/internal/Util.java | 61 +--
.../internal/WebConsolePluginAdapter.java | 24 +-
.../webconsole/internal/compendium/LogServlet.java | 3 +-
.../PreferencesConfigurationPrinter.java | 1 +
.../compendium/WireAdminConfigurationPrinter.java | 11 +-
.../internal/configuration/ConfigAdminSupport.java | 0
.../internal/configuration/ConfigJsonSupport.java | 6 +-
.../internal/configuration/ConfigManager.java | 3 +-
.../ConfigurationAdminConfigurationPrinter.java | 0
.../internal/configuration/ConfigurationUtil.java | 30 +-
.../configuration/MetaTypeServiceSupport.java | 0
.../internal/configuration/MetaTypeSupport.java | 7 +-
.../configuration/MetatypePropertyDescriptor.java | 0
.../internal/configuration/PropertyDescriptor.java | 0
.../internal/core/BaseUpdateInstallHelper.java | 80 ++--
.../internal/core/BundleContextUtil.java | 0
.../internal/core/BundlesConfigurationPrinter.java | 122 ++---
.../webconsole/internal/core/BundlesServlet.java | 36 +-
.../internal/core/CapabilitiesPrinter.java | 0
.../core/CapabilitiesProvidedInfoProvider.java | 0
.../core/CapabilitiesRequiredInfoProvider.java | 0
.../internal/core/FrameworkPropertiesPrinter.java | 0
.../webconsole/internal/core/InstallHelper.java | 23 +-
.../core/PermissionsConfigurationPrinter.java | 0
.../core/ServicesConfigurationPrinter.java | 0
.../webconsole/internal/core/ServicesServlet.java | 4 +-
.../internal/core/ServicesUsedInfoProvider.java | 0
.../webconsole/internal/core/UpdateHelper.java | 0
.../internal/filter/FilteringResponseWrapper.java | 0
.../internal/filter/ResourceFilteringWriter.java | 4 +-
.../internal/i18n/CombinedEnumeration.java | 0
.../internal/i18n/CombinedResourceBundle.java | 0
.../i18n/ConsolePropertyResourceBundle.java | 0
.../internal/i18n/ResourceBundleCache.java | 0
.../internal/i18n/ResourceBundleManager.java | 39 +-
.../internal/misc/ConfigurationRender.java | 0
.../webconsole/internal/misc/LicenseServlet.java | 1 +
.../webconsole/internal/misc/ServletSupport.java | 0
.../internal/misc/SystemPropertiesPrinter.java | 0
.../webconsole/internal/misc/ThreadDumper.java | 0
.../webconsole/internal/misc/ThreadPrinter.java | 0
.../felix/webconsole/internal/servlet/Base64.java | 0
.../servlet/BasicWebConsoleSecurityProvider.java | 0
.../servlet/ConfigurationMetatypeSupport.java | 15 +-
.../internal/servlet/ConfigurationSupport.java | 0
.../internal/servlet/ConfigurationUtil.java | 6 +-
.../webconsole/internal/servlet/OsgiManager.java | 515 +++++++++------------
.../internal/servlet/OsgiManagerHttpContext.java | 75 +--
.../webconsole/internal/servlet/Password.java | 0
.../felix/webconsole/internal/servlet/Plugin.java | 1 -
.../webconsole/internal/servlet/PluginHolder.java | 2 +
.../webconsole/internal/system/VMStatPlugin.java | 19 +
.../org/apache/felix/webconsole/package-info.java | 0
.../felix/webconsole/spi/ConfigurationHandler.java | 0
.../felix/webconsole/spi/ValidationException.java | 0
.../apache/felix/webconsole/spi/package-info.java | 0
.../main/resources/OSGI-INF/l10n/bundle.properties | 0
webconsole/src/main/resources/res/flags/en.gif | Bin
webconsole/src/main/resources/res/imgs/favicon.ico | Bin
webconsole/src/main/resources/res/imgs/loading.gif | Bin
webconsole/src/main/resources/res/imgs/logo.png | Bin
webconsole/src/main/resources/res/lib/asc.gif | Bin
.../src/main/resources/res/lib/autosize.min.js | 0
webconsole/src/main/resources/res/lib/bg.gif | Bin
webconsole/src/main/resources/res/lib/desc.gif | Bin
.../resources/res/lib/jquery-ui-i18n-1.12.1.js | 0
.../main/resources/res/lib/jquery.cookies-2.2.0.js | 0
.../resources/res/lib/jquery.multifile-1.4.6.js | 0
.../resources/res/lib/jquery.tablesorter-2.0.3.js | 0
.../src/main/resources/res/lib/reset-min.css | 0
webconsole/src/main/resources/res/lib/support.js | 0
.../images/ui-bg_glass_55_fbf9ee_1x400.png | Bin
.../images/ui-bg_glass_65_ffffff_1x400.png | Bin
.../images/ui-bg_glass_75_dadada_1x400.png | Bin
.../images/ui-bg_glass_75_e6e6e6_1x400.png | Bin
.../images/ui-bg_glass_95_fef1ec_1x400.png | Bin
.../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin
.../smoothness/images/ui-icons_222222_256x240.png | Bin
.../smoothness/images/ui-icons_2e83ff_256x240.png | Bin
.../smoothness/images/ui-icons_454545_256x240.png | Bin
.../smoothness/images/ui-icons_888888_256x240.png | Bin
.../smoothness/images/ui-icons_cd0a0a_256x240.png | Bin
.../res/lib/themes/smoothness/jquery-ui.css | 0
webconsole/src/main/resources/res/ui/bundles.css | 0
webconsole/src/main/resources/res/ui/bundles.js | 0
webconsole/src/main/resources/res/ui/config.css | 0
webconsole/src/main/resources/res/ui/config.js | 0
.../main/resources/res/ui/configurationrender.css | 0
.../main/resources/res/ui/configurationrender.js | 0
webconsole/src/main/resources/res/ui/license.css | 0
webconsole/src/main/resources/res/ui/license.js | 0
webconsole/src/main/resources/res/ui/logs.css | 0
webconsole/src/main/resources/res/ui/logs.js | 0
webconsole/src/main/resources/res/ui/packages.js | 0
webconsole/src/main/resources/res/ui/services.js | 0
.../src/main/resources/res/ui/ui.tabs.paging.js | 0
webconsole/src/main/resources/res/ui/vmstat.js | 0
.../src/main/resources/res/ui/webconsole.css | 0
.../src/main/resources/templates/bundles.html | 0
.../src/main/resources/templates/components.html | 0
.../src/main/resources/templates/config.html | 0
.../src/main/resources/templates/deployment.html | 0
.../src/main/resources/templates/license.html | 0
webconsole/src/main/resources/templates/logs.html | 0
.../src/main/resources/templates/main_footer.html | 0
.../src/main/resources/templates/main_header.html | 0
webconsole/src/main/resources/templates/obr.html | 0
.../src/main/resources/templates/services.html | 0
webconsole/src/main/resources/templates/shell.html | 0
.../src/main/resources/templates/vmstat.html | 2 +-
.../main/resources/templates/vmstat_restart.html | 7 +-
.../src/main/resources/templates/vmstat_stop.html | 0
.../webconsole/AbstractWebConsolePluginTest.java | 0
.../configuration/ConfigJsonSupportTest.java | 2 -
.../internal/misc/LicenseServletTest.java | 0
.../servlet/OsgiManagerHttpContextTest.java | 34 +-
.../internal/servlet/OsgiManagerTest.java | 145 +++---
185 files changed, 646 insertions(+), 861 deletions(-)
diff --git a/webconsole/src/main/appended-resources/META-INF/DEPENDENCIES b/webconsole/src/main/appended-resources/META-INF/DEPENDENCIES
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/appended-resources/META-INF/LICENSE b/webconsole/src/main/appended-resources/META-INF/LICENSE
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/appended-resources/META-INF/NOTICE b/webconsole/src/main/appended-resources/META-INF/NOTICE
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/arrow_down.png b/webconsole/src/main/compat/res/imgs/arrow_down.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/arrow_left.png b/webconsole/src/main/compat/res/imgs/arrow_left.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/arrow_right.png b/webconsole/src/main/compat/res/imgs/arrow_right.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/asc.gif b/webconsole/src/main/compat/res/imgs/asc.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bg.gif b/webconsole/src/main/compat/res/imgs/bg.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bundle_delete.png b/webconsole/src/main/compat/res/imgs/bundle_delete.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bundle_refresh.png b/webconsole/src/main/compat/res/imgs/bundle_refresh.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bundle_start.png b/webconsole/src/main/compat/res/imgs/bundle_start.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bundle_stop.png b/webconsole/src/main/compat/res/imgs/bundle_stop.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/bundle_update.png b/webconsole/src/main/compat/res/imgs/bundle_update.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/component_configure.png b/webconsole/src/main/compat/res/imgs/component_configure.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/component_disable.png b/webconsole/src/main/compat/res/imgs/component_disable.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/component_enable.png b/webconsole/src/main/compat/res/imgs/component_enable.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/desc.gif b/webconsole/src/main/compat/res/imgs/desc.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/down.gif b/webconsole/src/main/compat/res/imgs/down.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/element_add.png b/webconsole/src/main/compat/res/imgs/element_add.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/element_delete.png b/webconsole/src/main/compat/res/imgs/element_delete.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/element_run.png b/webconsole/src/main/compat/res/imgs/element_run.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/element_stop.png b/webconsole/src/main/compat/res/imgs/element_stop.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/left.gif b/webconsole/src/main/compat/res/imgs/left.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/right.gif b/webconsole/src/main/compat/res/imgs/right.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/imgs/ui-bg_glass_55_fbf9ee_1x400.png b/webconsole/src/main/compat/res/imgs/ui-bg_glass_55_fbf9ee_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/compat/res/ui/admin_compat.css b/webconsole/src/main/compat/res/ui/admin_compat.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery-ui.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery-ui.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.accordion.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.accordion.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.all.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.all.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.autocomplete.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.autocomplete.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.base.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.base.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.button.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.button.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.core.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.core.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.datepicker.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.datepicker.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.dialog.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.dialog.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.menu.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.menu.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.progressbar.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.progressbar.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.resizable.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.resizable.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.selectable.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.selectable.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.slider.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.slider.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.spinner.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.spinner.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.tabs.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.tabs.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.theme.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.theme.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.tooltip.css b/webconsole/src/main/debug-resources/res/lib/themes/base/jquery.ui.tooltip.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
old mode 100644
new mode 100755
index 282efd39b7..36f5af794b
--- a/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
@@ -389,7 +389,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
{
try
{
- Class cl = resourceProvider.getClass();
+ Class<?> cl = resourceProvider.getClass();
while ( tmpGetResourceMethod == null && cl != Object.class )
{
Method[] methods = cl.getDeclaredMethods();
@@ -633,6 +633,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
* @throws IOException on I/O error
* @see #endResponse(PrintWriter)
*/
+ @SuppressWarnings({ "unchecked" })
protected PrintWriter startResponse( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
response.setCharacterEncoding( "utf-8" ); //$NON-NLS-1$
@@ -674,6 +675,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
* @param request the HTTP request coming from the user
* @param pw the writer, where the HTML data is rendered
*/
+ @SuppressWarnings({ "rawtypes" })
protected void renderTopNavigation( HttpServletRequest request, PrintWriter pw )
{
// assume pathInfo to not be null, else this would not be called
@@ -730,6 +732,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
}
+ @SuppressWarnings({ "rawtypes" })
protected void renderMenu( Map menuMap, String appRoot, PrintWriter pw )
{
if ( menuMap != null )
@@ -745,6 +748,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
}
+ @SuppressWarnings({ "rawtypes" })
private void renderMenu( Map menuMap, String appRoot, PrintWriter pw, int level )
{
pw.println( "<ul class=\"navMenuLevel-" + level + "\">" );
@@ -753,6 +757,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
}
+ @SuppressWarnings({ "rawtypes" })
private void renderSubmenu( Map menuMap, String appRoot, PrintWriter pw, int level )
{
String liStyleClass = " class=\"navMenuItem-" + level + "\"";
@@ -935,7 +940,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
return readTemplateFile( getClass(), templateFile );
}
- private final String readTemplateFile( final Class clazz, final String templateFile) {
+ private final String readTemplateFile( final Class<?> clazz, final String templateFile) {
try(InputStream templateStream = clazz.getResourceAsStream( templateFile )) {
if ( templateStream != null ) {
@@ -979,7 +984,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
}
// build the CSS links from the references
- final StringBuffer buf = new StringBuffer();
+ final StringBuilder buf = new StringBuilder();
for ( int i = 0; i < cssRefs.length; i++ )
{
buf.append( "<link href='" ); //$NON-NLS-1$
@@ -1013,6 +1018,7 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
}
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private SortedMap sortMenuCategoryMap( Map map, String appRoot )
{
SortedMap sortedMap = new TreeMap<>( String.CASE_INSENSITIVE_ORDER );
@@ -1054,18 +1060,17 @@ public abstract class AbstractWebConsolePlugin extends HttpServlet
return sortedMap;
}
+ @SuppressWarnings({ "rawtypes" })
private static class MenuItem
{
private String link;
private Map subMenu;
-
public MenuItem( String link )
{
this.link = link;
}
-
public MenuItem( String link, Map subMenu )
{
super();
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/AttachmentProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/BrandingPlugin.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/ConfigurationPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/DefaultBrandingPlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/DefaultBrandingPlugin.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java b/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
old mode 100644
new mode 100755
index 42c685dfe9..b6885262c1
--- a/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/DefaultVariableResolver.java
@@ -31,6 +31,7 @@ import java.util.Map;
* {@link WebConsoleUtil#getVariableResolver(jakarta.servlet.ServletRequest)}
* as the variable resolver if none has yet been assigned to the request.
*/
+@SuppressWarnings({ "rawtypes" })
public class DefaultVariableResolver extends HashMap implements VariableResolver
{
@@ -77,6 +78,7 @@ public class DefaultVariableResolver extends HashMap implements VariableResolver
* @param source the map whose variables are to be placed in this resolver.
* @see HashMap#HashMap(Map)
*/
+ @SuppressWarnings({"unchecked"})
public DefaultVariableResolver( final Map source )
{
super( source );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/ModeAwareConfigurationPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/SimpleWebConsolePlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/SimpleWebConsolePlugin.java
old mode 100644
new mode 100755
index 88074b4fb6..ead43171a3
--- a/webconsole/src/main/java/org/apache/felix/webconsole/SimpleWebConsolePlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/SimpleWebConsolePlugin.java
@@ -29,12 +29,10 @@ import java.util.Map;
import java.util.ResourceBundle;
import org.apache.felix.webconsole.i18n.LocalizationHelper;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -65,10 +63,10 @@ public abstract class SimpleWebConsolePlugin extends AbstractWebConsolePlugin
// used for service registration
private final Object regLock = new Object();
- private ServiceRegistration reg;
+ private ServiceRegistration<Servlet> reg;
// used to obtain services. Structure is: service name -> ServiceTracker
- private final Map services = new HashMap();
+ private final Map<String, ServiceTracker<?, ?>> services = new HashMap<>();
// localized title as servlet name
private String servletName;
@@ -222,40 +220,37 @@ public abstract class SimpleWebConsolePlugin extends AbstractWebConsolePlugin
* @param bc the bundle context used for service registration.
* @return self
*/
- public final SimpleWebConsolePlugin register( BundleContext bc )
- {
- synchronized ( regLock )
- {
+ public final SimpleWebConsolePlugin register( BundleContext bc ) {
+ synchronized ( regLock ) {
activate( bc ); // don't know why this is needed!
- Dictionary<String, Object> props = new Hashtable<>();
- props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, getLabel());
- props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,
- "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + OsgiManager.DEFAULT_CONTEXT_NAME
- + ")");
+ final Dictionary<String, Object> props = new Hashtable<>();
props.put( WebConsoleConstants.PLUGIN_LABEL, getLabel() );
props.put( WebConsoleConstants.PLUGIN_TITLE, getTitle() );
- if ( getCategory() != null )
- {
+ if ( getCategory() != null ) {
props.put( WebConsoleConstants.PLUGIN_CATEGORY, getCategory() );
}
- reg = bc.registerService( Servlet.class, this, props );
+ reg = bc.registerService( Servlet.class, this, props ); //$NON-NLS-1$
}
return this;
}
+
/**
* An utility method that removes the service, registered by the
* {@link #register(BundleContext)} method.
*/
- public final void unregister()
- {
- synchronized ( regLock )
- {
+ public final void unregister() {
+ synchronized ( regLock ) {
deactivate(); // is this needed?
- if ( reg != null )
- reg.unregister();
+ if ( reg != null ) {
+ try {
+ reg.unregister();
+ } catch ( final IllegalStateException ise ) {
+ // ignore, bundle context already invalid
+ }
+ }
reg = null;
}
}
@@ -272,11 +267,10 @@ public abstract class SimpleWebConsolePlugin extends AbstractWebConsolePlugin
* @param serviceName the service name to obtain
* @return the service or <code>null</code> if missing.
*/
- public final Object getService( String serviceName )
- {
- ServiceTracker serviceTracker = ( ServiceTracker ) services.get( serviceName );
- if ( serviceTracker == null )
- {
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public final Object getService( String serviceName ) {
+ ServiceTracker<?,?> serviceTracker = services.get( serviceName );
+ if ( serviceTracker == null ) {
serviceTracker = new ServiceTracker( getBundleContext(), serviceName, new ServiceTrackerCustomizer() {
public Object addingService( ServiceReference reference ) {
return getBundleContext().getService( reference );
@@ -310,15 +304,12 @@ public abstract class SimpleWebConsolePlugin extends AbstractWebConsolePlugin
*
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#deactivate()
*/
- public void deactivate()
- {
- for ( Iterator ti = services.values().iterator(); ti.hasNext(); )
- {
- ServiceTracker tracker = ( ServiceTracker ) ti.next();
+ public void deactivate() {
+ for ( Iterator<ServiceTracker<?, ?>> ti = services.values().iterator(); ti.hasNext(); ) {
+ ServiceTracker<?, ?> tracker = ti.next();
tracker.close();
ti.remove();
}
super.deactivate();
}
-
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/User.java b/webconsole/src/main/java/org/apache/felix/webconsole/User.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java b/webconsole/src/main/java/org/apache/felix/webconsole/VariableResolver.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
old mode 100644
new mode 100755
index 2b8363d7c1..9b0e19aefc
--- a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
@@ -197,4 +197,17 @@ public interface WebConsoleConstants
* @since 3.1.2
*/
public static final String ATTR_LANG_MAP = "felix.webconsole.langMap"; //$NON-NLS-1$
+
+ /**
+ * The name of the request attribute holding the configuration params {@link java.util.Map}
+ * for the request (value is "felix.webconsole.configuration").
+ * <p>
+ * The type of this request attribute is <code>Map<String, Object></code>.
+ * <p>
+ * This map contains the web console configuration params managed by the web console.
+ * It can be used to access to the configuration values while processing requests.
+ *
+ * @since 3.5.0
+ */
+ public static final String ATTR_CONFIGURATION = "felix.webconsole.configuration";
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider2.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleSecurityProvider3.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleUtil.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleUtil.java
old mode 100644
new mode 100755
index 71f6803494..0ffab0a9d3
--- a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleUtil.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleUtil.java
@@ -72,6 +72,7 @@ public final class WebConsoleUtil
*
* @return The {@link VariableResolver} for the given request.
*/
+ @SuppressWarnings("unchecked")
public static VariableResolver getVariableResolver( final ServletRequest request )
{
final Object resolverObj = request.getAttribute( WebConsoleConstants.ATTR_CONSOLE_VARIABLE_RESOLVER );
@@ -81,9 +82,8 @@ public final class WebConsoleUtil
}
final DefaultVariableResolver resolver = new DefaultVariableResolver();
- // FIXME: don't we need a constant for the values below?
- resolver.put( "appRoot", request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT ) ); //$NON-NLS-1$
- resolver.put( "pluginRoot", request.getAttribute( WebConsoleConstants.ATTR_PLUGIN_ROOT ) ); //$NON-NLS-1$
+ resolver.put( "appRoot", request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT ) );
+ resolver.put( "pluginRoot", request.getAttribute( WebConsoleConstants.ATTR_PLUGIN_ROOT ) );
setVariableResolver( request, resolver );
return resolver;
}
@@ -120,7 +120,6 @@ public final class WebConsoleUtil
* and the specified parameter is field - then the value of the parameter
* is returned.
*/
- @SuppressWarnings({ "unchecked", "rawtypes" })
public static final String getParameter( HttpServletRequest request, String name )
{
// just get the parameter if not a multipart/form-data POST
@@ -130,6 +129,7 @@ public final class WebConsoleUtil
}
// check, whether we already have the parameters
+ @SuppressWarnings("unchecked")
Map<String, FileItem[]> params = ( Map<String, FileItem[]> ) request.getAttribute( AbstractWebConsolePlugin.ATTR_FILEUPLOAD );
if ( params == null )
{
@@ -175,7 +175,8 @@ public final class WebConsoleUtil
}
catch ( FileUploadException fue )
{
- // TODO: log
+ // fail
+ return null;
}
request.setAttribute( AbstractWebConsolePlugin.ATTR_FILEUPLOAD, params );
}
@@ -258,45 +259,42 @@ public final class WebConsoleUtil
*/
public static final String escapeHtml(String text)
{
- StringBuffer sb = new StringBuffer(text.length() * 4 / 3);
- synchronized (sb) // faster buffer operations
+ StringBuilder sb = new StringBuilder(text.length() * 4 / 3);
+ char ch, oldch = '_';
+ for (int i = 0; i < text.length(); i++)
{
- char ch, oldch = '_';
- for (int i = 0; i < text.length(); i++)
+ switch (ch = text.charAt(i))
{
- switch (ch = text.charAt(i))
- {
- case '<':
- sb.append("<"); //$NON-NLS-1$
- break;
- case '>':
- sb.append(">"); //$NON-NLS-1$
- break;
- case '&':
- sb.append("&"); //$NON-NLS-1$
- break;
- case ' ':
- sb.append(" "); //$NON-NLS-1$
- break;
- case '\'':
- sb.append("'"); //$NON-NLS-1$
- break;
- case '"':
- sb.append("""); //$NON-NLS-1$
- break;
- case '\r':
- case '\n':
- if (oldch != '\r' && oldch != '\n') // don't add twice <br>
- sb.append("<br/>\n"); //$NON-NLS-1$
- break;
- default:
- sb.append(ch);
- }
- oldch = ch;
+ case '<':
+ sb.append("<"); //$NON-NLS-1$
+ break;
+ case '>':
+ sb.append(">"); //$NON-NLS-1$
+ break;
+ case '&':
+ sb.append("&"); //$NON-NLS-1$
+ break;
+ case ' ':
+ sb.append(" "); //$NON-NLS-1$
+ break;
+ case '\'':
+ sb.append("'"); //$NON-NLS-1$
+ break;
+ case '"':
+ sb.append("""); //$NON-NLS-1$
+ break;
+ case '\r':
+ case '\n':
+ if (oldch != '\r' && oldch != '\n') // don't add twice <br>
+ sb.append("<br/>\n"); //$NON-NLS-1$
+ break;
+ default:
+ sb.append(ch);
}
-
- return sb.toString();
+ oldch = ch;
}
+
+ return sb.toString();
}
/**
@@ -338,6 +336,7 @@ public final class WebConsoleUtil
* @param value the value to decode
* @return the decoded string
*/
+ @SuppressWarnings("deprecation")
public static String urlDecode( final String value )
{
// shortcut for empty or missing values
@@ -346,14 +345,9 @@ public final class WebConsoleUtil
return value;
}
- try
- {
- return URLDecoder.decode( value, "UTF-8" ); //$NON-NLS-1$
- }
- catch ( Throwable t )
- {
- // expected NoSuchMethodError: if platform does not support it
- // expected UnsupportedEncoding (not really: UTF-8 is required)
+ try {
+ return URLDecoder.decode( value, "UTF-8" );
+ } catch (UnsupportedEncodingException e) {
return URLDecoder.decode( value );
}
}
@@ -376,42 +370,38 @@ public final class WebConsoleUtil
}
else if (value.getClass().isArray())
{
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
final int len = Array.getLength(value);
- synchronized (sb)
- { // it's faster to synchronize ALL loop calls
- sb.append('[');
- for (int i = 0; i < len; i++)
+ sb.append('[');
+ for (int i = 0; i < len; i++)
+ {
+ final Object element = Array.get(value, i);
+ if (element instanceof Byte)
{
- final Object element = Array.get(value, i);
- if (element instanceof Byte)
+ // convert byte[] to hex string
+ sb.append("0x"); //$NON-NLS-1$
+ final String x = Integer.toHexString(((Byte) element).intValue() & 0xff);
+ if (1 == x.length())
{
- // convert byte[] to hex string
- sb.append("0x"); //$NON-NLS-1$
- final String x = Integer.toHexString(((Byte) element).intValue() & 0xff);
- if (1 == x.length())
- {
- sb.append('0');
- }
- sb.append(x);
- }
- else
- {
- sb.append(toString(element));
+ sb.append('0');
}
+ sb.append(x);
+ }
+ else
+ {
+ sb.append(toString(element));
+ }
- if (i < len - 1)
- {
- sb.append(", "); //$NON-NLS-1$
- }
+ if (i < len - 1)
+ {
+ sb.append(", "); //$NON-NLS-1$
}
- return sb.append(']').toString();
}
+ return sb.append(']').toString();
}
else
{
return value.toString();
}
-
}
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfo.java b/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfo.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfoProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfoProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfoType.java b/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/BundleInfoType.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/package-info.java b/webconsole/src/main/java/org/apache/felix/webconsole/bundleinfo/package-info.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/i18n/LocalizationHelper.java b/webconsole/src/main/java/org/apache/felix/webconsole/i18n/LocalizationHelper.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/i18n/package-info.java b/webconsole/src/main/java/org/apache/felix/webconsole/i18n/package-info.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/AbstractConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/AbstractConfigurationPrinter.java
old mode 100644
new mode 100755
index 6360fc1474..9e45457b7a
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/AbstractConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/AbstractConfigurationPrinter.java
@@ -18,7 +18,6 @@ package org.apache.felix.webconsole.internal;
import org.apache.felix.webconsole.ConfigurationPrinter;
-import org.apache.felix.webconsole.internal.OsgiManagerPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -26,12 +25,13 @@ import org.osgi.framework.ServiceRegistration;
* AbstractConfigurationPrinter is an utility class, that provides a basic implementation
* of {@link ConfigurationPrinter} and {@link OsgiManagerPlugin} interfaces.
*/
+@SuppressWarnings("deprecation")
public abstract class AbstractConfigurationPrinter implements ConfigurationPrinter, OsgiManagerPlugin
{
private BundleContext bundleContext;
- private ServiceRegistration registration;
+ private ServiceRegistration<ConfigurationPrinter> registration;
/**
@@ -40,7 +40,7 @@ public abstract class AbstractConfigurationPrinter implements ConfigurationPrint
public void activate( BundleContext bundleContext )
{
this.bundleContext = bundleContext;
- this.registration = bundleContext.registerService( SERVICE, this, null );
+ this.registration = bundleContext.registerService( ConfigurationPrinter.class, this, null );
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/OsgiManagerActivator.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/OsgiManagerActivator.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/OsgiManagerPlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/OsgiManagerPlugin.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/Util.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/Util.java
old mode 100644
new mode 100755
index 880f8163be..3eec1ee758
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/Util.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/Util.java
@@ -18,10 +18,8 @@ package org.apache.felix.webconsole.internal;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
-import java.util.Enumeration;
import java.util.Locale;
import org.osgi.framework.Bundle;
@@ -37,31 +35,7 @@ import jakarta.servlet.http.HttpServletResponse;
* The <code>Util</code> class contains various utility methods used internally
* by the web console implementation and the build-in plugins.
*/
-public class Util
-{
-
- // FIXME: from the constants below only PARAM_ACTION is used, consider removal of others?
-
- /** web apps subpage */
- public static final String PAGE_WEBAPPS = "/webapps";
-
- /** vm statistics subpage */
- public static final String PAGE_VM_STAT = "/vmstat";
-
- /** Logs subpage */
- public static final String PAGE_LOGS = "/logs";
-
- /** Parameter name */
- public static final String PARAM_ACTION = "action";
-
- /** Parameter name */
- public static final String PARAM_CONTENT = "content";
-
- /** Parameter name */
- public static final String PARAM_SHUTDOWN = "shutdown";
-
- /** Parameter value */
- public static final String VALUE_SHUTDOWN = "shutdown";
+public class Util {
/**
* Return a display name for the given <code>bundle</code>:
@@ -129,25 +103,6 @@ public class Util
Arrays.sort( bundles, new BundleNameComparator( locale ) );
}
-
- /**
- * 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;
- }
-
/**
* This method expects a locale string in format language_COUNTRY, or
* language. The method will determine which is the correct form of locale
@@ -185,23 +140,15 @@ public class Util
return new Locale(language, country);
}
- private static final class BundleNameComparator implements Comparator
+ private static final class BundleNameComparator implements Comparator<Bundle>
{
private final Locale locale;
- BundleNameComparator( final Locale locale )
- {
+ BundleNameComparator( final Locale locale ) {
this.locale = locale;
}
-
- public int compare( Object o1, Object o2 )
- {
- return compare( ( Bundle ) o1, ( Bundle ) o2 );
- }
-
-
public int compare( Bundle b1, Bundle b2 )
{
@@ -273,4 +220,4 @@ public class Util
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/WebConsolePluginAdapter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/WebConsolePluginAdapter.java
old mode 100644
new mode 100755
index 30ef7ed513..362453a571
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/WebConsolePluginAdapter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/WebConsolePluginAdapter.java
@@ -20,15 +20,10 @@ package org.apache.felix.webconsole.internal;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
+import java.util.*;
import org.apache.felix.webconsole.AbstractWebConsolePlugin;
import org.apache.felix.webconsole.WebConsoleConstants;
import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletConfig;
@@ -59,8 +54,6 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
// the CSS references (null if none)
private final String[] cssReferences;
-
- private ServiceRegistration<Servlet> registration;
/**
* Creates a new wrapper for a Web Console Plugin
@@ -69,7 +62,7 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
* @param plugin the plugin itself
* @param serviceReference reference to the plugin
*/
- public WebConsolePluginAdapter( String label, Servlet plugin, ServiceReference serviceReference )
+ public WebConsolePluginAdapter( String label, Servlet plugin, ServiceReference<Servlet> serviceReference )
{
this.label = label;
this.plugin = plugin;
@@ -79,6 +72,7 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
activate( serviceReference.getBundle().getBundleContext() );
}
+
//---------- AbstractWebConsolePlugin API
/**
@@ -146,14 +140,13 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
}
- //---------- Servlet API override
+ //---------- Servlet API overwrite
/**
* Initializes this servlet as well as the plugin servlet.
*
* @see jakarta.servlet.GenericServlet#init(jakarta.servlet.ServletConfig)
*/
- @Override
public void init( ServletConfig config ) throws ServletException
{
// no need to activate the plugin, this has already been done
@@ -177,6 +170,7 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
}
}
+
/**
* Detects whether this request is intended to have the headers and
* footers of this plugin be rendered or not. The decision is taken based
@@ -242,18 +236,12 @@ public class WebConsolePluginAdapter extends AbstractWebConsolePlugin
finally
{
deactivate();
-
- if (registration != null)
- {
- registration.unregister();
-
- registration = null;
- }
}
}
//---------- internal
+ @SuppressWarnings("rawtypes")
private String[] toStringArray( final Object value )
{
if ( value instanceof String )
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
old mode 100644
new mode 100755
index b8e1eb901a..3c55ddd9e6
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
@@ -82,6 +82,7 @@ public class LogServlet extends SimpleWebConsolePlugin implements OsgiManagerPlu
return null == traces ? false : Boolean.valueOf( traces ).booleanValue();
}
+ @SuppressWarnings("rawtypes")
private final void renderJSON( final PrintWriter pw, int minLogLevel, boolean traces ) throws IOException
{
// create status line
@@ -185,7 +186,7 @@ public class LogServlet extends SimpleWebConsolePlugin implements OsgiManagerPlu
jw.endObject();
}
-
+ @SuppressWarnings("rawtypes")
private static final String serviceDescription( ServiceReference serviceReference )
{
if ( serviceReference == null )
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/PreferencesConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/PreferencesConfigurationPrinter.java
old mode 100644
new mode 100755
index cf0b00dac9..e279f26ada
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/PreferencesConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/PreferencesConfigurationPrinter.java
@@ -45,6 +45,7 @@ public class PreferencesConfigurationPrinter extends AbstractConfigurationPrinte
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
public void printConfiguration(PrintWriter printWriter)
{
ServiceReference sr = getBundleContext().getServiceReference(
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
old mode 100644
new mode 100755
index c7d8e2669a..512ee4c446
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/WireAdminConfigurationPrinter.java
@@ -53,6 +53,7 @@ public final class WireAdminConfigurationPrinter extends AbstractConfigurationPr
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
public final void printConfiguration(PrintWriter pw)
{
final BundleContext bc = getBundleContext();
@@ -170,7 +171,7 @@ public final class WireAdminConfigurationPrinter extends AbstractConfigurationPr
}
}
- Class[] flavors = wire.getFlavors();
+ Class<?>[] flavors = wire.getFlavors();
if (flavors == null)
{
pw.println(" Flavors: none");
@@ -187,7 +188,7 @@ public final class WireAdminConfigurationPrinter extends AbstractConfigurationPr
pw.println();
}
- Dictionary props = wire.getProperties();
+ Dictionary<String, Object> props = wire.getProperties();
if (props == null)
{
pw.println(" Properties: none");
@@ -195,11 +196,11 @@ public final class WireAdminConfigurationPrinter extends AbstractConfigurationPr
else
{
pw.println(" Properties: ");
- for (Enumeration e = props.keys(); e.hasMoreElements();)
+ for (Enumeration<String> e = props.keys(); e.hasMoreElements();)
{
- final Object key = e.nextElement();
+ final String key = e.nextElement();
pw.print(" "); //$NON-NLS-1$
- pw.print(key.toString());
+ pw.print(key);
pw.print('=');
pw.println(props.get(key));
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupport.java
old mode 100644
new mode 100755
index 5c06570766..c4a7288327
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupport.java
@@ -189,7 +189,7 @@ class ConfigJsonSupport {
}
json.endObject();
if ( props != null ) {
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
for(final String key : Collections.list(props.keys())) {
if ( !metatypeAttributes.contains(key) ) {
if ( sb.length() > 0 ) {
@@ -432,7 +432,7 @@ class ConfigJsonSupport {
// search for all variable patterns in name hint and replace them with configured/default values
Matcher matcher = ConfigAdminSupport.NAMEHINT_PLACEHOLER_REGEXP.matcher(nameHint);
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
while (matcher.find()) {
String propertyName = matcher.group(1);
String value = getConfigurationPropertyValueOrDefault(propertyName, props, adMap);
@@ -482,7 +482,7 @@ class ConfigJsonSupport {
}
// convert array to string
if (value.getClass().isArray()) {
- StringBuffer valueString = new StringBuffer();
+ StringBuilder valueString = new StringBuilder();
for (int i = 0; i < Array.getLength(value); i++) {
if (i > 0) {
valueString.append(", ");
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
old mode 100644
new mode 100755
index 56c0f1ba51..b9a82702bc
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
@@ -287,7 +287,7 @@ public class ConfigManager extends SimpleWebConsolePlugin implements OsgiManager
if ( ca != null )
{
// create filter
- final StringBuffer sb = new StringBuffer();
+ final StringBuilder sb = new StringBuilder();
if ( pid != null && pidFilter != null)
{
sb.append("(&"); //$NON-NLS-1$
@@ -439,6 +439,7 @@ public class ConfigManager extends SimpleWebConsolePlugin implements OsgiManager
// prepare variables
final String referer = request.getParameter( REFERER );
final boolean factoryCreate = "true".equals( request.getParameter(FACTORY_CREATE) ); //$NON-NLS-1$
+ @SuppressWarnings("unchecked")
final Map<String, Object> vars = ( ( Map<String, Object> ) WebConsoleUtil.getVariableResolver( request ) );
vars.put( "__data__", json.toString() ); //$NON-NLS-1$
vars.put( "selectedPid", pid != null ? pid : "" ); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationAdminConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationAdminConfigurationPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationUtil.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationUtil.java
old mode 100644
new mode 100755
index 3d894a0fbc..3df506a765
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationUtil.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigurationUtil.java
@@ -20,6 +20,7 @@ package org.apache.felix.webconsole.internal.configuration;
import java.io.IOException;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.List;
import java.util.Set;
@@ -106,7 +107,8 @@ public class ConfigurationUtil {
private final String factoryPid;
private String bundleLocation;
- PlaceholderConfiguration(final String factoryPid) {
+
+ PlaceholderConfiguration( final String factoryPid ) {
this.factoryPid = factoryPid;
}
@@ -121,7 +123,7 @@ public class ConfigurationUtil {
}
@Override
- public void setBundleLocation(final String bundleLocation) {
+ public void setBundleLocation( final String bundleLocation ) {
this.bundleLocation = bundleLocation;
}
@@ -142,7 +144,7 @@ public class ConfigurationUtil {
}
@Override
- public void update(Dictionary<String, ?> properties) {
+ public void update( Dictionary<String, ?> properties ) {
// dummy configuration cannot be updated
}
@@ -158,31 +160,31 @@ public class ConfigurationUtil {
}
@Override
- public Dictionary<String, Object> getProcessedProperties(ServiceReference<?> reference) {
- // dummy configuration has no properties
- return null;
+ public void addAttributes(ConfigurationAttribute... attrs) throws IOException {
+ // no attributes
}
@Override
- public boolean updateIfDifferent(Dictionary<String, ?> properties) throws IOException {
- // dummy configuration has no properties
- return false;
+ public Set<ConfigurationAttribute> getAttributes() {
+ // no attributes
+ return Collections.emptySet();
}
@Override
- public void addAttributes(ConfigurationAttribute... attrs) throws IOException {
+ public Dictionary<String, Object> getProcessedProperties(ServiceReference<?> reference) {
// dummy configuration has no properties
+ return null;
}
@Override
- public Set<ConfigurationAttribute> getAttributes() {
- // dummy configuration has no properties
- return null;
+ public void removeAttributes(ConfigurationAttribute... attrs) throws IOException {
+ // no attributes
}
@Override
- public void removeAttributes(ConfigurationAttribute... attrs) throws IOException {
+ public boolean updateIfDifferent(Dictionary<String, ?> properties) throws IOException {
// dummy configuration has no properties
+ return false;
}
}
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeServiceSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeServiceSupport.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeSupport.java
old mode 100644
new mode 100755
index 728ce0a1e4..51c4c728d0
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetaTypeSupport.java
@@ -163,6 +163,7 @@ class MetaTypeSupport
}
+ @SuppressWarnings("rawtypes")
private static List toList( Object value )
{
if ( value instanceof Vector )
@@ -190,11 +191,12 @@ class MetaTypeSupport
}
+ @SuppressWarnings("rawtypes")
static PropertyDescriptor createAttributeDefinition( final String id, final Object value )
{
int attrType;
int attrCardinality;
- Class type;
+ Class<?> type;
if ( value == null )
{
@@ -299,7 +301,7 @@ class MetaTypeSupport
return Byte.valueOf( value );
case AttributeDefinition.CHARACTER:
char c = ( value.length() > 0 ) ? value.charAt( 0 ) : 0;
- return new Character( c );
+ return Character.valueOf( c );
case AttributeDefinition.DOUBLE:
return Double.valueOf( value );
case AttributeDefinition.FLOAT:
@@ -318,6 +320,7 @@ class MetaTypeSupport
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
static void setPasswordProps( final Vector vec, final String[] properties, Object props )
{
List propList = ( props == null ) ? new ArrayList() : toList( props );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetatypePropertyDescriptor.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/MetatypePropertyDescriptor.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/PropertyDescriptor.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/PropertyDescriptor.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
old mode 100644
new mode 100755
index 718034896c..f3ae105e90
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
@@ -35,9 +35,10 @@ import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.startlevel.BundleStartLevel;
+import org.osgi.framework.startlevel.FrameworkStartLevel;
import org.osgi.framework.wiring.FrameworkWiring;
import org.osgi.service.log.LogService;
-import org.osgi.service.startlevel.StartLevel;
abstract class BaseUpdateInstallHelper implements Runnable
@@ -115,16 +116,16 @@ abstract class BaseUpdateInstallHelper implements Runnable
public final void run()
{
// now deploy the resolved bundles
- try
- {
+ try {
// we need the framework wiring before we call the bundle
// installation or update, since we might be updating
// our selves in which case the bundle context will be
// invalid by the time we want to call the update
- final FrameworkWiring fw = refreshPackages ? plugin.getBundle().getBundleContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class) : null;
+ final Bundle systemBundle = plugin.getBundle().getBundleContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
+ final FrameworkWiring fw = refreshPackages ? systemBundle.adapt(FrameworkWiring.class) : null;
// same for the startlevel
- StartLevel startLevel = null;
+ final FrameworkStartLevel startLevel = systemBundle.adapt(FrameworkStartLevel.class);
Bundle bundle = getTargetBundle();
@@ -133,26 +134,23 @@ abstract class BaseUpdateInstallHelper implements Runnable
// If the bundle has been started we want to stop it first, then update it, refresh it, and restart it
// because otherwise, it will be stopped and started twice (once by the update and once by the refresh)
- if ((state & (Bundle.ACTIVE | Bundle.STARTING)) != 0)
- {
+ if ((state & (Bundle.ACTIVE | Bundle.STARTING)) != 0) {
// we need the StartLevel service before we stop the bundle
// before the update, since we might be stopping
// our selves in which case the bundle context will be
// invalid by the time we want to call the startlevel
- startLevel = (StartLevel) getService(StartLevel.class.getName());
// We want to start the bundle afterwards without affecting the persistent state of the bundle
// However, we can only use the transient options if the framework startlevel is not less than the
// bundle startlevel (in case that there is no starlevel service we assume we are good).
- if (startLevel == null || startLevel.getStartLevel() >= startLevel.getBundleStartLevel(bundle))
- {
+ final BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
+ if (startLevel == null || bsl == null || startLevel.getStartLevel() >= bsl.getStartLevel()) {
startFlags |= Bundle.START_TRANSIENT;
}
// If the bundle is in the starting state it might be lazy and not started yet - hence, start it
// according to its policy.
- if (state == Bundle.STARTING)
- {
+ if (state == Bundle.STARTING) {
startFlags |= Bundle.START_ACTIVATION_POLICY;
}
@@ -163,46 +161,30 @@ abstract class BaseUpdateInstallHelper implements Runnable
// We want to catch an exception during update to be able to restart the bundle if we stopped it previously
Exception rethrow = null;
- try
- {
+ try {
// perform the action!
bundle = doRun();
- if ( bundle != null )
- {
+ if ( bundle != null ) {
// refresh packages and give it at most 5 seconds to finish
refreshPackages(fw, plugin.getBundle().getBundleContext(), 5000L, bundle );
}
- }
- catch (Exception ex)
- {
+ } catch (Exception ex) {
rethrow = ex;
throw ex;
- }
- finally
- {
+ } finally {
// If we stopped the bundle lets try to restart it (we created the correct flags above already).
- if ((state & (Bundle.ACTIVE | Bundle.STARTING)) != 0)
- {
- try
- {
+ if ((state & (Bundle.ACTIVE | Bundle.STARTING)) != 0) {
+ try {
bundle.start(startFlags);
- }
- catch (Exception ex)
- {
- if (rethrow == null)
- {
+ } catch (Exception ex) {
+ if (rethrow == null) {
throw ex;
- }
- else
- {
- try
- {
+ } else {
+ try{
getLog().log( LogService.LOG_ERROR, "Cannot restart bundle: " + bundle + " after exception during update!", ex);
- }
- catch ( Exception secondary )
- {
+ } catch ( Exception secondary ) {
// at the time this exception happens the log used might have
// been destroyed and is not available to use any longer. So
// we only can write to stderr at this time to at least get
@@ -214,15 +196,10 @@ abstract class BaseUpdateInstallHelper implements Runnable
}
}
}
- }
- catch ( Exception e )
- {
- try
- {
+ } catch ( Exception e ) {
+ try {
getLog().log( LogService.LOG_ERROR, "Cannot install or update bundle from " + bundleFile, e );
- }
- catch ( Exception secondary )
- {
+ } catch ( Exception secondary ) {
// at the time this exception happens the log used might have
// been destroyed and is not available to use any longer. So
// we only can write to stderr at this time to at least get
@@ -230,11 +207,8 @@ abstract class BaseUpdateInstallHelper implements Runnable
System.err.println( "Cannot install or update bundle from " + bundleFile );
e.printStackTrace( System.err );
}
- }
- finally
- {
- if ( bundleFile != null )
- {
+ } finally {
+ if ( bundleFile != null ) {
bundleFile.delete();
}
@@ -377,4 +351,4 @@ abstract class BaseUpdateInstallHelper implements Runnable
}
}
-}
\ No newline at end of file
+}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleContextUtil.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleContextUtil.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesConfigurationPrinter.java
old mode 100644
new mode 100755
index f06c016b52..6e48c8fe66
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesConfigurationPrinter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesConfigurationPrinter.java
@@ -19,89 +19,38 @@ package org.apache.felix.webconsole.internal.core;
import java.io.PrintWriter;
import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.Map;
import java.util.TreeMap;
import org.apache.felix.webconsole.internal.AbstractConfigurationPrinter;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.osgi.framework.wiring.BundleRevision;
/**
* The <code>BundlesConfigurationPrinter</code> prints out the bundle list.
*/
public class BundlesConfigurationPrinter
- extends AbstractConfigurationPrinter
-{
-
- private ServiceTracker<PackageAdmin, PackageAdmin> packageAdminTracker;
-
- /**
- * @see org.apache.felix.webconsole.internal.AbstractConfigurationPrinter#activate(org.osgi.framework.BundleContext)
- */
- public void activate(final BundleContext bundleContext)
- {
- super.activate(bundleContext);
- this.packageAdminTracker = new ServiceTracker(bundleContext, PackageAdmin.class, new ServiceTrackerCustomizer<PackageAdmin, PackageAdmin>() {
- public PackageAdmin addingService(final org.osgi.framework.ServiceReference<PackageAdmin> reference) {
- return bundleContext.getService(reference);
- }
-
- public void modifiedService(final org.osgi.framework.ServiceReference<PackageAdmin> reference, final PackageAdmin service) {
- // nothing to do
- }
-
- public void removedService(final org.osgi.framework.ServiceReference<PackageAdmin> reference, final PackageAdmin service) {
- try {
- bundleContext.ungetService(reference);
- } catch (IllegalStateException ise) {
- // ignore, bundle context was shut down concurrently
- }
- }
- });
- this.packageAdminTracker.open();
- }
-
- /**
- * @see org.apache.felix.webconsole.internal.AbstractConfigurationPrinter#deactivate()
- */
- public void deactivate()
- {
- if ( this.packageAdminTracker != null )
- {
- this.packageAdminTracker.close();
- this.packageAdminTracker = null;
- }
- super.deactivate();
- }
+ extends AbstractConfigurationPrinter {
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
*/
- public String getTitle()
- {
+ public String getTitle() {
return "Bundlelist";
}
private String getHeaderValue(final Bundle b, final String name)
{
String val = (String)b.getHeaders().get(name);
- if ( val == null )
- {
+ if ( val == null ) {
val = "";
}
return val;
}
- private String getState(final int state)
- {
- switch (state)
- {
+ private String getState(final int state) {
+ switch (state) {
case Bundle.ACTIVE : return "active";
case Bundle.INSTALLED : return "installed";
case Bundle.RESOLVED : return "resolved";
@@ -112,29 +61,26 @@ public class BundlesConfigurationPrinter
return String.valueOf(state);
}
- private final boolean isFragmentBundle( final Bundle bundle)
- {
- return ((PackageAdmin)this.packageAdminTracker.getService()).getBundleType( bundle ) == PackageAdmin.BUNDLE_TYPE_FRAGMENT;
+ private final boolean isFragmentBundle( final Bundle bundle) {
+ final BundleRevision rev = bundle.adapt(BundleRevision.class);
+ return rev != null && (rev.getTypes() & BundleRevision.TYPE_FRAGMENT) == BundleRevision.TYPE_FRAGMENT;
}
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
- public void printConfiguration( final PrintWriter pw )
- {
+ public void printConfiguration( final PrintWriter pw ) {
final Bundle[] bundles = BundleContextUtil.getWorkingBundleContext(this.getBundleContext()).getBundles();
// create a map for sorting first
- final TreeMap bundlesMap = new TreeMap();
+ final TreeMap<String, String> bundlesMap = new TreeMap<>();
int active = 0, installed = 0, resolved = 0, fragments = 0;
- for( int i =0; i<bundles.length; i++)
- {
+ for( int i =0; i<bundles.length; i++) {
final Bundle bundle = bundles[i];
final String symbolicName = bundle.getSymbolicName();
final String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
// count states and calculate prefix
- switch ( bundle.getState() )
- {
+ switch ( bundle.getState() ) {
case Bundle.ACTIVE:
active++;
break;
@@ -142,12 +88,9 @@ public class BundlesConfigurationPrinter
installed++;
break;
case Bundle.RESOLVED:
- if ( isFragmentBundle( bundle ) )
- {
+ if ( isFragmentBundle( bundle ) ) {
fragments++;
- }
- else
- {
+ } else {
resolved++;
}
break;
@@ -164,54 +107,43 @@ public class BundlesConfigurationPrinter
bundlesMap.put(key, value);
}
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
buffer.append("Status: ");
appendBundleInfoCount(buffer, "in total", bundles.length);
- if ( active == bundles.length || active + fragments == bundles.length )
- {
+ if ( active == bundles.length || active + fragments == bundles.length ) {
buffer.append(" - all ");
appendBundleInfoCount(buffer, "active.", bundles.length);
- }
- else
- {
- if ( active != 0 )
- {
+ } else{
+ if ( active != 0 ) {
buffer.append(", ");
appendBundleInfoCount(buffer, "active", active);
}
- if ( fragments != 0 )
- {
+ if ( fragments != 0 ) {
buffer.append(", ");
appendBundleInfoCount(buffer, "active fragments", fragments);
}
- if ( resolved != 0 )
- {
+ if ( resolved != 0 ) {
buffer.append(", ");
appendBundleInfoCount(buffer, "resolved", resolved);
}
- if ( installed != 0 )
- {
+ if ( installed != 0 ) {
buffer.append(", ");
appendBundleInfoCount(buffer, "installed", installed);
}
}
pw.println(buffer.toString());
pw.println();
- final Iterator i = bundlesMap.entrySet().iterator();
- while ( i.hasNext() )
- {
- final Map.Entry entry = (Map.Entry)i.next();
- pw.println(entry.getValue());
-
+ for(final String value : bundlesMap.values()) {
+ pw.println(value);
}
}
- private void appendBundleInfoCount( final StringBuffer buf, String msg, int count )
- {
+ private void appendBundleInfoCount( final StringBuilder buf, String msg, int count ) {
buf.append(count);
buf.append(" bundle");
- if ( count != 1 )
+ if ( count != 1 ) {
buf.append( 's' );
+ }
buf.append(' ');
buf.append(msg);
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
old mode 100644
new mode 100755
index e18d467922..d6599d8d37
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
@@ -234,6 +234,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
@Override
+ @SuppressWarnings({"rawtypes"})
public void printConfiguration( PrintWriter pw )
{
try
@@ -536,7 +537,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
}
- private void appendBundleInfoCount( final StringBuffer buf, String msg, int count )
+ private void appendBundleInfoCount( final StringBuilder buf, String msg, int count )
{
buf.append(count);
buf.append(" bundle");
@@ -685,7 +686,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
break;
}
}
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
buffer.append("Bundle information: ");
appendBundleInfoCount(buffer, "in total", bundles.length);
if ( active == bundles.length || active + fragments == bundles.length )
@@ -1154,10 +1155,10 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private String getServiceID(ServiceReference ref, final String servicesRoot)
{
String id = ref.getProperty( Constants.SERVICE_ID ).toString();
- StringBuffer val = new StringBuffer();
if ( servicesRoot != null )
{
+ StringBuilder val = new StringBuilder();
val.append( "<a href='" ).append( servicesRoot ).append( id ).append( "'>" );
val.append( id );
val.append( "</a>" );
@@ -1220,20 +1221,17 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private static final String enableLineWrapping(final String value)
{
- StringBuffer sb = new StringBuffer(value.length() * 2 / 3);
- synchronized (sb)
- { // faster
- for (int i = 0; i < value.length(); i++)
+ StringBuilder sb = new StringBuilder(value.length() * 2 / 3);
+ for (int i = 0; i < value.length(); i++)
+ {
+ final char ch = value.charAt( i );
+ sb.append( ch );
+ if ( ch == ';' || ch == ',' )
{
- final char ch = value.charAt( i );
- sb.append( ch );
- if ( ch == ';' || ch == ',' )
- {
- sb.append( ' ' );
- }
+ sb.append( ' ' );
}
- return sb.toString();
}
+ return sb.toString();
}
private void listFragmentInfo( final List props, final Bundle bundle, final String pluginRoot )
@@ -1271,7 +1269,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private void appendProperty( final List props, ServiceReference ref, String name, String label )
{
- StringBuffer dest = new StringBuffer();
+ StringBuilder dest = new StringBuilder();
Object value = ref.getProperty( name );
if ( value instanceof Object[] )
{
@@ -1301,7 +1299,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private Object collectExport( String name, String version )
{
- StringBuffer val = new StringBuffer();
+ StringBuilder val = new StringBuilder();
boolean bootDel = isBootDelegated( name );
if ( bootDel )
{
@@ -1334,7 +1332,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private Object collectImport( String name, String version, boolean optional, ExportedPackage export,
final String pluginRoot )
{
- StringBuffer val = new StringBuffer();
+ StringBuilder val = new StringBuilder();
boolean bootDel = isBootDelegated( name );
String marker = null;
@@ -1440,7 +1438,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
private String getBundleDescriptor( Bundle bundle, final String pluginRoot )
{
- StringBuffer val = new StringBuffer();
+ StringBuilder val = new StringBuilder();
if ( pluginRoot != null )
{
@@ -1604,7 +1602,7 @@ public class BundlesServlet extends SimpleWebConsolePlugin implements OsgiManage
// copy the data to a file for better processing
tmpFile = File.createTempFile( "install", ".tmp" );
tmpFile.delete(); // FIX for FILEUPLOAD-293
- bundleItem.write( tmpFile.toPath() );
+ bundleItem.write( tmpFile );
}
catch ( Exception e )
{
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesProvidedInfoProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesProvidedInfoProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesRequiredInfoProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/CapabilitiesRequiredInfoProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/FrameworkPropertiesPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/FrameworkPropertiesPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallHelper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallHelper.java
old mode 100644
new mode 100755
index de057b5ef0..6801df2f6c
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallHelper.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallHelper.java
@@ -27,11 +27,10 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
-import org.osgi.service.startlevel.StartLevel;
+import org.osgi.framework.startlevel.BundleStartLevel;
-class InstallHelper extends BaseUpdateInstallHelper
-{
+class InstallHelper extends BaseUpdateInstallHelper {
private final BundleContext bundleContext;
private final String location;
private final int startlevel;
@@ -51,25 +50,21 @@ class InstallHelper extends BaseUpdateInstallHelper
@Override
- protected Bundle doRun( InputStream bundleStream ) throws BundleException
- {
+ protected Bundle doRun( final InputStream bundleStream ) throws BundleException {
Bundle bundle = bundleContext.installBundle( location, bundleStream );
- if ( startlevel > 0 )
- {
- StartLevel sl = ( StartLevel ) getService( StartLevel.class.getName() );
- if ( sl != null )
- {
- sl.setBundleStartLevel( bundle, startlevel );
+ if ( startlevel > 0 ) {
+ final BundleStartLevel bsl = bundle.adapt(BundleStartLevel.class);
+ if (bsl != null) {
+ bsl.setStartLevel(startlevel);
}
}
// don't start fragments
- if ( doStart && bundle.getHeaders().get( Constants.FRAGMENT_HOST ) == null )
- {
+ if ( doStart && bundle.getHeaders().get( Constants.FRAGMENT_HOST ) == null ) {
bundle.start();
}
return bundle;
}
-}
\ No newline at end of file
+}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/PermissionsConfigurationPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesConfigurationPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesConfigurationPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesServlet.java
old mode 100644
new mode 100755
index 057faff0f2..a8fd5e205b
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesServlet.java
@@ -145,7 +145,7 @@ public class ServicesServlet extends SimpleWebConsolePlugin implements OsgiManag
// only use last part of the pathInfo
pathInfo = pathInfo.substring( pathInfo.lastIndexOf( '/' ) + 1 );
- StringBuffer filter = new StringBuffer();
+ StringBuilder filter = new StringBuilder();
filter.append( "(" ).append( Constants.SERVICE_ID ).append( "=" );
filter.append( pathInfo ).append( ")" );
String filterStr = filter.toString();
@@ -194,7 +194,7 @@ public class ServicesServlet extends SimpleWebConsolePlugin implements OsgiManag
static final String getStatusLine( final ServiceReference[] services )
{
final int count = services.length;
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
buffer.append( count );
buffer.append( " service" );
if ( count != 1 )
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesUsedInfoProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/ServicesUsedInfoProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/UpdateHelper.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/FilteringResponseWrapper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/FilteringResponseWrapper.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/ResourceFilteringWriter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/ResourceFilteringWriter.java
old mode 100644
new mode 100755
index 00c72f5187..e201dd03b0
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/ResourceFilteringWriter.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/filter/ResourceFilteringWriter.java
@@ -80,7 +80,7 @@ class ResourceFilteringWriter extends FilterWriter
/**
* The buffer to gather the text to be translated
*/
- private final StringBuffer lineBuffer = new StringBuffer();
+ private final StringBuilder lineBuffer = new StringBuilder();
/**
* The current state, starts with {@link #STATE_NULL}
@@ -232,4 +232,4 @@ class ResourceFilteringWriter extends FilterWriter
return value;
}
-}
\ No newline at end of file
+}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/CombinedEnumeration.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/CombinedEnumeration.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/CombinedResourceBundle.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/CombinedResourceBundle.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ConsolePropertyResourceBundle.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ConsolePropertyResourceBundle.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleCache.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleManager.java
old mode 100644
new mode 100755
index 03c9e706f6..391a46b548
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/i18n/ResourceBundleManager.java
@@ -19,10 +19,10 @@
package org.apache.felix.webconsole.internal.i18n;
-import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -35,26 +35,22 @@ import org.osgi.framework.BundleListener;
* It contains a local cache, for bundles, but when a bundle is being unistalled,
* its resources stored in the cache are cleaned up.
*/
-public class ResourceBundleManager implements BundleListener
-{
+public class ResourceBundleManager implements BundleListener {
private final BundleContext bundleContext;
private final ResourceBundleCache consoleResourceBundleCache;
- private final Map resourceBundleCaches;
-
+ private final Map<Long, ResourceBundleCache> resourceBundleCaches = new ConcurrentHashMap<>();
/**
* Creates a new object and adds self as a bundle listener
*
* @param bundleContext the bundle context of the Web Console.
*/
- public ResourceBundleManager( final BundleContext bundleContext )
- {
+ public ResourceBundleManager( final BundleContext bundleContext ) {
this.bundleContext = bundleContext;
this.consoleResourceBundleCache = new ResourceBundleCache( bundleContext.getBundle() );
- this.resourceBundleCaches = new HashMap();
bundleContext.addBundleListener( this );
}
@@ -78,8 +74,7 @@ public class ResourceBundleManager implements BundleListener
* @return the resource bundle - if not bundle with the requested locale exists,
* the default locale is used.
*/
- public ResourceBundle getResourceBundle( final Bundle provider, final Locale locale )
- {
+ public ResourceBundle getResourceBundle( final Bundle provider, final Locale locale ) {
// check whether we have to return the resource bundle for the
// Web Console itself in which case we directly return it
final ResourceBundle defaultResourceBundle = consoleResourceBundleCache.getResourceBundle( locale );
@@ -88,17 +83,7 @@ public class ResourceBundleManager implements BundleListener
return defaultResourceBundle;
}
- ResourceBundleCache cache;
- synchronized ( resourceBundleCaches )
- {
- Long key = new Long( provider.getBundleId() );
- cache = ( ResourceBundleCache ) resourceBundleCaches.get( key );
- if ( cache == null )
- {
- cache = new ResourceBundleCache( provider );
- resourceBundleCaches.put( key, cache );
- }
- }
+ final ResourceBundleCache cache = this.resourceBundleCaches.computeIfAbsent(provider.getBundleId(), key -> new ResourceBundleCache(provider));
final ResourceBundle bundleResourceBundle = cache.getResourceBundle( locale );
return new CombinedResourceBundle( bundleResourceBundle, defaultResourceBundle, locale );
@@ -110,15 +95,9 @@ public class ResourceBundleManager implements BundleListener
/**
* @see org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
*/
- public final void bundleChanged( BundleEvent event )
- {
- if ( event.getType() == BundleEvent.STOPPED )
- {
- Long key = new Long( event.getBundle().getBundleId() );
- synchronized ( resourceBundleCaches )
- {
- resourceBundleCaches.remove( key );
- }
+ public final void bundleChanged( BundleEvent event ) {
+ if ( event.getType() == BundleEvent.STOPPED ) {
+ resourceBundleCaches.remove( event.getBundle().getBundleId() );
}
}
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ConfigurationRender.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/LicenseServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/LicenseServlet.java
old mode 100644
new mode 100755
index 125e3a2154..826cf18aa3
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/LicenseServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/LicenseServlet.java
@@ -109,6 +109,7 @@ public final class LicenseServlet extends SimpleWebConsolePlugin implements Osgi
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
*/
+ @SuppressWarnings("unchecked")
protected void renderContent( HttpServletRequest request, HttpServletResponse res ) throws IOException
{
Bundle[] bundles = getBundleContext().getBundles();
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ServletSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ServletSupport.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/SystemPropertiesPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadDumper.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ThreadPrinter.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Base64.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Base64.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/BasicWebConsoleSecurityProvider.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/BasicWebConsoleSecurityProvider.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
old mode 100644
new mode 100755
index cac5440ea0..b70da50006
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
@@ -35,13 +35,12 @@ import org.osgi.service.metatype.ObjectClassDefinition;
class ConfigurationMetatypeSupport extends ConfigurationSupport implements MetaTypeProvider
{
private static final String[] CONF_PROPS = new String[]
- { OsgiManager.PROP_MANAGER_ROOT, OsgiManager.DEFAULT_MANAGER_ROOT, //
- OsgiManager.PROP_HTTP_SERVICE_SELECTOR, OsgiManager.DEFAULT_HTTP_SERVICE_SELECTOR, //
- OsgiManager.PROP_DEFAULT_RENDER, OsgiManager.DEFAULT_PAGE, //
- OsgiManager.PROP_REALM, OsgiManager.DEFAULT_REALM, //
- OsgiManager.PROP_USER_NAME, OsgiManager.DEFAULT_USER_NAME, //
- OsgiManager.PROP_CATEGORY, OsgiManager.DEFAULT_CATEGORY, //
- OsgiManager.PROP_LOCALE, "", //$NON-NLS-1$
+ { OsgiManager.PROP_MANAGER_ROOT, OsgiManager.DEFAULT_MANAGER_ROOT,
+ OsgiManager.PROP_DEFAULT_RENDER, OsgiManager.DEFAULT_PAGE,
+ OsgiManager.PROP_REALM, OsgiManager.DEFAULT_REALM,
+ OsgiManager.PROP_USER_NAME, OsgiManager.DEFAULT_USER_NAME,
+ OsgiManager.PROP_CATEGORY, OsgiManager.DEFAULT_CATEGORY,
+ OsgiManager.PROP_LOCALE, "",
};
private final Object ocdLock = new Object();
@@ -322,4 +321,4 @@ class ConfigurationMetatypeSupport extends ConfigurationSupport implements MetaT
}
}
-}
\ No newline at end of file
+}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationSupport.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
old mode 100644
new mode 100755
index 1c4ffdecba..ef5d1840b1
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
@@ -91,7 +91,7 @@ public class ConfigurationUtil
* @return The value of the named property as a string or <code>def</code>
* if the property does not exist
*/
- public static final String getProperty(Map config, String name, String def)
+ public static final String getProperty(Map<String, Object> config, String name, String def)
{
Object value = config.get(name);
if ( value instanceof String )
@@ -118,7 +118,7 @@ public class ConfigurationUtil
* @return The value of the named property as a string or <code>def</code>
* if the property does not exist
*/
- public static final int getProperty(Map config, String name, int def)
+ public static final int getProperty(Map<String, Object> config, String name, int def)
{
Object value = config.get(name);
if (value instanceof Number)
@@ -150,7 +150,7 @@ public class ConfigurationUtil
* @param name The name of the property to return
* @return the property value as string array - no matter if originally it was other kind of array, collection or comma-separated string. Returns <code>null</code> if the property is not set.
*/
- public static final String[] getStringArrayProperty(Map config, String name)
+ public static final String[] getStringArrayProperty(Map<String, Object> config, String name)
{
Object value = config.get(name);
if (value == null)
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
old mode 100644
new mode 100755
index 6e5334fba4..917a60e087
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
@@ -16,12 +16,6 @@
*/
package org.apache.felix.webconsole.internal.servlet;
-import static org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
-import static org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
-import static org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN;
-import static org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX;
-import static org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN;
-
import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
@@ -40,7 +34,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -84,11 +77,11 @@ import jakarta.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletResponse;
/**
- * The <code>OSGi Manager</code> is the actual Web Console Servlet which is
- * registered as a service and which maintains registered console plugins.
+ * The <code>OSGi Manager</code> is the actual Web Console Servlet. It is
+ * registered with the OSGi Http Whiteboard Service and it manages registered
+ * console plugins.
*/
-public class OsgiManager extends GenericServlet
-{
+public class OsgiManager extends GenericServlet {
/** Pseudo class version ID to keep the IDE quite. */
private static final long serialVersionUID = 1L;
@@ -146,6 +139,10 @@ public class OsgiManager extends GenericServlet
private static final String FRAMEWORK_PROP_LOCALE = "felix.webconsole.locale"; //$NON-NLS-1$
+ private static final String FRAMEWORK_SHUTDOWN_TIMEOUT = "felix.webconsole.shutdown.timeout"; //$NON-NLS-1$
+
+ private static final String FRAMEWORK_RELOAD_TIMEOUT = "felix.webconsole.reload.timeout"; //$NON-NLS-1$
+
static final String FRAMEWORK_PROP_SECURITY_PROVIDERS = "felix.webconsole.security.providers"; //$NON-NLS-1$
static final String SECURITY_PROVIDER_PROPERTY_NAME = "webconsole.security.provider.id"; //$NON-NLS-1$
@@ -171,6 +168,12 @@ public class OsgiManager extends GenericServlet
static final String PROP_ENABLE_SECRET_HEURISTIC = "secret.heuristic.enabled"; //$NON-NLS-1$
static final String PROP_HTTP_SERVICE_SELECTOR = "http.service.filter"; //$NON-NLS-1$
+
+ /** The framework shutdown timeout */
+ public static final String PROP_SHUTDOWN_TIMEOUT = "shutdown.timeout";
+
+ /** The timeout for VMStat plugin page reload */
+ public static final String PROP_RELOAD_TIMEOUT = "reload.timeout";
public static final int DEFAULT_LOG_LEVEL = LogService.LOG_WARNING;
@@ -184,9 +187,9 @@ public class OsgiManager extends GenericServlet
static final String DEFAULT_CATEGORY = "Main"; //$NON-NLS-1$
- static final String DEFAULT_HTTP_SERVICE_SELECTOR = ""; //$NON-NLS-1$
+ static final int DEFAULT_SHUTDOWN_TIMEOUT = 5; //$NON-NLS-1$
- public static final String DEFAULT_CONTEXT_NAME = "OsgiManagerDefaultHttpContext"; //$NON-NLS-1$
+ static final int DEFAULT_RELOAD_TIMEOUT = 40; //$NON-NLS-1$
/** Default value for secret heuristics */
public static final boolean DEFAULT_ENABLE_SECRET_HEURISTIC = false;
@@ -199,7 +202,7 @@ public class OsgiManager extends GenericServlet
* The default value for the {@link #PROP_MANAGER_ROOT} configuration
* property (value is "/system/console").
*/
- public static final String DEFAULT_MANAGER_ROOT = "/system/console"; //$NON-NLS-1$
+ 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$
@@ -225,11 +228,13 @@ public class OsgiManager extends GenericServlet
"org.apache.felix.webconsole.internal.system.VMStatPlugin", "vmstat", //$NON-NLS-1$ //$NON-NLS-2$
};
+ private static final String SERVLEXT_CONTEXT_NAME = "org.apache.felix.webconsole";
+
/** Flag to control whether secret heuristics is enabled */
public static volatile boolean ENABLE_SECRET_HEURISTICS = OsgiManager.DEFAULT_ENABLE_SECRET_HEURISTIC;
private BundleContext bundleContext;
-
+
private PluginHolder holder;
private ServiceTracker<BrandingPlugin, BrandingPlugin> brandingTracker;
@@ -240,22 +245,19 @@ public class OsgiManager extends GenericServlet
// list of OsgiManagerPlugin instances activated during init. All these
// instances will have to be deactivated during destroy
- private List<OsgiManagerPlugin> osgiManagerPlugins = new ArrayList<>();
+ private volatile List<OsgiManagerPlugin> osgiManagerPlugins = new ArrayList<>();
- private String webManagerRoot;
+ private volatile String webManagerRoot;
// not-null when the BasicWebConsoleSecurityProvider service is registered
private ServiceRegistration<WebConsoleSecurityProvider> basicSecurityServiceRegistration;
-
+
// not-null when the ServletContextHelper service is registered
- private ServiceRegistration<ServletContextHelper> servletContextHelperRegistration;
+ private volatile ServiceRegistration<ServletContextHelper> servletContextRegistration;
- // not-null when the Servlet service is registered
- private ServiceRegistration<Servlet> servletRegistration;
+ // not-null when the main servlet and the resources are registered
+ private volatile ServiceRegistration<Servlet> servletRegistration;
- // not-null when the resources are registered
- private ServiceRegistration<Object> resourcesRegistration;
-
// default configuration from framework properties
private Map<String, Object> defaultConfiguration;
@@ -366,7 +368,11 @@ public class OsgiManager extends GenericServlet
ConfigurationUtil.getProperty( bundleContext, FRAMEWORK_PROP_LOG_LEVEL, DEFAULT_LOG_LEVEL ) );
this.defaultConfiguration.put( PROP_LOCALE,
ConfigurationUtil.getProperty( bundleContext, FRAMEWORK_PROP_LOCALE, null ) );
-
+ this.defaultConfiguration.put( PROP_SHUTDOWN_TIMEOUT,
+ ConfigurationUtil.getProperty( bundleContext, FRAMEWORK_SHUTDOWN_TIMEOUT, DEFAULT_SHUTDOWN_TIMEOUT ) );
+ this.defaultConfiguration.put( PROP_RELOAD_TIMEOUT,
+ ConfigurationUtil.getProperty( bundleContext, FRAMEWORK_RELOAD_TIMEOUT, DEFAULT_RELOAD_TIMEOUT ) );
+
// configure and start listening for configuration
updateConfiguration(null);
@@ -411,28 +417,18 @@ public class OsgiManager extends GenericServlet
put( Constants.SERVICE_PID, getConfigurationPid() );
}
} );
-
- if (this.requiredSecurityProviders.isEmpty()) {
- updateRegistrationState();
- }
}
void updateRegistrationState() {
- if (getBundleContext() != null) {
- if (this.registeredSecurityProviders.containsAll(this.requiredSecurityProviders)) {
- // register servlet context helper, servlet, resources and security provider as services
- registerServices();
- return;
- } else {
- log(LogService.LOG_INFO,
- "Not all requirements met for the Web Console. Required security providers: "
- + this.registeredSecurityProviders + " Registered security providers: "
- + this.registeredSecurityProviders);
- }
+ if (this.registeredSecurityProviders.containsAll(this.requiredSecurityProviders)) {
+ // register servlet context helper, servlet, resources
+ this.registerHttpWhiteboardServices();
+ } else {
+ log(LogService.LOG_INFO, "Not all requirements met for the Web Console. Required security providers: "
+ + this.registeredSecurityProviders + " Registered security providers: " + this.registeredSecurityProviders);
+ // Not all requirements met, unregister services
+ this.unregisterHttpWhiteboardServices();
}
-
- // Not all requirements met, unregister services
- unregisterServices();
}
public void dispose()
@@ -464,9 +460,9 @@ public class OsgiManager extends GenericServlet
// simply remove all operations, we should not be used anymore
this.osgiManagerPlugins.clear();
- // now drop the servlet context helper, servlet, resources and security provider as services, and continue with further destroyals
- unregisterServices();
-
+ // now drop the HttpService and continue with further destroyals
+ this.unregisterHttpWhiteboardServices();
+
// stop listening for configuration
if (configurationListener != null)
{
@@ -514,7 +510,18 @@ public class OsgiManager extends GenericServlet
@Override
public Object run() throws Exception
{
- service((HttpServletRequest) req, (HttpServletResponse) res);
+ final HttpServletRequest wrapper = new HttpServletRequestWrapper((HttpServletRequest) req) {
+ @Override
+ public String getServletPath() {
+ return "";
+ }
+
+ @Override
+ public String getPathInfo() {
+ return super.getServletPath();
+ }
+ };
+ service(wrapper, (HttpServletResponse) res);
return null;
}
});
@@ -555,16 +562,13 @@ public class OsgiManager extends GenericServlet
}
void service(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
+ throws ServletException, IOException {
// check whether we are not at .../{webManagerRoot}
final String pathInfo = request.getPathInfo();
- if (pathInfo == null || pathInfo.equals("/")) //$NON-NLS-1$
- {
+ if (pathInfo == null || pathInfo.isEmpty() || pathInfo.equals("/")) {
String path = request.getRequestURI();
- if (!path.endsWith("/")) //$NON-NLS-1$
- {
- path = path.concat("/"); //$NON-NLS-1$
+ if (!path.endsWith("/")) {
+ path = path.concat("/");
}
path = path.concat(holder.getDefaultPluginLabel());
response.setContentLength(0);
@@ -572,7 +576,7 @@ public class OsgiManager extends GenericServlet
return;
}
- if (pathInfo.equals("/logout")) { //$NON-NLS-1$
+ if (pathInfo.equals("/logout")) {
logout(request, response);
return;
}
@@ -586,38 +590,11 @@ public class OsgiManager extends GenericServlet
final Locale locale = getConfiguredLocale(request);
final String label = pathInfo.substring(1, slash);
AbstractWebConsolePlugin plugin = getConsolePlugin(label);
- if (plugin != null)
- {
- final Map labelMap = holder.getLocalizedLabelMap( resourceBundleManager, locale, this.defaultCategory );
- final Object flatLabelMap = labelMap.remove( WebConsoleConstants.ATTR_LABEL_MAP );
-
- // the official request attributes
- request.setAttribute(WebConsoleConstants.ATTR_LANG_MAP, getLangMap());
- request.setAttribute(WebConsoleConstants.ATTR_LABEL_MAP, flatLabelMap);
- request.setAttribute( ATTR_LABEL_MAP_CATEGORIZED, labelMap );
- request.setAttribute(WebConsoleConstants.ATTR_APP_ROOT,
- request.getContextPath() + request.getServletPath());
- request.setAttribute(WebConsoleConstants.ATTR_PLUGIN_ROOT,
- request.getContextPath() + request.getServletPath() + '/' + label);
-
- // deprecated request attributes
- request.setAttribute(ATTR_LABEL_MAP_OLD, flatLabelMap);
- request.setAttribute(ATTR_APP_ROOT_OLD,
- request.getContextPath() + request.getServletPath());
-
- // fix for https://issues.apache.org/jira/browse/FELIX-3408
- ensureLocaleCookieSet(request, response, locale);
-
- // wrap the response for localization and template variable replacement
- request = wrapRequest(request, locale);
- response = wrapResponse(request, response, plugin);
-
- plugin.service(request, response);
- }
- else
+
+ if (plugin == null)
{
final String body404 = MessageFormat.format(
- resourceBundleManager.getResourceBundle(getBundleContext().getBundle(), locale).getString(
+ resourceBundleManager.getResourceBundle(bundleContext.getBundle(), locale).getString(
"404"), //$NON-NLS-1$
new Object[] { request.getContextPath() + request.getServletPath() + '/'
+ BundlesServlet.NAME });
@@ -625,57 +602,79 @@ public class OsgiManager extends GenericServlet
response.setContentType("text/html"); //$NON-NLS-1$
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.getWriter().println(body404);
+
+ return;
}
+
+ @SuppressWarnings("rawtypes")
+ final Map labelMap = holder.getLocalizedLabelMap( resourceBundleManager, locale, this.defaultCategory );
+ final Object flatLabelMap = labelMap.remove( WebConsoleConstants.ATTR_LABEL_MAP );
+
+ // the official request attributes
+ request.setAttribute(WebConsoleConstants.ATTR_LANG_MAP, getLangMap());
+ request.setAttribute(WebConsoleConstants.ATTR_LABEL_MAP, flatLabelMap);
+ request.setAttribute( ATTR_LABEL_MAP_CATEGORIZED, labelMap );
+ request.setAttribute(WebConsoleConstants.ATTR_APP_ROOT,
+ request.getContextPath() + request.getServletPath());
+ request.setAttribute(WebConsoleConstants.ATTR_PLUGIN_ROOT,
+ request.getContextPath() + request.getServletPath() + '/' + label);
+ request.setAttribute(WebConsoleConstants.ATTR_CONFIGURATION, configuration);
+
+ // deprecated request attributes
+ request.setAttribute(ATTR_LABEL_MAP_OLD, flatLabelMap);
+ request.setAttribute(ATTR_APP_ROOT_OLD,
+ request.getContextPath() + request.getServletPath());
+
+ // fix for https://issues.apache.org/jira/browse/FELIX-3408
+ ensureLocaleCookieSet(request, response, locale);
+
+ // wrap the response for localization and template variable replacement
+ request = wrapRequest(request, locale);
+ response = wrapResponse(request, response, plugin);
+
+ plugin.service(request, response);
}
private final void logout(HttpServletRequest request, HttpServletResponse response)
- throws IOException
- {
- // check if special logout cookie is set, this is used to prevent
- // from an endless loop with basic auth
- Cookie[] cookies = request.getCookies();
- boolean found = false;
- if ( cookies != null )
- {
- for(int i=0;i<cookies.length;i++)
- {
- if ( cookies[i].getName().equals("logout") ) //$NON-NLS-1$
- {
- found = true;
- break;
+ throws IOException {
+ final Object securityProvider = securityProviderTracker.getService();
+ if (securityProvider instanceof WebConsoleSecurityProvider3) {
+ ((WebConsoleSecurityProvider3) securityProvider).logout(request, response);
+ } else {
+ // check if special logout cookie is set, this is used to prevent
+ // from an endless loop with basic auth
+ final Cookie[] cookies = request.getCookies();
+ boolean found = false;
+ if ( cookies != null ) {
+ for(final Cookie c : cookies) {
+ if (c.getName().equals("logout") ) {
+ found = true;
+ break;
+ }
}
}
- }
- if ( found )
- {
- // redirect to main page
- String url = request.getRequestURI();
- final int lastSlash = url.lastIndexOf('/');
- final Cookie c = new Cookie("logout", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- c.setMaxAge(0);
- response.addCookie(c);
- response.sendRedirect(url.substring(0, lastSlash));
- return;
- }
- Object securityProvider = securityProviderTracker.getService();
- if (securityProvider instanceof WebConsoleSecurityProvider3)
- {
- ((WebConsoleSecurityProvider3) securityProvider).logout(request, response);
- }
- else
- {
- // if the security provider doesn't support logout, we try to
- // logout the default basic authentication mechanism
- // See https://issues.apache.org/jira/browse/FELIX-3006
-
- // check for basic authentication
- String auth = request.getHeader(HEADER_AUTHORIZATION); //$NON-NLS-1$
- if (null != auth && auth.toLowerCase().startsWith("basic ")) { //$NON-NLS-1$
- Map<String, Object> config = getConfiguration();
- String realm = ConfigurationUtil.getProperty(config, PROP_REALM, DEFAULT_REALM);
- response.setHeader(HEADER_WWW_AUTHENTICATE, "Basic realm=\"" + realm + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- response.addCookie(new Cookie("logout", "true")); //$NON-NLS-1$ //$NON-NLS-2$
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ if ( found ) {
+ // redirect to main page
+ final String url = request.getRequestURI();
+ final int lastSlash = url.lastIndexOf('/');
+ final Cookie c = new Cookie("logout", "true");
+ c.setMaxAge(0);
+ response.addCookie(c);
+ response.sendRedirect(url.substring(0, lastSlash));
+ } else {
+ // if the security provider doesn't support logout, we try to
+ // logout the default basic authentication mechanism
+ // See https://issues.apache.org/jira/browse/FELIX-3006
+
+ // check for basic authentication
+ final String auth = request.getHeader(HEADER_AUTHORIZATION);
+ if (null != auth && auth.toLowerCase().startsWith("basic ")) {
+ Map<String, Object> config = getConfiguration();
+ String realm = ConfigurationUtil.getProperty(config, PROP_REALM, DEFAULT_REALM);
+ response.setHeader(HEADER_WWW_AUTHENTICATE, "Basic realm=\"" + realm + "\"");
+ response.addCookie(new Cookie("logout", "true"));
+ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ }
}
}
@@ -724,8 +723,6 @@ public class OsgiManager extends GenericServlet
}
}
- // TODO: check UserAdmin ?
-
if (locale == null)
locale = configuredLocale;
if (locale == null)
@@ -894,124 +891,116 @@ public class OsgiManager extends GenericServlet
}
- synchronized void registerServices() {
- Map<String, Object> config = getConfiguration();
-
- // get authentication details
- String realm = ConfigurationUtil.getProperty(config, PROP_REALM, DEFAULT_REALM);
- String userId = ConfigurationUtil.getProperty(config, PROP_USER_NAME, DEFAULT_USER_NAME);
- String password = ConfigurationUtil.getProperty(config, PROP_PASSWORD, DEFAULT_PASSWORD);
-
- // register the servlet context helper, servlet, resources and security provider
- // as services - if not already registered
- try {
- if (!isServletContextHelperRegistered()) {
- OsgiManagerHttpContext httpContext = new OsgiManagerHttpContext(getBundleContext().getBundle(),
- securityProviderTracker, realm);
- registerServletContextHelper(httpContext);
- }
+ synchronized void registerHttpWhiteboardServices() {
+ final String realm = ConfigurationUtil.getProperty(this.getConfiguration(), PROP_REALM, DEFAULT_REALM);
+
+ try{
+ final String httpServiceSelector = ConfigurationUtil.getProperty(this.getConfiguration(), PROP_HTTP_SERVICE_SELECTOR, null);
- if (!isbasicSecurityServiceRegistered()) {
- // register this component
- BasicWebConsoleSecurityProvider service = new BasicWebConsoleSecurityProvider(getBundleContext(), userId,
- password, realm);
- Dictionary<String, Object> serviceProperties = new Hashtable<>(); // NOSONAR
- // this is a last resort service, so use a low service ranking to prefer all
- // other services over this one
+ if (this.basicSecurityServiceRegistration == null) {
+ //register this component
+ final String userId = ConfigurationUtil.getProperty(this.getConfiguration(), PROP_USER_NAME, DEFAULT_USER_NAME);
+ final String password = ConfigurationUtil.getProperty(this.getConfiguration(), PROP_PASSWORD, DEFAULT_PASSWORD);
+ final BasicWebConsoleSecurityProvider service = new BasicWebConsoleSecurityProvider(bundleContext,
+ userId, password, realm);
+ final Dictionary<String, Object> serviceProperties = new Hashtable<>(); // NOSONAR
+ // this is a last resort service, so use a low service ranking to prefer all other services over this one
serviceProperties.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
- basicSecurityServiceRegistration = bundleContext.registerService(WebConsoleSecurityProvider.class,
+ this.basicSecurityServiceRegistration = bundleContext.registerService(WebConsoleSecurityProvider.class,
service, serviceProperties);
}
- if (!isServletRegistered()) {
- Dictionary<String, String> servletConfig = toStringConfig(config);
+ if (this.servletContextRegistration == null) {
+ final ServletContextHelper httpContext = new OsgiManagerHttpContext(this.bundleContext.getBundle(),
+ securityProviderTracker, realm);
+ final Dictionary<String, Object> props = new Hashtable<>();
+ if (httpServiceSelector != null) {
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_TARGET, httpServiceSelector);
+ }
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, SERVLEXT_CONTEXT_NAME);
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, this.webManagerRoot);
- registerServlet(this.webManagerRoot + "/*", servletConfig);
+ this.servletContextRegistration = getBundleContext().registerService(ServletContextHelper.class,
+ httpContext, props);
}
- if (!isResourcesRegistered()) {
- registerResources(this.webManagerRoot + "/res/*", "/res");
- }
+ if (this.servletRegistration == null) {
+ // register this servlet and take note of this
+ final Dictionary<String, Object> props = new Hashtable<>();
+ for(final Map.Entry<String, Object> entry : this.getConfiguration().entrySet()) {
+ props.put(entry.getKey(), String.valueOf(entry.getValue()));
+ }
+ if (httpServiceSelector != null) {
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_TARGET, httpServiceSelector);
+ }
- } catch (Exception e) {
- log(LogService.LOG_ERROR, "registerServices: Problem registering services", e);
- }
- }
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/");
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + SERVLEXT_CONTEXT_NAME + ")");
- synchronized void unregisterServices() {
- if (isResourcesRegistered()) {
- try {
- resourcesRegistration.unregister();
- } catch (Throwable t) {
- log(LogService.LOG_WARNING, "Failed unregistering Resources", t);
- }
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/res/*");
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/res");
- resourcesRegistration = null;
+ this.servletRegistration = getBundleContext().registerService(Servlet.class, this, props);
+ }
+ } catch (final Exception e) {
+ log(LogService.LOG_ERROR, "registerHttpWhiteboardServices: Problem setting up", e);
+ this.unregisterHttpWhiteboardServices();
}
+ }
- if (isServletRegistered()) {
+ synchronized void unregisterHttpWhiteboardServices() {
+ if (this.basicSecurityServiceRegistration != null) {
try {
- servletRegistration.unregister();
- } catch (Throwable t) {
- log(LogService.LOG_WARNING, "Failed unregistering Servlet", t);
+ this.basicSecurityServiceRegistration.unregister();
+ } catch (final IllegalStateException ignore) {
+ // ignore
}
-
- servletRegistration = null;
+ this.basicSecurityServiceRegistration = null;
}
- if (isbasicSecurityServiceRegistered()) {
+ if (this.servletRegistration != null) {
try {
- basicSecurityServiceRegistration.unregister();
- } catch (Throwable t) {
- log(LogService.LOG_WARNING, "Failed unregistering basic WebConsoleSecurityProvider", t);
+ this.servletRegistration.unregister();
+ } catch (final IllegalStateException ignore) {
+ // ignore
}
-
- basicSecurityServiceRegistration = null;
+ this.servletRegistration = null;
}
- if (isServletContextHelperRegistered()) {
+ if (this.servletContextRegistration != null) {
try {
- servletContextHelperRegistration.unregister();
- } catch (Throwable t) {
- log(LogService.LOG_WARNING, "Failed unregistering ServletContextHelper", t);
+ this.servletContextRegistration.unregister();
+ } catch (final IllegalStateException ignore) {
+ // ignore
}
-
- servletContextHelperRegistration = null;
+ this.servletContextRegistration = null;
}
}
- private Map<String, Object> getConfiguration()
- {
+ private Map<String, Object> getConfiguration() {
return configuration;
}
-
- Map<String, Object> getDefaultConfiguration()
- {
+ Map<String, Object> getDefaultConfiguration() {
return defaultConfiguration;
}
+ synchronized void updateConfiguration( final Dictionary<String, Object> osgiConfig) {
+ final Map<String, Object> config = new HashMap<String, Object>( this.defaultConfiguration );
- synchronized void updateConfiguration( Dictionary<String, Object> osgiConfig )
- {
- Map<String, Object> config = new HashMap<String, Object>( this.defaultConfiguration );
-
- if ( osgiConfig != null )
- {
- for ( Enumeration<String> keys = osgiConfig.keys(); keys.hasMoreElements(); )
- {
+ if ( osgiConfig != null ) {
+ for ( Enumeration<String> keys = osgiConfig.keys(); keys.hasMoreElements(); ) {
final String key = keys.nextElement();
config.put( key, osgiConfig.get( key ) );
}
}
- configuration = config;
+ this.configuration = config;
final Object locale = config.get(PROP_LOCALE);
- configuredLocale = locale == null || locale.toString().trim().length() == 0 //
- ? null : Util.parseLocaleString(locale.toString().trim());
+ this.configuredLocale = locale == null || locale.toString().trim().length() == 0 ? null : Util.parseLocaleString(locale.toString().trim());
- logLevel = ConfigurationUtil.getProperty(config, PROP_LOG_LEVEL, DEFAULT_LOG_LEVEL);
+ this.logLevel = ConfigurationUtil.getProperty(config, PROP_LOG_LEVEL, DEFAULT_LOG_LEVEL);
AbstractWebConsolePlugin.setLogLevel(logLevel);
// default plugin page configuration
@@ -1019,52 +1008,33 @@ public class OsgiManager extends GenericServlet
// get the web manager root path
String newWebManagerRoot = ConfigurationUtil.getProperty(config, PROP_MANAGER_ROOT, DEFAULT_MANAGER_ROOT);
- if (!newWebManagerRoot.startsWith("/")) //$NON-NLS-1$
- {
- newWebManagerRoot = "/" + newWebManagerRoot; //$NON-NLS-1$
- }
-
- if (newWebManagerRoot.endsWith("/"))
- {
- newWebManagerRoot = newWebManagerRoot.substring(0, newWebManagerRoot.lastIndexOf("/"));
+ if (!newWebManagerRoot.startsWith("/")) { //$NON-NLS-1$
+ newWebManagerRoot = "/".concat(newWebManagerRoot); //$NON-NLS-1$
}
// default category
this.defaultCategory = ConfigurationUtil.getProperty( config, PROP_CATEGORY, DEFAULT_CATEGORY );
-
+
// secret heuristics
final boolean enableHeuristics = ConfigurationUtil.getProperty(config, PROP_ENABLE_SECRET_HEURISTIC, DEFAULT_ENABLE_SECRET_HEURISTIC);
OsgiManager.ENABLE_SECRET_HEURISTICS = enableHeuristics;
// get enabled plugins
- String[] plugins = ConfigurationUtil.getStringArrayProperty(config, PROP_ENABLED_PLUGINS);
- enabledPlugins = null == plugins ? null : new HashSet<String>(Arrays.asList(plugins));
+ final String[] plugins = ConfigurationUtil.getStringArrayProperty(config, PROP_ENABLED_PLUGINS);
+ this.enabledPlugins = null == plugins ? null : new HashSet<String>(Arrays.asList(plugins));
// check for moved config manager class (see FELIX-4074)
- if ( enabledPlugins != null )
- {
- if ( enabledPlugins.remove(OLD_CONFIG_MANAGER_CLASS) )
- {
+ if ( enabledPlugins != null ) {
+ if ( enabledPlugins.remove(OLD_CONFIG_MANAGER_CLASS) ) {
enabledPlugins.add(NEW_CONFIG_MANAGER_CLASS);
}
}
initInternalPlugins();
- if (osgiConfig != null) {
-
- // unbind old location first
- unregisterServices();
-
- // switch location
- this.webManagerRoot = newWebManagerRoot;
-
- // bind new location now
- registerServices();
-
- } else {
-
- // just set the configured location (FELIX-2034)
- this.webManagerRoot = newWebManagerRoot;
- }
+ // update http service registrations.
+ this.unregisterHttpWhiteboardServices();
+ // switch location
+ this.webManagerRoot = newWebManagerRoot;
+ this.registerHttpWhiteboardServices();
}
private void initInternalPlugins()
@@ -1103,18 +1073,6 @@ public class OsgiManager extends GenericServlet
return enabledPlugins != null && !enabledPlugins.contains( pluginClass );
}
-
- private Dictionary<String, String> toStringConfig( Map<String, Object> config )
- {
- Dictionary<String, String> stringConfig = new Hashtable<>();
- for ( Iterator<Map.Entry<String, Object>> ei = config.entrySet().iterator(); ei.hasNext(); )
- {
- Entry<String, Object> entry = ei.next();
- stringConfig.put( entry.getKey(), String.valueOf( entry.getValue() ) );
- }
- return stringConfig;
- }
-
static Set<String> splitCommaSeparatedString(final String str) {
if (str == null)
return Collections.emptySet();
@@ -1137,7 +1095,7 @@ public class OsgiManager extends GenericServlet
if (null != langMap)
return langMap;
final Map<String, String> map = new HashMap<>();
- final Bundle bundle = getBundleContext().getBundle();
+ final Bundle bundle = bundleContext.getBundle();
final Enumeration<URL> e = bundle.findEntries("res/flags", null, false); //$NON-NLS-1$
while (e != null && e.hasMoreElements())
{
@@ -1196,57 +1154,6 @@ public class OsgiManager extends GenericServlet
// ignore on shutdown
}
}
- }
-
- private void registerServletContextHelper(ServletContextHelper servletContextHelper) {
- final Dictionary<String, Object> servletContextProps = new Hashtable<>();
- servletContextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, DEFAULT_CONTEXT_NAME);
- servletContextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/");
-
- this.servletContextHelperRegistration = getBundleContext().registerService(ServletContextHelper.class,
- servletContextHelper, servletContextProps);
- }
-
- private void registerServlet(String servletPath, Dictionary<String, String> servletConfig) {
- final Dictionary<String, Object> servletProps = new Hashtable<>();
-
- if (servletConfig != null) {
- Iterator<String> servletConfigKeysIt = servletConfig.keys().asIterator();
- while (servletConfigKeysIt.hasNext()) {
- String servletConfigKey = servletConfigKeysIt.next();
- servletProps.put(servletConfigKey, servletConfig.get(servletConfigKey));
- }
- }
-
- servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, servletPath);
- servletProps.put(HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HTTP_WHITEBOARD_CONTEXT_NAME + "=" + DEFAULT_CONTEXT_NAME + ")");
-
- this.servletRegistration = getBundleContext().registerService(Servlet.class, this, servletProps);
- }
-
- private void registerResources(String pattern, String prefix) throws InterruptedException {
- final Dictionary<String, Object> resourceProps = new Hashtable<>();
- resourceProps.put(HTTP_WHITEBOARD_RESOURCE_PATTERN, pattern);
- resourceProps.put(HTTP_WHITEBOARD_RESOURCE_PREFIX, prefix);
- resourceProps.put(HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HTTP_WHITEBOARD_CONTEXT_NAME + "=" + DEFAULT_CONTEXT_NAME + ")");
-
- this.resourcesRegistration = getBundleContext().registerService(Object.class,
- new Object(), resourceProps);
- }
-
- private boolean isbasicSecurityServiceRegistered() {
- return (this.basicSecurityServiceRegistration != null);
- }
-
- private boolean isServletContextHelperRegistered() {
- return (this.servletContextHelperRegistration != null);
- }
-
- private boolean isServletRegistered() {
- return (this.servletRegistration != null);
- }
- private boolean isResourcesRegistered() {
- return (this.resourcesRegistration != null);
}
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContext.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContext.java
old mode 100644
new mode 100755
index a58d860023..913d67d346
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContext.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContext.java
@@ -32,6 +32,7 @@ import org.osgi.service.servlet.context.ServletContextHelper;
import org.osgi.util.tracker.ServiceTracker;
import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletResponse;
final class OsgiManagerHttpContext extends ServletContextHelper
@@ -40,44 +41,48 @@ final class OsgiManagerHttpContext extends ServletContextHelper
private final String realm;
- OsgiManagerHttpContext(final Bundle bundle,
+ private final Bundle bundle;
+
+ OsgiManagerHttpContext(final Bundle webConsoleBundle,
final ServiceTracker<WebConsoleSecurityProvider, WebConsoleSecurityProvider> tracker,
- final String realm)
- {
- super(bundle);
+ final String realm) {
+ super(webConsoleBundle);
this.tracker = tracker;
this.realm = realm;
- }
+ this.bundle = webConsoleBundle;
+ }
- @Override
- public URL getResource( String name )
- {
- URL url = super.getResource( name );
- if ( url == null && name.endsWith( "/" ) )
- {
- return super.getResource( name.substring( 0, name.length() - 1 ) );
+ public URL getResource(final String name) {
+ URL url = this.bundle.getResource( name );
+ if ( url == null && name.endsWith( "/" ) ) {
+ url = this.bundle.getResource( name.substring( 0, name.length() - 1 ) );
}
return url;
}
-
- /**
- * Checks the <code>Authorization</code> header of the request for Basic
- * authentication user name and password. If contained, the credentials are
- * compared to the user name and password set for the OSGi Console.
- * <p>
- * If no user name is set, the <code>Authorization</code> header is
- * ignored and the client is assumed to be authenticated.
- *
- * @param request The HTTP request used to get the
- * <code>Authorization</code> header.
- * @param response The HTTP response used to send the authentication request
- * if authentication is required but not satisfied.
- * @return {@code} true if authentication is required and not satisfied by the request.
- */
+
@Override
- public boolean handleSecurity( final HttpServletRequest request, final HttpServletResponse response ) {
+ public boolean handleSecurity( final HttpServletRequest r, final HttpServletResponse response ) {
final WebConsoleSecurityProvider provider = tracker.getService();
+ // for compatibility we have to adjust a few methods on the request
+ final HttpServletRequest request = new HttpServletRequestWrapper(r) {
+
+ @Override
+ public String getContextPath() {
+ return "";
+ }
+
+ @Override
+ public String getServletPath() {
+ return r.getContextPath();
+ }
+
+ @Override
+ public String getPathInfo() {
+ return r.getServletPath();
+ }
+ };
+
// check whether the security provider can fully handle the request
final boolean result;
if ( provider instanceof WebConsoleSecurityProvider2 ) {
@@ -146,8 +151,8 @@ final class OsgiManagerHttpContext extends ServletContextHelper
if ( authenticate( provider, username, userPass[1] ) )
{
// as per the spec, set attributes
- request.setAttribute( ServletContextHelper.AUTHENTICATION_TYPE, HttpServletRequest.BASIC_AUTH );
- request.setAttribute( ServletContextHelper.REMOTE_USER, username );
+ request.setAttribute( AUTHENTICATION_TYPE, HttpServletRequest.BASIC_AUTH );
+ request.setAttribute( REMOTE_USER, username );
// set web console user attribute
request.setAttribute( WebConsoleSecurityProvider2.USER_ATTRIBUTE, username );
@@ -165,15 +170,12 @@ final class OsgiManagerHttpContext extends ServletContextHelper
}
// request authentication
- try
- {
+ try {
response.setHeader( HEADER_WWW_AUTHENTICATE, AUTHENTICATION_SCHEME_BASIC + " realm=\"" + this.realm + "\"" );
response.setStatus( HttpServletResponse.SC_UNAUTHORIZED );
response.setContentLength( 0 );
response.flushBuffer();
- }
- catch ( IOException ioe )
- {
+ } catch ( IOException ioe ) {
// failed sending the response ... cannot do anything about it
}
@@ -181,8 +183,7 @@ final class OsgiManagerHttpContext extends ServletContextHelper
return false;
}
- private boolean authenticate( WebConsoleSecurityProvider provider, String username, byte[] password )
- {
+ private boolean authenticate( WebConsoleSecurityProvider provider, String username, byte[] password ) {
if ( provider != null )
{
return provider.authenticate( username, BasicWebConsoleSecurityProvider.toString( password ) ) != null;
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Password.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Password.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Plugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Plugin.java
old mode 100644
new mode 100755
index 86f3e3b580..d0463a3b5b
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Plugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/Plugin.java
@@ -168,7 +168,6 @@ public abstract class Plugin implements ServletConfig, Comparable<Plugin> {
return null;
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Enumeration getInitParameterNames() {
return Collections.emptyEnumeration();
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
old mode 100644
new mode 100755
index c95514f7b5..5a30de010c
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
@@ -209,6 +209,7 @@ class PluginHolder implements ServiceTrackerCustomizer<Servlet, Plugin> {
*
* @return The localized map of labels to titles
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
Map getLocalizedLabelMap( final ResourceBundleManager resourceBundleManager, final Locale locale, final String defaultCategory )
{
final Map map = new HashMap();
@@ -259,6 +260,7 @@ class PluginHolder implements ServiceTrackerCustomizer<Servlet, Plugin> {
}
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private Map findCategoryMap( Map map, String categoryPath )
{
Map categoryMap = null;
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
old mode 100644
new mode 100755
index b75c2afd33..195266ec0e
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/system/VMStatPlugin.java
@@ -24,6 +24,7 @@ import java.io.StringWriter;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.Date;
+import java.util.Map;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
@@ -32,8 +33,10 @@ import jakarta.servlet.http.HttpServletResponse;
import org.apache.felix.utils.json.JSONWriter;
import org.apache.felix.webconsole.DefaultVariableResolver;
import org.apache.felix.webconsole.SimpleWebConsolePlugin;
+import org.apache.felix.webconsole.WebConsoleConstants;
import org.apache.felix.webconsole.WebConsoleUtil;
import org.apache.felix.webconsole.internal.OsgiManagerPlugin;
+import org.apache.felix.webconsole.internal.servlet.OsgiManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.service.startlevel.StartLevel;
@@ -170,6 +173,7 @@ public class VMStatPlugin extends SimpleWebConsolePlugin implements OsgiManagerP
*/
protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
{
+ Map<String, Object> configuration = (Map<String, Object>) request.getAttribute( WebConsoleConstants.ATTR_CONFIGURATION );
String body;
if ( request.getAttribute( ATTR_TERMINATED ) != null )
@@ -177,6 +181,18 @@ public class VMStatPlugin extends SimpleWebConsolePlugin implements OsgiManagerP
Object restart = request.getAttribute( PARAM_SHUTDOWN_TYPE );
if ( ( restart instanceof Boolean ) && ( ( Boolean ) restart ).booleanValue() )
{
+ StringWriter json = new StringWriter();
+
+ int reloadTimeout = (int) configuration.get( OsgiManager.PROP_RELOAD_TIMEOUT );
+ JSONWriter jw = new JSONWriter(json);
+ jw.object();
+ jw.key( "reloadTimeout").value( reloadTimeout );
+ jw.endObject();
+ jw.flush();
+
+ DefaultVariableResolver vars = ( ( DefaultVariableResolver ) WebConsoleUtil.getVariableResolver( request ) );
+ vars.put( "data", json.toString() );
+
body = TPL_VM_RESTART;
}
else
@@ -220,6 +236,9 @@ public class VMStatPlugin extends SimpleWebConsolePlugin implements OsgiManagerP
jw.key( "mem_used").value(usedMem );
jw.key( "shutdownType").value(shutdownType );
+ int shutdownTimeout = (int) configuration.get( OsgiManager.PROP_SHUTDOWN_TIMEOUT );
+ jw.key( "shutdownTimeout").value(shutdownTimeout );
+
// only add the processors if the number is available
final int processors = getAvailableProcessors();
if ( processors > 0 )
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java b/webconsole/src/main/java/org/apache/felix/webconsole/package-info.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/spi/ConfigurationHandler.java b/webconsole/src/main/java/org/apache/felix/webconsole/spi/ConfigurationHandler.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/spi/ValidationException.java b/webconsole/src/main/java/org/apache/felix/webconsole/spi/ValidationException.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/spi/package-info.java b/webconsole/src/main/java/org/apache/felix/webconsole/spi/package-info.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/flags/en.gif b/webconsole/src/main/resources/res/flags/en.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/imgs/favicon.ico b/webconsole/src/main/resources/res/imgs/favicon.ico
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/imgs/loading.gif b/webconsole/src/main/resources/res/imgs/loading.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/imgs/logo.png b/webconsole/src/main/resources/res/imgs/logo.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/asc.gif b/webconsole/src/main/resources/res/lib/asc.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/autosize.min.js b/webconsole/src/main/resources/res/lib/autosize.min.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/bg.gif b/webconsole/src/main/resources/res/lib/bg.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/desc.gif b/webconsole/src/main/resources/res/lib/desc.gif
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/jquery-ui-i18n-1.12.1.js b/webconsole/src/main/resources/res/lib/jquery-ui-i18n-1.12.1.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/jquery.cookies-2.2.0.js b/webconsole/src/main/resources/res/lib/jquery.cookies-2.2.0.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/jquery.multifile-1.4.6.js b/webconsole/src/main/resources/res/lib/jquery.multifile-1.4.6.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/jquery.tablesorter-2.0.3.js b/webconsole/src/main/resources/res/lib/jquery.tablesorter-2.0.3.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/reset-min.css b/webconsole/src/main/resources/res/lib/reset-min.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/support.js b/webconsole/src/main/resources/res/lib/support.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_222222_256x240.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_222222_256x240.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_2e83ff_256x240.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_2e83ff_256x240.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_454545_256x240.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_454545_256x240.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_888888_256x240.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_888888_256x240.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_cd0a0a_256x240.png b/webconsole/src/main/resources/res/lib/themes/smoothness/images/ui-icons_cd0a0a_256x240.png
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/lib/themes/smoothness/jquery-ui.css b/webconsole/src/main/resources/res/lib/themes/smoothness/jquery-ui.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/bundles.css b/webconsole/src/main/resources/res/ui/bundles.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/bundles.js b/webconsole/src/main/resources/res/ui/bundles.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/config.css b/webconsole/src/main/resources/res/ui/config.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/configurationrender.css b/webconsole/src/main/resources/res/ui/configurationrender.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/configurationrender.js b/webconsole/src/main/resources/res/ui/configurationrender.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/license.css b/webconsole/src/main/resources/res/ui/license.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/license.js b/webconsole/src/main/resources/res/ui/license.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/logs.css b/webconsole/src/main/resources/res/ui/logs.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/logs.js b/webconsole/src/main/resources/res/ui/logs.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/packages.js b/webconsole/src/main/resources/res/ui/packages.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/services.js b/webconsole/src/main/resources/res/ui/services.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/ui.tabs.paging.js b/webconsole/src/main/resources/res/ui/ui.tabs.paging.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/vmstat.js b/webconsole/src/main/resources/res/ui/vmstat.js
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/res/ui/webconsole.css b/webconsole/src/main/resources/res/ui/webconsole.css
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/bundles.html b/webconsole/src/main/resources/templates/bundles.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/components.html b/webconsole/src/main/resources/templates/components.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/deployment.html b/webconsole/src/main/resources/templates/deployment.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/license.html b/webconsole/src/main/resources/templates/license.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/logs.html b/webconsole/src/main/resources/templates/logs.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/main_footer.html b/webconsole/src/main/resources/templates/main_footer.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/main_header.html b/webconsole/src/main/resources/templates/main_header.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/obr.html b/webconsole/src/main/resources/templates/obr.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/services.html b/webconsole/src/main/resources/templates/services.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/shell.html b/webconsole/src/main/resources/templates/shell.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/main/resources/templates/vmstat.html b/webconsole/src/main/resources/templates/vmstat.html
old mode 100644
new mode 100755
index 0c2ad551f0..71c7ee5889
--- a/webconsole/src/main/resources/templates/vmstat.html
+++ b/webconsole/src/main/resources/templates/vmstat.html
@@ -68,7 +68,7 @@ var statData = ${startData};
<input type="hidden" name="shutdown_type" id="shutdown_type" value="" />
<input class="ui-state-error" type="button" value="${abort}" onclick="abort('${pluginRoot}')" />
${vmstat.shutdown.in} <span id='countdowncell'> </span>
- <script type="text/javascript">if(statData.shutdownTimer) shutdown(3, 'shutdownform2', 'countdowncell');</script>
+ <script type="text/javascript">if(statData.shutdownTimer) shutdown(statData.shutdownTimeout, 'shutdownform2', 'countdowncell');</script>
</div>
</form>
</td>
diff --git a/webconsole/src/main/resources/templates/vmstat_restart.html b/webconsole/src/main/resources/templates/vmstat_restart.html
old mode 100644
new mode 100755
index 7eaaf60521..2aaf7467f2
--- a/webconsole/src/main/resources/templates/vmstat_restart.html
+++ b/webconsole/src/main/resources/templates/vmstat_restart.html
@@ -1,4 +1,9 @@
<script type="text/javascript" src="${appRoot}/res/ui/vmstat.js"></script>
+<script type="text/javascript">
+// <![CDATA[
+var data = ${data};
+// ]]>
+</script>
<!-- status line -->
<p class="statline">${vmstat.restarting}</p>
@@ -7,7 +12,7 @@
<div style="width:100%; text-align: center">
<input class="ui-state-error" type="submit" value="${reload}" />
${vmstat.reloading.in} <span id="reloadcountdowncell"> </span>
- <script type="text/javascript">shutdown(10, "reloadform", "reloadcountdowncell");</script>
+ <script type="text/javascript">shutdown(${data.reloadTimeout}, "reloadform", "reloadcountdowncell");</script>
</div>
</form>
diff --git a/webconsole/src/main/resources/templates/vmstat_stop.html b/webconsole/src/main/resources/templates/vmstat_stop.html
old mode 100644
new mode 100755
diff --git a/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java b/webconsole/src/test/java/org/apache/felix/webconsole/AbstractWebConsolePluginTest.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/test/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupportTest.java b/webconsole/src/test/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupportTest.java
old mode 100644
new mode 100755
index a6f0dfe856..ea682fda44
--- a/webconsole/src/test/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupportTest.java
+++ b/webconsole/src/test/java/org/apache/felix/webconsole/internal/configuration/ConfigJsonSupportTest.java
@@ -19,14 +19,12 @@
package org.apache.felix.webconsole.internal.configuration;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.List;
import org.apache.felix.webconsole.spi.ConfigurationHandler;
import org.apache.felix.webconsole.spi.ValidationException;
diff --git a/webconsole/src/test/java/org/apache/felix/webconsole/internal/misc/LicenseServletTest.java b/webconsole/src/test/java/org/apache/felix/webconsole/internal/misc/LicenseServletTest.java
old mode 100644
new mode 100755
diff --git a/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContextTest.java b/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContextTest.java
old mode 100644
new mode 100755
index 7f9bdf4ef9..6b9a6c7848
--- a/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContextTest.java
+++ b/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerHttpContextTest.java
@@ -18,25 +18,25 @@
*/
package org.apache.felix.webconsole.internal.servlet;
-import static org.junit.Assert.assertEquals;
-
-import java.lang.reflect.Method;
-
import org.apache.felix.webconsole.WebConsoleSecurityProvider;
import org.junit.Test;
import org.mockito.Mockito;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import java.lang.reflect.Method;
+
+import static org.junit.Assert.assertEquals;
+
public class OsgiManagerHttpContextTest {
-
@Test
public void testAuthenticate() throws Exception {
BundleContext bc = Mockito.mock(BundleContext.class);
+ Bundle bundle = Mockito.mock(Bundle.class);
+ OsgiManagerHttpContext ctx = new OsgiManagerHttpContext(bundle, null, "blah");
- OsgiManagerHttpContext ctx = new OsgiManagerHttpContext(bc.getBundle(), null, "blah");
-
- Method authenticateMethod = OsgiManagerHttpContext.class.getDeclaredMethod("authenticate",
- new Class[] { WebConsoleSecurityProvider.class, String.class, byte[].class });
+ Method authenticateMethod = OsgiManagerHttpContext.class.getDeclaredMethod(
+ "authenticate", new Class [] {WebConsoleSecurityProvider.class, String.class, byte[].class});
authenticateMethod.setAccessible(true);
BasicWebConsoleSecurityProvider lastResortSp = new BasicWebConsoleSecurityProvider(bc, "foo", "bar", "blah");
@@ -45,8 +45,8 @@ public class OsgiManagerHttpContextTest {
WebConsoleSecurityProvider sp = new TestSecurityProvider();
assertEquals(true, authenticateMethod.invoke(ctx, sp, "xxx", "yyy".getBytes()));
- assertEquals("The default username and password should not be accepted with security provider", false,
- authenticateMethod.invoke(ctx, sp, "foo", "bar".getBytes()));
+ assertEquals("The default username and password should not be accepted with security provider",
+ false, authenticateMethod.invoke(ctx, sp, "foo", "bar".getBytes()));
}
@Test
@@ -54,15 +54,15 @@ public class OsgiManagerHttpContextTest {
BundleContext bc = Mockito.mock(BundleContext.class);
Mockito.when(bc.getProperty(OsgiManager.FRAMEWORK_PROP_SECURITY_PROVIDERS)).thenReturn("a");
- OsgiManagerHttpContext ctx = new OsgiManagerHttpContext(bc.getBundle(), null, "blah");
+ Bundle bundle = Mockito.mock(Bundle.class);
+ OsgiManagerHttpContext ctx = new OsgiManagerHttpContext(bundle, null, "blah");
- Method authenticateMethod = OsgiManagerHttpContext.class.getDeclaredMethod("authenticate",
- new Class[] { WebConsoleSecurityProvider.class, String.class, byte[].class });
+ Method authenticateMethod = OsgiManagerHttpContext.class.getDeclaredMethod(
+ "authenticate", new Class [] {WebConsoleSecurityProvider.class, String.class, byte[].class});
authenticateMethod.setAccessible(true);
- assertEquals(
- "A required security provider is configured, logging in using "
- + "username and password should be disabled",
+ assertEquals("A required security provider is configured, logging in using "
+ + "username and password should be disabled",
false, authenticateMethod.invoke(ctx, null, "foo", "bar".getBytes()));
assertEquals(false, authenticateMethod.invoke(ctx, null, "foo", "blah".getBytes()));
assertEquals(false, authenticateMethod.invoke(ctx, null, "blah", "bar".getBytes()));
diff --git a/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerTest.java b/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerTest.java
old mode 100644
new mode 100755
index e042ef68ba..f3e243b336
--- a/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerTest.java
+++ b/webconsole/src/test/java/org/apache/felix/webconsole/internal/servlet/OsgiManagerTest.java
@@ -19,7 +19,6 @@
package org.apache.felix.webconsole.internal.servlet;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -34,7 +33,9 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import jakarta.servlet.Servlet;
import org.apache.felix.webconsole.WebConsoleSecurityProvider;
import org.junit.Test;
import org.mockito.Mockito;
@@ -48,6 +49,7 @@ import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.servlet.context.ServletContextHelper;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class OsgiManagerTest {
@@ -56,20 +58,22 @@ public class OsgiManagerTest {
assertEquals(0, OsgiManager.splitCommaSeparatedString(null).size());
assertEquals(0, OsgiManager.splitCommaSeparatedString("").size());
assertEquals(0, OsgiManager.splitCommaSeparatedString(" ").size());
- assertEquals(Collections.singleton("foo.bar"), OsgiManager.splitCommaSeparatedString("foo.bar "));
+ assertEquals(Collections.singleton("foo.bar"),
+ OsgiManager.splitCommaSeparatedString("foo.bar "));
Set<String> expected = new HashSet<String>();
expected.add("abc");
expected.add("x.y.z");
expected.add("123");
- assertEquals(expected, OsgiManager.splitCommaSeparatedString(" abc , x.y.z,123"));
+ assertEquals(expected,
+ OsgiManager.splitCommaSeparatedString(" abc , x.y.z,123"));
}
@SuppressWarnings({ "unchecked", "rawtypes", "serial" })
@Test
public void testUpdateDependenciesCustomizerAdd() throws Exception {
BundleContext bc = mockBundleContext();
-
+
final List<Boolean> updateCalled = new ArrayList<Boolean>();
OsgiManager mgr = new OsgiManager(bc) {
@Override
@@ -82,7 +86,7 @@ public class OsgiManagerTest {
ServiceReference sref = Mockito.mock(ServiceReference.class);
stc.addingService(sref);
- assertEquals(1, updateCalled.size());
+ assertEquals(0, updateCalled.size());
ServiceReference sref2 = Mockito.mock(ServiceReference.class);
Mockito.when(sref2.getProperty(OsgiManager.SECURITY_PROVIDER_PROPERTY_NAME)).thenReturn("xyz");
@@ -90,9 +94,9 @@ public class OsgiManagerTest {
Mockito.when(bc.getService(sref2)).thenReturn(Mockito.mock(WebConsoleSecurityProvider.class));
stc.addingService(sref2);
assertEquals(Collections.singleton("xyz"), mgr.registeredSecurityProviders);
- assertEquals(2, updateCalled.size());
+ assertEquals(1, updateCalled.size());
}
-
+
@SuppressWarnings({ "unchecked", "rawtypes", "serial" })
@Test
public void testUpdateDependenciesCustomzerRemove() throws Exception {
@@ -122,14 +126,16 @@ public class OsgiManagerTest {
ServiceReference sref = Mockito.mock(ServiceReference.class);
Mockito.when(sref.getProperty(Constants.SERVICE_ID)).thenReturn(3L);
stc.removedService(sref, null);
- assertEquals(3, updateCalled.size());
+
+ assertEquals(2, updateCalled.size());
assertEquals(2, mgr.registeredSecurityProviders.size());
assertTrue(mgr.registeredSecurityProviders.contains("abc"));
assertTrue(mgr.registeredSecurityProviders.contains("xyz"));
+
stc.removedService(sref2, null);
assertEquals(Collections.singleton("abc"), mgr.registeredSecurityProviders);
- assertEquals(4, updateCalled.size());
+ assertEquals(3, updateCalled.size());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -148,8 +154,7 @@ public class OsgiManagerTest {
}
@Override
- public void removedService(ServiceReference<WebConsoleSecurityProvider> reference,
- WebConsoleSecurityProvider service) {
+ public void removedService(ServiceReference<WebConsoleSecurityProvider> reference, WebConsoleSecurityProvider service) {
invocations.add("removed:" + reference);
}
};
@@ -164,96 +169,123 @@ public class OsgiManagerTest {
assertEquals("added:blah!", invocations.get(1));
}
- @SuppressWarnings("serial")
+
@Test
public void testUpdateRegistrationStateNoRequiredProviders() throws Exception {
BundleContext bc = mockBundleContext();
- final List<String> invocations = new ArrayList<String>();
- OsgiManager mgr = new OsgiManager(bc) {
+ final AtomicReference<String> invocation = new AtomicReference<String>();
+ new OsgiManager(bc) {
@Override
- protected synchronized void registerServices() {
- invocations.add("register");
+ protected synchronized void registerHttpWhiteboardServices() {
+ invocation.set("register");
}
@Override
- protected synchronized void unregisterServices() {
- invocations.add("unregister");
+ protected synchronized void unregisterHttpWhiteboardServices() {
+ invocation.set("unregister");
}
};
- assertEquals(Collections.singletonList("register"), invocations);
+ // services are registered by default
+ assertEquals("register", invocation.get());
}
- @SuppressWarnings("serial")
@Test
public void testUpdateRegistrationStateSomeRequiredProviders() throws Exception {
BundleContext bc = mockBundleContext();
- Mockito.when(bc.getProperty(OsgiManager.FRAMEWORK_PROP_SECURITY_PROVIDERS)).thenReturn("foo,blah");
+ Mockito.when(bc.getProperty(OsgiManager.FRAMEWORK_PROP_SECURITY_PROVIDERS)).
+ thenReturn("foo,blah");
final List<String> invocations = new ArrayList<String>();
OsgiManager mgr = new OsgiManager(bc) {
@Override
- protected synchronized void registerServices() {
+ protected synchronized void registerHttpWhiteboardServices() {
invocations.add("register");
}
@Override
- protected synchronized void unregisterServices() {
+ protected synchronized void unregisterHttpWhiteboardServices() {
invocations.add("unregister");
}
};
- // BundleContext present, some required providers, no registered providers ->
- // unregister
+ // some required providers, no registered providers -> unregister
invocations.clear();
mgr.registeredSecurityProviders.clear();
mgr.updateRegistrationState();
assertEquals(Collections.singletonList("unregister"), invocations);
- // BundleContext present, some required providers, more registered ones ->
- // register
+ // some required providers, more registered ones -> register
invocations.clear();
mgr.registeredSecurityProviders.addAll(Arrays.asList("foo", "bar", "blah"));
mgr.updateRegistrationState();
assertEquals(Collections.singletonList("register"), invocations);
- // BundleContext present, some required providers, different registered ones ->
- // unregister
+ // some required providers, different registered ones -> unregister
invocations.clear();
mgr.registeredSecurityProviders.clear();
mgr.registeredSecurityProviders.addAll(Arrays.asList("foo", "bar"));
mgr.updateRegistrationState();
assertEquals(Collections.singletonList("unregister"), invocations);
- // BundleContext not present, some required providers, more registered ones ->
- // unregister
+ // some required providers, more registered ones -> unregister
invocations.clear();
mgr.registeredSecurityProviders.addAll(Arrays.asList("foo", "bar", "blah"));
- setPrivateField(OsgiManager.class, mgr, "bundleContext", null);
mgr.updateRegistrationState();
- assertEquals(Collections.singletonList("unregister"), invocations);
+ assertEquals(Collections.singletonList("register"), invocations);
}
+
+ @SuppressWarnings({ "unchecked" })
@Test
- public void testUnregisterServices() throws Exception {
- BundleContext bc = mockBundleContext();
- OsgiManager mgr = new OsgiManager(bc);
+ public void testRegisterHttpWhiteboardServices() throws Exception {
+ final BundleContext bc = mockBundleContext();
+ final OsgiManager mgr = new OsgiManager(bc);
+
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(WebConsoleSecurityProvider.class), Mockito.isA(WebConsoleSecurityProvider.class), Mockito.isA(Dictionary.class));
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(ServletContextHelper.class), Mockito.isA(ServletContextHelper.class), Mockito.isA(Dictionary.class));
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(Servlet.class), Mockito.isA(Servlet.class), Mockito.isA(Dictionary.class));
+
+ mgr.registerHttpWhiteboardServices();
+
+ // Should not re-register the services, as they were already registered
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(WebConsoleSecurityProvider.class), Mockito.isA(WebConsoleSecurityProvider.class), Mockito.isA(Dictionary.class));
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(ServletContextHelper.class), Mockito.isA(ServletContextHelper.class), Mockito.isA(Dictionary.class));
+ Mockito.verify(bc, Mockito.times(1))
+ .registerService(Mockito.eq(Servlet.class), Mockito.isA(Servlet.class), Mockito.isA(Dictionary.class));
+ }
- setPrivateField(OsgiManager.class, mgr, "servletContextHelperRegistration",
- Mockito.mock(ServiceRegistration.class));
- setPrivateField(OsgiManager.class, mgr, "servletRegistration", Mockito.mock(ServiceRegistration.class));
- setPrivateField(OsgiManager.class, mgr, "resourcesRegistration", Mockito.mock(ServiceRegistration.class));
+ @SuppressWarnings({ "rawtypes" })
+ @Test
+ public void testUnregisterHttpService() throws Exception {
+ final BundleContext bc = mockBundleContext();
+ final OsgiManager mgr = new OsgiManager(bc);
- assertNotNull(getPrivateField(OsgiManager.class, mgr, "servletContextHelperRegistration"));
- assertNotNull(getPrivateField(OsgiManager.class, mgr, "servletRegistration"));
- assertNotNull(getPrivateField(OsgiManager.class, mgr, "resourcesRegistration"));
+ final ServiceRegistration reg1 = Mockito.mock(ServiceRegistration.class);
+ final ServiceRegistration reg2 = Mockito.mock(ServiceRegistration.class);
- mgr.unregisterServices();
+ setPrivateField(OsgiManager.class, mgr, "servletContextRegistration", reg1);
+ setPrivateField(OsgiManager.class, mgr, "servletRegistration", reg2);
- assertNull(getPrivateField(OsgiManager.class, mgr, "servletContextHelperRegistration"));
+ mgr.unregisterHttpWhiteboardServices();
+ assertNull(getPrivateField(OsgiManager.class, mgr, "servletContextRegistration"));
assertNull(getPrivateField(OsgiManager.class, mgr, "servletRegistration"));
- assertNull(getPrivateField(OsgiManager.class, mgr, "resourcesRegistration"));
+
+ Mockito.verify(reg1, Mockito.times(1)).unregister();
+ Mockito.verify(reg2, Mockito.times(1)).unregister();
+
+ mgr.unregisterHttpWhiteboardServices();
+ assertNull(getPrivateField(OsgiManager.class, mgr, "servletContextRegistration"));
+ assertNull(getPrivateField(OsgiManager.class, mgr, "servletRegistration"));
+
+ Mockito.verify(reg1, Mockito.times(1)).unregister();
+ Mockito.verify(reg2, Mockito.times(1)).unregister();
}
private Object getPrivateField(Class<?> cls, Object obj, String field) throws Exception {
@@ -280,20 +312,19 @@ public class OsgiManagerTest {
return FrameworkUtil.createFilter(fs);
}
});
- // FELIX-6341 - mock the getHeaders to avoid a NPE during
- // ResourceBundleCache#getResourceBundleEntries
+ // FELIX-6341 - mock the getHeaders to avoid a NPE during ResourceBundleCache#getResourceBundleEntries
final Dictionary<String, String> headers = new Hashtable<>();
Mockito.when(bundle.getHeaders()).thenReturn(headers);
- // FELIX-6341 - mock bundle#findEntries so
- // ResourceBundleCache#getResourceBundleEntries will function
+ // FELIX-6341 - mock bundle#findEntries so ResourceBundleCache#getResourceBundleEntries will function
URL rbUrl = getClass().getResource("/OSGI-INF/l10n/bundle.properties");
- Mockito.when(bundle.findEntries("OSGI-INF/l10n", "bundle*.properties", false))
- .thenAnswer(new Answer<Enumeration<URL>>() {
- @Override
- public Enumeration<URL> answer(InvocationOnMock invocation) throws Throwable {
- return Collections.enumeration(Collections.singleton(rbUrl));
- }
- });
+ Mockito.when(bundle.findEntries("OSGI-INF/l10n", "bundle*.properties", false)).thenAnswer(new Answer<Enumeration<URL>>() {
+ @Override
+ public Enumeration<URL> answer(InvocationOnMock invocation) throws Throwable {
+ return Collections.enumeration(Collections.singleton(rbUrl));
+ }
+ });
+ Mockito.when(bc.registerService((Class)Mockito.any(), (Object)Mockito.any(), (Dictionary)Mockito.any()))
+ .thenReturn(Mockito.mock(ServiceRegistration.class));
return bc;
}
}