[224185] Binary Java EE 5 IArchive support
diff --git a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java
index d14dbe8..b1b49f1 100644
--- a/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java
+++ b/plugins/org.eclipse.jst.j2ee.ui/j2ee_ui/org/eclipse/jst/j2ee/internal/JARDependencyPropertiesPage.java
@@ -167,10 +167,6 @@
 		isDisposed = true;
 		JavaCore.removeElementChangedListener(this);
 		J2EEComponentClasspathUpdater.getInstance().resumeUpdates();
-		if (model.earArtifactEdit != null) {
-			model.earArtifactEdit.dispose();
-			model.earArtifactEdit = null;
-		}
 	}
 
 	private void updateModelManifest() {
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
index 5542bc5..d1c9d3e 100644
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
+++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
@@ -23,7 +23,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
@@ -36,21 +35,11 @@
 import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection;
 import org.eclipse.jst.j2ee.application.internal.operations.ClasspathElement;
 import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ManifestException;
 import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifest;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl;
 import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent;
-import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
 import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities;
 import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
 import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
-import org.eclipse.jst.j2ee.model.IModelProvider;
-import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.jee.archive.ArchiveOpenFailureException;
-import org.eclipse.jst.jee.archive.IArchive;
 import org.eclipse.wst.common.componentcore.ComponentCore;
 import org.eclipse.wst.common.componentcore.UnresolveableURIException;
 import org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel;
@@ -68,11 +57,7 @@
 
 	protected IProject project;
 	protected IVirtualComponent selectedEARComponent;
-	protected IArchive earFile;
 	protected IVirtualComponent component;
-//	protected IArchive archive;
-	public EARArtifactEdit earArtifactEdit;
-	/** The EAR nature runtimes for all the open EAR projects in the workspace */
 	protected IVirtualComponent[] availableEARComponents = null;
 	protected ClassPathSelection classPathSelection;
 	protected List listeners;
@@ -92,7 +77,6 @@
 		}
 	};
 
-
 	public ClasspathModel(ArchiveManifest initialManifest) {
 		this(initialManifest, false);
 	}
@@ -140,11 +124,6 @@
 		return availableEARComponents;
 	}
 
-	/**
-	 * Gets the selectedEARComponent.
-	 * 
-	 * @return Returns a EARNatureRuntime
-	 */
 	public IVirtualComponent getSelectedEARComponent() {
 		return selectedEARComponent;
 	}
@@ -167,93 +146,15 @@
 		return null;
 	}
 
-	/**
-	 * 
-	 * @deprecated - will be removed in WTP 3.0
-	 */
-	public EARArtifactEdit getEARArtifactEdit() {
-		if (earArtifactEdit == null || selectedEARComponentChanged())
-			earArtifactEdit = EARArtifactEdit.getEARArtifactEditForRead(selectedEARComponent);
-		return earArtifactEdit;
-	}
-
-	private boolean selectedEARComponentChanged() {
-		if (earArtifactEdit != null && !earArtifactEdit.getComponent().getName().equals(selectedEARComponent.getName())) {
-			earArtifactEdit.dispose();
-			earArtifactEdit = null;
-			return true;
-		}
-		return false;
-	}
-
-	protected void initializeEARFile() {
-		if (selectedEARComponent == null || !isDDInEAR(selectedEARComponent)) {
-			earFile = null;
-			return;
-		}
-		try {
-			earFile = JavaEEArchiveUtilities.INSTANCE.openArchive(selectedEARComponent);
-		} catch (ArchiveOpenFailureException aofex)
-		{
-			handleOpenFailureException(aofex);
-		}
-	}
-
-	/**
-	 * initializeSelection method comment.
-	 */
 	protected void initializeSelection(ArchiveManifest existing) {
-		try {
-			initializeEARFile();
-			initializeArchive();
 			if (!J2EEProjectUtilities.isEARProject(getProject())) {
 				if (getProject() != null) {
-					if (existing == null) {
-						if (manifest != null)
-						{
-							J2EEProjectUtilities.writeManifest(getProject(), manifest);
-						}
-						else
-							// Load it now because we're going to close the EAR;
-							// this might be a binary project
-							manifest = J2EEProjectUtilities.readManifest(getProject());
-					} else
-					{
-						J2EEProjectUtilities.writeManifest(getProject(), existing);
+					if(existing != null){
 						manifest = existing;
 					}
-					if (selectedEARComponent != null) {
-						IVirtualReference[] archiveFiles = selectedEARComponent.getReferences();
-						IVirtualComponent anArchive = null;
-						for (int i = 0; i < archiveFiles.length; i++) {
-							anArchive = archiveFiles[i].getReferencedComponent();
-							try {
-								if (J2EEProjectUtilities.isEJBComponent(anArchive)) {
-									IModelProvider modelProvider = ModelProviderManager.getModelProvider(anArchive.getProject());
-									modelProvider.getModelObject();
-								}
-								J2EEProjectUtilities.readManifest(anArchive.getProject());
-							} catch (ManifestException mfEx) {
-								Logger.getLogger().logError(mfEx);
-								// anArchive.setManifest((ArchiveManifest) new ArchiveManifestImpl());
-							} catch (DeploymentDescriptorLoadException ddException) {
-								Logger.getLogger().logError(ddException);
-							}
-						}
-					}
 				}
 				createClassPathSelection();
 			}
-		} catch (IOException e) {
-			handleOpenFailureException(e);
-		} finally {
-			if (earFile != null)
-				JavaEEArchiveUtilities.INSTANCE.closeArchive(earFile);
-		}
-	}
-
-	protected void initializeArchive() {
-		// do nothing now- just use the project
 	}
 
 	protected void createClassPathSelection() {
@@ -266,23 +167,7 @@
 		}
 	}
 
