Skip to content

Commit

Permalink
fixes #5: Openfire 5.0.0 compatibility
Browse files Browse the repository at this point in the history
Updates the plugin to be compatible with Openfire 5.0.0 (in particular: with the new version of Jetty that's part of that release).

This drops compatibility with versions of Openfire prior to 5.0.0.

Drop unnecessary manual initialization of JasperInitializer

To quote Joakim Erdfelt, a Jetty developer:

> For a `WebAppContext`, this manual initialization of JasperInitializer is not necessary. (it is necessary for a `ServletContextHandler`)
> The fact that jetty-ee8-apache-jsp-<ver>.jar is in your classpath should be enough for that webapp to automatically have JSP support enabled.
>
> If you find that you don't have a `jsp` servlet initialized, then that means you'll want to declare the `WebAppContext.setDefaultDescriptor()` to point to the `webdefault-ee8.xml` for your version. You can find that file in the `jetty-ee8-webapp-<ver>-config.jar` -
> See https://repo1.maven.org/maven2/org/eclipse/jetty/ee8/jetty-ee8-webapp/12.0.14/

Drop explicit InstanceManager configuration

Removing initialization of an attribute that I believe to be something that has been carried over from earlier versions, without this being neccesary anymore.
  • Loading branch information
guusdk committed Nov 20, 2024
1 parent 0de91dc commit 202715f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
6 changes: 6 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ <h1>
Random Avatar Plugin Changelog
</h1>

<p><b>1.2.0</b> -- (to be determined)</p>
<ul>
<li>Requires Openfire 5.0.0 or later</li>
<li><a href="https://github.com/igniterealtime/openfire-randomavatar-plugin/issues/5">#5:</a> Openfire 5.0.0 compatibility</li>
</ul>

<p><b>1.1.1</b> -- November 20, 2024</p>
<ul>
<li>Marked as last version to be compatible with Openfire versions prior to 5.0.0.</li>
Expand Down
4 changes: 1 addition & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
<author>Guus der Kinderen</author>
<version>${project.version}</version>
<date>2024-11-20</date>
<minServerVersion>4.1.5</minServerVersion>
<priorToServerVersion>5.0.0</priorToServerVersion>
<minJavaVersion>1.8</minJavaVersion>
<minServerVersion>5.0.0</minServerVersion>
</plugin>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>org.igniterealtime.openfire</groupId>
<version>4.3.0</version>
<version>5.0.0-SNAPSHOT</version>
</parent>

<groupId>org.igniterealtime.openfire.plugins</groupId>
Expand All @@ -34,8 +34,8 @@
</plugin>
<!-- Compiles the Openfire Admin Console JSP pages.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-jspc-maven-plugin</artifactId>
</plugin> -->
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2019-2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,20 +15,14 @@
*/
package org.igniterealtime.openfire.plugins.randomavatar;

import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.ee8.webapp.WebAppContext;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.http.HttpBindManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
* An Openfire plugin that makes available an avatar-exposing webservice.
Expand Down Expand Up @@ -56,10 +50,6 @@ public void initializePlugin( PluginManager manager, File pluginDirectory )
context.setClassLoader( this.getClass().getClassLoader() );

Log.debug( "Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs)." );
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add( new ContainerInitializer( new JettyJasperInitializer(), null ) );
context.setAttribute( "org.eclipse.jetty.containerInitializers", initializers );
context.setAttribute( InstanceManager.class.getName(), new SimpleInstanceManager() );
context.setAttribute( "org.igniterealtime.openfire.plugins.randomavatar.plugindirectory", pluginDirectory.toPath() );
Log.debug( "Registering context with the embedded webserver." );
HttpBindManager.getInstance().addJettyHandler( context );
Expand Down

0 comments on commit 202715f

Please sign in to comment.