Author: rob.stryker(a)jboss.com
Date: 2008-08-22 20:24:20 -0400 (Fri, 22 Aug 2008)
New Revision: 9876
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/icons/packages/
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml
Log:
JBIDE-2677 - removing the as.core's dependency on archives by way of addding an
extension point for publishers and a new plugin for the archives / publishing integration
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-08-22
20:46:59 UTC (rev 9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-08-23
00:24:20 UTC (rev 9876)
@@ -18,13 +18,11 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.jst.common.project.facet.core,
org.eclipse.wst.xml.core,
- org.jboss.ide.eclipse.archives.core,
org.apache.ant,
org.eclipse.jst.server.tomcat.core,
org.eclipse.wst.web
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.as.core,
- org.jboss.ide.eclipse.as.core.extensions.archives,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
org.jboss.ide.eclipse.as.core.extensions.events,
org.jboss.ide.eclipse.as.core.extensions.jmx,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -23,6 +23,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -31,6 +33,9 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.IPollerFailureHandler;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
@@ -57,6 +62,8 @@
/** The map of pollerID -> PollerObject */
private HashMap<String, IPollerFailureHandler> pollerFailureHandlers;
+ private ArrayList<PublisherWrapper> publishers;
+
/** The method used to load / instantiate the pollers */
public void loadPollers() {
pollers = new HashMap<String, ServerStatePollerType>();
@@ -142,4 +149,53 @@
}
return null;
}
+
+
+ public IJBossServerPublisher getPublisher(IServer server, IModule[] module) {
+ if( publishers == null )
+ loadPublishers();
+ Iterator i = publishers.iterator();
+ PublisherWrapper wrapper;
+ while(i.hasNext()) {
+ wrapper = (PublisherWrapper)i.next();
+ if( wrapper.publisher.accepts(server, module))
+ return wrapper.publisher;
+ }
+ return null;
+ }
+
+ private void loadPublishers() {
+ ArrayList<PublisherWrapper> publishers = new
ArrayList<PublisherWrapper>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] cf =
registry.getConfigurationElementsFor(JBossServerCorePlugin.PLUGIN_ID,
"publishers");
+ for( int i = 0; i < cf.length; i++ ) {
+ try {
+ Object clazz = cf[i].createExecutableExtension("class");
+ String priority = cf[i].getAttribute("priority");
+ int p = -1;
+ try {
+ p = Integer.parseInt(priority);
+ } catch( NumberFormatException nfe) {}
+ publishers.add(new PublisherWrapper(p, (IJBossServerPublisher)clazz));
+ } catch( CoreException e ) {
+ } catch( ClassCastException cce ) {
+ }
+ }
+ this.publishers = publishers;
+ Comparator<PublisherWrapper> comparator = new
Comparator<PublisherWrapper>() {
+ public int compare(PublisherWrapper o1, PublisherWrapper o2) {
+ return o2.priority - o1.priority;
+ }
+ };
+ Collections.sort(this.publishers, comparator);
+ }
+
+ private class PublisherWrapper {
+ private int priority;
+ private IJBossServerPublisher publisher;
+ private PublisherWrapper(int priority, IJBossServerPublisher publisher) {
+ this.priority = priority;
+ this.publisher = publisher;
+ }
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -30,7 +30,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
-import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
import org.osgi.framework.BundleContext;
@@ -73,7 +72,6 @@
super.start(context);
// Start the array of models that need to be started
- ArchivesBuildListener.getInstance();
XPathModel.getDefault();
UnitedServerListenerManager.getDefault();
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EarArchiveType.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,118 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.server.core.IEnterpriseApplication;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.as.core.modules.ModulePackageTypeConverter;
-
-/**
- * @author rob.stryker(a)redhat.com
- */
-public class EarArchiveType extends J2EEArchiveType {
- public final static String ID =
"org.jboss.ide.eclipse.as.core.packages.earPackageType";
- public String getAssociatedModuleType() {
- return "jst.ear";
- }
-
- public String getId() {
- return ID;
- }
-
- public String getLabel() {
- return "EAR";
- }
-
-
- public IArchive createDefaultConfiguration(String project, IProgressMonitor monitor) {
- IModule mod = getModule(project);
- if( mod != null )
- return createDefaultConfigFromModule(mod, monitor);
- else
- return createDefaultConfiguration2(project, monitor);
- }
-
- public IArchive createDefaultConfiguration2(String projectName,
- IProgressMonitor monitor) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() +
".ear");
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- fillDefaultConfiguration(projectName, topLevel, monitor);
- return topLevel;
- }
-
- public IArchive createDefaultConfigFromModule(IModule module,
- IProgressMonitor monitor) {
- IProject project = module.getProject();
- IContainer sourceContainer = project.getFolder(EARCONTENT);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() +
".ear", sourceContainer);
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- fillDefaultConfiguration(project.getName(), topLevel, monitor);
- return topLevel;
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
- try {
- IModule mod = getModule(projectName);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-
- if( mod == null ) {
- // add fileset
- IArchiveFolder metainf = addFolder(project, topLevel, METAINF);
- addFileset(project, metainf, new Path(projectName).append(METAINF).toOSString(),
null);
-
- } else {
- // now add children
- addFileset(project, topLevel, new
Path(project.getName()).append(EARCONTENT).toOSString(), "**/*.*");
- IEnterpriseApplication earModule =
(IEnterpriseApplication)mod.loadAdapter(IEnterpriseApplication.class, monitor);
- IModule[] childModules = earModule.getModules();
- for( int i = 0; i < childModules.length; i++ ) {
- IModule child = childModules[i];
- IArchiveType type = ModulePackageTypeConverter.getPackageTypeFor(child);
- IArchive childPack;
- if( type == null ) {
- childPack = createGenericIArchive(child.getProject(), null,
child.getProject().getName() + ".jar");
- } else {
- childPack = type.createDefaultConfiguration(child.getProject().getName(), new
NullProgressMonitor());
- }
- topLevel.addChild(childPack);
- }
- }
-
- } catch( ArchivesModelException ame) {}
- return topLevel;
- }
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/EjbArchiveType.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,81 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-
-/**
- *
- * @author rob.stryker(a)redhat.com
- */
-public class EjbArchiveType extends J2EEArchiveType {
-
- public final static String ID =
"org.jboss.ide.eclipse.as.core.packages.ejbPackageType";
- public String getAssociatedModuleType() {
- return "jst.ejb";
- }
-
- public String getId() {
- return ID;
- }
-
- public String getLabel() {
- return "EJB JAR";
- }
-
- public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor)
{
- IProject project = getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() +
".jar");
- return fillDefaultConfiguration(project, topLevel, monitor);
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
- return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
- }
- public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel,
IProgressMonitor monitor) {
-
- IModule mod = getModule(project.getName());
-
- if( mod == null ) {
- // TODO fix me
- } else {
- if( mod.getModuleType().getId().equals("jst.ejb") ) {
- try {
- IJavaProject proj = JavaCore.create(project);
- IPath outputLoc = proj.getOutputLocation();
- addFileset(project, topLevel, outputLoc.toOSString(), null);
- } catch( JavaModelException jmde) {
- } catch( ArchivesModelException ame ) {}
- }
- }
- return topLevel;
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,163 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public abstract class J2EEArchiveType implements IArchiveType {
- public static final String METAINF = "META-INF";
- public static final String WEBINF = "WEB-INF";
- public static final String CLASSES = "classes";
- public static final String LIB = "lib";
- public static final String WEBCONTENT = "WebContent";
- public static final String EARCONTENT = "EarContent";
- public static final String EJBMODULE = "ejbModule";
-
-
- protected boolean isModuleType(IModule module, String moduleTypeId){
- if(module.getModuleType()!=null &&
moduleTypeId.equals(module.getModuleType().getId()))
- return true;
- return false;
- }
-
- protected IModule getModule(String projectName) {
- IModuleArtifact moduleArtifacts[] =
ServerPlugin.getModuleArtifacts(getProject(projectName));
-
- if (moduleArtifacts != null && moduleArtifacts.length > 0)
- return moduleArtifacts[0].getModule();
- else return null;
- }
-
- protected IProject getProject(String projectName) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
- // Find the source folder, then create the IPackage appropriately
- public static IArchive createGenericIArchive(IProject project, String deployDirectory,
String packageName) {
- try {
- IJavaProject javaProject = JavaCore.create(project);
- Assert.isNotNull(javaProject);
-
- IPath sourcePath;
- try {
- sourcePath = javaProject.getOutputLocation();
- } catch (JavaModelException e) {
- return null;
- }
- sourcePath = sourcePath.removeFirstSegments(1);
- IContainer sourcePathContainer;
- if( sourcePath.segmentCount() == 0 )
- sourcePathContainer = project;
- else
- sourcePathContainer = project.getFolder(sourcePath);
- return createGenericIArchive(project, deployDirectory, packageName,
sourcePathContainer);
- } catch( Exception e ) {
- JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
JBossServerCorePlugin.PLUGIN_ID, "Unexpected Exception", e));
- }
- return null;
- }
-
- // Create a detached package with some generic settings
- public static IArchive createGenericIArchive(IProject project, String deployDirectory,
String packageName, IContainer sourceContainer) {
- IArchive jar = ArchiveNodeFactory.createArchive();
-
- if( deployDirectory != null ) {
- jar.setDestinationPath(new Path(deployDirectory));
- jar.setInWorkspace(ResourcesPlugin.getWorkspace().getRoot().getLocation().isPrefixOf(new
Path(deployDirectory)));
- jar.setExploded(false);
- } else {
- jar.setDestinationPath(project.getFullPath());
- jar.setInWorkspace(true);
- jar.setExploded(false);
- }
- jar.setName(packageName);
- return jar;
- }
-
-
- public static IArchiveFolder addFolder(IProject project,
- IArchiveNode parent, String name) throws ArchivesModelException {
- IArchiveFolder folder = ArchiveNodeFactory.createFolder();
- folder.setName(name);
- parent.addChild(folder);
- return folder;
- }
- public static IArchiveFileSet addFileset(IProject project, IArchiveNode parent,
- String sourcePath, String includePattern) throws ArchivesModelException {
- IArchiveFileSet fs = ArchiveNodeFactory.createFileset();
- Assert.isNotNull(project);
- IJavaProject javaProject = JavaCore.create(project);
- Assert.isNotNull(javaProject);
-
- IContainer sourceContainer;
- if( sourcePath != null && !sourcePath.equals("")) {
- Path p = new Path(sourcePath);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- sourceContainer = p.segmentCount() != 1 ? (IContainer)root.getFolder(p) :
root.getProject(p.segment(0));
- } else {
- sourceContainer = project;
- }
-
- fs.setRawSourcePath(sourceContainer.getFullPath().toString());
- fs.setInWorkspace(true);
- fs.setIncludesPattern( includePattern == null ? "**/*" : includePattern );
- parent.addChild(fs);
- return fs;
- }
-
- public abstract String getAssociatedModuleType();
-
- /*
- * Creates a directory scanner for some global path
- */
- public static DirectoryScannerExtension createDirectoryScanner (String rawPath, String
includes, String excludes, boolean scan) {
- return DirectoryScannerFactory.createDirectoryScanner(rawPath, null, includes,
excludes, null, false, 1, scan);
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,246 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.archives;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-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.IWebModule;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
-import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class WarArchiveType extends J2EEArchiveType {
- public static final String WAR_PACKAGE_TYPE =
"org.jboss.ide.eclipse.as.core.packages.warPackage";
-
- public String getAssociatedModuleType() {
- return "jst.web";
- }
-
- public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor)
{
- IModule mod = getModule(projectName);
- if( mod == null )
- return createDefaultConfiguration2(projectName, monitor);
- else
- return createDefaultConfigFromModule(mod, monitor);
- }
-
- protected IArchive createDefaultConfiguration2(String projectName, IProgressMonitor
monitor) {
- IProject project = getProject(projectName);
- IArchive topLevel = createGenericIArchive(project, null, project.getName() +
".war");
- return fillDefaultConfiguration(project, topLevel, monitor);
- }
-
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
- return fillDefaultConfiguration(getProject(projectName), topLevel, monitor);
- }
- public IArchive fillDefaultConfiguration(IProject project, IArchive topLevel,
IProgressMonitor monitor) {
- try {
- IModule mod = getModule(project.getName());
- IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
- IArchiveFolder lib = addFolder(project, webinf, LIB);
- IArchiveFolder classes = addFolder(project, webinf, CLASSES);
- addReferencedProjectsAsLibs(project, lib);
- addLibFileset(project, lib, true);
- addClassesFileset(project, classes);
-
- if( mod == null ) {
- addWebinfFileset(project, webinf);
- } else {
- addWebContentFileset(project, topLevel);
- }
- } catch( ArchivesModelException ame) {}
- return topLevel;
- }
-
- // For modules only
- protected void addWebContentFileset(IProject project, IArchiveNode packageRoot) throws
ArchivesModelException {
- try {
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
- // just take the first
- if( files.length > 0 ) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(2); // remove the file name
- path = new Path(project.getName()).append(path); // pre-pend project name to make
workspace-relative
- IArchiveFileSet fs = addFileset(project, packageRoot, path.toOSString(),
"**/*");
- //If we have separate file set for libraries, we do not need to duplicate jars.
- fs.setExcludesPattern("**/WEB-INF/lib/*.jar");
- }
- } catch( IllegalStateException ise ) {
- IStatus status = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
"Directory could not be scanned", ise);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- protected void addClassesFileset(IProject project, IArchiveFolder folder) throws
ArchivesModelException {
- IJavaProject jp = JavaCore.create(project);
- if( jp != null ) {
- try {
- IPath outputLoc = project.getWorkspace().getRoot().getLocation();
- outputLoc = outputLoc.append(jp.getOutputLocation());
- addFileset(project, folder, jp.getOutputLocation().toOSString(), "**/*");
- } catch( JavaModelException jme ) {
- // no logging
- }
- }
- }
- protected void addWebinfFileset(IProject project, IArchiveFolder folder) throws
ArchivesModelException {
- try {
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
- // just take the first
- if( files.length > 0 ) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(1); // remove the file name
- path = new Path(project.getName()).append(path); // pre-pend project name to make
workspace-relative
- addFileset(project, folder, path.toOSString(), "**/*");
- }
- } catch( IllegalStateException ise ) {
- IStatus status = new Status(IStatus.WARNING, ArchivesCorePlugin.PLUGIN_ID,
"Directory could not be scanned", ise);
- ArchivesCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- // Lib support
- protected void addLibFileset(IProject project, IArchiveFolder folder, boolean
includeTopLevelJars) throws ArchivesModelException {
- // Let us find /WEB-INF/lib directory and set it as source for the file set.
- String sourcePath = null;
-
- IPath projectPath = project.getLocation();
- DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
- String[] files = scanner.getIncludedFiles();
-
- if(files != null && files.length > 0) {
- IPath path = new Path(files[0]);
- path = path.removeLastSegments(1).append("lib");
- sourcePath = project.getFullPath().append(path).toString();
- addFileset(project, folder, sourcePath, "*.jar"); // add default jars
- } else {
- //having failed to find 'lib' directory, let us make source of the project
itself
- sourcePath = project.getName();
- DirectoryScanner scanner2 = createDirectoryScanner(projectPath.toString(),
"**/*.jar", null, true);
- String[] files2 = scanner2.getIncludedFiles();
- IPath p;
- ArrayList list = new ArrayList();
- for( int i = 0; i < files2.length; i++ ) {
- p = project.getFullPath().append(files2[i]).removeLastSegments(1);
- if( !list.contains(p)) {
- list.add(p);
- addFileset(project, folder, p.toString(), "*.jar"); // add default jars
- }
- }
- }
- }
- protected void addReferencedProjectsAsLibs(IProject project, IArchiveFolder folder)
throws ArchivesModelException {
- IJavaProject jp = JavaCore.create(project);
- if( jp != null && jp.exists()) {
- try {
- IClasspathEntry[] entries = jp.getRawClasspath();
- for( int i = 0; i < entries.length; i++ ) {
- if( entries[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IPath path = entries[i].getPath();
- IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if( res instanceof IProject ) {
- createLibFromProject((IProject)res, folder);
- }
- }
- }
- } catch( JavaModelException jme ) {
- // no logging
- }
- }
- }
-
-
- protected void createLibFromProject(IProject project, IArchiveFolder folder) throws
ArchivesModelException {
- IArchive pack = createGenericIArchive(project, null, project.getName() +
".jar");
- folder.addChild(pack);
- }
-
- protected IArchive createDefaultConfigFromModule(IModule mod, IProgressMonitor monitor)
{
- try {
- IProject project = mod.getProject();
-
- // create the stub
- IArchive topLevel = createGenericIArchive(project, null, project.getName() +
".war");
- topLevel.setDestinationPath(new Path(project.getName()));
- topLevel.setInWorkspace(true);
-
- // add lib folder so we can add libraries
- IArchiveFolder webinf = addFolder(project, topLevel, WEBINF);
- IArchiveFolder lib = addFolder(project, webinf, LIB);
- IArchiveFolder classes = addFolder(project, webinf, CLASSES);
-
-
- IVirtualComponent vc = ComponentCore.createComponent(project);
- IPath webContentPath = vc.getRootFolder().getUnderlyingFolder().getFullPath();
- addFileset(project, topLevel, webContentPath.toOSString(), "**/*");
- addClassesFileset(project, classes);
-
- // package each child and add to lib folder
- IWebModule webModule = (IWebModule)mod.loadAdapter(IWebModule.class, monitor);
- IModule[] childModules = webModule.getModules();
- for (int i = 0; i < childModules.length; i++) {
- IModule child = childModules[i];
- lib.addChild(createGenericIArchive(child.getProject(), null,
child.getProject().getName() + ".jar"));
- }
- return topLevel;
- } catch( Exception e ) {
- JBossServerCorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR,
JBossServerCorePlugin.PLUGIN_ID, "Unexpected Exception", e));
- }
- return null;
- }
-
- public String getId() {
- return WAR_PACKAGE_TYPE;
- }
-
- public String getLabel() {
- return "WAR";
- }
-}
\ No newline at end of file
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesBuildListener.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,215 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import
org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ArchivesBuildListener implements IArchiveBuildListener,
IArchiveModelListener {
-
- public static ArchivesBuildListener instance;
- public static final String DEPLOY_SERVERS =
"org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployServers";
- public static final String DEPLOY_AFTER_BUILD =
"org.jboss.ide.eclipse.as.core.model.PackagesListener.DeployAfterBuild";
-
- public static ArchivesBuildListener getInstance() {
- if( instance == null ) {
- instance = new ArchivesBuildListener();
- }
- return instance;
- }
-
- public ArchivesBuildListener() {
- ArchivesModel.instance().addBuildListener(this);
- ArchivesModel.instance().addModelListener(this); // ? , ArchivesModel.LIST_FRONT);
- }
-
- public void cleanArchive(IArchive pkg) {
- }
-
-
- public void finishedBuildingArchive(IArchive pkg) {
- if( pkg.isTopLevel() && new
Boolean(pkg.getProperty(DEPLOY_AFTER_BUILD)).booleanValue()) {
- publish(pkg);
- }
- }
-
- public void fileRemoved(IArchive topLevelPackage, IArchiveFileSet fileset, IPath
filePath) {
- }
- public void fileUpdated(IArchive topLevelPackage, IArchiveFileSet fileset, IPath
filePath) {
- }
-
- // If we're supposed to auto-deploy, get on it
- protected static void publish(IArchive pkg) {
- String servers = pkg.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- publish(pkg, servers, IServer.PUBLISH_INCREMENTAL);
- }
- public static void publish(IArchive pkg, String servers, int publishType) {
- IModule[] module = getModule(pkg);
- if( module[0] == null ) return;
- DeployableServerBehavior[] serverBehaviors =
ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- publish(serverBehaviors[i].getServer(), publishType, module );
- }
- }
- }
-
- protected static IStatus publish(IServer server, int publishType, IModule[] module ) {
- try {
- IServerWorkingCopy copy = server.createWorkingCopy();
- copy.modifyModules(module, new IModule[0], new NullProgressMonitor());
- IServer saved = copy.save(false, new NullProgressMonitor());
- saved.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
- } catch( CoreException ce ) {
- return new Status(Status.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Cannot deploy file " + module[0].getName(), ce);
- }
- return Status.OK_STATUS;
-
- }
- protected static IModule[] getModule(IArchive node) {
- ModuleFactory factory =
ServerPlugin.findModuleFactory("org.jboss.ide.eclipse.as.core.PackageModuleFactory");
- IModule mod = factory.findModule(PackageModuleFactory.getID(node), new
NullProgressMonitor());
- return new IModule[] { mod };
- }
- protected static PackagedModuleDelegate getModuleDelegate(IArchive node) {
- IModule mod = getModule(node)[0];
- return (PackagedModuleDelegate)mod.loadAdapter(PackagedModuleDelegate.class, new
NullProgressMonitor());
- }
-
- protected IDeployableServer getDeployableServerFromBehavior(DeployableServerBehavior
dsb) {
- IServer server = dsb.getServer();
- IDeployableServer ids = (IDeployableServer)server.loadAdapter(IDeployableServer.class,
new NullProgressMonitor());
- return ids;
- }
-
- public static DeployableServerBehavior[] getServers(String servers) {
- if( servers == null || "".equals(servers))
- return null;
- ArrayList<DeployableServerBehavior> list = new
ArrayList<DeployableServerBehavior>();
- String[] byId = servers.split(",");
- for( int i = 0; i < byId.length; i++ ) {
- IServer server = ServerCore.findServer(byId[i]);
- if( server != null ) {
- Object o = server.loadAdapter(DeployableServerBehavior.class, new
NullProgressMonitor());
- if( o != null ) {
- list.add((DeployableServerBehavior)o);
- }
- }
- }
- return list.toArray(new DeployableServerBehavior[list.size()]);
- }
-
- /*
- * If a node is changing from exploded to imploded, or vice versa
- * make sure to delete the pre-existing file or folder on the server.
- */
- public void packageBuildTypeChanged(IArchive topLevelPackage, boolean isExploded) {
- String servers = topLevelPackage.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- DeployableServerBehavior[] serverBehaviors =
ArchivesBuildListener.getServers(servers);
- if( serverBehaviors != null ) {
- IPath sourcePath, destPath;
- IDeployableServer depServer;
- for( int i = 0; i < serverBehaviors.length; i++ ) {
- sourcePath = topLevelPackage.getArchiveFilePath();
- depServer = getDeployableServerFromBehavior(serverBehaviors[i]);
- destPath = new
Path(depServer.getDeployDirectory()).append(sourcePath.lastSegment());
- FileUtil.safeDelete(destPath.toFile());
- FileUtil.fileSafeCopy(sourcePath.toFile(), destPath.toFile());
- }
- }
- }
-
- public void buildFailed(IArchive pkg, IStatus status) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void finishedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuild(IPath project) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedBuildingArchive(IArchive pkg) {
- // TODO Auto-generated method stub
-
- }
-
- public void startedCollectingFileSet(IArchiveFileSet fileset) {
- // TODO Auto-generated method stub
- }
- public void startedBuildingPackage(IArchive pkg) {
- // TODO Auto-generated method stub
- }
-
- public void cleanProject(IPath project) {
- }
-
- public void modelChanged(IArchiveNodeDelta delta) {
- IPath p ;
- if( delta.getPreNode() == null )
- p = delta.getPostNode().getProjectPath();
- else
- p = delta.getPreNode().getProjectPath();
-
- ArchivesModelModuleContributor.getInstance().refreshProject(p);
- }
-
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ArchivesModelModuleContributor.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,185 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IModuleContributor;
-import
org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-
-/**
- *
- * @author Rob Stryker rob.stryker(a)jboss.com
- *
- */
-public class ArchivesModelModuleContributor implements IModuleContributor {
-
- private static ArchivesModelModuleContributor instance;
- public static ArchivesModelModuleContributor getInstance() {
- if( instance == null ) {
- instance = new ArchivesModelModuleContributor(PackageModuleFactory.getFactory());
- }
- return instance;
- }
-
- private PackageModuleFactory factory;
- protected ArrayList<IModule> modules = null;
- protected HashMap<IPath, ArrayList<IModule>> projectToModules = new
HashMap<IPath, ArrayList<IModule>>(5); //IPath to IModule
- protected HashMap<IModule, Object> moduleDelegates = new HashMap<IModule,
Object>(5);
- protected HashMap<IArchive, IModule> packageToModule = new HashMap<IArchive,
IModule>(5);
-
- private ArchivesModelModuleContributor(PackageModuleFactory factory) {
- this.factory = factory;
- }
-
- public IModule[] getModules() {
- if( modules == null ) {
- modules = new ArrayList<IModule>();
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if (projects2[i].isAccessible()) {
-
- if( !ArchivesModel.instance().isProjectRegistered(projects2[i].getLocation())) {
- if( ArchivesModel.instance().canReregister(projects2[i].getLocation()))
- // registration should also add this to the factory manually, so do not create the
module
- ArchivesModel.instance().registerProject(projects2[i].getLocation(), new
NullProgressMonitor());
- } else {
- try {
- // project is already registered. create the module
- createModules(projects2[i]);
- } catch(ArchivesModelException ame) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
- return modules.toArray(new IModule[modules.size()]);
- }
-
- protected void createModules(IProject project) throws ArchivesModelException {
- IArchive[] packages = ModelUtil.getProjectArchives(project.getLocation());
- if( packages != null && packages.length > 0 ) {
- IModule module;
- boolean requiresSave = ensureArchivesHaveIDs(project, packages);
- ArrayList<IModule> mods = new ArrayList<IModule>();
- for( int i = 0; i < packages.length; i++ ) {
- module = factory.createModule2(packages[i], project);
- modules.add(module);
- Object moduleDelegate = new PackagedModuleDelegate(packages[i]);
- packageToModule.put(packages[i], module);
- moduleDelegates.put(module, moduleDelegate);
- mods.add(module);
- }
- projectToModules.put(project.getLocation(), mods);
- if( requiresSave ) {
- try {
- ArchivesModel.instance().save(project.getLocation(),
- new NullProgressMonitor());
- } catch( ArchivesModelException ame ) {
- }
- }
- }
- }
-
- public boolean containsModule(IModule module) {
- return moduleDelegates.containsKey(module);
- }
-
- public PackagedModuleDelegate getModuleDelegate(IModule module) {
- return (PackagedModuleDelegate)moduleDelegates.get(module);
- }
-
- public void refreshProject(IPath projectLoc) {
- // prime, make sure all are found
- if( modules == null )
- getModules();
-
- // remove old mods
- ArrayList<IModule> mods = projectToModules.get(projectLoc);
- IModule mod;
- PackagedModuleDelegate delegate;
- if (mods != null) {
- for( Iterator<IModule> i = mods.iterator(); i.hasNext();) {
- mod = (IModule)i.next();
- if( modules.contains(mod)) {
- delegate = ((PackagedModuleDelegate)moduleDelegates.get(mod));
- moduleDelegates.remove(mod);
- modules.remove(mod);
- if( delegate != null )
- packageToModule.remove(delegate.getPackage());
- }
- }
- }
- try {
- createModules(findProject(projectLoc));
- } catch( ArchivesModelException ame ) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ame.getMessage(), ame);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- }
-
- protected IProject findProject(IPath projectLoc) {
- IProject proj = null;
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int size = projects2.length;
- for (int i = 0; i < size; i++) {
- if( projects2[i].getLocation().equals(projectLoc))
- proj = projects2[i];
- }
- return proj;
- }
-
- /**
- * Set a property so that each module that's here in the factory
- * has a unique ID other than it's name (which is not unique)
- * @param archives
- * @return returns whether a save has occurred
- */
- protected boolean ensureArchivesHaveIDs(IProject project, IArchive[] archives) {
- boolean requiresSave = false;
- for( int i = 0; i < archives.length; i++ ) {
- if( PackageModuleFactory.getID(archives[i]) == null ) {
- requiresSave = true;
- archives[i].setProperty(PackageModuleFactory.MODULE_ID_PROPERTY_KEY,
- PackageModuleFactory.getID(archives[i], true));
- }
- }
- return requiresSave;
- }
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ModulePackageTypeConverter.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,48 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import org.eclipse.wst.server.core.IModule;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.EarArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.EjbArchiveType;
-import org.jboss.ide.eclipse.as.core.extensions.archives.WarArchiveType;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class ModulePackageTypeConverter {
- public static IArchiveType getPackageTypeFor(IModule module) {
- String modType = module.getModuleType().getId();
- if("jst.web".equals(modType)) {
- return
ArchivesCore.getInstance().getExtensionManager().getArchiveType(WarArchiveType.WAR_PACKAGE_TYPE);
- } else if("jst.ear".equals(modType)) {
- return
ArchivesCore.getInstance().getExtensionManager().getArchiveType(EarArchiveType.ID);
- } else if("jst.ejb".equals(modType)) {
- return
ArchivesCore.getInstance().getExtensionManager().getArchiveType(EjbArchiveType.ID);
- }
-
- return null;
- }
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,412 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.core.model.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.ModuleDelegate;
-import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
-import org.eclipse.wst.server.core.util.ModuleFile;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
-import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.jboss.ide.eclipse.archives.core.util.PathUtils;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PackageModuleFactory extends ModuleFactoryDelegate {
-
- public static final String FACTORY_TYPE_ID =
"org.jboss.ide.eclipse.as.core.PackageModuleFactory";
- public static final String MODULE_TYPE = "jboss.package";
- public static final String VERSION = "1.0";
-
- public static final String MODULE_ID_PROPERTY_KEY =
"org.jboss.ide.eclipse.as.core.packages.ModuleIDPropertyKey";
-
- // the factory delegate and the factory respectively
- private static PackageModuleFactory factDelegate;
- private static ModuleFactory factory;
-
- /**
- * Find the module factory wrapper WTP provides for us
- * @return
- */
- public static PackageModuleFactory getFactory() {
- if( factDelegate == null ) {
- ModuleFactory[] factories = ServerPlugin.getModuleFactories();
-
- for( int i = 0; i < factories.length; i++ ) {
- if( factories[i].getId().equals(PackageModuleFactory.FACTORY_TYPE_ID)) {
- Object o = factories[i].getDelegate(new NullProgressMonitor());
- if( o instanceof PackageModuleFactory ) {
- factory = factories[i];
- factDelegate = (PackageModuleFactory)o;
- return factDelegate;
- }
- }
- }
- }
- return factDelegate;
- }
-
- /**
- * Get the module ID of this IArchive if it exists.
- * Do not create a new one otherwise
- * @param pack
- * @return
- */
- public static String getID(IArchive pack) {
- return getID(pack, false);
- }
-
- /**
- * Get the module ID of this IArchive if it exists.
- * If create is true, and the ID is not set, set a default ID.
- * @param pack
- * @param create
- * @return
- */
- protected static String getID(IArchive pack, boolean create) {
- String propVal = pack.getProperty(MODULE_ID_PROPERTY_KEY);
- if( propVal == null && create ) {
- return "" + new Date().getTime();
- }
- return propVal;
- }
-
- /**
- * Return the name of the project in the workspace
- * @param node
- * @return
- */
- public static String getProjectName(IArchiveNode node) {
- IPath projPath = node.getProjectPath();
- if( projPath == null ) return null;
- IProject[] list = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for( int i = 0; i < list.length; i++ )
- if( list[i].getLocation().equals(projPath))
- return list[i].getName();
- return null;
- }
-
- /**
- * Get the visible name of this module
- * @param pack
- * @return
- */
- public static String getName(IArchive pack) {
- return getProjectName(pack) + "/" + pack.getName();
- }
-
-
-
- protected ArchivesModelModuleContributor moduleContributor;
- public PackageModuleFactory() {
- super();
- }
-
- public void initialize() {
- moduleContributor = ArchivesModelModuleContributor.getInstance();
- }
-
- protected IModule createModule2(IArchive pack, IProject project) {
- return createModule(getID(pack), getName(pack), MODULE_TYPE, VERSION, project);
- }
-
- public IModule[] getModules(IProject project) {
- moduleContributor.refreshProject(project.getLocation());
- return super.getModules(project);
- }
- public IModule[] getModules() {
- return moduleContributor.getModules();
- }
-
- public ModuleDelegate getModuleDelegate(IModule module) {
- return moduleContributor.getModuleDelegate(module);
- }
-
- public static interface IModuleContributor {
- public IModule[] getModules();
- public boolean containsModule(IModule module);
- public PackagedModuleDelegate getModuleDelegate(IModule module);
- }
-
- public static interface IExtendedModuleResource extends IModuleResource {
- public IPath getSourcePath();
- public IArchiveNode getNode();
- // deep destination is the full path this resource represents, even if it's inside
a jar
- public IPath getDeepDestination();
- // the concrete file this resource is part of... so the top most zipped jar or, if all
is exploded, the file itself
- public IPath getConcreteDestFile();
- }
-
- public static class DelegateInitVisitor implements IArchiveNodeVisitor {
-
- private IArchive pack;
- private HashMap<IArchiveNode, ArchiveContainerResource> members; // node ->
imoduleresource
- private HashMap<IPath, IArchiveNode> pathToNode; // path -> node
- public DelegateInitVisitor(IArchive pack) {
- this.pack = pack;
- reset();
- }
- public void reset() {
- members = new HashMap<IArchiveNode, ArchiveContainerResource>();
- pathToNode = new HashMap<IPath, IArchiveNode>();
- }
- public boolean visit(IArchiveNode node) {
- int type = node.getNodeType();
- if( type == IArchiveNode.TYPE_ARCHIVE && ((IArchive)node).isTopLevel()) {
- IPath rel = ((IArchive)node).getRootArchiveRelativePath();
- members.put(node, new ArchiveContainerResource(((IArchive)node).getName(), node,
rel));
- pathToNode.put(rel, node);
- } else if( type == IArchiveNode.TYPE_ARCHIVE || type ==
IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- String name = type == IArchiveNode.TYPE_ARCHIVE ? ((IArchive)node).getName() :
((IArchiveFolder)node).getName();
- // if we're any other archive or a folder, create us and add to parent
- IArchiveNode parent = node.getParent();
- ArchiveContainerResource parentAsResource = members.get(parent);
- IPath rel = node.getRootArchiveRelativePath();
- members.put(node, new ArchiveContainerResource(name, node, rel));
- pathToNode.put(rel, node);
- parentAsResource.addChild(members.get(node));
- } else if( type == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- ArchiveContainerResource parentAsResource = members.get(node.getParent());
- parentAsResource.addFilesetAsChild((IArchiveFileSet)node);
- }
-
- return true;
- }
-
- public IModuleResource getRootResource() {
- return members.get(pack);
- }
-
- public IModuleResource getResourceForNode(IArchiveNode node) {
- return members.get(node);
- }
- }
-
- public static class ArchiveContainerResource implements IModuleFolder,
IExtendedModuleResource {
-
- protected IPath moduleRelativePath;
- protected IPath fsRelative;
- protected IArchiveNode node;
- protected String name;
- private HashMap<IPath, IModuleResource> members;
-
- // represents source folder on disk. only used if node is fileset
-// private IPath folderGlobalPath = null;
- public ArchiveContainerResource(String name,IArchiveNode node,IPath moduleRelativePath
) {
- this.name = name;
- this.node = node;
- this.moduleRelativePath = moduleRelativePath;
- members = new HashMap<IPath, IModuleResource>();
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- fsRelative =
moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
- }
- }
-
- public int hashCode() {
- return name.hashCode() * 37 + moduleRelativePath.hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof IModuleFolder) {
- IModuleFolder resource = (IModuleFolder) other;
- return resource.getModuleRelativePath().equals(getModuleRelativePath());
- }
- return false;
- }
-
- public void addChild(IModuleResource resource) {
- members.put(resource.getModuleRelativePath(), resource);
- }
-
- public void removeChild(IPath moduleRelativePath) {
- members.remove(moduleRelativePath);
- }
- public IModuleResource getChild(IPath path) {
- return members.get(path);
- }
-
- public void addFilesetAsChild(IArchiveFileSet fs) {
- FileWrapper[] files = fs.findMatchingPaths(); // file-system based source paths
- for( int i = 0; i < files.length; i++ ) {
- addFilesetPathAsChild(fs, files[i]);
- }
- }
-
- public void addFilesetPathAsChild(IArchiveFileSet fs, FileWrapper file) {
- IPath fsRelative = new Path(file.getFilesetRelative());
- ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), true);
- ExtendedModuleFile emf = new ExtendedModuleFile(file, fs);
- parent.addChild(emf);
- }
-
- protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean
create) {
- ArchiveContainerResource resource = this;
- ArchiveContainerResource tmpResource;
- IPath tmpPath = fs.getRootArchiveRelativePath();
- int count = fsRelative.segmentCount();
- for( int i = 0; i < count; i++ ) {
- tmpPath = tmpPath.append(fsRelative.segment(i));
- tmpResource = (ArchiveContainerResource)resource.getChild(tmpPath);
- if( tmpResource == null ) {
- if( !create )
- return null;
- tmpResource = new ArchiveContainerResource(tmpPath.lastSegment(), fs, tmpPath);
- resource.addChild(tmpResource);
- }
- resource = tmpResource;
- }
- return resource;
- }
-
- public IModuleResource[] members() {
- Collection<IModuleResource> c = members.values();
- return c.toArray(new IModuleResource[c.size()]);
- }
-
- public IPath getModuleRelativePath() {
- return moduleRelativePath;
- }
-
- public String getName() {
- return name;
- }
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- public IPath getDeepDestination() {
- IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
- ? moduleRelativePath : node.getRootArchiveRelativePath();
- return PathUtils.getGlobalLocation(node.getRootArchive()).append(tmp);
- }
-
- public IPath getConcreteDestFile() {
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET )
- return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node,fsRelative);
- else
- return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node);
- }
- public IArchiveNode getNode() {
- return node;
- }
-
- public IPath getSourcePath() {
- return null;
- }
-
- }
-
- public static class ExtendedModuleFile extends ModuleFile implements
IExtendedModuleResource {
- private FileWrapper wrapper;
- private IArchiveFileSet node;
- public ExtendedModuleFile(FileWrapper wrapper, IArchiveFileSet fs) {
- super(wrapper.getOutputName(), wrapper.getRootArchiveRelative(),
wrapper.lastModified());
- this.node = fs;
- this.wrapper = wrapper;
- }
- public int hashCode() {
- return getName().hashCode() * 37 + getPath().hashCode();
- }
-
- public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
- public IArchiveNode getNode() { return node; }
- public IPath getDeepDestination() {
- return
PathUtils.getGlobalLocation(node.getRootArchive()).append(wrapper.getRootArchiveRelative());
- }
- public IPath getSourcePath() {
- return new Path(this.wrapper.getAbsolutePath());
- }
-
- public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node, new
Path(this.wrapper.getFilesetRelative()));
- }
-
- public boolean equals(Object other) {
- if (other instanceof IModuleFile) {
- IModuleFile resource = (IModuleFile) other;
- return resource.getModuleRelativePath().equals(getModuleRelativePath());
- }
- return false;
- }
-
- }
-
- public static class PackagedModuleDelegate extends ModuleDelegate {
- private IArchive pack;
- private IModuleResource rootResource;
- private DelegateInitVisitor initVisitor;
- public PackagedModuleDelegate(IArchive pack) {
- this.pack = pack;
- initVisitor = new DelegateInitVisitor(pack);
- }
-
- public IArchive getPackage() {
- return pack;
- }
- public IModule[] getChildModules() {
- return new IModule[0];
- }
-
- protected void init() {
- initVisitor.reset();
- pack.accept(initVisitor);
- rootResource = initVisitor.getRootResource();
- }
-
- public IModuleResource[] members() throws CoreException {
- init();
- return new IModuleResource[] { rootResource };
- }
-
- public IStatus validate() {
- return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID,
- 0, "", null);
- }
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackagedArtifactAdapter.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,81 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.modules;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate;
-/**
- *
- * @author Rob Stryker rob.stryker(a)redhat.com
- *
- */
-public class PackagedArtifactAdapter extends ModuleArtifactAdapterDelegate {
-
- public PackagedArtifactAdapter() {
- }
-
- public IModuleArtifact getModuleArtifact(Object obj) {
- if( obj instanceof IJavaProject ) {
- IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- boolean done = false;
- String jpName = ((IJavaProject)obj).getElementName();
- for( int i = 0; i < projects2.length && !done; i++ ) {
- if( projects2[i].getName().equals(jpName)) {
- done = true;
- obj = projects2[i];
- break;
- }
- }
- }
-
- if( obj instanceof IProject ) {
- PackageModuleFactory factory = PackageModuleFactory.getFactory();
- if( factory != null ) {
-// IModule[] mods = factory.getModulesFromProject((IProject)obj);
-// if( mods != null && mods.length != 0) {
-// return getArtifact(mods);
-// }
- }
- }
- return null;
- }
-
- protected IModuleArtifact getArtifact(IModule[] mod) {
- //return new PackagedArtifact(mod);
- // TODO Blocking on eclipse bug 174372
- return null;
- }
-
- public class PackagedArtifact implements IModuleArtifact{
- protected IModule mod;
- public PackagedArtifact(IModule module) {
- this.mod = module;
- }
- public IModule getModule() {
- return mod;
- }
- }
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/SingleDeployableFactory.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -55,7 +55,6 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListener;
import org.jboss.ide.eclipse.as.core.server.UnitedServerListenerManager;
@@ -227,7 +226,8 @@
private IPath workspaceRelative;
public SingleDeployableModuleDelegate(IPath workspaceRelative) {
this.workspaceRelative = workspaceRelative;
- global =
ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(workspaceRelative);
+ IResource res =
ResourcesPlugin.getWorkspace().getRoot().findMember(workspaceRelative);
+ global = res.getLocation();
}
public IModule[] getChildModules() {
return new IModule[0];
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -35,6 +35,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.internal.DeletedModule;
@@ -73,16 +74,8 @@
protected int publishState = IServer.PUBLISH_STATE_NONE;
- public JstPublisher(IDeployableServer server, EventLogTreeItem context) {
- this.server = server;
- eventRoot = context;
+ public JstPublisher() {
}
- public JstPublisher(IServer server, EventLogTreeItem eventContext) {
- this( ServerConverter.getDeployableServer(server), eventContext);
- }
- public void setDelta(IModuleResourceDelta[] delta) {
- this.delta = delta;
- }
protected String getModulePath(IModule[] module ) {
String modulePath = "";
@@ -93,9 +86,14 @@
return modulePath;
}
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor)
- throws CoreException {
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
IStatus status = null;
+ this.server = ServerConverter.getDeployableServer(server);
+ this.eventRoot = log;
+ this.delta = delta;
+
boolean deleted = false;
for( int i = 0; i < module.length; i++ ) {
if( module[i] instanceof DeletedModule )
@@ -103,7 +101,7 @@
}
if (publishType == REMOVE_PUBLISH ) {
- status = unpublish(server, module, monitor);
+ status = unpublish(this.server, module, monitor);
} else {
if( deleted ) {
publishState = IServer.PUBLISH_STATE_UNKNOWN;
@@ -395,4 +393,8 @@
}
return count;
}
+
+ public boolean accepts(IServer server, IModule[] module) {
+ return ModuleCoreNature.isFlexibleProject(module[0].getProject());
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/NullPublisher.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -27,6 +27,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
/**
@@ -38,12 +39,13 @@
public int getPublishState() {
return IServer.PUBLISH_STATE_NONE;
}
-
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor) throws CoreException {
- return null;
+ public boolean accepts(IServer server, IModule[] module) {
+ return true;
}
- public void setDelta(IModuleResourceDelta[] delta) {
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+ return null;
}
-
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -1,250 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.publishers;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleFile;
-import org.eclipse.wst.server.core.model.IModuleFolder;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.util.PathUtils;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.ExtendedModuleFile;
-import
org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.IExtendedModuleResource;
-import
org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.PackagedModuleDelegate;
-import
org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublisherFileUtilListener;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.core.util.FileUtil;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-
-/**
- *
- * @author rob.stryker(a)jboss.com
- */
-public class PackagesPublisher implements IJBossServerPublisher {
-
- protected IDeployableServer server;
- protected IModuleResourceDelta[] delta;
- protected EventLogTreeItem eventRoot;
-
- public PackagesPublisher(IDeployableServer server, EventLogTreeItem eventContext) {
- this.server = server;
- eventRoot = eventContext;
- }
- public PackagesPublisher(IServer server, EventLogTreeItem eventContext) {
- this( ServerConverter.getDeployableServer(server), eventContext);
- }
- public void setDelta(IModuleResourceDelta[] delta) {
- this.delta = delta;
- }
-
-
- public int getPublishState() {
- return IServer.PUBLISH_STATE_NONE;
- }
-
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor) throws CoreException {
- try {
- IModule module2 = module[0];
- // if it's being removed
- if( publishType == REMOVE_PUBLISH ) {
- removeModule(module2, monitor);
- } else if( publishType == FULL_PUBLISH ) {
- publishModule(module2, false, monitor);
- } else if( publishType == INCREMENTAL_PUBLISH ) {
- publishModule(module2, true, monitor);
- }
- }catch(Exception e) {
- IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Error during publish", e);
- JBossServerCorePlugin.getDefault().getLog().log(status);
- }
- return null;
- }
-
- protected void removeModule(IModule module, IProgressMonitor monitor) {
- IArchive pack = getPackage(module);
- // remove all of the deployed items
- if( pack != null ) {
- IPath sourcePath = pack.getArchiveFilePath();
- IPath destPath = new
Path(server.getDeployDirectory()).append(sourcePath.lastSegment());
- // remove the entire file or folder
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
- FileUtil.safeDelete(destPath.toFile(), listener);
- }
- }
-
-
-
- protected void publishModule(IModule module, boolean incremental, IProgressMonitor
monitor) {
- IArchive pack = getPackage(module);
- IPath sourcePath = pack.getArchiveFilePath();
- IPath destPathRoot = new Path(server.getDeployDirectory());
-
- // if destination is deploy directory... no need to re-copy!
- if( destPathRoot.toOSString().equals(PathUtils.getGlobalLocation(pack).toOSString()))
{
- // fire null publish event
- return;
- }
-
- PublisherFileUtilListener listener = new PublisherFileUtilListener(eventRoot);
- eventRoot.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT,
countChanges(delta));
- if( incremental ) {
- publishFromDelta(module, destPathRoot, sourcePath.removeLastSegments(1), delta,
listener);
- } else {
- // full publish, copy whole folder or file
- FileUtil.fileSafeCopy(sourcePath.toFile(),
destPathRoot.append(sourcePath.lastSegment()).toFile(), listener);
- }
- }
-
- protected void publishFromDelta(IModule module, IPath destPathRoot, IPath sourcePrefix,
- IModuleResourceDelta[] delta, PublisherFileUtilListener listener) {
- ArrayList<IPath> changedFiles = new ArrayList<IPath>();
- for( int i = 0; i < delta.length; i++ ) {
- publishFromDeltaHandle(delta[i], destPathRoot, sourcePrefix, changedFiles, listener);
- }
- }
-
- protected int countChanges(IModuleResourceDelta[] deltas) {
- IModuleResource res;
- int count = 0;
- if( deltas == null ) return 0;
- for( int i = 0; i < deltas.length; i++ ) {
- res = deltas[i].getModuleResource();
- if( res != null && res instanceof IModuleFile)
- count++;
- count += countChanges(deltas[i].getAffectedChildren());
- }
- return count;
- }
-
- protected int countConcreteFiles(IModule module) {
- PackagedModuleDelegate delegate =
(PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new
NullProgressMonitor());
- try {
- ArrayList list = new ArrayList();
- countConcreteFiles(delegate.members()[0], list);
- return list.size();
- } catch( CoreException ce ) {
-
- }
- return -1;
- }
- protected void countConcreteFiles(IModuleResource mr, ArrayList list) {
- if( mr instanceof IExtendedModuleResource) {
- IExtendedModuleResource emr = ((IExtendedModuleResource)mr);
- if( mr instanceof IModuleFile ) {
- IPath p = emr.getConcreteDestFile();
- if( !list.contains(p))
- list.add(p);
- }
- if( mr instanceof IModuleFolder) {
- IModuleResource[] children = ((IModuleFolder)mr).members();
- for( int i = 0; i < children.length; i++ )
- countConcreteFiles(children[i], list);
- }
- }
- }
-
- protected void publishFromDeltaHandle(IModuleResourceDelta delta, IPath destRoot,
- IPath sourcePrefix, ArrayList<IPath> changedFiles, PublisherFileUtilListener
listener) {
- switch( delta.getKind()) {
- case IModuleResourceDelta.REMOVED:
- // removed might not be IExtendedModuleResource
- IModuleResource imr = delta.getModuleResource();
- if( imr instanceof IExtendedModuleResource) {
- IExtendedModuleResource emr = ((IExtendedModuleResource)imr);
- IPath concrete = emr.getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- IPath destPath =
destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
-
- // file hasnt been updated yet.
- // But we don't know whether to delete or copy this file.
- // depends where it is in the tree and what's exploded.
- changedFiles.add(concrete);
- IPath concreteRelative =
concrete.removeFirstSegments(sourcePrefix.segmentCount()).setDevice(null);
- IPath emrModRelative = emr.getModuleRelativePath();
- boolean delete = concreteRelative.equals(emrModRelative);
-
- if( delete ) {
- FileUtil.safeDelete(destPath.toFile(), listener);
- } else {
- // copy
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- }
- return;
- } else {
- // TODO
- return;
- }
- case IModuleResourceDelta.ADDED:
- imr = delta.getModuleResource();
- if( imr instanceof IExtendedModuleResource) {
- IPath concrete = ((IExtendedModuleResource)imr).getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- changedFiles.add(concrete);
- IPath destPath =
destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- return;
- } else {
- // TODO
- return;
- }
- case IModuleResourceDelta.CHANGED:
- imr = delta.getModuleResource();
- if( imr instanceof ExtendedModuleFile ) {
- IPath concrete = ((ExtendedModuleFile)imr).getConcreteDestFile();
- if( !changedFiles.contains(concrete)) {
- changedFiles.add(concrete);
- IPath destPath =
destRoot.append(concrete.removeFirstSegments(sourcePrefix.segmentCount()));
- FileUtil.fileSafeCopy(concrete.toFile(), destPath.toFile(), listener);
- }
- }
- break;
- }
-
- IModuleResourceDelta[] children = delta.getAffectedChildren();
- if( children != null ) {
- for( int i = 0; i < children.length; i++ ) {
- publishFromDeltaHandle(children[i], destRoot, sourcePrefix, changedFiles, listener);
- }
- }
- }
-
- protected IArchive getPackage(IModule module) {
- PackagedModuleDelegate delegate =
(PackagedModuleDelegate)module.loadAdapter(PackagedModuleDelegate.class, new
NullProgressMonitor());
- return delegate == null ? null : delegate.getPackage();
- }
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -30,28 +30,38 @@
private IDeployableServer server;
private EventLogTreeItem root;
private int publishState = IServer.PUBLISH_STATE_NONE;
- public SingleFilePublisher(IServer server, EventLogTreeItem root) {
- this.server = ServerConverter.getDeployableServer(server);
- this.root = root;
+ public SingleFilePublisher() {
}
public int getPublishState() {
return publishState;
}
+
+ public boolean accepts(IServer server, IModule[] module) {
+ if( module != null && module.length > 0
+ && module[module.length-1] != null
+ &&
module[module.length-1].getModuleType().getId().equals("jboss.singlefile"))
+ return true;
+ return false;
+ }
- public IStatus publishModule(IModule[] module, int publishType, IProgressMonitor
monitor)
- throws CoreException {
-
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException {
+
+ this.server = ServerConverter.getDeployableServer(server);
+ this.root = log;
+
IModule module2 = module[0];
IStatus status = null;
if(publishType == REMOVE_PUBLISH){
- status = unpublish(server, module2, monitor);
+ status = unpublish(this.server, module2, monitor);
} else if( publishType == FULL_PUBLISH ){
// if there's no change, do nothing. Otherwise, on change or add,
re-publish
- status = publish(server, module2, true, monitor);
+ status = publish(this.server, module2, true, monitor);
} else if( publishType == INCREMENTAL_PUBLISH ) {
- status = publish(server, module2, false, monitor);
+ status = publish(this.server, module2, false, monitor);
}
root.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, new Integer(1));
return status;
@@ -97,9 +107,6 @@
return null;
}
- public void setDelta(IModuleResourceDelta[] delta) {
- // ignore delta
- }
public static class FileUtilListener implements IFileUtilListener {
protected EventLogTreeItem root;
@@ -128,6 +135,5 @@
EventLogModel.markChanged(root);
}
}
- };
-
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IJBossServerPublisher.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -25,7 +25,9 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
/**
*
@@ -38,8 +40,14 @@
public static final int FULL_PUBLISH = 2;
public static final int REMOVE_PUBLISH = 3;
- public IStatus publishModule(IModule[] module, int publishType,
- IProgressMonitor monitor) throws CoreException;
+ // pre-publish
+ public boolean accepts(IServer server, IModule[] module);
+
+
+ public IStatus publishModule(IServer server, IModule[] module,
+ int publishType, IModuleResourceDelta[] delta,
+ EventLogTreeItem log, IProgressMonitor monitor) throws CoreException;
+
+ // post publish
public int getPublishState();
- public void setDelta(IModuleResourceDelta[] delta);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -24,18 +24,13 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
-import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory;
-import org.jboss.ide.eclipse.as.core.publishers.JstPublisher;
-import org.jboss.ide.eclipse.as.core.publishers.NullPublisher;
-import org.jboss.ide.eclipse.as.core.publishers.PackagesPublisher;
import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher;
import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.DeployableLaunchConfiguration;
@@ -92,39 +87,30 @@
int publishType = getPublishType(kind, deltaKind, modulePublishState);
IJBossServerPublisher publisher;
-
if( module.length > 0 && publishType != IJBossServerPublisher.NO_PUBLISH) {
Integer i,j;
i = (Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_MODULE_COUNT);
publishRootEvent.setProperty(PublisherEventLogger.CHANGED_MODULE_COUNT, new Integer(i
== null ? 1 : i.intValue()+1));
PublishEvent modulePublishEvent =
PublisherEventLogger.createModuleRootEvent(publishRootEvent, module, kind, deltaKind,
modulePublishState);
- IModule lastMod = module[module.length -1];
- if( isPackagesTypeModule(lastMod) ) {
- publisher = new PackagesPublisher(getServer(), modulePublishEvent);
- } else if( lastMod.getModuleType().getId().equals("jboss.singlefile")){
- publisher = new SingleFilePublisher(getServer(), modulePublishEvent);
- } else if( lastMod.getProject() != null &&
- ModuleCoreNature.isFlexibleProject(lastMod.getProject())) {
- publisher = new JstPublisher(getServer(), modulePublishEvent);
- } else {
- publisher = new NullPublisher();
+ publisher = ExtensionManager.getDefault().getPublisher(getServer(), module);
+ if( publisher != null ) {
+ try {
+ publisher.publishModule(getServer(), module, publishType,
+ getPublishedResourceDelta(module),
+ modulePublishEvent, monitor);
+ } catch( CoreException ce ) {
+ throw ce;
+ } finally {
+ setModulePublishState(module, publisher.getPublishState());
+ }
+ // add file changed count to top level element
+ i =
(Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
+ j =
(Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
+ j = j == null ? new Integer(0) : j;
+ int count = (i == null ? 0 : i.intValue()) + j.intValue();
+ publishRootEvent.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, count);
}
- publisher.setDelta(getPublishedResourceDelta(module));
- try {
- publisher.publishModule(module, publishType, monitor);
- } catch( CoreException ce ) {
- throw ce;
- } finally {
- setModulePublishState(module, publisher.getPublishState());
- }
-
- // add file changed count to top level element
- i =
(Integer)publishRootEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j =
(Integer)modulePublishEvent.getProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT);
- j = j == null ? new Integer(0) : j;
- int count = (i == null ? 0 : i.intValue()) + j.intValue();
- publishRootEvent.setProperty(PublisherEventLogger.CHANGED_RESOURCE_COUNT, count);
}
}
@@ -141,10 +127,6 @@
return IJBossServerPublisher.NO_PUBLISH;
}
- protected boolean isPackagesTypeModule(IModule module) {
- return module.getModuleType().getId().equals(PackageModuleFactory.MODULE_TYPE);
- }
-
/*
* Change the state of the server
*/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-08-22
20:46:59 UTC (rev 9875)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-08-23
00:24:20 UTC (rev 9876)
@@ -21,15 +21,8 @@
*/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.io.IOException;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.management.ReflectionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,15 +34,12 @@
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXRunnable;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXSafeRunner;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger;
-import org.jboss.ide.eclipse.as.core.publishers.PublisherEventLogger.PublishEvent;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-08-22 20:46:59 UTC (rev
9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-08-23 00:24:20 UTC (rev
9876)
@@ -4,6 +4,7 @@
<extension-point id="pollers"
name="org.jboss.ide.eclipse.as.core.runtime.server.pollers"
schema="schema/pollers.exsd"/>
<extension-point id="pollerFailureHandler"
name="org.jboss.ide.eclipse.as.core.runtime.server.pollerFailureHandler"
schema="schema/pollerFailureHandler.exsd"/>
+ <extension-point id="publishers"
name="org.jboss.ide.eclipse.as.core.publishers"
schema="schema/publishers.exsd"/>
<extension
point="org.eclipse.wst.server.core.serverTypes">
@@ -291,14 +292,6 @@
<extension
point="org.eclipse.wst.server.core.moduleFactories">
<moduleFactory
- class="org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory"
- id="org.jboss.ide.eclipse.as.core.PackageModuleFactory"
- projects="true">
- <moduleType
- types="jboss.package"
- versions="1.0"/>
- </moduleFactory>
- <moduleFactory
class="org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory"
id="org.jboss.ide.eclipse.as.core.singledeployablefactory"
projects="false">
@@ -309,26 +302,7 @@
</moduleFactory>
</extension>
-
-
-
- <!-- Adapters and clients to make stuff 'runnable' on server -->
<extension
- point="org.eclipse.wst.server.core.moduleArtifactAdapters">
- <moduleArtifactAdapter
-
class="org.jboss.ide.eclipse.as.core.modules.PackagedArtifactAdapter"
- id="org.jboss.ide.eclipse.as.core.PackagedArtifactAdapter"
- priority="0">
- <enablement>
- <or>
- <instanceof value="org.eclipse.core.resources.IProject"/>
- <instanceof value="org.eclipse.jdt.core.IJavaProject"/>
- </or>
- </enablement>
- </moduleArtifactAdapter>
- </extension>
-
- <extension
point="org.eclipse.wst.server.core.launchableAdapters">
<launchableAdapter
class="org.jboss.ide.eclipse.as.core.server.internal.JBossLaunchAdapter"
@@ -482,29 +456,8 @@
</extension>
+
<extension
- point="org.eclipse.wst.server.core.moduleTypes">
- <moduleType
- id="jboss.package"
- name="Project Package"/>
- </extension>
-
- <extension
- point="org.jboss.ide.eclipse.archives.core.archiveTypes">
- <packageType
-
class="org.jboss.ide.eclipse.as.core.extensions.archives.WarArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.warArchive"
- label="WAR"/>
- <packageType
-
class="org.jboss.ide.eclipse.as.core.extensions.archives.EjbArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.ejbPackageType"
- label="EJB JAR"/>
- <packageType
-
class="org.jboss.ide.eclipse.as.core.extensions.archives.EarArchiveType"
- id="org.jboss.ide.eclipse.as.core.packages.earPackageType"
- label="EAR"/>
- </extension>
- <extension
point="org.eclipse.jst.j2ee.classpathdep">
<filteredClasspathContainer
containerID="org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer">
@@ -598,4 +551,19 @@
</public>
</catalogContribution>
</extension>
+ <extension
+ point="org.jboss.ide.eclipse.as.core.publishers">
+ <publisher
+ class="org.jboss.ide.eclipse.as.core.publishers.JstPublisher"
+ priority="5">
+ </publisher>
+ <publisher
+
class="org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher"
+ priority="5">
+ </publisher>
+ <publisher
+ class="org.jboss.ide.eclipse.as.core.publishers.NullPublisher"
+ priority="0">
+ </publisher>
+ </extension>
</plugin>
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd
(rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/schema/publishers.exsd 2008-08-23
00:24:20 UTC (rev 9876)
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.ide.eclipse.as.core"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.ide.eclipse.as.core"
id="publishers" name="org.jboss.ide.eclipse.as.core.publishers"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="publisher" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="publisher">
+ <complexType>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-08-22 20:46:59 UTC (rev
9875)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-08-23 00:24:20 UTC (rev
9876)
@@ -277,39 +277,6 @@
-->
<extension
- point="org.jboss.ide.eclipse.archives.ui.nodePopupMenus">
- <nodeContribution
- class="org.jboss.ide.eclipse.as.ui.packages.PublishAction"
- icon="icons/publish.gif"
- id="org.jboss.ide.eclipse.as.ui.publishNodeContextContrib"
- label="Publish To Server"
- weight="1"/>
- <nodeContribution
- class="org.jboss.ide.eclipse.as.ui.packages.EditPublishAction"
- icon="icons/publishDetails.gif"
- id="org.jboss.ide.eclipse.as.ui.modifyPublishNodeContextContrib"
- label="Edit publish settings...">
- </nodeContribution>
- </extension>
- <extension
- point="org.jboss.ide.eclipse.archives.ui.newArchiveActions">
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewWARAction"
- icon="icons/packages/war.gif"
- id="org.jboss.ide.eclipse.packages.ui.newWARAction"
- label="WAR"/>
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewEJBJARAction"
- icon="icons/packages/EJBJar.gif"
- id="org.jboss.ide.eclipse.packages.ui.newEJBJarAction"
- label="EJB JAR"/>
- <newPackageAction
- class="org.jboss.ide.eclipse.as.ui.packages.NewEARAction"
- icon="icons/packages/ear.gif"
- id="org.jboss.ide.eclipse.packages.ui.newEARAction"
- label="EAR"/>
- </extension>
- <extension
point="org.eclipse.help.contexts">
<contexts
file="InlineDocs/Twiddle/twiddleContext.xml">
Modified: trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml
===================================================================
--- trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml 2008-08-22 20:46:59 UTC
(rev 9875)
+++ trunk/core/features/org.jboss.ide.eclipse.feature/feature.xml 2008-08-23 00:24:20 UTC
(rev 9876)
@@ -499,4 +499,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.ide.eclipse.archives.webtools"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>