Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToHomeInterfaceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToHomeInterfaceGenerator.java:1.6 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToHomeInterfaceGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,88 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToHomeInterfaceGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ + package org.codelutin.topia.generators.ejb; + +//import java.io.BufferedWriter; +//import java.io.File; +//import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; +//import org.codelutin.generator.models.object.ObjectModelInterface; +//import org.codelutin.generator.models.object.ObjectModelOperation; +//import org.codelutin.generator.models.object.ObjectModelParameter; + +/** +* +*/ +public class ObjectModelToHomeInterfaceGenerator extends ObjectModelGenerator { + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + "Home.java"; + } + + +public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + + if(! Util.isService(clazz)) return; + // ------------- File Header + if(!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + +// ------------- Imports +/*{ +import java.rmi.RemoteException; +import javax.ejb.*; +}*/ + +// ------------- Class start +/*{ +public interface <%=clazz.getName()%>Home extends javax.ejb.EJBHome +}*/ + +/*{ + { + <%=clazz.getName()%> create() throws javax.ejb.CreateException,java.rmi.RemoteException; + } +}*/ + + + + } +} Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToBeanClassGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToBeanClassGenerator.java:1.7 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToBeanClassGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,121 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToBeanClassGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.7 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ +package org.codelutin.topia.generators.ejb; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.topia.generators.Util; + +/** + * + */ +public class ObjectModelToBeanClassGenerator extends ObjectModelGenerator { + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + "Bean.java"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) + throws IOException { + if (! Util.isService(clazz)) + return; + + // ------------- File Header + if (!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + + // ------------- Imports +/*{ +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +}*/ + + // ------------- Class start +/*{ +public class <%=clazz.getName()%>Bean implements javax.ejb.SessionBean { +}*/ + +/*{ + private SessionContext ctx; + + public void ejbCreate() {} + + public void ejbRemove() {} + + public void ejbActivate() {} + + public void ejbPassivate(){} + + public void setSessionContext(javax.ejb.SessionContext ctx){ + this.ctx=ctx; + } + +}*/ + + for (Iterator i = clazz.getOperations().iterator(); i.hasNext();) { + ObjectModelOperation operation = (ObjectModelOperation) i.next(); +/*{ + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%>(}*/ + for (Iterator j = operation.getParameters().iterator(); j.hasNext();) { + ObjectModelParameter parameter = (ObjectModelParameter) j.next(); +/*{<%=parameter.getType()%> <%=parameter.getName()%>}*/ + if (j.hasNext()) { +/*{,}*/ + } + } +/*{){ + +}*/ + if (! "void".equals(operation.getReturnType())) { +/*{ + return null; + } +}*/ + + } +/*{ +} +}*/ + } + } + +} Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalHomeInterfaceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalHomeInterfaceGenerator.java:1.6 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalHomeInterfaceGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,80 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToLocalHomeInterfaceGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ + package org.codelutin.topia.generators.ejb; + +import java.io.IOException; +import java.io.Writer; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +/** +* +*/ +public class ObjectModelToLocalHomeInterfaceGenerator extends ObjectModelGenerator { + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + "LocalHome.java"; + } + + +public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + + if(! Util.isService(clazz)) return; + + // ------------- File Header + if(!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + +// ------------- Imports +/*{ +import java.rmi.RemoteException; +import javax.ejb.*; +}*/ + +// ------------- Class start +/*{ +public interface <%=clazz.getName()%>LocalHome extends javax.ejb.EJBLocalHome +}*/ + +/*{ + { + <%=clazz.getName()%>Local create() throws javax.ejb.CreateException; + } +}*/ + } +} Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToObjectInterfaceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToObjectInterfaceGenerator.java:1.6 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToObjectInterfaceGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,96 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToObjectInterfaceGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ + package org.codelutin.topia.generators.ejb; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.topia.generators.Util; + +/** +* +*/ +public class ObjectModelToObjectInterfaceGenerator extends ObjectModelGenerator { + + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + ".java"; + } + + + public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + if(! Util.isService(clazz)) return; + +// ------------- File Header + if(!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + +// ------------- Imports +/*{ +import javax.ejb.*; +}*/ + +// ------------- Class start +/*{ +public interface <%=clazz.getName()%> extends javax.ejb.EJBObject { + +}*/ + Iterator operation=clazz.getOperations().iterator(); + while (operation.hasNext()){ + ObjectModelOperation opera=(ObjectModelOperation)operation.next(); +/*{ + <%=opera.getVisibility()%> <%=opera.getReturnType()%> <%=opera.getName()%>(}*/ + Iterator param=opera.getParameters().iterator(); + while (param.hasNext()){ + ObjectModelParameter parameter=(ObjectModelParameter)param.next(); +/*{<%=parameter.getType()%> <%=parameter.getName()%>}*/ + if(param.hasNext()){ +/*{,}*/ + } + } +/*{) throws java.rmi.RemoteException; +} +}*/ + } + } + + +} Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalObjectInterfaceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalObjectInterfaceGenerator.java:1.6 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToLocalObjectInterfaceGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,99 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToLocalObjectInterfaceGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ + package org.codelutin.topia.generators.ejb; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.topia.generators.Util; + +/** +* +*/ +public class ObjectModelToLocalObjectInterfaceGenerator extends ObjectModelGenerator { + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + "Local.java"; + } + + + + + public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + + if(! Util.isService(clazz)) return; + + // ------------- File Header + if(!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + +// ------------- Imports +/*{ +import javax.ejb.*; +}*/ + +// ------------- Class start +/*{ +public interface <%=clazz.getName()%>Local extends javax.ejb.EJBLocalObject { + +}*/ + Iterator operation=clazz.getOperations().iterator(); + while (operation.hasNext()){ + ObjectModelOperation opera=(ObjectModelOperation)operation.next(); +/*{ + <%=opera.getVisibility()%> <%=opera.getReturnType()%> <%=opera.getName()%>(}*/ + Iterator param=opera.getParameters().iterator(); + while (param.hasNext()){ + ObjectModelParameter parameter=(ObjectModelParameter)param.next(); +/*{<%=parameter.getType()%> <%=parameter.getName()%>}*/ + if(param.hasNext()){ +/*{,}*/ + } + } + +/*{) throws java.rmi.RemoteException; + + } +}*/ + } + } + +} \ No newline at end of file Index: topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToEJBJARFileGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToEJBJARFileGenerator.java:1.6 --- /dev/null Fri Jul 30 14:39:03 2004 +++ topia/src/java/org/codelutin/topia/generators/ejb/ObjectModelToEJBJARFileGenerator.java Fri Jul 30 14:38:58 2004 @@ -0,0 +1,100 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * Initial Work of Ye Fang & Zhou Kun (trainee at Code Lutin, summer 2004) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToEJBJARFileGenerator.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2004/07/30 14:38:58 $ + * by : $Author: pineau $ + */ + package org.codelutin.topia.generators.ejb; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +/** +* +*/ +public class ObjectModelToEJBJARFileGenerator extends ObjectModelGenerator { + + + public String getFilenameForModel(ObjectModel model) { + return "META-INF/ejb-jar.xml"; + } + + + public void generateFromModel(Writer output, ObjectModel model) throws IOException { + +//------------- start +/*{ + +}*/ + + Iterator classes = model.getClasses().iterator(); + while (classes.hasNext()) { + ObjectModelClass clazz = (ObjectModelClass) classes.next(); + generate(output, clazz); + } + + } + + public void generate(Writer output, ObjectModelClass clazz) throws IOException{ + if(! Util.isService(clazz)) return; + +/*{ + + + +<%=clazz.getPackageName()%>.<%=clazz.getName()%> +<%=clazz.getPackageName()%>.<%=clazz.getName()%>Home +<%=clazz.getPackageName()%>.<%=clazz.getName()%> +<%=clazz.getPackageName()%>.<%=clazz.getName()%>Bean +Stateless +Container + + + + + +<%=clazz.getPackageName()%>.<%=clazz.getName()%> +* + +Supports + + + +}*/ + + } +} + +