-	protected boolean isDDInEAR(IVirtualComponent aComponent) {
-		IContainer mofRoot = aComponent.getProject();
-		if (mofRoot == null || !mofRoot.exists())
-			return false;
-
-		return mofRoot.exists(new Path(aComponent.getRootFolder().getProjectRelativePath().toString() + "//" + J2EEConstants.APPLICATION_DD_URI)); //$NON-NLS-1$
-	}
-
-	protected void handleOpenFailureException(Exception ex) {
-		org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(ex);
-	}
-
 	public void dispose() {
-		if (earArtifactEdit != null) {
-			earArtifactEdit.dispose();
-			earArtifactEdit = null;
-		}
 	}
 
 	public ClassPathSelection getClassPathSelection() {
@@ -363,16 +248,6 @@
 	}
 
 	/**
-	 * Gets the archive.
-	 * 
-	 * @return Returns a Archive
-	 * @deprecated - use the project
-	 */
-	public Archive getArchive() {
-		return null;
-	}
-
-	/**
 	 * Updates the manifest Class-Path:, and sends out a notification of type
 	 * {@link ClasspathModelEvent#CLASS_PATH_CHANGED}
 	 */
@@ -419,17 +294,15 @@
 		try {
 			J2EEProjectUtilities.writeManifest(getProject(), newManifest);
 		} catch (IOException e) {
-			handleOpenFailureException(e);
+			J2EEPlugin.logError(e);
 		}
 		getClassPathSelection(); // Ensure the selection is initialized.
 		fireNotification(new ClasspathModelEvent(ClasspathModelEvent.MANIFEST_CHANGED));
 	}
 
 	public void selectEAR(int index) {
-		ArchiveManifest mf = new ArchiveManifestImpl((ArchiveManifestImpl) getArchive().getManifest());
-		JavaEEArchiveUtilities.INSTANCE.closeArchive(earFile);
 		selectedEARComponent = availableEARComponents[index];
-		initializeSelection(mf);
+		initializeSelection(null);
 		fireNotification(new ClasspathModelEvent(ClasspathModelEvent.EAR_PROJECT_CHANGED));
 	}
 
@@ -451,14 +324,12 @@
 		resetClassPathSelection(mf);
 	}
 
-
 	/**
 	 * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#cacheNonResourceValidateState(List)
 	 */
 	public void cacheNonResourceValidateState(List roNonResourceFiles) {
 	}
 
-
 	/**
 	 * @see com.ibm.etools.emf.workbench.ResourceStateInputProvider#getNonResourceFiles()
 	 */
@@ -470,7 +341,7 @@
 
 	protected void initNonResourceFiles() {
 		// Might be opened from a JAR
-		if (getComponent() == null){
+		if (getComponent() == null || getComponent().isBinary()){
 			return;
 		} 
 		nonResourceFiles = new ArrayList(1);
@@ -787,12 +658,4 @@
 		return isWLPModel;
 	}
 
-	/**
-	 * @deprecated do not use this method
-	 * @param isWLPModel
-	 */
-	public void setWLPModel(boolean isWLPModel) {
-		this.isWLPModel = isWLPModel;
-	}
-	
 }
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java
index 3ccf6f2..180da11 100644
--- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java
+++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java
@@ -560,11 +560,16 @@
 				currentComponent = references[cnt].getReferencedComponent();
 				if (J2EEProjectUtilities.isEJBComponent(currentComponent))
 				{
-					modelProvider = ModelProviderManager.getModelProvider(currentComponent);
-					if(modelProvider==null) {
+					if(currentComponent.isBinary()){
+						//TODO add binary support
 						continue;
+					} else {
+						modelProvider = ModelProviderManager.getModelProvider(currentComponent);
+						if(modelProvider==null) {
+							continue;
+						}
+						rootModelObject = modelProvider.getModelObject();
 					}
-					rootModelObject = modelProvider.getModelObject();
 					if (rootModelObject instanceof EJBJar)
 					{
 						ejbClientJarName = ((EJBJar)rootModelObject).getEjbClientJar();