[jbosstools-commits] JBoss Tools SVN: r23080 - in branches/jbosstools-3.1.x/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:29:45 EDT 2010


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

Added:
   branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java
Modified:
   branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
   branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java
Log:
JBDS-1103 - because max said (branch)

Added: branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java
===================================================================
--- branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java	                        (rev 0)
+++ branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JSTPublisherXMLToucher.java	2010-06-29 08:29:44 UTC (rev 23080)
@@ -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: branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- branches/jbosstools-3.1.x/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)
+++ branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java	2010-06-29 08:29:44 UTC (rev 23080)
@@ -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;
 
@@ -125,7 +124,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, 
@@ -141,16 +140,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 {
@@ -176,7 +167,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: branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java
===================================================================
--- branches/jbosstools-3.1.x/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)
+++ branches/jbosstools-3.1.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossRuntimeResourceConstants.java	2010-06-29 08:29:44 UTC (rev 23080)
@@ -89,4 +89,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