Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jakarta migration #30

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>com.neva.felix</groupId>
<artifactId>search-webconsole-plugin</artifactId>
<packaging>bundle</packaging>
<version>2.0.0</version>
<version>2.0.1-SNAPSHOT</version>
<name>search-webconsole-plugin</name>
<description>Search everywhere plugin for Apache Felix Web Console</description>
<inceptionYear>2017</inceptionYear>
Expand Down Expand Up @@ -64,27 +64,6 @@
</repository>
</distributionManagement>

<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>

<build>
<resources>
<resource>
Expand Down Expand Up @@ -116,15 +95,12 @@
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-SymbolicName>com.neva.felix.webconsole.plugins.search</Bundle-SymbolicName>
<Bundle-Activator>com.neva.felix.webconsole.plugins.search.SearchActivator</Bundle-Activator>
<Import-Package>javax.management.*,javax.lang.*,org.slf4j.*,org.osgi.*</Import-Package>
<Import-Package>javax.management.*,javax.lang.*,org.slf4j.*,org.osgi.*,jakarta.servlet.*,org.apache.felix.webconsole.*</Import-Package>
<DynamicImport-Package>
org.osgi.service.log;version="[1.3,2)",
org.osgi.service.cm;version="[1.2,2)",
org.osgi.service.metatype;version="[1.1,2)",
org.osgi.util.tracker;version="[1.5.1,2)",
javax.servlet;
javax.servlet.http;version="[2.3,4)",
org.apache.felix.webconsole;version="[3.0,4)"
</DynamicImport-Package>
<Private-Package>
com.neva.felix.webconsole.plugins.search.*,
Expand Down Expand Up @@ -214,13 +190,13 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.webconsole</artifactId>
<version>3.0.0</version>
<version>4.9.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,59 @@
import com.neva.felix.webconsole.plugins.search.plugin.AbstractPlugin;
import com.neva.felix.webconsole.plugins.search.plugin.SearchPlugin;
import com.google.common.collect.ImmutableSet;
import com.neva.felix.webconsole.plugins.search.rest.*;
import jakarta.servlet.Servlet;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;

public class SearchActivator implements BundleActivator {

private SearchHttpTracker httpTracker;
private final List<ServiceRegistration> services = new LinkedList<>();

@Override
public void start(BundleContext bundleContext) throws Exception {
for (AbstractPlugin plugin : getPlugins(bundleContext)) {
plugin.register();
ServiceRegistration service = bundleContext.registerService(Servlet.class.getName(), this, plugin.getProps());
if (service != null) {
services.add(service);
}
}
for (RestServlet servlet : getServlets(bundleContext)) {
ServiceRegistration service = bundleContext.registerService(Servlet.class.getName(), servlet, servlet.getProps());
if (service != null) {
services.add(service);
}
}

httpTracker = new SearchHttpTracker(bundleContext);
httpTracker.open();
}

@Override
public void stop(BundleContext bundleContext) throws Exception {
httpTracker.close();
httpTracker = null;
for (ServiceRegistration service : services) {
service.unregister();
}
}

private Set<AbstractPlugin> getPlugins(BundleContext bundleContext) {
return ImmutableSet.<AbstractPlugin>of(
return ImmutableSet.of(
new SearchPlugin(bundleContext)
);
}

private ImmutableSet<RestServlet> getServlets(BundleContext context) {
return ImmutableSet.of(
new ByPhraseServlet(context),
new BundleDownloadServlet(context),
new BundleClassesServlet(context),
new ClassDecompileServlet(context),
new ClassSearchServlet(context),
new SourceGenerateServlet(context),
new FileDownloadServlet(context),
new BundleAssembleServlet(context)
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.neva.felix.webconsole.plugins.search.plugin;

import com.google.common.collect.ImmutableMap;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.text.StrSubstitutor;
import org.apache.felix.webconsole.AbstractWebConsolePlugin;
import org.apache.felix.webconsole.servlet.AbstractServlet;
import org.osgi.framework.BundleContext;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URL;
import java.util.Dictionary;
import java.util.Hashtable;

public abstract class AbstractPlugin extends AbstractWebConsolePlugin {
public abstract class AbstractPlugin extends AbstractServlet {

public static final String CATEGORY = "OSGi";

Expand All @@ -25,34 +24,24 @@ public AbstractPlugin(BundleContext bundleContext) {
}

@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
public void renderContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final String common = readTemplateFile("/search/common.html");
final String specific = readTemplateFile("/" + getLabel() + "/plugin.html");
final String content = StrSubstitutor.replace(specific, ImmutableMap.of("common", common));

response.getWriter().write(content);
}

protected Dictionary<String, Object> createProps() {
public abstract String getLabel();

public abstract String getTitle();

public Dictionary<String, Object> getProps() {
final Dictionary<String, Object> props = new Hashtable<>();

props.put("felix.webconsole.label", getLabel());
props.put("felix.webconsole.category", CATEGORY);

return props;
}

public void register() {
bundleContext.registerService(Servlet.class.getName(), this, createProps());
}

public URL getResource(final String path) {
String prefix = "/" + getLabel() + "/";
if (path.startsWith(prefix)) {
return this.getClass().getResource(path);
}

return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
import static com.neva.felix.webconsole.plugins.search.utils.JsonUtils.MessageType;
import static com.neva.felix.webconsole.plugins.search.utils.JsonUtils.writeMessage;

import com.google.common.collect.Lists;
import com.neva.felix.webconsole.plugins.search.core.BundleJar;
import com.neva.felix.webconsole.plugins.search.core.OsgiExplorer;
import com.neva.felix.webconsole.plugins.search.core.SearchMonitor;
import com.neva.felix.webconsole.plugins.search.core.bundleassemble.BundleAssembleJob;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.neva.felix.webconsole.plugins.search.core.SearchPaths;
import com.neva.felix.webconsole.plugins.search.utils.JsonUtils;
import com.neva.felix.webconsole.plugins.search.utils.io.FileDownloader;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.neva.felix.webconsole.plugins.search.core.SearchService;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.osgi.framework.BundleContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.neva.felix.webconsole.plugins.search.core.SearchPaths;
import com.neva.felix.webconsole.plugins.search.decompiler.Decompilers;
import com.neva.felix.webconsole.plugins.search.utils.JsonUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.neva.felix.webconsole.plugins.search.core.OsgiExplorer;
import com.neva.felix.webconsole.plugins.search.core.SearchMonitor;
import com.neva.felix.webconsole.plugins.search.core.classsearch.ClassSearchJob;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.neva.felix.webconsole.plugins.search.core.SearchPaths;
import com.neva.felix.webconsole.plugins.search.utils.io.FileDownloader;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down
Loading