Index: E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF =================================================================== --- E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF (revision 11626) +++ E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF (working copy) @@ -22,9 +22,10 @@ org.eclipse.jdt.launching, org.eclipse.jst.j2ee, org.eclipse.jst.ws.consumption.ui, - org.eclipse.jst.common.frameworks;bundle-version="1.1.200", + org.eclipse.jst.common.frameworks, org.eclipse.wst.server.core, - org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0" + org.eclipse.jst.common.project.facet.core, + org.jboss.ide.eclipse.as.classpath.core Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName Export-Package: org.jboss.tools.esb.core, Index: E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java =================================================================== --- E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java (revision 11626) +++ E:/workspace-3.4M7-JBoss/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java (working copy) @@ -18,14 +18,17 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.ClasspathContainerInitializer; +import org.eclipse.jdt.core.IAccessRule; +import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.ServerCore; +import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer; +import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer; +import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations; import org.jboss.tools.esb.core.ESBProjectCorePlugin; import org.jboss.tools.esb.core.StatusUtils; import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages; @@ -34,10 +37,11 @@ * @author Denny Xu */ public class JBossRuntimeClassPathInitializer extends - ClasspathContainerInitializer { + AbstractClasspathContainerInitializer { public final static String JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID = "org.jboss.esb.runtime.classpath"; public final static String JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED = "server.supplied"; + public JBossRuntimeClassPathInitializer() { } @@ -51,36 +55,40 @@ this.javaProject = project; if (containerPath.segment(0).equals( JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)) { - if(containerPath.segmentCount() == 3 - && containerPath.segment(1).equals(JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED)){ + if (containerPath.segmentCount() == 3 + && containerPath.segment(1).equals( + JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED)) { segment = containerPath.segment(2); isServerSupplied = true; - }else{ + } else { segment = containerPath.segment(1); isServerSupplied = false; } - + JBossRuntimeClasspathContainer container = new JBossRuntimeClasspathContainer( containerPath, project, isServerSupplied); JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, - new IClasspathContainer[] { container }, null); + new IClasspathContainer[] { container }, null); } } public IClasspathEntry[] getEntries(IPath path) { - return new JBossRuntimeClasspathContainer(path, javaProject, isServerSupplied).getClasspathEntries(); + return new JBossRuntimeClasspathContainer(path, javaProject, + isServerSupplied).getClasspathEntries(); } - public class JBossRuntimeClasspathContainer implements - IClasspathContainer { + public class JBossRuntimeClasspathContainer extends + AbstractClasspathContainer { private IPath path; private boolean isFromServer = false; private IClasspathEntry[] entries = null; private IJavaProject jproject; private List jars; - public JBossRuntimeClasspathContainer(IPath path, IJavaProject project, boolean isFromServer) { + public JBossRuntimeClasspathContainer(IPath path, IJavaProject project, + boolean isFromServer) { + super(path, JBossFacetCoreMessages.JBoss_Runtime, null); this.path = path; this.isFromServer = isFromServer; this.jproject = project; @@ -98,47 +106,63 @@ return path; } - public IClasspathEntry[] getClasspathEntries() { - if (entries == null) { - ArrayList entryList = new ArrayList(); - if (isFromServer) { - IRuntime serverRuntime = ServerCore.findRuntime(segment); + public IClasspathEntry[] computeEntries() { + ArrayList entryList = new ArrayList(); + if (isFromServer) { + IRuntime serverRuntime = ServerCore.findRuntime(segment); - if(serverRuntime == null){ - IStatus status = StatusUtils.errorStatus("Can not find the runtime: "+ segment); - ESBProjectCorePlugin.getDefault().getLog().log(status); - } - String runtimeLocation = serverRuntime.getLocation().toOSString(); - jars = JBossRuntimeManager.getInstance().getAllRuntimeJars(runtimeLocation); + if (serverRuntime == null) { + IStatus status = StatusUtils + .errorStatus("Can not find the runtime: " + segment); + ESBProjectCorePlugin.getDefault().getLog().log(status); + } + String runtimeLocation = serverRuntime.getLocation() + .toOSString(); + jars = JBossRuntimeManager.getInstance().getAllRuntimeJars( + runtimeLocation); - } else { + } else { - JBossRuntime jbws = JBossRuntimeManager.getInstance() - .findRuntimeByName(segment); - if (jbws != null) { - jars = JBossRuntimeManager.getInstance() - .getAllRuntimeJars(jbws); - } + JBossRuntime jbws = JBossRuntimeManager.getInstance() + .findRuntimeByName(segment); + if (jbws != null) { + jars = JBossRuntimeManager.getInstance().getAllRuntimeJars( + jbws); } - - if(jars == null) return new IClasspathEntry[0]; - - for (String jar : jars) { - entryList.add(getEntry(new Path(jar))); + } + + if (jars == null) + return new IClasspathEntry[0]; + + for (String jar : jars) { + + IPath entryPath = new Path(jar); + + IPath sourceAttachementPath = null; + IPath sourceAttachementRootPath = null; + + final ClasspathDecorations dec = decorations.getDecorations( + getDecorationManagerKey(getPath().toString()), + entryPath.toString()); + + IClasspathAttribute[] attrs = {}; + if (dec != null) { + sourceAttachementPath = dec.getSourceAttachmentPath(); + sourceAttachementRootPath = dec + .getSourceAttachmentRootPath(); + attrs = dec.getExtraAttributes(); } - entries = entryList.toArray(new IClasspathEntry[entryList - .size()]); - if (entries == null) - return new IClasspathEntry[0]; + + IAccessRule[] access = {}; + IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath, + sourceAttachementPath, sourceAttachementRootPath, + access, attrs, false); + entryList.add(entry); } + entries = entryList.toArray(new IClasspathEntry[entryList.size()]); return entries; } - protected IClasspathEntry getEntry(IPath path) { - return JavaRuntime.newArchiveRuntimeClasspathEntry(path) - .getClasspathEntry(); - } - public void removeEntry(String jarName) { if (entries == null) { return; @@ -164,4 +188,15 @@ return true; } + @Override + protected AbstractClasspathContainer createClasspathContainer(IPath path) { + return new JBossRuntimeClasspathContainer(path, javaProject, + isServerSupplied); + } + + @Override + protected String getClasspathContainerID() { + return JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID; + } + }