[jboss-cvs] jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module ...

Robert Stryker rawblem at gmail.com
Thu Nov 9 23:28:01 EST 2006


  User: rawb    
  Date: 06/11/09 23:28:01

  Modified:    as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module      
                        JBossModuleFactory.java ArchiveModuleFactory.java
  Added:       as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module      
                        XMLModuleFactory.java
                        JBossModuleArtifactAdapter.java
                        PathModuleFactory.java
  Removed:     as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module      
                        ArchiveModuleArtifactAdapter.java
  Log:
  Added xml module factory
  
  Revision  Changes    Path
  1.2       +5 -0      jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/JBossModuleFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JBossModuleFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/JBossModuleFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- JBossModuleFactory.java	10 Nov 2006 00:26:26 -0000	1.1
  +++ JBossModuleFactory.java	10 Nov 2006 04:28:01 -0000	1.2
  @@ -34,10 +34,13 @@
   import org.eclipse.core.resources.IResourceDeltaVisitor;
   import org.eclipse.core.resources.ResourcesPlugin;
   import org.eclipse.core.runtime.CoreException;
  +import org.eclipse.core.runtime.NullProgressMonitor;
   import org.eclipse.wst.server.core.IModule;
   import org.eclipse.wst.server.core.IServer;
   import org.eclipse.wst.server.core.ServerCore;
  +import org.eclipse.wst.server.core.internal.ModuleFactory;
   import org.eclipse.wst.server.core.internal.Server;
  +import org.eclipse.wst.server.core.internal.ServerPlugin;
   import org.eclipse.wst.server.core.model.ModuleDelegate;
   import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
   import org.jboss.ide.eclipse.as.core.JBossServerCore;
  @@ -46,6 +49,8 @@
   
   public abstract class JBossModuleFactory extends ModuleFactoryDelegate {
   	
  +	
  +
   	public static final String NO_LOCATION = "__NO_LOCATION__";
   	
   	protected HashMap pathToModule = null;
  
  
  
  1.2       +13 -48    jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/ArchiveModuleFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ArchiveModuleFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/ArchiveModuleFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ArchiveModuleFactory.java	10 Nov 2006 00:26:26 -0000	1.1
  +++ ArchiveModuleFactory.java	10 Nov 2006 04:28:01 -0000	1.2
  @@ -27,14 +27,17 @@
   
   import org.eclipse.core.runtime.CoreException;
   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.ServerCore;
  +import org.eclipse.wst.server.core.internal.ModuleFactory;
   import org.eclipse.wst.server.core.internal.ServerPlugin;
   import org.eclipse.wst.server.core.model.IModuleResource;
   import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
   
  -public class ArchiveModuleFactory extends JBossModuleFactory {
  +public class ArchiveModuleFactory extends PathModuleFactory {
   	
   	private static String GENERIC_JAR = "jboss.archive";
   	private static String VERSION = "1.0";
  @@ -43,41 +46,14 @@
   
   	private static ArchiveModuleFactory factory;
   	public static ArchiveModuleFactory getDefault() {
  +		if( factory == null ) {
  +			factory = (ArchiveModuleFactory)PathModuleFactory.getDefaultInstance(FACTORY_ID);
  +		}
   		return factory;
   	}
   	
   	public ArchiveModuleFactory() {
  -		factory = this;
  -	}
  -
  -	public void initialize() {
  -	}
  -
  -	protected IModule acceptAddition(String path) {
  -		if( !supports(path)) 
  -			return null;
  -
  -		// otherwise create the module
  -		//String path = getPath(resource);
  -		String name = new Path(path).lastSegment();
  -		IModule module = createModule(path, name, 
  -				GENERIC_JAR, VERSION, null);
  -		
  -		
  -		ArchiveModuleDelegate delegate = new ArchiveModuleDelegate();
  -		delegate.initialize(module);
  -		delegate.setResourcePath(path);
  -		delegate.setFactory(this);
  -		
  -		// and insert it
  -		pathToModule.put(path, module);
  -		moduleToDelegate.put(module, delegate);
  -		
  -		// ensure the factory clears its cache
  -		clearModuleCache();
  -		
  -		return module;	
  -		
  +		super();
   	}
   
   	public boolean supports(String path) {
  @@ -90,22 +66,11 @@
   		return false;
   	}
   	
  -	
  -	public class ArchiveModuleDelegate extends JBossModuleDelegate {
  -		public IModule[] getChildModules() {
  -			return null;
  +	public String getModuleType(String path) {
  +		return GENERIC_JAR;
   		}
   
  -		public void initialize() {
  -		}
  -
  -		public IStatus validate() {
  -			return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, 
  -					0, "Deployment is valid", null);
  -		}
  -
  -		public IModuleResource[] members() throws CoreException {
  -			return new IModuleResource[0];
  -		}
  +	public String getModuleVersion(String path) {
  +		return VERSION;
   	}
   }
  
  
  
  1.1      date: 2006/11/10 04:28:01;  author: rawb;  state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/XMLModuleFactory.java
  
  Index: XMLModuleFactory.java
  ===================================================================
  package org.jboss.ide.eclipse.as.core.module;
  
  
  public class XMLModuleFactory extends PathModuleFactory {
  
  	private static String XML_FILE = "jboss.xml";
  	private static String VERSION = "1.0";
  	
  	public static final String FACTORY_ID = "org.jboss.ide.eclipse.as.core.XMLFactory";
  
  	private static XMLModuleFactory factory;
  	public static XMLModuleFactory getDefault() {
  		if( factory == null ) {
  			factory = (XMLModuleFactory)PathModuleFactory.getDefaultInstance(FACTORY_ID);
  		}
  		return factory;
  	}
  
  	public boolean supports(String path) {
  		if( path.endsWith(".xml"))
  			return true;
  		return false;
  	}
  	
  	public String getModuleType(String path) {
  		return XML_FILE;
  	}
  
  	public String getModuleVersion(String path) {
  		return VERSION;
  	}
  
  	
  }
  
  
  
  1.1      date: 2006/11/10 04:28:01;  author: rawb;  state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/JBossModuleArtifactAdapter.java
  
  Index: JBossModuleArtifactAdapter.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, JBoss Inc., 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.module;
  
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.runtime.NullProgressMonitor;
  import org.eclipse.wst.server.core.IModule;
  import org.eclipse.wst.server.core.IModuleArtifact;
  import org.eclipse.wst.server.core.internal.ModuleFactory;
  import org.eclipse.wst.server.core.internal.ServerPlugin;
  import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate;
  import org.jboss.ide.eclipse.as.core.JBossServerCore;
  
  public class JBossModuleArtifactAdapter extends ModuleArtifactAdapterDelegate {
  	public IModuleArtifact getModuleArtifact(Object obj) {
  		if( obj instanceof IResource ) {
  			IResource res = (IResource)obj;
  			
  			ModuleFactory[] mfs = JBossServerCore.getJBossModuleFactories();
  			IModule mod = null;
  			for( int i = 0; i < mfs.length && mod == null; i++ ) {
  				if( getDelegate(mfs[i]) != null && getDelegate(mfs[i]).supports(res)) {
  					mod = getDelegate(mfs[i]).getModule(res);
  				}
  			}
  			if( mod != null )
  				return new JBossModuleArtifact(mod);
  		}
  		return null;
  	}
  	
  	protected JBossModuleFactory getDelegate(ModuleFactory mf) {
  		return (JBossModuleFactory) mf.getDelegate(new NullProgressMonitor());
  	}
  	
  	public static class JBossModuleArtifact implements IModuleArtifact {
  		private IModule module;
  		public JBossModuleArtifact(IModule module) {
  			this.module = module;
  		}
  		public IModule getModule() {
  			return this.module;
  		}
  	}
  	
  }
  
  
  1.1      date: 2006/11/10 04:28:01;  author: rawb;  state: Exp;jbosside/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/module/PathModuleFactory.java
  
  Index: PathModuleFactory.java
  ===================================================================
  /**
   * 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.module;
  
  import org.eclipse.core.runtime.CoreException;
  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.IModuleResource;
  import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
  
  /**
   *
   * @author rob.stryker at jboss.com
   */
  public abstract class PathModuleFactory extends JBossModuleFactory {
  	
  	public static JBossModuleFactory getDefaultInstance(String type) {
  		ModuleFactory[] factories = ServerPlugin.getModuleFactories(); // just make sure they're loaded
  		for( int i = 0; i < factories.length; i++ ) {
  			if( factories[i].getId().equals(type)) {
  				return (ArchiveModuleFactory)factories[i].getDelegate(new NullProgressMonitor());
  			}
  		}
  		return null;
  	}
  	
  	public void initialize() {
  	}
  
  	protected IModule acceptAddition(String path) {
  		if( !supports(path)) 
  			return null;
  
  		// otherwise create the module
  		String name = new Path(path).lastSegment();
  		IModule module = createModule(path, name, 
  				getModuleType(path), getModuleVersion(path), null);
  		
  		
  		PathModuleDelegate delegate = new PathModuleDelegate();
  		delegate.initialize(module);
  		delegate.setResourcePath(path);
  		delegate.setFactory(this);
  		
  		// and insert it
  		pathToModule.put(path, module);
  		moduleToDelegate.put(module, delegate);
  		
  		// ensure the factory clears its cache
  		clearModuleCache();
  		
  		return module;	
  	}
  	
  	public abstract String getModuleType(String path);
  	public abstract String getModuleVersion(String path);
  	
  
  	public boolean supports(String path) {
  		return false;
  	}
  	
  	
  	public class PathModuleDelegate extends JBossModuleDelegate {
  		public IModule[] getChildModules() {
  			return null;
  		}
  
  		public void initialize() {
  		}
  
  		public IStatus validate() {
  			return new Status(IStatus.OK, JBossServerCorePlugin.PLUGIN_ID, 
  					0, "valid", null);
  		}
  
  		public IModuleResource[] members() throws CoreException {
  			return new IModuleResource[0];
  		}
  	}
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list