[jbosstools-commits] JBoss Tools SVN: r23079 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: util and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jun 29 04:26:02 EDT 2010


Author: rob.stryker at jboss.com
Date: 2010-06-29 04:26:01 -0400 (Tue, 29 Jun 2010)
New Revision: 23079

Added:
   trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java
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/util/IJBossRuntimeResourceConstants.java
Log:
JBDS-1103 - because max said so

Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java	                        (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java	2010-06-29 08:26:01 UTC (rev 23079)
@@ -0,0 +1,104 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 Red Hat, Inc. 
+ * Distributed under license by Red Hat, Inc. All rights reserved. 
+ * This program is made available under the terms of the 
+ * Eclipse Public License v1.0 which accompanies this distribution, 
+ * and is available at http://www.eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors: 
+ * Red Hat, Inc. - initial API and implementation 
+ ******************************************************************************/ 
+package org.jboss.ide.eclipse.as.core.publishers;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Date;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
+
+public class JSTPublisherXMLToucher {
+	public static JSTPublisherXMLToucher instance;
+	public static JSTPublisherXMLToucher getInstance() {
+		if( instance == null ) 
+			instance = new JSTPublisherXMLToucher();
+		return instance;
+	}
+	
+	public interface IDescriptorToucher {
+		public void touchDescriptors(IPath moduleRoot);
+	}
+	
+	public static class PathDescriptorToucher implements IDescriptorToucher {
+		private IPath[] paths;
+		// Takes relative paths
+		public PathDescriptorToucher(String s) {
+			this(new Path(s));
+		}
+		public PathDescriptorToucher(IPath p) {
+			this(new IPath[]{p});
+		}
+		public PathDescriptorToucher(IPath[] path) {
+			this.paths = path == null ? new IPath[0] : path;
+		}
+		public void touchDescriptors(IPath moduleRoot) {
+			File tmp;
+			for( int i = 0; i < paths.length; i++ ) {
+				tmp = moduleRoot.append(paths[i]).toFile();
+				if( tmp.exists())
+					tmp.setLastModified(new Date().getTime());
+			}
+		}
+	}
+ 
+	private HashMap<String, IDescriptorToucher> map;
+	
+	/**
+	 * Constructor limited
+	 * This constructor will add default touchers, but any new project type should
+	 * add their own custom behaviour or path. 
+	 */
+	JSTPublisherXMLToucher() {
+		// I know this is ugly but I don't care. it works. 
+		map = new HashMap<String, IDescriptorToucher>();
+		IJBossRuntimeResourceConstants i = new IJBossRuntimeResourceConstants(){};
+		map.put(IWTPConstants.FACET_WEB, new PathDescriptorToucher(i.DESCRIPTOR_WEB));
+		map.put(IWTPConstants.FACET_EJB, new PathDescriptorToucher(i.DESCRIPTOR_EJB));
+		map.put(IWTPConstants.FACET_EAR, new PathDescriptorToucher(i.DESCRIPTOR_EAR));
+		map.put(IWTPConstants.FACET_APP_CLIENT, new PathDescriptorToucher(i.DESCRIPTOR_CLIENT));
+		map.put(IWTPConstants.FACET_CONNECTOR, new PathDescriptorToucher(i.DESCRIPTOR_CONNECTOR));
+	}
+	
+	public void addDescriptorToucher(String typeId, IDescriptorToucher toucher) {
+		map.put(typeId, toucher);
+	}
+	
+	public void touch(IPath root, IModule module) {
+		String id = module.getModuleType().getId();
+		IDescriptorToucher toucher = map.get(id);
+		if( toucher == null )
+			defaultTouch(root);
+		else
+			toucher.touchDescriptors(root);
+	}
+	
+	
+	// Touch all XML if we don't know what we're doing
+	protected void defaultTouch(IPath deployPath) {
+		// adjust timestamps
+		FileFilter filter = new FileFilter() {
+			public boolean accept(File pathname) {
+				if( pathname.getAbsolutePath().toLowerCase().endsWith(IConstants.EXT_XML))
+					return true;
+				return false;
+			}
+		};
+		FileUtil.touch(filter, deployPath.toFile(), true);
+	}
+}

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	2010-06-29 06:05:40 UTC (rev 23078)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java	2010-06-29 08:26:01 UTC (rev 23079)
@@ -11,7 +11,6 @@
 package org.jboss.ide.eclipse.as.core.publishers;
 
 import java.io.File;
-import java.io.FileFilter;
 import java.util.ArrayList;
 import java.util.Arrays;
 
@@ -39,7 +38,6 @@
 import org.jboss.ide.eclipse.as.core.util.FileUtil;
 import org.jboss.ide.eclipse.as.core.util.FileUtil.FileUtilListener;
 import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
-import org.jboss.ide.eclipse.as.core.util.IConstants;
 import org.jboss.ide.eclipse.as.core.util.ServerConverter;
 
 /**
@@ -124,7 +122,7 @@
 			list.addAll(Arrays.asList(packModuleIntoJar(moduleTree[moduleTree.length-1], deployPath)));
 		
 
-		touchXMLFiles(deployPath);
+		touchXMLFiles(deployPath, module);
 
 		if( list.size() > 0 ) {
 			MultiStatus ms = new MultiStatus(JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_FULL_FAIL, 
@@ -140,16 +138,8 @@
 		return ret;
 	}
 	
-	private void touchXMLFiles(IPath deployPath) {
-		// adjust timestamps
-		FileFilter filter = new FileFilter() {
-			public boolean accept(File pathname) {
-				if( pathname.getAbsolutePath().toLowerCase().endsWith(IConstants.EXT_XML))
-					return true;
-				return false;
-			}
-		};
-		FileUtil.touch(filter, deployPath.toFile(), true);
+	private void touchXMLFiles(IPath deployPath, IModule module) {
+		JSTPublisherXMLToucher.getInstance().touch(deployPath, module);
 	}
 
 	protected IStatus incrementalPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
@@ -175,7 +165,7 @@
 		}
 		
 		if( handler != null && handler.shouldRestartModule() )
-			touchXMLFiles(deployPath);
+			touchXMLFiles(deployPath, module);
 
 		IStatus ret = new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, IEventCodes.JST_PUB_FULL_SUCCESS, 
 				NLS.bind(Messages.CountModifiedMembers, countChanges(delta), module.getName()), null);

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java	2010-06-29 06:05:40 UTC (rev 23078)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java	2010-06-29 08:26:01 UTC (rev 23079)
@@ -90,4 +90,10 @@
 	public static final String DEFAULT_CONFIGURATION = CONFIG_DEFAULT;
 	public static final String CONFIG_ALL = "all"; //$NON-NLS-1$
 	public static final String CONFIG_MINIMAL = "minimal"; //$NON-NLS-1$
+	
+	public static final String DESCRIPTOR_WEB = "WEB-INF/web.xml"; //$NON-NLS-1$
+	public static final String DESCRIPTOR_EJB = "META-INF/ejb-jar.xml"; //$NON-NLS-1$
+	public static final String DESCRIPTOR_EAR = "META-INF/application.xml"; //$NON-NLS-1$
+	public static final String DESCRIPTOR_CLIENT = "META-INF/application-client.xml"; //$NON-NLS-1$
+	public static final String DESCRIPTOR_CONNECTOR = "META-INF/ra.xml"; //$NON-NLS-1$
 }



More information about the jbosstools-commits mailing list