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

Thomas Heute theute at jboss.com
Mon Aug 14 11:57:43 EDT 2006


  User: theute  
  Date: 06/08/14 11:57:43

  Added:       src/java/org/jboss/seam/tools/exporter      
                        EjbProjectExporter.java WebProjectExporter.java
                        EarProjectExporter.java AbstractSeamExporter.java
                        AbstractContext.java WebinfExporter.java
  Log:
  Moved to hibernate Tools
  
  (ban cvs imports)
  
  Revision  Changes    Path
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/EjbProjectExporter.java
  
  Index: EjbProjectExporter.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.exporter;
  
  import java.io.File;
  import java.io.IOException;
  
  import org.jboss.seam.tools.Util;
  import org.jboss.seam.tools.context.Context;
  import org.jboss.seam.tools.context.EjbContext;
  
  public class EjbProjectExporter extends AbstractSeamExporter {
  
  	private EjbContext ejbContext;
  	
  	private Context context;
  
  	private Object earContext;
  	
  	public EjbProjectExporter(Context context)
  	{
  		this.context = context;
  		init();
  	}
  	
  	public void doStart()
  	{
  		configureExporter("ejb/ejb-jar.xml.ftl", ejbContext.getContentDirectory() + "/META-INF/ejb-jar.xml").start();
  		configureExporter("ejb/persistence.xml.ftl", ejbContext.getContentDirectory() + "/META-INF/persistence.xml").start();
  		configureExporter("ejb/seam.properties.ftl", ejbContext.getContentDirectory() + "/seam.properties").start();
  		
  		if (context.getEclipseSupport())
  		{
  			configureExporter("ejb/eclipse.classpath.ftl", ".classpath").start();
  			configureExporter("ejb/eclipse.project.ftl", ".project").start();
  			configureExporter("ejb/org.eclipse.wst.common.component.ftl", ".settings/org.eclipse.wst.common.component").start();
  			configureExporter("ejb/org.eclipse.jdt.core.prefs.ftl", ".settings/org.eclipse.jdt.core.prefs").start();
  			configureExporter("ejb/org.eclipse.jst.common.project.facet.core.prefs.ftl", ".settings/org.eclipse.jst.common.project.facet.core.prefs").start();
  			configureExporter("ejb/org.eclipse.wst.common.project.facet.core.xml.ftl", ".settings/org.eclipse.wst.common.project.facet.core.xml").start();
  		}
  		
  		if (context.isBasicProject())
  		{
  			configureExporter("basic/Register.java.ftl", ejbContext.getContentDirectory() + "/" + context.getSrcPackage().replace('.', '/')  + "/Register.java").start();
  			configureExporter("basic/RegisterAction.java.ftl", ejbContext.getContentDirectory() + "/" + context.getSrcPackage().replace('.', '/')  + "/RegisterAction.java").start();
  			configureExporter("basic/User.java.ftl", ejbContext.getContentDirectory() + "/" + context.getSrcPackage().replace('.', '/')  + "/User.java").start();
  		}
  		
  		if (context.isTestSupport())
  		{
  			configureExporter("test/components.properties.ftl", "conftest/components.properties").start();
  			configureExporter("test/components.xml.ftl", "conftest/components.xml").start();
  			configureExporter("test/default.persistence.properties.ftl", "conftest/default.persistence.properties").start();
  			configureExporter("test/ejb3-interceptors-aop.xml.ftl", "conftest/ejb3-interceptors-aop.xml").start();
  			configureExporter("test/embedded-jboss-beans.xml.ftl", "conftest/embedded-jboss-beans.xml").start();
  			configureExporter("test/jboss-jms-beans.xml.ftl", "conftest/jboss-jms-beans.xml").start();
  			configureExporter("test/jndi.properties.ftl", "conftest/jndi.properties").start();
  			configureExporter("test/log4j.xml.ftl", "conftest/log4j.xml").start();
  		}
  		
  		File file = new File(getOutputDirectory(), "lib");
  		file.mkdirs();
  		
  		// TODO: nice way of copying files...
  		copyLib(context, "jboss-ejb3-all.jar");
  		copyLib(context, "hibernate-all.jar");
  		copyLib(context, "myfaces-api-1.1.3.jar");
  		copyLib(context, "myfaces-impl-1.1.3.jar");
  		copyLib(context, "testng-4.5.1-jdk15.jar");
  		if (context.isTestSupport())
  		{
  			copyLib(context, "servlet-api.jar");
  			copyLib(context, "thirdparty-all.jar");
  		}
  		
  	}
  	
  	private void copyLib(Context context, String libName)
  	{
  		File src = new File(context.getSeamLocation() + File.separatorChar + "lib" + File.separatorChar + libName);
  		File dst = new File(getOutputDirectory().getAbsolutePath() + File.separatorChar + "lib" + File.separatorChar + libName);
  		try {
  			Util.copy(src, dst);
  		} catch (IOException e) {
  			e.printStackTrace();
  		}
  	}
  	
  	public void setupContext()
  	{
  		getProperties().put("ejbContext", ejbContext);	
  		getProperties().put("earContext", earContext);	
  		getProperties().put("context", context);	
  		super.setupContext();
  	}
  	
      private void init() {
      	setTemplatePrefix("ejb/");		
  	}
  
  	public EjbContext getEjbContext() {
  		return ejbContext;
  	}
  
  	public void setEjbContext(EjbContext ejbContext) {
  		this.ejbContext = ejbContext;
  	}
  
  	public Object getEarContext() {
  		return earContext;
  	}
  
  	public void setEarContext(Object earContext) {
  		this.earContext = earContext;
  	}
  	
  }
  
  
  
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/WebProjectExporter.java
  
  Index: WebProjectExporter.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.exporter;
  
  import java.io.File;
  
  import org.jboss.seam.tools.context.Context;
  import org.jboss.seam.tools.context.EarContext;
  import org.jboss.seam.tools.context.WebContext;
  
  public class WebProjectExporter extends AbstractSeamExporter {
  
  	private EarContext earContext;
  	private WebContext webContext;
  	private Context context;
  	
  	public WebProjectExporter(Context context)
  	{
  		this.context = context;
  		init();
  	}
  	
  	public void doStart()
  	{
  		WebinfExporter webinfExporter = new WebinfExporter(new File(getOutputDirectory().getAbsolutePath() + File.separatorChar + webContext.getContentDirectory() + File.separatorChar + "WEB-INF"), context, webContext);
  		webinfExporter.setEarContext(earContext);
  		webinfExporter.start();
  		
  		if (context.getEclipseSupport())
  		{
  			configureExporter("web/eclipse.classpath.ftl", ".classpath").start();
  			configureExporter("web/eclipse.project.ftl", ".project").start();
  			configureExporter("web/org.eclipse.wst.common.component.ftl", ".settings/org.eclipse.wst.common.component").start();
  			configureExporter("web/org.eclipse.jdt.core.prefs.ftl", ".settings/org.eclipse.jdt.core.prefs").start();
  			configureExporter("web/org.eclipse.jst.common.project.facet.core.prefs.ftl", ".settings/org.eclipse.jst.common.project.facet.core.prefs").start();
  			configureExporter("web/org.eclipse.wst.common.project.facet.core.xml.ftl", ".settings/org.eclipse.wst.common.project.facet.core.xml").start();
  		}
  		
  		if (context.isBasicProject())
  		{
  			configureExporter("basic/index.html.ftl", webContext.getContentDirectory() + "/index.html").start();
  			configureExporter("basic/register.jsp.ftl", webContext.getContentDirectory() + "/register." + webContext.getJsfExtension()).start();
  			configureExporter("basic/registered.jsp.ftl", webContext.getContentDirectory() + "/registered." + webContext.getJsfExtension()).start();
  		}
  		
  		File file = new File(getOutputDirectory(), "src");
  		file.mkdirs();
  		
  	}
  	
  	public void setupContext()
  	{
  		getProperties().put("webContext", webContext);	
  		getProperties().put("context", context);	
  		super.setupContext();
  	}
  	
      private void init() {
      	setTemplatePrefix("web/");		
  	}
  
  	public WebContext getWebContext() {
  		return webContext;
  	}
  
  	public void setWebContext(WebContext webContext) {
  		this.webContext = webContext;
  	}
  
  	public EarContext getEarContext() {
  		return earContext;
  	}
  
  	public void setEarContext(EarContext earContext) {
  		this.earContext = earContext;
  	}
  
  }
  
  
  
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/EarProjectExporter.java
  
  Index: EarProjectExporter.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.exporter;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.jboss.seam.tools.Util;
  import org.jboss.seam.tools.UtilityJar;
  import org.jboss.seam.tools.context.Context;
  import org.jboss.seam.tools.context.EarContext;
  import org.jboss.seam.tools.context.EjbContext;
  import org.jboss.seam.tools.context.WebContext;
  
  public class EarProjectExporter extends AbstractSeamExporter {
  
  	private EarContext earContext;
  	
  	private Context context;
  	
  	private List webContexts;
  	
  	private List ejbContexts;
  	
  	private List utilityJars = new ArrayList();
  	
  	public EarProjectExporter(Context context)
  	{
  		this.context = context;
  		webContexts = new ArrayList();
  		ejbContexts = new ArrayList();
  		init();
  	}
  	
  	public void setupContext()
  	{
  		utilityJars.add(new UtilityJar("jboss-seam.jar"));
  		getProperties().put("utilityJars", utilityJars);
  		getProperties().put("earContext", earContext);
  		getProperties().put("webContexts", webContexts);
  		getProperties().put("ejbContexts", ejbContexts);
  		getProperties().put("context", context);
  		
  		
  		/*
  		getProperties().put("projectName", earContext.getProjectName());
  		getProperties().put("displayName", earContext.getDisplayName());
  		getProperties().put("contentDirectory", earContext.getContentDirectory());
  		getProperties().put("utilityJars", utilityJars);
  		getProperties().put("webContexts", webContexts);
  		getProperties().put("ejbContexts", ejbContexts);
  		getProperties().put("eclipseSupport", "" + context.getEclipseSupport());
  		getProperties().put("isolationClassLoadingName", context.getIsolationClassLoadingName());
  		*/
  		super.setupContext();
  	}
  	
  	public void doStart()
  	{
  		configureExporter("ear/application.xml.ftl", earContext.getContentDirectory() + "/META-INF/application.xml").start();
  		configureExporter("ear/jboss-app.xml.ftl", earContext.getContentDirectory() + "/META-INF/jboss-app.xml").start();
  		
  		if (context.getEclipseSupport())
  		{
  			configureExporter("ear/eclipse.project.ftl", ".project").start();
  			configureExporter("ear/org.eclipse.wst.common.component.ftl", ".settings/org.eclipse.wst.common.component").start();
  			configureExporter("ear/org.eclipse.wst.common.project.facet.core.xml.ftl", ".settings/org.eclipse.wst.common.project.facet.core.xml").start();
  		}
  		
  		// TODO: nice way of copying files...
  		File file = new File(getOutputDirectory().getAbsolutePath() + File.separatorChar + getEarContext().getContentDirectory());
  		file.mkdirs();
  		File src = new File(context.getSeamLocation() + File.separatorChar + "jboss-seam.jar");
  		File dst = new File(getOutputDirectory().getAbsolutePath() + File.separatorChar + getEarContext().getContentDirectory() + File.separatorChar + "jboss-seam.jar");
  		try {
  			Util.copy(src, dst);
  		} catch (IOException e) {
  			e.printStackTrace();
  		}
  	}
  	
      private void init() {
      	setTemplatePrefix("web/");		
  	}
  
  	public EarContext getEarContext() {
  		return earContext;
  	}
  
  	public void setEarContext(EarContext earContext) {
  		this.earContext = earContext;
  	}
  	
  	public void setWebContexts(List contexts)
  	{
  		this.webContexts = contexts;
  	}
  	
  	public void addWebContext(WebContext context)
  	{
  		this.webContexts.add(context);
  	}
  	
  	public List getWebContexts()
  	{
  		return webContexts;
  	}
  
  	public void setEjbContexts(List contexts)
  	{
  		this.ejbContexts = contexts;
  	}
  	
  	public void addEjbContext(EjbContext context)
  	{
  		this.ejbContexts.add(context);
  	}
  	
  	public List getEjbContexts()
  	{
  		return ejbContexts;
  	}
  
  }
  
  
  
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/AbstractSeamExporter.java
  
  Index: AbstractSeamExporter.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.exporter;
  
  import java.util.Properties;
  
  import org.hibernate.tool.hbm2x.AbstractExporter;
  import org.hibernate.tool.hbm2x.GenericExporter;
  
  public abstract class AbstractSeamExporter extends AbstractExporter {
  
  	protected GenericExporter configureExporter(String template, String pattern) {
  		GenericExporter exporter = new GenericExporter();
  		exporter.setOutputDirectory(getOutputDirectory());
  		exporter.setProperties((Properties) getProperties().clone());
  		exporter.setTemplatePath(getTemplatePaths());
  		exporter.setTemplateName(template);
  		exporter.setFilePattern(pattern);
  		exporter.setArtifactCollector(getArtifactCollector());
  		return exporter;
  	}	
  }
  
  
  
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/AbstractContext.java
  
  Index: AbstractContext.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.exporter;
  
  import java.util.Map;
  
  public abstract class AbstractContext {
  
  	protected Map map;
  
  	public Map getMap()
  	{
  		return map;
  	}
  	
  }
  
  
  
  1.1      date: 2006/08/14 15:57:43;  author: theute;  state: Exp;jboss-seam-tools/src/java/org/jboss/seam/tools/exporter/WebinfExporter.java
  
  Index: WebinfExporter.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.exporter;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.Properties;
  
  import org.hibernate.tool.hbm2x.AbstractExporter;
  import org.hibernate.tool.hbm2x.GenericExporter;
  import org.jboss.seam.tools.Util;
  import org.jboss.seam.tools.context.Context;
  import org.jboss.seam.tools.context.EarContext;
  import org.jboss.seam.tools.context.WebContext;
  
  public class WebinfExporter extends AbstractExporter {
  
  	private EarContext earContext;
  	
  	private Context context;
  	private WebContext webContext;
  	
  	public WebinfExporter(File outputDirectory, Context context, WebContext webContext)
  	{
  		this.context = context;
  		this.webContext = webContext;
  		setOutputDirectory(outputDirectory);
  		init();
  	}
  	
  	public void doStart()
  	{
  		configureExporter("web/web.xml.ftl", "web.xml").start();
  		configureExporter("web/components.xml.ftl", "components.xml").start();
  		configureExporter("web/faces-config.xml.ftl", "faces-config.xml").start();
  		configureExporter("web/pages.xml.ftl", "pages.xml").start();
  		
  		File file = new File(getOutputDirectory(), "lib");
  		file.mkdirs();
  		
  		
  		File seamLocation = new File(context.getSeamLocation());
  		copyLib(seamLocation, "jboss-seam-ui.jar");
  		if (context.isFaceletsSupport() | context.isDebug())
  		{
  			copyLib(seamLocation, "jboss-seam-debug.jar");
  			File faceletsLocation = new File(context.getSeamLocation() + File.separatorChar + "facelets" + File.separatorChar + "lib");
  			copyLib(faceletsLocation, "jsf-facelets.jar");
  			copyLib(faceletsLocation, "el-api.jar");
  			copyLib(faceletsLocation, "el-ri.jar");
  		}
  	}
  	
  	private void copyLib(File sourceDirectory, String libName)
  	{
  		File src = new File(sourceDirectory, libName);
  		File dst = new File(getOutputDirectory().getAbsolutePath() + File.separatorChar + "lib" + File.separatorChar + libName);
  		try {
  			Util.copy(src, dst);
  		} catch (IOException e) {
  			e.printStackTrace();
  		}
  	}
  	
  	public void setupContext()
  	{
  		getProperties().put("earContext", earContext);	
  		getProperties().put("webContext", webContext);	
  		getProperties().put("context", context);	
  		super.setupContext();
  	}
  	
  	private void init() {
      	setTemplatePrefix("web/");		
  	}
  	
  	private GenericExporter configureExporter(String template, String pattern) {
  		GenericExporter exporter = new GenericExporter();
  		exporter.setOutputDirectory(getOutputDirectory());
  		exporter.setProperties((Properties) getProperties().clone());
  		exporter.setTemplatePath(getTemplatePaths());
  		exporter.setTemplateName(template);
  		exporter.setFilePattern(pattern);
  		exporter.setArtifactCollector(getArtifactCollector());
  		return exporter;
  	}
  	
  
  	public EarContext getEarContext() {
  		return earContext;
  	}
  
  	public void setEarContext(EarContext earContext) {
  		this.earContext = earContext;
  	}
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list