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

#21565 removes osgi proxy servlet reference #21566

Merged
merged 2 commits into from
Jan 20, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;

import com.dotcms.LicenseTestUtil;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.osgi.GenericBundleActivator;
import com.dotmarketing.osgi.HostActivator;
import com.dotmarketing.osgi.OSGIProxyServlet;
import com.dotmarketing.portlets.rules.RuleComponentInstance;
import com.dotmarketing.portlets.rules.model.ParameterModel;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.Logger;
import org.apache.felix.framework.OSGIUtil;
import java.util.Map;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.felix.framework.OSGIUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.osgi.framework.BundleContext;
import com.dotcms.LicenseTestUtil;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.osgi.GenericBundleActivator;
import com.dotmarketing.osgi.HostActivator;
import com.dotmarketing.portlets.rules.RuleComponentInstance;
import com.dotmarketing.portlets.rules.model.ParameterModel;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.Logger;

public class ConditionletOSGIFTest {

Expand All @@ -36,7 +34,6 @@ public static void prepare () throws Exception {

Mockito.when(Config.CONTEXT.getRealPath("/WEB-INF/felix")).thenReturn(Config.getStringProperty("felix.base.dir","/WEB-INF/felix"));
final ServletConfig servletConfig = mock(ServletConfig.class);
OSGIProxyServlet.servletConfig = servletConfig;

OSGIUtil.getInstance().initializeFramework();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ protected void initializeServices ( BundleContext context ) throws Exception {
//Override the classes found in the Override-Classes attribute
overrideClasses(context);

forceHttpServiceLoading( context );
//Forcing the loading of the ToolboxManager
forceToolBoxLoading( context );
//Forcing the loading of the WorkflowService
Expand Down Expand Up @@ -279,57 +278,8 @@ private void forceCacheProviderServiceLoading ( BundleContext context ) {
}
}

/**
* Forcing the registry of the HttpService, usually need it when the felix framework is reloaded and we need to update the
* bundle context of our already registered services.
*
* @param context
*/
private void forceHttpServiceLoading ( BundleContext context ) throws Exception {

try {
//Working with the http bridge
if ( System.getProperty(WebKeys.OSGI_ENABLED)!=null ) {//If it is null probably the servlet wasn't even been loaded...

if (null == OSGIProxyServlet.bundleContext) {
synchronized (this) {
if (null == OSGIProxyServlet.bundleContext) {
initProxyServlet(context);
}
}
} else {
try {
OSGIProxyServlet.bundleContext.getBundle();
} catch (IllegalStateException e) {
initProxyServlet(context);
}
}

}
} catch ( Exception e ) {
Logger.error( this, "Error loading HttpService.", e );
throw e;
}
}

/**
* Sets the bundle context to the OSGIProxyServlet
*/
private void initProxyServlet(BundleContext context) throws Exception {

Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles) {
if (bundle.getSymbolicName().equals(OSGIUtil.BUNDLE_HTTP_BRIDGE_SYMBOLIC_NAME)) {
//If we are here is because we have an invalid bundle context, so we need to provide a new one
BundleContext httpBundle = bundle.getBundleContext();
OSGIProxyServlet.tracker = new DispatcherTracker(httpBundle, null,
OSGIProxyServlet.servletConfig);
OSGIProxyServlet.tracker.open();
OSGIProxyServlet.bundleContext = httpBundle;
}

}
}



Expand Down
116 changes: 0 additions & 116 deletions dotCMS/src/main/java/com/dotmarketing/osgi/OSGIProxyServlet.java

This file was deleted.

73 changes: 32 additions & 41 deletions dotCMS/src/main/java/org/apache/felix/framework/OSGIUtil.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
package org.apache.felix.framework;

import com.dotcms.api.system.event.Payload;
import com.dotcms.api.system.event.SystemEventType;
import com.dotcms.api.system.event.message.MessageSeverity;
import com.dotcms.api.system.event.message.SystemMessageEventUtil;
import com.dotcms.api.system.event.message.builder.SystemMessageBuilder;
import com.dotcms.concurrent.Debouncer;
import com.dotcms.repackage.org.apache.commons.io.IOUtils;
import com.dotcms.util.CollectionsUtils;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.osgi.HostActivator;
import com.dotmarketing.osgi.OSGIProxyServlet;
import com.dotmarketing.portlets.workflows.business.WorkflowAPIOsgiService;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.DateUtil;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.ResourceCollectorUtil;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.WebKeys;
import com.google.common.collect.ImmutableList;
import com.liferay.portal.language.LanguageUtil;
import com.liferay.util.FileUtil;
import com.liferay.util.StringPool;
import io.vavr.control.Try;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.felix.framework.util.FelixConstants;
import org.apache.felix.http.proxy.DispatcherTracker;
import org.apache.felix.main.AutoProcessor;
import org.apache.felix.main.Main;
import org.apache.velocity.tools.view.PrimitiveToolboxManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -61,6 +26,37 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.felix.framework.util.FelixConstants;
import org.apache.felix.main.AutoProcessor;
import org.apache.felix.main.Main;
import org.apache.velocity.tools.view.PrimitiveToolboxManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
import com.dotcms.api.system.event.Payload;
import com.dotcms.api.system.event.SystemEventType;
import com.dotcms.api.system.event.message.MessageSeverity;
import com.dotcms.api.system.event.message.SystemMessageEventUtil;
import com.dotcms.api.system.event.message.builder.SystemMessageBuilder;
import com.dotcms.concurrent.Debouncer;
import com.dotcms.repackage.org.apache.commons.io.IOUtils;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.osgi.HostActivator;
import com.dotmarketing.portlets.workflows.business.WorkflowAPIOsgiService;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.DateUtil;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.ResourceCollectorUtil;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.WebKeys;
import com.google.common.collect.ImmutableList;
import com.liferay.portal.language.LanguageUtil;
import com.liferay.util.FileUtil;
import com.liferay.util.StringPool;
import io.vavr.control.Try;

/**
* Created by Jonathan Gamba
Expand Down Expand Up @@ -409,12 +405,7 @@ private void moveNewBundlesToFelixLoadFolder(final File uploadFolderFile, final
public void stopFramework() {

try {
//Closing tracker associated to the HttpServlet
DispatcherTracker tracker = OSGIProxyServlet.tracker;
if (null != tracker) {
tracker.close();
OSGIProxyServlet.tracker = null;
}


if (null != felixFramework) {

Expand Down