Author: snjeza
Date: 2010-11-03 18:07:20 -0400 (Wed, 03 Nov 2010)
New Revision: 26237
Modified:
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java
trunk/download.jboss.org/jbosstools/examples/project-examples-community-3...
workspace/Denny/esb-example-soa-p5.0/helloworld_all.zip
Log:
JBDS-1355 Import ESB examples - JBDS complains about runtime name - even if the name is
what the error message specifies
Modified:
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
---
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2010-11-03
18:36:33 UTC (rev 26236)
+++
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2010-11-03
22:07:20 UTC (rev 26237)
@@ -30,7 +30,8 @@
org.eclipse.equinox.p2.ui.sdk,
org.eclipse.equinox.p2.metadata,
org.jboss.tools.portlet.core,
- org.eclipse.equinox.p2.operations
+ org.eclipse.equinox.p2.operations,
+ org.eclipse.jst.server.core
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.jboss.tools.project.examples,
Modified:
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java
===================================================================
---
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java 2010-11-03
18:36:33 UTC (rev 26236)
+++
branches/jbosstools-3.2.0.Beta1/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/fixes/WTPRuntimeFix.java 2010-11-03
22:07:20 UTC (rev 26237)
@@ -1,7 +1,6 @@
package org.jboss.tools.project.examples.fixes;
import java.io.File;
-import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
@@ -11,7 +10,15 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.server.core.internal.JavaServerPlugin;
+import org.eclipse.jst.server.core.internal.RuntimeClasspathContainer;
+import org.eclipse.jst.server.core.internal.RuntimeClasspathProviderWrapper;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
@@ -21,7 +28,6 @@
import org.eclipse.wst.server.core.ServerCore;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.core.internal.PortletRuntimeComponentProvider;
import org.jboss.tools.project.examples.Messages;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
@@ -37,6 +43,7 @@
private static final String ESB = "esb"; //$NON-NLS-1$
private static final String PORTLET = "portlet"; //$NON-NLS-1$
private static final String REQUIRED_COMPONENTS = "required-components";
//$NON-NLS-1$
+ private static final IPath ESB_SERVER_SUPPLIED_CONTAINER_PATH = new
Path("org.jboss.esb.runtime.classpath/server.supplied");
public boolean canFix(Project project, ProjectFix fix) {
if (!ProjectFix.WTP_RUNTIME.equals(fix.getType())) {
@@ -69,6 +76,7 @@
wtpRuntime = RuntimeManager.getRuntime(runtime.getId());
facetedProject.addTargetedRuntime(wtpRuntime, monitor);
facetedProject.setPrimaryRuntime(wtpRuntime, monitor);
+ fixEsb(eclipseProject, fix, wtpRuntime);
}
}
}
@@ -80,6 +88,61 @@
return ret;
}
+ private void fixEsb(IProject eclipseProject,
+ ProjectFix fix, org.eclipse.wst.common.project.facet.core.runtime.IRuntime wtpRuntime)
throws JavaModelException {
+ String required_components = fix.getProperties().get(REQUIRED_COMPONENTS);
+ if (required_components == null) {
+ return;
+ }
+ List<String> components = tokenize(required_components);
+ if (components == null) {
+ return;
+ }
+ boolean esbRequired = false;
+ for (String component:components) {
+ if (ESB.equals(component)) {
+ esbRequired = true;
+ break;
+ }
+ }
+ if (esbRequired) {
+ IJavaProject javaProject = JavaCore.create(eclipseProject);
+ if (javaProject != null) {
+ if (!javaProject.isOpen()) {
+ javaProject.open(null);
+ }
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length];
+ boolean changed = false;
+ IRuntime runtime = getRuntime(wtpRuntime);
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
+ IPath path = entry.getPath();
+ if (new Path(RuntimeClasspathContainer.SERVER_CONTAINER).isPrefixOf(path)) {
+ RuntimeClasspathProviderWrapper rcpw =
JavaServerPlugin.findRuntimeClasspathProvider(runtime.getRuntimeType());
+ IPath serverContainerPath = new Path(RuntimeClasspathContainer.SERVER_CONTAINER)
+ .append(rcpw.getId()).append(runtime.getId());
+ newEntries[i] = JavaCore.newContainerEntry(serverContainerPath);
+ changed = true;
+ } else if (ESB_SERVER_SUPPLIED_CONTAINER_PATH.isPrefixOf(path)) {
+ IPath esbContainerPath =
ESB_SERVER_SUPPLIED_CONTAINER_PATH.append(runtime.getId());
+ newEntries[i] = JavaCore.newContainerEntry(esbContainerPath);
+ changed = true;
+ } else {
+ newEntries[i] = entry;
+ }
+ } else {
+ newEntries[i] = entry;
+ }
+ }
+ if (changed) {
+ javaProject.setRawClasspath(newEntries, new NullProgressMonitor());
+ }
+ }
+ }
+ }
+
private IRuntime getBestRuntime(Project project, ProjectFix fix) {
String allowedTypes = fix.getProperties().get(
ProjectFix.ALLOWED_TYPES);
Modified:
trunk/download.jboss.org/jbosstools/examples/project-examples-community-3...
===================================================================
---
trunk/download.jboss.org/jbosstools/examples/project-examples-community-3... 2010-11-03
18:36:33 UTC (rev 26236)
+++
trunk/download.jboss.org/jbosstools/examples/project-examples-community-3... 2010-11-03
22:07:20 UTC (rev 26237)
@@ -508,7 +508,7 @@
<fixes>
<fix type="wtpruntime">
<property
name="allowed-types">org.jboss.ide.eclipse.as.runtime.eap.50</property>
- <property name="eclipse-projects">helloworld</property>
+ <property
name="eclipse-projects">helloworld,helloworld_testclient</property>
<property name="required-components">esb</property>
<property name="description">This project example requires the JBoss
SOA-P 5.0 and the runtime name should be "jboss-soa-p.5.0
Runtime"</property>
</fix>
Modified: workspace/Denny/esb-example-soa-p5.0/helloworld_all.zip
===================================================================
(Binary files differ)