Bug 534874 - Fix preview server adaptors if java ee implementations have unexpected BSNs
Same change as 60bbd0c, needed in one more place.
Change-Id: I372e73a659e7e211e1e4ec7689773361484ae9c6
Signed-off-by: Mat Booth <mat.booth@redhat.com>
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java
index b3ea20d..0f9554f 100644
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java
+++ b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,18 +22,25 @@
import org.eclipse.wst.server.core.IRuntime;
import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+
/**
*
*/
public class PreviewRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate {
private static final String[] REQUIRED_BUNDLE_IDS = new String[] {
- "javax.servlet",
- "javax.servlet.jsp"
+ getBundleForClass(javax.servlet.ServletContext.class),
+ getBundleForClass(javax.servlet.jsp.JspContext.class),
};
- /** (non-Javadoc)
- * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime)
+ /**
+ * Gets the symbolic name of the bundle that supplies the given class.
*/
+ private static String getBundleForClass(Class<?> cls) {
+ return FrameworkUtil.getBundle(cls).getSymbolicName();
+ }
+
+ @Override
public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) {
List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();