[jboss-cvs] jboss-seam-tools/src/org/jboss/seam/tools ...

Thomas Heute theute at jboss.com
Tue Aug 8 07:33:12 EDT 2006


  User: theute  
  Date: 06/08/08 07:33:12

  Modified:    src/org/jboss/seam/tools            EarProject.java
                        Project.java WebProject.java EjbProject.java
                        UtilityJar.java
  Added:       src/org/jboss/seam/tools            Util.java
                        RootProject.java Structure.java
  Removed:     src/org/jboss/seam/tools            InputParameters.java
                        SeamProject.java Context.java
  Log:
   - WTP and Maven support
   - Legal headers
   - Moved the templates
  
  Revision  Changes    Path
  1.2       +38 -91    jboss-seam-tools/src/org/jboss/seam/tools/EarProject.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EarProject.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/EarProject.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- EarProject.java	19 Jul 2006 16:11:33 -0000	1.1
  +++ EarProject.java	8 Aug 2006 11:33:12 -0000	1.2
  @@ -1,55 +1,51 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, 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.seam.tools;
   
  -import java.io.File;
   import java.util.ArrayList;
   import java.util.List;
   
  -import org.jboss.seam.tools.exception.GenerationException;
  -import org.jboss.seam.tools.freemarker.ConfigurationFactory;
  -import org.jboss.seam.tools.freemarker.EarHashModel;
  -import org.jboss.seam.tools.freemarker.TemplateProcessor;
  -
  -import freemarker.template.Configuration;
  -import freemarker.template.TemplateHashModel;
  +import org.jboss.seam.tools.contexts.EarContext;
   
  +/**
  + * Common structure for EAR projects
  + * 
  + * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  + * @version <tt>$Revision: 1.2 $</tt>
  + */
   public abstract class EarProject extends Project {
   
  -	private String contentDirectory;
  -	
  -	private File outputLocation;
  +	private EarContext earContext;
   	
  -	private String displayName;
  +	private RootProject rootProject;
   	
   	private List<UtilityJar> utilityJars = new ArrayList<UtilityJar>();
   	
  -	private List<EjbProject> ejbProjects = new ArrayList<EjbProject>();
  -	
  -	private List<WebProject> webProjects = new ArrayList<WebProject>();
  -
  -	public List<EjbProject> getEjbProjects() {
  -		return ejbProjects;
  -	}
  -
  -	public void setEjbProjects(List<EjbProject> ejbProjects) {
  -		this.ejbProjects = ejbProjects;
  -	}
  -	
  -	public void addEjbProject(EjbProject ejbProject)
  -	{
  -		ejbProjects.add(ejbProject);
  +	public EarContext getEarContext() {
  +		return earContext;
   	}
   
  -	public List<WebProject> getWebProjects() {
  -		return webProjects;
  -	}
  -
  -	public void setWebProjects(List<WebProject> webProjects) {
  -		this.webProjects = webProjects;
  -	}
  -	
  -	public void addWebProject(WebProject webProject)
  -	{
  -		webProjects.add(webProject);
  +	public void setEarContext(EarContext earContext) {
  +		this.earContext = earContext;
   	}
   
   	public List<UtilityJar> getUtilityJars() {
  @@ -64,61 +60,12 @@
   		utilityJars.add(utilityJar);
   	}
   	
  -	public String getContentDirectory() {
  -		return contentDirectory;
  -	}
  -
  -	public void setContentDirectory(String contentDirectory) {
  -		this.contentDirectory = contentDirectory;
  -	}
  -	
  -	public File getOutputLocation() {
  -		return outputLocation;
  +	public RootProject getRootProject() {
  +		return rootProject;
   	}
   
  -	public void setOutputLocation(File outputLocation) {
  -		this.outputLocation = outputLocation;
  +	public void setRootProject(RootProject rootProject) {
  +		this.rootProject = rootProject;
   	}
   	
  -	public String getDisplayName() {
  -		return displayName;
  -	}
  -
  -	public void setDisplayName(String displayName) {
  -		this.displayName = displayName;
  -	}
  -
  -	public void generate(Context context) throws GenerationException
  -	{
  -		// Create outputLocation directory
  -		String outputDirectoryPath = outputLocation.getAbsolutePath();
  -		boolean created = outputLocation.mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + outputDirectoryPath);
  -		
  -		// Create contentLocation directory
  -		String contentDirectoryPath = outputDirectoryPath + File.separatorChar + contentDirectory;
  -		created = new File(contentDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + contentDirectoryPath);
  -		
  -		// Create META-INF directory
  -		String metainfDirectory = contentDirectoryPath + File.separatorChar + "META-INF";
  -		created = new File(metainfDirectory).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + metainfDirectory);
  -		
  -		Configuration cfg = ConfigurationFactory.getConfiguration();
  -		
  -		TemplateHashModel earHash = new EarHashModel(this, context);
  -		
  -		// Process WebContent/META-INF/application.xml
  -		File file = new File(metainfDirectory + File.separatorChar + "application.xml");
  -		TemplateProcessor.process(cfg, "ear/application.xml.ftl", earHash, file);
  -		
  -		// Process WebContent/META-INF/jboss-app.xml
  -		file = new File(metainfDirectory + File.separatorChar + "jboss-app.xml");
  -		TemplateProcessor.process(cfg, "ear/jboss-app.xml.ftl", earHash, file);
  -		
  -	}
  -	
  -
  -
   }
  
  
  
  1.2       +31 -1     jboss-seam-tools/src/org/jboss/seam/tools/Project.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Project.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/Project.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Project.java	19 Jul 2006 16:11:33 -0000	1.1
  +++ Project.java	8 Aug 2006 11:33:12 -0000	1.2
  @@ -1,8 +1,38 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, 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.seam.tools;
   
  +import java.io.IOException;
  +
  +import org.jboss.seam.tools.contexts.Context;
   import org.jboss.seam.tools.exception.GenerationException;
   import org.jboss.seam.tools.exception.InvalidNameException;
   
  +/**
  + * Common structure for any project
  + * 
  + * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  + * @version <tt>$Revision: 1.2 $</tt>
  + */
   public abstract class Project {
   
   	private String projectName;
  @@ -51,7 +81,7 @@
   		return true;
   	}
   
  -	public abstract void generate(Context context) throws GenerationException;
  +	public abstract void generate(Context context) throws GenerationException, IOException;
   	
   	
   }
  
  
  
  1.3       +109 -74   jboss-seam-tools/src/org/jboss/seam/tools/WebProject.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WebProject.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/WebProject.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- WebProject.java	24 Jul 2006 15:00:23 -0000	1.2
  +++ WebProject.java	8 Aug 2006 11:33:12 -0000	1.3
  @@ -1,86 +1,143 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, 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.seam.tools;
   
   import java.io.File;
  +import java.io.IOException;
   
  +import org.jboss.seam.tools.contexts.Context;
  +import org.jboss.seam.tools.contexts.WebContext;
   import org.jboss.seam.tools.exception.GenerationException;
   import org.jboss.seam.tools.freemarker.ConfigurationFactory;
   import org.jboss.seam.tools.freemarker.TemplateProcessor;
  -import org.jboss.seam.tools.freemarker.WebHashModel;
   
   import freemarker.template.Configuration;
   import freemarker.template.TemplateHashModel;
   
  +/**
  + * Common structure for Web projects
  + * 
  + * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  + * @version <tt>$Revision: 1.3 $</tt>
  + */
   public abstract class WebProject extends Project {
   
  -	private String id;
  +	protected WebContext webContext;
   	
  -	private String contextRoot;
  +	protected RootProject rootProject;
   	
  -	private String outputLocation;
  -	
  -	private String contentDirectory;
  -	
  -	public String getId() {
  -		return id;
  +	public WebContext getWebContext() {
  +		return webContext;
   	}
   
  -	public void setId(String id) {
  -		this.id = id;
  +	public void setWebContext(WebContext webContext) {
  +		this.webContext = webContext;
   	}
   
  -	public String getContextRoot() {
  -		return contextRoot;
  -	}
   
  -	public void setContextRoot(String contextRoot) {
  -		this.contextRoot = contextRoot;
  +	public void copyBasicProject(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  +	{
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
  +		
  +		// Process index.html
  +		File file = new File(destDir + File.separatorChar + "index.html");
  +		TemplateProcessor.process(cfg, "basic/index.html.ftl", ejbHash, file);
  +
  +		// Process register.jsp
  +		file = new File(destDir + File.separatorChar + "register." + context.getJsfExtension());
  +		TemplateProcessor.process(cfg, "basic/register.jsp.ftl", ejbHash, file);
  +
  +		// Process registered.jsp
  +		file = new File(destDir + File.separatorChar + "registered." + context.getJsfExtension());
  +		TemplateProcessor.process(cfg, "basic/registered.jsp.ftl", ejbHash, file);
   	}
   	
  -	public String getOutputLocation() {
  -		return outputLocation;
  +	public void copyLibs(Context context) throws GenerationException
  +	{
  +		String dstDir = webContext.getOutputLocation() + File.separatorChar + webContext.getContentDirectory() + File.separatorChar + "WEB-INF" + File.separatorChar + "lib" + File.separatorChar;
  +		
  +		File src = new File(context.getSeamLocation() + File.separatorChar + "jboss-seam-ui.jar");
  +		File dst = new File(dstDir + "jboss-seam-ui.jar");
  +		try {
  +			Util.copy(src, dst);
  +		} catch (IOException e) {
  +			throw new GenerationException("Cannot copy:" + src.getAbsolutePath() + " to " + dst.getAbsolutePath());
   	}
   
  -	public void setOutputLocation(String outputLocation) {
  -		this.outputLocation = outputLocation;
  +		src = new File(context.getSeamLocation() + File.separatorChar + "jboss-seam-debug.jar");
  +		dst = new File(dstDir + "jboss-seam-debug.jar");
  +		try {
  +			Util.copy(src, dst);
  +		} catch (IOException e) {
  +			throw new GenerationException("Cannot copy:" + src.getAbsolutePath() + " to " + dst.getAbsolutePath());
   	}
   
  -	public String getContentDirectory() {
  -		return contentDirectory;
  +		if (context.isFaceletsSupport())
  +		{
  +			src = new File(context.getSeamLocation() + File.separatorChar + "facelets" + File.separatorChar + "lib" + File.separatorChar + "el-api.jar");
  +			dst = new File(dstDir + "el-api.jar");
  +
  +			try {
  +				Util.copy(src, dst);
  +			} catch (IOException e) {
  +				throw new GenerationException("Cannot copy:" + src.getAbsolutePath() + " to " + dst.getAbsolutePath());
   	}
   
  -	public void setContentDirectory(String contentDirectory) {
  -		this.contentDirectory = contentDirectory;
  +			src = new File(context.getSeamLocation() + File.separatorChar + "facelets" + File.separatorChar + "lib" + File.separatorChar + "el-ri.jar");
  +			dst = new File(dstDir + "el-ri.jar");
  +
  +			try {
  +				Util.copy(src, dst);
  +			} catch (IOException e) {
  +				throw new GenerationException("Cannot copy:" + src.getAbsolutePath() + " to " + dst.getAbsolutePath());
   	}
   
  -	public void generate(Context context) throws GenerationException
  -	{
  -		boolean created = new File(outputLocation).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + outputLocation);
  +			src = new File(context.getSeamLocation() + File.separatorChar + "facelets" + File.separatorChar + "lib" + File.separatorChar + "jsf-facelets.jar");
  +			dst = new File(dstDir + "jsf-facelets.jar");
   	
  +			try {
  +				Util.copy(src, dst);
  +			} catch (IOException e) {
  +				throw new GenerationException("Cannot copy:" + src.getAbsolutePath() + " to " + dst.getAbsolutePath());
  +			}
   
  -		// Create contentLocation directory
  -		String contentDirectoryPath = outputLocation + File.separatorChar + contentDirectory;
  -		created = new File(contentDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + contentDirectoryPath);
  -
  -		// Create src directory
  -		String srcDirectoryPath = outputLocation + File.separatorChar + "src";
  -		created = new File(srcDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + srcDirectoryPath);
  +		}
  +	}
   		
  -		// Create WEB-INF directory
  -		String webinfDirectoryPath = contentDirectoryPath + File.separatorChar + "WEB-INF";
  -		created = new File(webinfDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + webinfDirectoryPath);
  -		
  -		// Create WEB-INF/lib directory
  -		String webinfLibDirectoryPath = webinfDirectoryPath + File.separatorChar + "lib";
  -		created = new File(webinfLibDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + webinfLibDirectoryPath);
  +	public RootProject getRootProject() {
  +		return rootProject;
  +	}
  +
  +	public void setRootProject(RootProject rootProject) {
  +		this.rootProject = rootProject;
  +	}
   		
  +	protected void createWebInf(String directory, TemplateHashModel webHash) throws IOException, GenerationException
  +	{
   		Configuration cfg = ConfigurationFactory.getConfiguration();
   		
  -		TemplateHashModel webHash = new WebHashModel(this, context);
  +		// Create WEB-INF directory
  +		String webinfDirectoryPath = directory + File.separatorChar + "WEB-INF";
  +		Util.createDirectory(webinfDirectoryPath);
   		
   		// Process WEB-INF/components.xml
   		File file = new File(webinfDirectoryPath + File.separatorChar + "components.xml");
  @@ -98,28 +155,6 @@
   		file = new File(webinfDirectoryPath + File.separatorChar + "web.xml");
   		TemplateProcessor.process(cfg, "web/web.xml.ftl", webHash, file);
   		
  -		if (context.isBasicProject())
  -		{
  -			copyBasicProject(contentDirectoryPath, webHash, context);
  -		}
  -	}
  -	
  -	public void copyBasicProject(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  -	{
  -		Configuration cfg = ConfigurationFactory.getConfiguration();
  -		
  -		// Process index.html
  -		File file = new File(destDir + File.separatorChar + "index.html");
  -		TemplateProcessor.process(cfg, "basic/index.html.ftl", ejbHash, file);
  -
  -		// Process register.jsp
  -		file = new File(destDir + File.separatorChar + "register." + context.getJsfExtension());
  -		TemplateProcessor.process(cfg, "basic/register.jsp.ftl", ejbHash, file);
  -
  -		// Process registered.jsp
  -		file = new File(destDir + File.separatorChar + "registered." + context.getJsfExtension());
  -		TemplateProcessor.process(cfg, "basic/registered.jsp.ftl", ejbHash, file);
  -
   	
   	}
   }
  
  
  
  1.3       +126 -99   jboss-seam-tools/src/org/jboss/seam/tools/EjbProject.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EjbProject.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/EjbProject.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- EjbProject.java	24 Jul 2006 15:00:23 -0000	1.2
  +++ EjbProject.java	8 Aug 2006 11:33:12 -0000	1.3
  @@ -1,150 +1,177 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, 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.seam.tools;
   
   import java.io.File;
  +import java.io.IOException;
   
  +import org.jboss.seam.tools.contexts.Context;
  +import org.jboss.seam.tools.contexts.EjbContext;
   import org.jboss.seam.tools.exception.GenerationException;
   import org.jboss.seam.tools.freemarker.ConfigurationFactory;
  -import org.jboss.seam.tools.freemarker.EjbHashModel;
   import org.jboss.seam.tools.freemarker.TemplateProcessor;
   
   import freemarker.template.Configuration;
   import freemarker.template.TemplateHashModel;
   
  +/**
  + * Common structure for EJB projects
  + * 
  + * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  + * @version <tt>$Revision: 1.3 $</tt>
  + */
   public abstract class EjbProject extends Project {
   
  -	private String id;
  +	protected EjbContext ejbContext;
   	
  -	private String outputLocation;
  +	private RootProject rootProject;
   	
  -	private String contentDirectory;
  -
  -	private String persistenceUnitName;
  +	public EjbContext getEjbContext() {
  +		return ejbContext;
  +	}
   
  -	private String jtaDataSource;
  +	public void setEjbContext(EjbContext ejbContext) {
  +		this.ejbContext = ejbContext;
  +	}
   	
  -	private EarProject earProject;
  +	public void createBasicProjectMainSources(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  +	{
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
   
  -	public String getId() {
  -		return id;
  -	}
  +		// Create src package directory
  +		String srcPackageDir = destDir + File.separatorChar + "org" + File.separatorChar + "jboss" + File.separatorChar + "seam"; 
  +		File file = new File(srcPackageDir);
  +		file.mkdirs();
   
  -	public void setId(String id) {
  -		this.id = id;
  -	}
  +		// Process Register.java
  +		file = new File(srcPackageDir + File.separatorChar + "Register.java");
  +		TemplateProcessor.process(cfg, "basic/Register.java.ftl", ejbHash, file);
   
  -	public String getOutputLocation() {
  -		return outputLocation;
  -	}
  +		// Process RegisterAction.java
  +		file = new File(srcPackageDir + File.separatorChar + "RegisterAction.java");
  +		TemplateProcessor.process(cfg, "basic/RegisterAction.java.ftl", ejbHash, file);
   
  -	public void setOutputLocation(String outputLocation) {
  -		this.outputLocation = outputLocation;
  +		// Process User.java
  +		file = new File(srcPackageDir + File.separatorChar + "User.java");
  +		TemplateProcessor.process(cfg, "basic/User.java.ftl", ejbHash, file);
   	}
   
  -	public String getContentDirectory() {
  -		return contentDirectory;
  -	}
  +	public void createBasicProjectTestSources(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  +	{
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
   
  -	public void setContentDirectory(String contentDirectory) {
  -		this.contentDirectory = contentDirectory;
  -	}
  +		// Create src package directory
  +		String srcPackageDir = destDir + File.separatorChar + "org" + File.separatorChar + "jboss" + File.separatorChar + "seam"; 
  +		File file = new File(srcPackageDir);
  +		file.mkdirs();
   
  +		// Process RegisterTest.java
  +		file = new File(srcPackageDir + File.separatorChar + "RegisterTest.java");
  +		TemplateProcessor.process(cfg, "basic/RegisterTest.java.ftl", ejbHash, file);
   	
  -	public String getPersistenceUnitName() {
  -		return persistenceUnitName;
   	}
   
  -	public void setPersistenceUnitName(String persistenceUnitName) {
  -		this.persistenceUnitName = persistenceUnitName;
  -	}
  +	public void createBasicProjectTestResources(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  +	{
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
   
  -	public String getJtaDataSource() {
  -		return jtaDataSource;
  +		// Process testng.xml
  +		File file = new File(destDir + File.separatorChar + "testng.xml");
  +		TemplateProcessor.process(cfg, "basic/testng.xml.ftl", ejbHash, file);
   	}
   
  -	public void setJtaDataSource(String jtaDataSource) {
  -		this.jtaDataSource = jtaDataSource;
  -	}
   	
  -	public void generate(Context context) throws GenerationException
  +	public void createTestSupport(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
   	{
  -		boolean created = new File(outputLocation).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + outputLocation);
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
   	
  -		// Create contentLocation directory
  -		String contentDirectoryPath = outputLocation + File.separatorChar + contentDirectory;
  -		created = new File(contentDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + contentDirectoryPath);
  -	
  -		// Create lib directory
  -		String libDirectoryPath = outputLocation + File.separatorChar + "lib";
  -		created = new File(libDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + libDirectoryPath);
  +		// Create confTest/WEB-INF directory
  +		String webInfTestDir = destDir + File.separatorChar + "WEB-INF"; 
  +		File file = new File(webInfTestDir);
  +		file.mkdirs();
   
  -		// Create META-INF directory
  -		String metainfDirectoryPath = contentDirectoryPath + File.separatorChar + "META-INF";
  -		created = new File(metainfDirectoryPath).mkdirs();
  -		if (!created) throw new GenerationException("Could not create directory: " + metainfDirectoryPath);
  +		// Process components.properties
  +		file = new File(destDir + File.separatorChar + "components.properties");
  +		TemplateProcessor.process(cfg, "test/components.properties.ftl", ejbHash, file);
   		
  -		Configuration cfg = ConfigurationFactory.getConfiguration();
  +		// Process components.xml
  +		file = new File(webInfTestDir + File.separatorChar + "components.xml");
  +		TemplateProcessor.process(cfg, "test/components.xml.ftl", ejbHash, file);
   		
  -		TemplateHashModel ejbHash = new EjbHashModel(this, context);
  +		// Process default.persistence.properties
  +		file = new File(destDir + File.separatorChar + "default.persistence.properties");
  +		TemplateProcessor.process(cfg, "test/default.persistence.properties.ftl", ejbHash, file);
   		
  -		// Process META-INF/ejb-jar.xml
  -		File file = new File(metainfDirectoryPath + File.separatorChar + "ejb-jar.xml");
  -		TemplateProcessor.process(cfg, "ejb/ejb-jar.xml.ftl", ejbHash, file);
  +		// Process ejb3-interceptors-aop.xml
  +		file = new File(destDir + File.separatorChar + "ejb3-interceptors-aop.xml");
  +		TemplateProcessor.process(cfg, "test/ejb3-interceptors-aop.xml.ftl", ejbHash, file);
   
  -		// Process META-INF/persistence.xml
  -		file = new File(metainfDirectoryPath + File.separatorChar + "persistence.xml");
  -		TemplateProcessor.process(cfg, "ejb/persistence.xml.ftl", ejbHash, file);
  +		// Process embedded-jboss-beans.xml
  +		file = new File(destDir + File.separatorChar + "embedded-jboss-beans.xml");
  +		TemplateProcessor.process(cfg, "test/embedded-jboss-beans.xml.ftl", ejbHash, file);
   
  -		// Process seam.properties
  -		file = new File(contentDirectoryPath + File.separatorChar + "seam.properties");
  -		TemplateProcessor.process(cfg, "ejb/seam.properties.ftl", ejbHash, file);
  +		// Process jboss-jms-beans.xml
  +		file = new File(destDir + File.separatorChar + "jboss-jms-beans.xml");
  +		TemplateProcessor.process(cfg, "test/jboss-jms-beans.xml.ftl", ejbHash, file);
   
  -		if (context.isBasicProject())
  -		{
  -			copyBasicProject(contentDirectoryPath, ejbHash, context);
  -		}
  +		// Process jndi.properties
  +		file = new File(destDir + File.separatorChar + "jndi.properties");
  +		TemplateProcessor.process(cfg, "test/jndi.properties.ftl", ejbHash, file);
  +
  +		// Process log4j.xml
  +		file = new File(destDir + File.separatorChar + "log4j.xml");
  +		TemplateProcessor.process(cfg, "test/log4j.xml.ftl", ejbHash, file);
   	}
   	
  -	public void copyBasicProject(String destDir, TemplateHashModel ejbHash, Context context) throws GenerationException
  -	{
  -		Configuration cfg = ConfigurationFactory.getConfiguration();
  +	public RootProject getRootProject() {
  +		return rootProject;
  +	}
   		
  -		// Create src package directory
  -		String srcPackageDir = destDir + File.separatorChar + "org" + File.separatorChar + "jboss" + File.separatorChar + "seam"; 
  -		File file = new File(srcPackageDir);
  -		file.mkdirs();
  +	public void setRootProject(RootProject rootProject) {
  +		this.rootProject = rootProject;
  +	}
   		
  -		// Create test package directory
  -		String testPackageDir = destDir + File.separatorChar + "org" + File.separatorChar + "jboss" + File.separatorChar + "seam"  + File.separatorChar + "test"; 
  -		file = new File(testPackageDir);
  -		file.mkdirs();
   
  -		// Process Register.java
  -		file = new File(srcPackageDir + File.separatorChar + "Register.java");
  -		TemplateProcessor.process(cfg, "basic/Register.java.ftl", ejbHash, file);
  +	public void createResources(String directory, TemplateHashModel ejbHash) throws IOException, GenerationException
  +	{
  +		Configuration cfg = ConfigurationFactory.getConfiguration();
   
  +		// Create META-INF directory
  +		String metainfDirectoryPath = directory + File.separatorChar + "META-INF";
  +		Util.createDirectory(metainfDirectoryPath);
   		
  -		// Process RegisterTest.java
  -		file = new File(testPackageDir + File.separatorChar + "RegisterTest.java");
  -		TemplateProcessor.process(cfg, "basic/RegisterTest.java.ftl", ejbHash, file);
   		
  +		// Process META-INF/ejb-jar.xml
  +		File file = new File(metainfDirectoryPath + File.separatorChar + "ejb-jar.xml");
  +		TemplateProcessor.process(cfg, "ejb/ejb-jar.xml.ftl", ejbHash, file);
   		
  -		// Process RegisterAction.java
  -		file = new File(srcPackageDir + File.separatorChar + "RegisterAction.java");
  -		TemplateProcessor.process(cfg, "basic/RegisterAction.java.ftl", ejbHash, file);
  +		// Process META-INF/persistence.xml
  +		file = new File(metainfDirectoryPath + File.separatorChar + "persistence.xml");
  +		TemplateProcessor.process(cfg, "ejb/persistence.xml.ftl", ejbHash, file);
   
  -		// Process User.java
  -		file = new File(srcPackageDir + File.separatorChar + "User.java");
  -		TemplateProcessor.process(cfg, "basic/User.java.ftl", ejbHash, file);
  -	}
  +		// Process seam.properties
  +		file = new File(directory + File.separatorChar + "seam.properties");
  +		TemplateProcessor.process(cfg, "ejb/seam.properties.ftl", ejbHash, file);
   
  -	public EarProject getEarProject() {
  -		return earProject;
   	}
   
  -	public void setEarProject(EarProject earProject) {
  -		this.earProject = earProject;
  -	}
   }
  
  
  
  1.2       +25 -0     jboss-seam-tools/src/org/jboss/seam/tools/UtilityJar.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UtilityJar.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam-tools/src/org/jboss/seam/tools/UtilityJar.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- UtilityJar.java	19 Jul 2006 16:11:33 -0000	1.1
  +++ UtilityJar.java	8 Aug 2006 11:33:12 -0000	1.2
  @@ -1,5 +1,30 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + * Copyright 2005, 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.seam.tools;
   
  +/**
  + * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  + * @version <tt>$Revision: 1.2 $</tt>
  + */
   public class UtilityJar {
   
   	public String filename;
  
  
  
  1.1      date: 2006/08/08 11:33:12;  author: theute;  state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/Util.java
  
  Index: Util.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, 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.seam.tools;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  import org.jboss.seam.tools.exception.GenerationException;
  
  /**
   * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
   * @version <tt>$Revision: 1.1 $</tt>
   */
  public class Util {
  	
  	public static void createDirectory(String directoryName) throws IOException {
  		boolean created = new File(directoryName).mkdirs();
  		if (!created)
  		{
  			throw new IOException("Cannot create directory: " + directoryName);
  		}
  	}
  	
  	public static void copy(File src, File dst) throws IOException {
          InputStream in = new FileInputStream(src);
          OutputStream out = new FileOutputStream(dst);
      
          // Transfer bytes from in to out
          byte[] buf = new byte[1024];
          int len;
          while ((len = in.read(buf)) > 0) {
              out.write(buf, 0, len);
          }
          in.close();
          out.close();
      }
  
  }
  
  
  
  1.1      date: 2006/08/08 11:33:12;  author: theute;  state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/RootProject.java
  
  Index: RootProject.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, 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.seam.tools;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.jboss.seam.tools.contexts.Context;
  import org.jboss.seam.tools.contexts.RootContext;
  import org.jboss.seam.tools.exception.GenerationException;
  
  /**
   * Wrapper project for EAR Project + EJB Projects + WEB projects
   * 
   * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
   * @version <tt>$Revision: 1.1 $</tt>
   */
  public abstract class RootProject {
  
  	private String name;
  	
  	protected EarProject earProject;
  	
  	private List<WebProject> webProjects;
  	
  	private List<EjbProject> ejbProjects;
  
  	private RootContext rootContext;
  	
  	public EarProject getEarProject() {
  		return earProject;
  	}
  
  	public void setEarProject(EarProject earProject) {
  		this.earProject = earProject;
  		earProject.setRootProject(this);
  	}
  
  	public List<EjbProject> getEjbProjects() {
  		return ejbProjects;
  	}
  	
  	public void addEjbProject(EjbProject ejbProject)
  	{
  		if (ejbProjects == null)
  		{
  			ejbProjects = new ArrayList<EjbProject>();
  		}
  		ejbProjects.add(ejbProject);
  		ejbProject.setRootProject(this);
  	}
  
  
  	public List<WebProject> getWebProjects() {
  		return webProjects;
  	}
  
  	public void addWebProject(WebProject webProject)
  	{
  		if (webProjects == null)
  		{
  			webProjects = new ArrayList<WebProject>();
  		}
  		webProjects.add(webProject);
  		webProject.setRootProject(this);
  	}
  
  	public String getName() {
  		return name;
  	}
  
  	public void setName(String name) {
  		this.name = name;
  	}
  
  	public abstract void generate(Context context) throws GenerationException, IOException;
  
  	public RootContext getRootContext() {
  		return rootContext;
  	}
  	
  	public void setRootContext(RootContext rootContext) {
  		this.rootContext = rootContext;
  	}
  }
  
  
  
  1.1      date: 2006/08/08 11:33:12;  author: theute;  state: Exp;jboss-seam-tools/src/org/jboss/seam/tools/Structure.java
  
  Index: Structure.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, 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.seam.tools;
  
  /**
   * Structure to choose from when generating the projects
   * 
   * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
   * @version <tt>$Revision: 1.1 $</tt>
   */
  public enum Structure {
  	WTP, maven
  }
  
  
  



More information about the jboss-cvs-commits mailing list