[overlord-commits] Overlord SVN: r254 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src: java/org/jboss/tools/overlord/jbossesb/dialogs and 4 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Tue Aug 19 12:23:55 EDT 2008


Author: objectiser
Date: 2008-08-19 12:23:55 -0400 (Tue, 19 Aug 2008)
New Revision: 254

Added:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/AntBuildSystem.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildConfigurationGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildSystem.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BusinessObjectTypeGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ConversationBasedGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/DeploymentFileGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Generator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorException.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorUtil.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/JBMQConfigurationGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/MavenBuildSystem.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Messages.properties
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ModelBasedGenerator.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/TypeMapper.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/generator/
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/generator/TypeMapperTest.java
Removed:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java
Modified:
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
   cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
Log:
Basic type mapping, covering XSD (string, boolean, decimal, integer) mapping to Java base types, java: prefixed namespace being mapped to Java types, and all others being mapped to DOM element. Refactored the generator to separate out generation of the various artefacts and started to add Javadoc comments into business object type.

Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java	2008-08-19 11:53:13 UTC (rev 253)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-package org.jboss.tools.overlord.jbossesb.dialogs;
-
-/**
- * This class represents the Ant build system.
- */
-public class AntBuildSystem implements BuildSystem {
-
-	private static final String BUILD_FILE = "build.xml";
-	private static final String ANT = "Ant";
-	private static final String ESB_CONFIG_PATH = "src/conf/jboss-esb.xml";
-	private static final String DEPLOYMENT_PATH = "src/conf/deployment.xml";
-	private static final String JBMQ_CONFIG_PATH = "src/conf/jbmq-queue-service.xml";
-	private static final String JAVA_SOURCE_PATH = "src/java";
-
-	/**
-	 * This method represents the name of the build
-	 * system.
-	 * 
-	 * @return The name
-	 */
-	public String getName() {
-		return(ANT);
-	}
-	
-	/**
-	 * This method returns the build configuration file
-	 * path.
-	 * 
-	 * @return The build configuration file path
-	 */
-	public String getBuildFilePath() {
-		return(BUILD_FILE);
-	}
-	
-	/**
-	 * This method returns the contents for the build
-	 * configuration file.
-	 * 
-	 * @param projectName The project name
-	 * @return The build file contents
-	 */
-	public String getBuildFileContents(String projectName) {
-		StringBuffer ret=new StringBuffer();
-		
-		ret.append("<project name=\""+projectName+
-					"\" default=\"startdb\" basedir=\".\">\r\n");
-
-		ret.append("</project>\r\n");
-		
-		return(ret.toString());
-	}
-	
-	/**
-	 * This method returns the ESB configuration file
-	 * path.
-	 * 
-	 * @return The ESB configuration file path
-	 */
-	public String getESBConfigFilePath() {
-		return(ESB_CONFIG_PATH);
-	}
-	
-	/**
-	 * This method returns the deployment file
-	 * path.
-	 * 
-	 * @return The deployment file path
-	 */
-	public String getDeploymentFilePath() {
-		return(DEPLOYMENT_PATH);
-	}
-	
-	/**
-	 * This method returns the JBMQ configuration file
-	 * path.
-	 * 
-	 * @return The JBMQ configuration file path
-	 */
-	public String getJBMQConfigFilePath() {
-		return(JBMQ_CONFIG_PATH);
-	}
-	
-	/**
-	 * This method returns the Java source path.
-	 * 
-	 * @return The Java source path
-	 */
-	public String getJavaSourcePath() {
-		return(JAVA_SOURCE_PATH);
-	}
-	
-}

Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java	2008-08-19 11:53:13 UTC (rev 253)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-package org.jboss.tools.overlord.jbossesb.dialogs;
-
-/**
- * This interface represents a build system used when
- * generating the ESB projects.
- */
-public interface BuildSystem {
-
-	/**
-	 * This method represents the name of the build
-	 * system.
-	 * 
-	 * @return The name
-	 */
-	public String getName();
-	
-	/**
-	 * This method returns the build configuration file
-	 * path.
-	 * 
-	 * @return The build configuration file path
-	 */
-	public String getBuildFilePath();
-	
-	/**
-	 * This method returns the contents for the build
-	 * configuration file.
-	 * 
-	 * @param projectName The project name
-	 * @return The build file contents
-	 */
-	public String getBuildFileContents(String projectName);
-	
-	/**
-	 * This method returns the ESB configuration file
-	 * path.
-	 * 
-	 * @return The ESB configuration file path
-	 */
-	public String getESBConfigFilePath();
-	
-	/**
-	 * This method returns the deployment file
-	 * path.
-	 * 
-	 * @return The deployment file path
-	 */
-	public String getDeploymentFilePath();
-	
-	/**
-	 * This method returns the JBMQ configuration file
-	 * path.
-	 * 
-	 * @return The JBMQ configuration file path
-	 */
-	public String getJBMQConfigFilePath();
-	
-	/**
-	 * This method returns the Java source path.
-	 * 
-	 * @return The Java source path
-	 */
-	public String getJavaSourcePath();
-	
-}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java	2008-08-19 11:53:13 UTC (rev 253)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -17,35 +17,18 @@
  */
 package org.jboss.tools.overlord.jbossesb.dialogs;
 
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.*;
 import org.eclipse.swt.layout.*;
 import org.eclipse.swt.widgets.*;
-import org.jboss.tools.overlord.jbossesb.model.*;
-import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
+import org.jboss.tools.overlord.jbossesb.generator.*;
 import org.scribble.conversation.model.ConversationModel;
 import org.scribble.extensions.RegistryFactory;
 import org.scribble.model.*;
-import org.scribble.model.change.ModelGenerator;
-import org.scribble.conversation.model.*;
-import org.w3c.dom.Node;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.dom.*;
-import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
 
 /**
  * This class provides the dialog for generating JBossESB
@@ -53,9 +36,6 @@
  */
 public class GenerateDialog extends org.eclipse.jface.dialogs.Dialog {
 
-	private static final String CLASSPATH_FILENAME = ".classpath";
-	private static final String OUTPUT_LOCATION = "classes";
-	
 	/**
 	 * This is the constructor for the generate dialog.
 	 * 
@@ -343,10 +323,13 @@
 	public void okPressed() {
 		
 		try {
+			Generator generator=new Generator(m_file,
+						getSelectedBuildSystem());
+			
 			for (int i=0; i < m_roles.size(); i++) {
 				
 				if (m_roleButtons.get(i).getSelection()) {
-					generateRole(m_roles.get(i),
+					generator.generateRole(m_roles.get(i),
 							m_projectNames.get(i).getText());
 				}
 			}
@@ -361,630 +344,7 @@
 		return(m_buildSystems.get(m_build.getSelectionIndex()));
 	}
 		
-	protected void generateRole(Role role, String projectName)
-						throws Exception {
-		
-		if (logger.isLoggable(Level.FINEST)) {
-			logger.finest("Generate role '"+role+"' for: "+
-						m_conversationModel);
-		}
-		
-		// Project to role
-		org.scribble.projector.Projector projector=
-			(org.scribble.projector.Projector)
-			RegistryFactory.getRegistry().getExtension(
-					org.scribble.projector.Projector.class, null);
-
-		if (projector != null) {
-			Model localModel=projector.project(m_conversationModel,
-					role, new DefaultModelListener());
-			
-			if (localModel instanceof ConversationModel &&
-					((ConversationModel)localModel).getConversation() != null) {
-				ConversationModel lcm=(ConversationModel)localModel;
-				
-				ModelReference targetRef=
-					new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
-				
-				DefaultESBLanguageModel target=
-					new DefaultESBLanguageModel(targetRef);
-				
-				ModelGenerator generator=(ModelGenerator)
-					RegistryFactory.getRegistry().getExtension(
-							ModelGenerator.class, null);
-				
-				if (generator != null) {
-					generator.generate(targetRef, role, target,
-								lcm);
-					
-					generateRoleProject(projectName,
-								target.getESBConfiguration(),
-								lcm, target);
-				} else {
-					logger.severe("Unable to find model generator");
-				}
-			}
-		}
-	}
-	
-	protected void generateRoleProject(String projectName,
-			org.w3c.dom.Element esbConfig, ConversationModel localcm,
-			ESBLanguageModel model)	throws Exception {
-		
-		final IJavaProject jproj=createJavaProject(projectName);
-		
-		if (jproj != null && esbConfig != null) {
-			// Generate business object types for
-			// local conversation model
-			localcm.visit(new Visitor() {
-
-				public boolean visit(ModelObject obj) {
-					
-					if (obj instanceof Conversation) {
-						try {
-							generateBusinessObjectType(jproj,
-									(Conversation)obj);
-						} catch(Exception e) {
-							error("Failed to generate business object type",
-									e);
-						}
-					}
-					
-					return true;
-				}	
-			});
-			
-			// Store ESB configuration
-			IPath esbConfigPath=jproj.getPath().append(
-					new Path(getSelectedBuildSystem().getESBConfigFilePath()));
-			
-			IFile esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
-			createParentFolder(esbConfigFile);
-			esbConfigFile.create(null, true,
-					new org.eclipse.core.runtime.NullProgressMonitor());
-			
-			String config=getText(esbConfig);
-			
-			if (config != null) {
-				esbConfigFile.setContents(new java.io.ByteArrayInputStream(
-						config.getBytes()), true, false,
-						new org.eclipse.core.runtime.NullProgressMonitor());
-			}
-			
-			generateBuildConfigurationFile(jproj);
-			
-			generateDeploymentFile(jproj, model);
-			generateJBMQConfigurationFile(jproj, model);
-		}
-	}
-	
-	protected void generateBuildConfigurationFile(IJavaProject jproj)
-							throws Exception {
-		
-		IPath buildConfigPath=jproj.getPath().append(
-				new Path(getSelectedBuildSystem().getBuildFilePath()));
-		
-		IFile buildConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
-		createParentFolder(buildConfigFile);
-		buildConfigFile.create(null, true,
-				new org.eclipse.core.runtime.NullProgressMonitor());
-		
-		String config=getSelectedBuildSystem().getBuildFileContents(jproj.getProject().getName());
-		
-		if (config != null) {
-			buildConfigFile.setContents(new java.io.ByteArrayInputStream(
-					config.getBytes()), true, false,
-					new org.eclipse.core.runtime.NullProgressMonitor());
-		}
-	}
-	
-	
-	protected void generateJBMQConfigurationFile(IJavaProject jproj,
-					ESBLanguageModel model)	throws Exception {
-		
-		IPath buildConfigPath=jproj.getPath().append(
-				new Path(getSelectedBuildSystem().getJBMQConfigFilePath()));
-		
-		IFile buildConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
-		createParentFolder(buildConfigFile);
-		buildConfigFile.create(null, true,
-				new org.eclipse.core.runtime.NullProgressMonitor());
-		
-		StringBuffer buf=new StringBuffer();
-		buf.append("<server>\r\n");
-		
-		java.util.Iterator<ESBService> iter=model.getServices().iterator();
-		
-		while (iter.hasNext()) {
-			ESBService service=iter.next();
-			
-			String dest=model.getJMSDefinition(service.getJMSBusIdRef());
-			
-			if (dest != null) {
-				buf.append("\t<mbean code=\"org.jboss.mq.server.jmx.Queue\"\r\n");
-				buf.append("\t\t\tname=\""+service.getCategory()+".destination:service=Queue,name="+dest+"\">\r\n");
-				buf.append("\t\t<depends optional-attribute-name=\"DestinationManager\">\r\n");
-				buf.append("\t\t\tjboss.mq:service=DestinationManager\r\n");
-				buf.append("\t\t</depends>\r\n");
-				buf.append("\t</mbean>\r\n");
-			} else {
-				logger.severe("Failed to find destination for JMS bus id '"+
-						service.getJMSBusIdRef()+"'");
-			}
-		}
-		
-		buf.append("</server>\r\n");
-
-		buildConfigFile.setContents(new java.io.ByteArrayInputStream(
-					buf.toString().getBytes()), true, false,
-					new org.eclipse.core.runtime.NullProgressMonitor());
-	}
-	
-	protected void generateDeploymentFile(IJavaProject jproj,
-			ESBLanguageModel model)	throws Exception {
-
-		IPath deploymentPath=jproj.getPath().append(
-				new Path(getSelectedBuildSystem().getDeploymentFilePath()));
-		
-		IFile deploymentFile=jproj.getProject().getWorkspace().getRoot().getFile(deploymentPath);
-		createParentFolder(deploymentFile);
-		deploymentFile.create(null, true,
-				new org.eclipse.core.runtime.NullProgressMonitor());
-
-		StringBuffer buf=new StringBuffer();
-		buf.append("<jbossesb-deployment>\r\n");
-		
-		java.util.Iterator<ESBService> iter=model.getServices().iterator();
-		
-		while (iter.hasNext()) {
-			ESBService service=iter.next();
-			
-			String dest=model.getJMSDefinition(service.getJMSBusIdRef());
-			
-			if (dest != null) {
-				buf.append("\t<depends>"+service.getCategory()+
-						".destination:service=Queue,name="+dest+
-						"</depends>\r\n");
-			} else {
-				logger.severe("Failed to find destination for JMS bus id '"+
-						service.getJMSBusIdRef()+"'");
-			}
-		}
-		
-		buf.append("</jbossesb-deployment>\r\n");
-		
-		deploymentFile.setContents(new java.io.ByteArrayInputStream(
-					buf.toString().getBytes()), true, false,
-					new org.eclipse.core.runtime.NullProgressMonitor());
-	}
-
-	protected void generateBusinessObjectType(IJavaProject jproj,
-					Conversation conversation) throws Exception {
-		
-		IPath sourceLocation=jproj.getPath().append(
-				new Path(getSelectedBuildSystem().getJavaSourcePath()));
-		
-		String javaClass=ConversationUtil.getBusinessObjectType(conversation);
-		
-		String javaPath=javaClass.replace('.', '/')+".java";
-		
-		IPath javaFile=sourceLocation.append(new Path(javaPath));
-				
-		IFile file=jproj.getProject().getWorkspace().getRoot().getFile(javaFile);
-		createParentFolder(file);
-		file.create(null, true, new org.eclipse.core.runtime.NullProgressMonitor());
-
-		String text="package "+
-			ConversationUtil.getBusinessObjectTypePackageName(conversation)+";\r\n"+
-			"public class "+
-			ConversationUtil.getBusinessObjectTypeClassName(conversation)+" {\r\n}\r\n";
-		
-		ASTParser parser = ASTParser.newParser(AST.JLS3);
-		parser.setResolveBindings(true);
-		parser.setSource(new char[0]);
-		
-		CompilationUnit root=(CompilationUnit)parser.createAST(null);
-		
-		AST ast=root.getAST();
-		
-		org.eclipse.jface.text.IDocument doc=
-					new org.eclipse.jface.text.Document();
-
-		root.recordModifications();
-		
-		PackageDeclaration pd=ast.newPackageDeclaration();
-		pd.setName(ast.newName(ConversationUtil.getBusinessObjectTypePackageName(conversation)));
-		root.setPackage(pd);
-		
-		TypeDeclaration type=ast.newTypeDeclaration();
-		
-		type.setName(ast.newSimpleName(ConversationUtil.getBusinessObjectTypeClassName(conversation)));
-
-		Modifier pubmod=ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD);
-		type.modifiers().add(pubmod);
-		
-		root.types().add(type);
-		
-		// Process conversation to obtain necessary methods and
-		// properties
-		generateBusinessObjectTypeMethods(type, conversation);
-		
-		org.eclipse.text.edits.TextEdit edits=root.rewrite(doc, null);
-		
-		try {
-			edits.apply(doc);
-		} catch(Exception e) {
-			e.printStackTrace();
-		}
-		
-		java.io.ByteArrayInputStream is=
-			new java.io.ByteArrayInputStream(doc.get().getBytes());
-		
-		file.setContents(is, false, true, null);
-			
-		is.close();
-	}
-	
-	protected void generateBusinessObjectTypeMethods(TypeDeclaration type,
-					final Conversation conversation) throws Exception {
-		final java.util.List<Role> roles=new java.util.Vector<Role>();
-		final java.util.List<Variable> variables=new java.util.Vector<Variable>();
-		
-		conversation.visit(new Visitor() {
-			public boolean visit(ModelObject obj) {
-				boolean ret=true;
-				
-				if (obj instanceof Conversation &&
-						obj != conversation) {
-					ret = false;
-				} else if (obj instanceof Interaction) {
-					Interaction interaction=(Interaction)obj;
-					
-					// If send and a response, then create
-					// 'to' role service category/name
-					// methods
-					if (InteractionUtil.isSend(interaction) &&
-							interaction.getReplyToLabel() == null &&
-							interaction.getToRole() != null &&
-							roles.contains(interaction.getToRole()) == false) {
-						roles.add(interaction.getToRole());
-					}
-				} else if (obj instanceof VariableList) {
-					VariableList vars=(VariableList)obj;
-					
-					variables.addAll(vars.getVariables());
-				}
-				
-				return(ret);
-			}
-		});
-
-		for (int i=0; i < roles.size(); i++) {
-			AST ast=type.getAST();
-			
-			String methodName=
-				InteractionUtil.getRoleServiceCategoryAccessorMethod(roles.get(i).getName());
-			
-			MethodDeclaration method=ast.newMethodDeclaration();
-			method.setName(ast.newSimpleName(methodName));
-			method.setReturnType2(ast.newSimpleType(
-					ast.newName("String")));
-	
-			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
-	
-			org.eclipse.jdt.core.dom.Block block=ast.newBlock();
-						
-			ReturnStatement retStatement=ast.newReturnStatement();
-			
-			retStatement.setExpression(ast.newNullLiteral());
-			
-			block.statements().add(retStatement);
-			
-			method.setBody(block);				
-			
-			type.bodyDeclarations().add(method);
-			
-			methodName=
-				InteractionUtil.getRoleServiceNameAccessorMethod(roles.get(i).getName());
-			
-			method=ast.newMethodDeclaration();
-			method.setName(ast.newSimpleName(methodName));
-			method.setReturnType2(ast.newSimpleType(
-					ast.newName("String")));
-	
-			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
-	
-			block=ast.newBlock();
-			
-			retStatement=ast.newReturnStatement();
-			
-			retStatement.setExpression(ast.newNullLiteral());
-			
-			block.statements().add(retStatement);
-			
-			method.setBody(block);				
-			
-			type.bodyDeclarations().add(method);
-		}
-
-		for (int i=0; i < variables.size(); i++) {
-			AST ast=type.getAST();
-			
-			String methodName=
-				ConversationUtil.getVariableAccessorMethod(variables.get(i).getName());
-			
-			MethodDeclaration method=ast.newMethodDeclaration();
-			method.setName(ast.newSimpleName(methodName));
-			method.setReturnType2(ast.newSimpleType(
-					ast.newName("Object")));
-	
-			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
-	
-			org.eclipse.jdt.core.dom.Block block=ast.newBlock();
-			
-			ReturnStatement retStatement=ast.newReturnStatement();
-			
-			retStatement.setExpression(ast.newNullLiteral());
-			
-			block.statements().add(retStatement);
-			
-			method.setBody(block);				
-			
-			type.bodyDeclarations().add(method);
-			
-			// Generate setter method
-			methodName=
-				ConversationUtil.getVariableModifierMethod(variables.get(i).getName());
-			
-			method=ast.newMethodDeclaration();
-			method.setName(ast.newSimpleName(methodName));
-			method.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
-			
-			SingleVariableDeclaration svd=ast.newSingleVariableDeclaration();
-			svd.setName(ast.newSimpleName("value"));
-			svd.setType(ast.newSimpleType(
-							ast.newName("Object")));
-			
-			method.parameters().add(svd);
-	
-			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
-	
-			block=ast.newBlock();
-			
-			method.setBody(block);				
-			
-			type.bodyDeclarations().add(method);
-		}
-	}
-		
-	protected IJavaProject createJavaProject(String projectName)
-							throws Exception {
-		
-		// Create project
-		IProject project=m_file.getWorkspace().getRoot().getProject(projectName);
-		project.create(new org.eclipse.core.runtime.NullProgressMonitor());
-
-		IJavaProject jproj=JavaCore.create(project);
-		
-		project.open(new org.eclipse.core.runtime.NullProgressMonitor());
-		
-		IProjectDescription description = jproj.getProject().getDescription();
-		
-		// Update the project natures to include Java Nature
-		String[] prevNatures= description.getNatureIds();
-		String[] newNatures= new String[prevNatures.length + 1];
-		System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
-		newNatures[prevNatures.length]= JavaCore.NATURE_ID;
-		description.setNatureIds(newNatures);
-		
-		// Setup project reference to CDM project
-		IProject[] prevProjects=description.getReferencedProjects();
-		IProject[] newProjects=new IProject[prevProjects.length+1];
-		System.arraycopy(prevProjects, 0, newProjects, 0, prevProjects.length);
-		newProjects[prevProjects.length] = m_file.getProject();
-		description.setReferencedProjects(newProjects);
-		
-		// Set the description
-		jproj.getProject().setDescription(description,
-				new org.eclipse.core.runtime.NullProgressMonitor());
-		
-		IPath outputLocation=jproj.getPath().append(new Path(OUTPUT_LOCATION));
-		IPath classpathLocation=jproj.getPath().append(new Path(CLASSPATH_FILENAME));
-		IPath sourceLocation=jproj.getPath().append(
-				new Path(getSelectedBuildSystem().getJavaSourcePath()));
-		
-		// create and set the output and source paths first
-		IFolder outputFolder= jproj.getProject().getWorkspace().getRoot().getFolder(outputLocation);
-		createParentFolder(outputFolder);
-		outputFolder.create(true, true, new org.eclipse.core.runtime.NullProgressMonitor());
-		outputFolder.setDerived(true);		
-		
-		IFolder sourceFolder= jproj.getProject().getWorkspace().getRoot().getFolder(sourceLocation);
-		createParentFolder(sourceFolder);
-		sourceFolder.create(true, true, new org.eclipse.core.runtime.NullProgressMonitor());
-		sourceFolder.setDerived(true);		
-		
-		IFile file=jproj.getProject().getWorkspace().getRoot().getFile(classpathLocation);
-		file.create(null, true, new org.eclipse.core.runtime.NullProgressMonitor());
-		file.setDerived(true);
-		
-		// Write empty contents, to overcome 'Resource '..' is not local' exception
-		String classpath="<classpath/>";
-		file.setContents(new java.io.ByteArrayInputStream(classpath.getBytes()), true,
-				false, new org.eclipse.core.runtime.NullProgressMonitor());
-			
-		IClasspathEntry[] classpaths=new IClasspathEntry[2];
-		
-		classpaths[0] = JavaCore.newContainerEntry(
-				new Path("org.eclipse.jdt.launching.JRE_CONTAINER"));
-					
-		classpaths[1] = JavaCore.newSourceEntry(sourceLocation);
-					
-		jproj.setRawClasspath(classpaths, outputLocation,
-				new org.eclipse.core.runtime.NullProgressMonitor());
-		
-		return(jproj);
-	}
-
 	/**
-	 * This method checks whether the parent folder exists,
-	 * and if not attempts to create it.
-	 * 
-	 * @param res The current resource
-	 */
-	protected void createParentFolder(IResource res) {
-		
-		if (res.getParent() instanceof IFolder) {
-			IFolder parent=(IFolder)res.getParent();
-			
-			if (parent.exists() == false) {
-				createParentFolder(parent);
-
-				try {
-					parent.create(true, true,
-							new org.eclipse.core.runtime.NullProgressMonitor());
-				} catch(Exception e) {
-					e.printStackTrace();
-				}
-			}
-		}
-	}
-
-	/**
-	 * This class converts a DOM representation node to
-	 * text.
-	 * 
-	 * @param node The DOM node
-	 * @return The text
-	 * @throws Exception Failed to convert
-	 */
-	protected String getText(Node node) throws Exception {
-		String ret=null;
-			
-		try {
-			// Transform the DOM represent to text
-			java.io.ByteArrayOutputStream xmlstr=
-					new java.io.ByteArrayOutputStream();
-				
-			DOMSource source=new DOMSource();
-			source.setNode(node);
-			
-			StreamResult result=new StreamResult(xmlstr);
-			
-			Transformer trans=
-					TransformerFactory.newInstance().newTransformer();
-			trans.transform(source, result);
-			
-			xmlstr.close();
-			
-			ret = new String(xmlstr.toByteArray());
-			
-			if ((node instanceof org.w3c.dom.Document) == false) {
-				
-				// Strip off any <?xml> header
-				int index=ret.indexOf("<?xml");
-				if (index != -1) {
-					index = ret.indexOf("<", 1);
-					
-					if (index != -1) {
-						ret = ret.substring(index);
-					} else {
-						index = ret.indexOf("?>");
-						
-						if (index != -1) {
-							index += 2;
-							
-							// Remove any trailing whitespaces
-							// after XML header
-							while (index < ret.length() &&
-									Character.isWhitespace(ret.charAt(index))) {
-								index++;
-							}
-							
-							ret = ret.substring(index);
-						}
-					}
-				}
-			}
-
-		} catch(Exception e) {
-			throw new Exception("Failed to transform " +
-					"DOM representation into text", e);
-		}
-		
-		int pos=0;
-		int prevpos=0;
-		StringBuffer buf=new StringBuffer();
-		int level=0;
-		
-		while ((pos=ret.indexOf('<', prevpos)) != -1) {
-			
-			if (prevpos < pos &&
-					ret.substring(prevpos, pos).trim().length() > 0 &&
-					ret.charAt(prevpos-1) != '?') {
-				
-				if (ret.charAt(prevpos) == '\r' &&
-						ret.charAt(prevpos+1) == '\n') {
-					prevpos += 2;
-				}
-				for (int i=0; i < level; i++) {
-					buf.append("    ");
-				}
-				
-				buf.append(ret.substring(prevpos, pos).trim());
-				buf.append("\r\n");
-			}
-			
-			int endpos=ret.indexOf('>', pos);
-		
-			if (endpos > 0) {
-				boolean noreturn=false;
-				
-				if (pos > 0 && ret.charAt(pos+1) == '/') {
-					level--;
-				}
-				
-				for (int i=0; i < level; i++) {
-					buf.append("    ");
-				}
-				buf.append(ret.substring(pos, endpos+1));
-				
-				if (ret.charAt(endpos-1)== '?') {
-					//noreturn = true;
-					
-				} else if (ret.charAt(endpos-1) == '/') {
-					// Ignore
-				} else if (pos > 0 && ret.charAt(pos+1) == '/') {
-					// Ignore
-					
-				} else if (pos > 0 && ret.charAt(pos+1) == '!') {
-					// Ignore
-					
-				} else {
-					level++;
-				}
-							
-				if (noreturn == false) {
-					buf.append("\r\n");
-				}
-				
-				pos = endpos+1;
-			}
-			
-			prevpos = pos;
-		}
-		
-		if (prevpos != -1 &&
-				ret.substring(prevpos).trim().length() > 0) {
-			buf.append(ret.substring(prevpos));
-		}
-		
-		ret = buf.toString();
-		
-		return(ret);
-	}
-
-	/**
 	 * This method is used to report an error.
 	 * 
 	 * @param mesg The error message
@@ -998,6 +358,8 @@
 				SWT.ICON_ERROR|SWT.OK);
 		mbox.setMessage(mesg);
 		mbox.open();
+		
+		logger.log(java.util.logging.Level.SEVERE, mesg, ex);
 	}
 
 	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.dialogs");

Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java	2008-08-19 11:53:13 UTC (rev 253)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-package org.jboss.tools.overlord.jbossesb.dialogs;
-
-/**
- * This class represents the Ant build system.
- */
-public class MavenBuildSystem implements BuildSystem {
-
-	private static final String BUILD_FILE = "pom.xml";
-	private static final String MAVEN = "Maven";
-	private static final String ESB_CONFIG_PATH = "src/main/resources/META-INF/jboss-esb.xml";
-	private static final String DEPLOYMENT_PATH = "src/main/resources/META-INF/deployment.xml";
-	private static final String JBMQ_CONFIG_PATH = "src/main/resources/jbmq-queue-service.xml";
-	private static final String JAVA_SOURCE_PATH = "src/main/java";
-
-	/**
-	 * This method represents the name of the build
-	 * system.
-	 * 
-	 * @return The name
-	 */
-	public String getName() {
-		return(MAVEN);
-	}
-	
-	/**
-	 * This method returns the build configuration file
-	 * path.
-	 * 
-	 * @return The build configuration file path
-	 */
-	public String getBuildFilePath() {
-		return(BUILD_FILE);
-	}
-	
-	/**
-	 * This method returns the contents for the build
-	 * configuration file.
-	 * 
-	 * @param projectName The project name
-	 * @return The build file contents
-	 */
-	public String getBuildFileContents(String projectName) {
-		StringBuffer ret=new StringBuffer();
-		
-		ret.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n");
-		ret.append("\t\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"); 
-		ret.append("\t\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\r\n");
-
-		ret.append("</project>\r\n");
-		
-		return(ret.toString());
-	}
-	
-	/**
-	 * This method returns the ESB configuration file
-	 * path.
-	 * 
-	 * @return The ESB configuration file path
-	 */
-	public String getESBConfigFilePath() {
-		return(ESB_CONFIG_PATH);
-	}
-	
-	/**
-	 * This method returns the deployment file
-	 * path.
-	 * 
-	 * @return The deployment file path
-	 */
-	public String getDeploymentFilePath() {
-		return(DEPLOYMENT_PATH);
-	}
-	
-	/**
-	 * This method returns the JBMQ configuration file
-	 * path.
-	 * 
-	 * @return The JBMQ configuration file path
-	 */
-	public String getJBMQConfigFilePath() {
-		return(JBMQ_CONFIG_PATH);
-	}
-	
-	/**
-	 * This method returns the Java source path.
-	 * 
-	 * @return The Java source path
-	 */
-	public String getJavaSourcePath() {
-		return(JAVA_SOURCE_PATH);
-	}
-	
-}

Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/AntBuildSystem.java (from rev 223, cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/AntBuildSystem.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/AntBuildSystem.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/AntBuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class AntBuildSystem implements BuildSystem {
+
+	private static final String BUILD_FILE = "build.xml";
+	private static final String ANT = "Ant";
+	private static final String ESB_CONFIG_PATH = "src/conf/jboss-esb.xml";
+	private static final String DEPLOYMENT_PATH = "src/conf/deployment.xml";
+	private static final String JBMQ_CONFIG_PATH = "src/conf/jbmq-queue-service.xml";
+	private static final String JAVA_SOURCE_PATH = "src/java";
+
+	/**
+	 * This method represents the name of the build
+	 * system.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(ANT);
+	}
+	
+	/**
+	 * This method returns the build configuration file
+	 * path.
+	 * 
+	 * @return The build configuration file path
+	 */
+	public String getBuildFilePath() {
+		return(BUILD_FILE);
+	}
+	
+	/**
+	 * This method returns the contents for the build
+	 * configuration file.
+	 * 
+	 * @param projectName The project name
+	 * @return The build file contents
+	 */
+	public String getBuildFileContents(String projectName) {
+		StringBuffer ret=new StringBuffer();
+		
+		ret.append("<project name=\""+projectName+
+					"\" default=\"startdb\" basedir=\".\">\r\n");
+
+		ret.append("</project>\r\n");
+		
+		return(ret.toString());
+	}
+	
+	/**
+	 * This method returns the ESB configuration file
+	 * path.
+	 * 
+	 * @return The ESB configuration file path
+	 */
+	public String getESBConfigFilePath() {
+		return(ESB_CONFIG_PATH);
+	}
+	
+	/**
+	 * This method returns the deployment file
+	 * path.
+	 * 
+	 * @return The deployment file path
+	 */
+	public String getDeploymentFilePath() {
+		return(DEPLOYMENT_PATH);
+	}
+	
+	/**
+	 * This method returns the JBMQ configuration file
+	 * path.
+	 * 
+	 * @return The JBMQ configuration file path
+	 */
+	public String getJBMQConfigFilePath() {
+		return(JBMQ_CONFIG_PATH);
+	}
+	
+	/**
+	 * This method returns the Java source path.
+	 * 
+	 * @return The Java source path
+	 */
+	public String getJavaSourcePath() {
+		return(JAVA_SOURCE_PATH);
+	}
+	
+}


Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/AntBuildSystem.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildConfigurationGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildConfigurationGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildConfigurationGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+
+/**
+ * This class implements the model based generator to generate
+ * the build configuration.
+ */
+public class BuildConfigurationGenerator implements ModelBasedGenerator {
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied model, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param model The model
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			ESBLanguageModel model, BuildSystem buildSystem)
+					throws GeneratorException {
+	
+		IPath buildConfigPath=jproj.getPath().append(
+				new Path(buildSystem.getBuildFilePath()));
+		
+		IFile buildConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
+		
+		GeneratorUtil.createParentFolder(buildConfigFile);
+		
+		try {
+			buildConfigFile.create(null, true,
+					new org.eclipse.core.runtime.NullProgressMonitor());
+			
+			String config=buildSystem.getBuildFileContents(jproj.getProject().getName());
+			
+			if (config != null) {
+				buildConfigFile.setContents(new java.io.ByteArrayInputStream(
+						config.getBytes()), true, false,
+						new org.eclipse.core.runtime.NullProgressMonitor());
+			}
+		} catch(Exception e) {
+			throw new GeneratorException("Failed to create build config", e);
+		}
+	}
+}

Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildSystem.java (from rev 223, cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/BuildSystem.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildSystem.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+/**
+ * This interface represents a build system used when
+ * generating the ESB projects.
+ */
+public interface BuildSystem {
+
+	/**
+	 * This method represents the name of the build
+	 * system.
+	 * 
+	 * @return The name
+	 */
+	public String getName();
+	
+	/**
+	 * This method returns the build configuration file
+	 * path.
+	 * 
+	 * @return The build configuration file path
+	 */
+	public String getBuildFilePath();
+	
+	/**
+	 * This method returns the contents for the build
+	 * configuration file.
+	 * 
+	 * @param projectName The project name
+	 * @return The build file contents
+	 */
+	public String getBuildFileContents(String projectName);
+	
+	/**
+	 * This method returns the ESB configuration file
+	 * path.
+	 * 
+	 * @return The ESB configuration file path
+	 */
+	public String getESBConfigFilePath();
+	
+	/**
+	 * This method returns the deployment file
+	 * path.
+	 * 
+	 * @return The deployment file path
+	 */
+	public String getDeploymentFilePath();
+	
+	/**
+	 * This method returns the JBMQ configuration file
+	 * path.
+	 * 
+	 * @return The JBMQ configuration file path
+	 */
+	public String getJBMQConfigFilePath();
+	
+	/**
+	 * This method returns the Java source path.
+	 * 
+	 * @return The Java source path
+	 */
+	public String getJavaSourcePath();
+	
+}


Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BuildSystem.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BusinessObjectTypeGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BusinessObjectTypeGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/BusinessObjectTypeGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,429 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.Assignment;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ExpressionStatement;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Javadoc;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.PackageDeclaration;
+import org.eclipse.jdt.core.dom.PrimitiveType;
+import org.eclipse.jdt.core.dom.ReturnStatement;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.TagElement;
+import org.eclipse.jdt.core.dom.TextElement;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+import org.jboss.tools.overlord.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.jbossesb.model.util.InteractionUtil;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.Variable;
+import org.scribble.conversation.model.VariableList;
+import org.scribble.model.Interaction;
+import org.scribble.model.ModelObject;
+import org.scribble.model.Role;
+import org.scribble.model.Visitor;
+
+/**
+ * This class implements the conversation based generator
+ * for generating the business object type associated with
+ * a conversation.
+ */
+public class BusinessObjectTypeGenerator implements ConversationBasedGenerator {
+
+	private static final String GENERATOR_MESSAGES = "org.jboss.tools.overlord.jbossesb.generator.Messages";
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied conversation, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param conversation The conversation
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			Conversation conversation, BuildSystem buildSystem)
+						throws GeneratorException {
+		IPath sourceLocation=jproj.getPath().append(
+				new Path(buildSystem.getJavaSourcePath()));
+		
+		String javaClass=ConversationUtil.getBusinessObjectType(conversation);
+		
+		String javaPath=javaClass.replace('.', '/')+".java";
+		
+		IPath javaFile=sourceLocation.append(new Path(javaPath));
+				
+		IFile file=jproj.getProject().getWorkspace().getRoot().getFile(javaFile);
+
+		GeneratorUtil.createParentFolder(file);
+		
+		try {
+			file.create(null, true, new org.eclipse.core.runtime.NullProgressMonitor());
+		} catch(Exception e) {
+			throw new GeneratorException("Failed to create the file", e);
+		}
+		
+		ASTParser parser = ASTParser.newParser(AST.JLS3);
+		parser.setResolveBindings(true);
+		parser.setSource(new char[0]);
+		
+		CompilationUnit root=(CompilationUnit)parser.createAST(null);
+		
+		AST ast=root.getAST();
+		
+		org.eclipse.jface.text.IDocument doc=
+					new org.eclipse.jface.text.Document();
+
+		root.recordModifications();
+		
+		PackageDeclaration pd=ast.newPackageDeclaration();
+		pd.setName(ast.newName(ConversationUtil.getBusinessObjectTypePackageName(conversation)));
+		root.setPackage(pd);
+		
+		TypeDeclaration type=ast.newTypeDeclaration();
+		
+		type.setName(ast.newSimpleName(ConversationUtil.getBusinessObjectTypeClassName(conversation)));
+
+		Modifier pubmod=ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD);
+		type.modifiers().add(pubmod);
+		
+		root.types().add(type);
+		
+		// Process conversation to obtain necessary methods and
+		// properties
+		generateBusinessObjectTypeMethods(type, conversation);
+		
+		org.eclipse.text.edits.TextEdit edits=root.rewrite(doc, null);
+		
+		try {
+			edits.apply(doc);
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+		
+		java.io.ByteArrayInputStream is=
+			new java.io.ByteArrayInputStream(doc.get().getBytes());
+		
+		try {
+			file.setContents(is, false, true, null);
+			
+			is.close();
+		} catch(Exception e) {
+			throw new GeneratorException("Failed to set file contents and close", e);
+		}
+	}
+	
+	protected void generateBusinessObjectTypeMethods(TypeDeclaration type,
+					final Conversation conversation) throws GeneratorException {
+		final java.util.List<Role> roles=new java.util.Vector<Role>();
+		final java.util.List<Variable> variables=new java.util.Vector<Variable>();
+		
+		conversation.visit(new Visitor() {
+			public boolean visit(ModelObject obj) {
+				boolean ret=true;
+				
+				if (obj instanceof Conversation &&
+						obj != conversation) {
+					ret = false;
+				} else if (obj instanceof Interaction) {
+					Interaction interaction=(Interaction)obj;
+					
+					// If send and a response, then create
+					// 'to' role service category/name
+					// methods
+					if (InteractionUtil.isSend(interaction) &&
+							interaction.getReplyToLabel() == null &&
+							interaction.getToRole() != null &&
+							roles.contains(interaction.getToRole()) == false) {
+						roles.add(interaction.getToRole());
+					}
+				} else if (obj instanceof VariableList) {
+					VariableList vars=(VariableList)obj;
+					
+					variables.addAll(vars.getVariables());
+				}
+				
+				return(ret);
+			}
+		});
+
+		generateServiceCategoryAndNameMethods(type, roles);
+		
+		generateAccessorAndModifierMethods(type, variables);
+		generateMemberVariables(type, variables);
+	}
+	
+	/**
+	 * This method generates the methods for returning the
+	 * service category and name associated with a service
+	 * being invoked.
+	 * 
+	 * @param type The type declaration
+	 * @param roles The list of roles representing the invoked
+	 * 						services
+	 */
+	protected void generateServiceCategoryAndNameMethods(TypeDeclaration type,
+							java.util.List<Role> roles) {
+		AST ast=type.getAST();
+
+		for (int i=0; i < roles.size(); i++) {
+			String methodName=
+				InteractionUtil.getRoleServiceCategoryAccessorMethod(roles.get(i).getName());
+			
+			MethodDeclaration method=ast.newMethodDeclaration();
+			method.setName(ast.newSimpleName(methodName));
+			method.setReturnType2(ast.newSimpleType(
+					ast.newName("String")));
+	
+			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+	
+			org.eclipse.jdt.core.dom.Block block=ast.newBlock();
+						
+			ReturnStatement retStatement=ast.newReturnStatement();
+			
+			retStatement.setExpression(ast.newNullLiteral());
+			
+			block.statements().add(retStatement);
+			
+			method.setBody(block);				
+			
+			type.bodyDeclarations().add(method);
+			
+			methodName=
+				InteractionUtil.getRoleServiceNameAccessorMethod(roles.get(i).getName());
+			
+			method=ast.newMethodDeclaration();
+			method.setName(ast.newSimpleName(methodName));
+			method.setReturnType2(ast.newSimpleType(
+					ast.newName("String")));
+	
+			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+	
+			block=ast.newBlock();
+			
+			retStatement=ast.newReturnStatement();
+			
+			retStatement.setExpression(ast.newNullLiteral());
+			
+			block.statements().add(retStatement);
+			
+			method.setBody(block);				
+			
+			type.bodyDeclarations().add(method);
+		}
+	}
+	
+	/**
+	 * This method generates the accessor and modifier methods
+	 * associated with the business state variables used by
+	 * the conversation based actions.
+	 * 
+	 * @param type The type declaration
+	 * @param variables The list of variables
+	 */
+	protected void generateAccessorAndModifierMethods(TypeDeclaration type,
+			java.util.List<Variable> variables) {
+		AST ast=type.getAST();
+	
+		for (int i=0; i < variables.size(); i++) {			
+			String methodName=
+				ConversationUtil.getVariableAccessorMethod(variables.get(i).getName());
+			String memberVariableName=
+				ConversationUtil.getMemberVariableName(variables.get(i).getName());
+			
+			MethodDeclaration method=ast.newMethodDeclaration();
+			method.setName(ast.newSimpleName(methodName));
+			
+			String typeName=TypeMapper.getJavaType(
+					variables.get(i).getType().getNamespace(),
+					variables.get(i).getType().getLocalpart());
+			
+			Type returnType=null;
+			
+			// Check if qualified or base type
+			if (typeName.indexOf('.') == -1) {
+				returnType = ast.newPrimitiveType(PrimitiveType.toCode(typeName));
+			} else {
+				returnType = getType(ast, typeName);			
+			}
+	
+			method.setReturnType2(returnType);
+			
+			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+	
+			org.eclipse.jdt.core.dom.Block block=ast.newBlock();
+			
+			ReturnStatement retStatement=ast.newReturnStatement();
+			
+			retStatement.setExpression(ast.newSimpleName(memberVariableName));
+			
+			block.statements().add(retStatement);
+			
+			method.setBody(block);				
+			
+			Javadoc jdoc=ast.newJavadoc();
+			TagElement tag=ast.newTagElement();
+			
+			TextElement text=ast.newTextElement();
+			
+			text.setText(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+							GENERATOR_MESSAGES),
+								"_ACCESSOR_DESCRIPTION",
+							new String[]{variables.get(i).getName()}));
+			
+			tag.fragments().add(text);
+			
+			jdoc.tags().add(tag);
+			
+			method.setJavadoc(jdoc);
+
+			type.bodyDeclarations().add(method);
+			
+			// Generate setter method
+			methodName=
+				ConversationUtil.getVariableModifierMethod(variables.get(i).getName());
+			
+			method=ast.newMethodDeclaration();
+			method.setName(ast.newSimpleName(methodName));
+			method.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
+			
+			SingleVariableDeclaration svd=ast.newSingleVariableDeclaration();
+			svd.setName(ast.newSimpleName("value"));
+
+			Type paramType=null;
+			
+			// Check if qualified or base type
+			if (typeName.indexOf('.') == -1) {
+				paramType = ast.newPrimitiveType(PrimitiveType.toCode(typeName));
+			} else {
+				paramType = getType(ast, typeName);			
+			}
+			
+			svd.setType(paramType);
+			
+			method.parameters().add(svd);
+	
+			method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
+	
+			block=ast.newBlock();
+			
+			method.setBody(block);
+			
+			// Assign value to member variable
+			Assignment assign=ast.newAssignment();
+			assign.setLeftHandSide(ast.newSimpleName(memberVariableName));
+			assign.setRightHandSide(ast.newSimpleName("value"));
+			
+			ExpressionStatement statement=ast.newExpressionStatement(assign);
+			
+			block.statements().add(statement);
+			
+			jdoc = ast.newJavadoc();
+			tag = ast.newTagElement();
+			
+			text = ast.newTextElement();
+			
+			text.setText(org.scribble.util.MessageUtil.format(
+					java.util.PropertyResourceBundle.getBundle(
+							GENERATOR_MESSAGES),
+								"_MODIFIER_DESCRIPTION",
+							new String[]{variables.get(i).getName()}));
+			
+			tag.fragments().add(text);
+			
+			jdoc.tags().add(tag);
+			
+			method.setJavadoc(jdoc);
+			
+			type.bodyDeclarations().add(method);
+		}
+	}
+	
+	/**
+	 * This method generates the member variables
+	 * associated with the business state variables used by
+	 * the conversation based actions.
+	 * 
+	 * @param type The type declaration
+	 * @param variables The list of variables
+	 */
+	protected void generateMemberVariables(TypeDeclaration type,
+			java.util.List<Variable> variables) {
+		AST ast=type.getAST();
+
+		for (int i=0; i < variables.size(); i++) {			
+			String memberVariableName=
+				ConversationUtil.getMemberVariableName(variables.get(i).getName());
+			
+			VariableDeclarationFragment fragment=
+				ast.newVariableDeclarationFragment();
+			fragment.setName(ast.newSimpleName(memberVariableName));
+
+			FieldDeclaration memberVariable=ast.newFieldDeclaration(fragment);
+
+			Type paramType=null;
+			String typeName=TypeMapper.getJavaType(
+					variables.get(i).getType().getNamespace(),
+					variables.get(i).getType().getLocalpart());
+			
+			// Check if qualified or base type
+			if (typeName.indexOf('.') == -1) {
+				paramType = ast.newPrimitiveType(PrimitiveType.toCode(typeName));
+			} else {
+				paramType = getType(ast, typeName);			
+			}
+			
+			memberVariable.setType(paramType);
+			
+			memberVariable.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD));
+			
+			type.bodyDeclarations().add(memberVariable);
+		}
+	}
+	
+	protected Type getType(AST ast, String typeName) {
+		Type ret=null;
+		
+		java.util.StringTokenizer st=new java.util.StringTokenizer(typeName, ".");
+		while (st.hasMoreTokens()) {
+			String token=st.nextToken();
+			
+			if (ret == null) {
+				ret = ast.newSimpleType(ast.newSimpleName(token));
+			} else {
+				ret = ast.newQualifiedType(ret, ast.newSimpleName(token));
+			}
+		}
+		
+		return(ret);
+	}
+		
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ConversationBasedGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ConversationBasedGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ConversationBasedGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.scribble.conversation.model.Conversation;
+
+/**
+ * This interface represents a module that generates artefacts
+ * based on a specific conversation.
+ */
+public interface ConversationBasedGenerator {
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied conversation, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param conversation The conversation
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			Conversation conversation, BuildSystem buildSystem)
+					throws GeneratorException;
+	
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/DeploymentFileGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/DeploymentFileGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/DeploymentFileGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.jboss.tools.overlord.jbossesb.model.ESBService;
+
+/**
+ * This class implements the model based generator to generate
+ * the deployment file.
+ */
+public class DeploymentFileGenerator implements ModelBasedGenerator {
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied model, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param model The model
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			ESBLanguageModel model, BuildSystem buildSystem)
+					throws GeneratorException {
+		
+		try {
+			IPath deploymentPath=jproj.getPath().append(
+					new Path(buildSystem.getDeploymentFilePath()));
+			
+			IFile deploymentFile=jproj.getProject().getWorkspace().getRoot().getFile(deploymentPath);
+			GeneratorUtil.createParentFolder(deploymentFile);
+			deploymentFile.create(null, true,
+					new org.eclipse.core.runtime.NullProgressMonitor());
+	
+			StringBuffer buf=new StringBuffer();
+			buf.append("<jbossesb-deployment>\r\n");
+			
+			java.util.Iterator<ESBService> iter=model.getServices().iterator();
+			
+			while (iter.hasNext()) {
+				ESBService service=iter.next();
+				
+				String dest=model.getJMSDefinition(service.getJMSBusIdRef());
+				
+				if (dest != null) {
+					buf.append("\t<depends>"+service.getCategory()+
+							".destination:service=Queue,name="+dest+
+							"</depends>\r\n");
+				} else {
+					logger.severe("Failed to find destination for JMS bus id '"+
+							service.getJMSBusIdRef()+"'");
+				}
+			}
+			
+			buf.append("</jbossesb-deployment>\r\n");
+			
+			deploymentFile.setContents(new java.io.ByteArrayInputStream(
+						buf.toString().getBytes()), true, false,
+						new org.eclipse.core.runtime.NullProgressMonitor());
+		} catch(Exception e) {
+			throw new GeneratorException("Failed to save deployment file", e);
+		}
+	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.generator");
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Generator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Generator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,443 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.overlord.jbossesb.generator.BuildSystem;
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.change.ModelGenerator;
+import org.scribble.conversation.model.*;
+import org.w3c.dom.Node;
+import org.eclipse.jdt.core.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+/**
+ * This class provides the mechanism for generating JBossESB
+ * service artefacts.
+ */
+public class Generator {
+
+	private static final String CLASSPATH_FILENAME = ".classpath";
+	private static final String OUTPUT_LOCATION = "classes";
+	
+	/**
+	 * This is the constructor for the generator.
+	 * 
+	 */
+	public Generator(IFile file, BuildSystem buildSystem) {
+		m_file = file;
+		m_buildSystem = buildSystem;
+		
+		initialize(m_file);
+	}
+	
+	/**
+	 * This method initializes the conversation model associated
+	 * with the supplied file resource.
+	 * 
+	 * @param res The file
+	 */
+	protected void initialize(IFile res) {
+		
+		// Initialize the artefact generators
+		m_conversationBasedGen.add(new BusinessObjectTypeGenerator());
+		
+		m_modelBasedGen.add(new BuildConfigurationGenerator());
+		m_modelBasedGen.add(new JBMQConfigurationGenerator());
+		m_modelBasedGen.add(new DeploymentFileGenerator());
+		
+		// Initialize the model
+		ModelReference ref=
+			org.scribble.osgi.model.OSGIModelRepository.createReference(res);
+		
+		if (ref != null) {
+			ModelRepository mrep=(ModelRepository)
+					RegistryFactory.getRegistry().getExtension(
+						ModelRepository.class, null);
+
+			if (mrep != null) {
+				Model model=mrep.getModel(ref,
+								new DefaultModelListener());
+				
+				if (model instanceof ConversationModel) {
+					m_conversationModel = (ConversationModel)model;
+					
+					m_roles = m_conversationModel.getRoles();
+				}
+			}
+		}
+		
+		if (m_conversationModel == null) {
+			logger.severe("Unable to load model used to generate " +
+					"the ESB artefacts");
+		}
+	}
+	
+	/**
+	 * This method returns the roles that can be generated.
+	 * 
+	 * @return The roles
+	 */
+	public java.util.List<Role> getRoles() {
+		return(m_roles);
+	}
+	
+	/**
+	 * This method generates the project associated with the
+	 * supplied role.
+	 * 
+	 * @param role The role
+	 * @param projectName The project name
+	 * @throws Exception Failed to generate role
+	 */
+	public void generateRole(Role role, String projectName)
+						throws Exception {
+		
+		if (logger.isLoggable(Level.FINEST)) {
+			logger.finest("Generate role '"+role+"' for: "+
+						m_conversationModel);
+		}
+		
+		// Project to role
+		org.scribble.projector.Projector projector=
+			(org.scribble.projector.Projector)
+			RegistryFactory.getRegistry().getExtension(
+					org.scribble.projector.Projector.class, null);
+
+		if (projector != null) {
+			Model localModel=projector.project(m_conversationModel,
+					role, new DefaultModelListener());
+			
+			if (localModel instanceof ConversationModel &&
+					((ConversationModel)localModel).getConversation() != null) {
+				ConversationModel lcm=(ConversationModel)localModel;
+				
+				ModelReference targetRef=
+					new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
+				
+				DefaultESBLanguageModel target=
+					new DefaultESBLanguageModel(targetRef);
+				
+				ModelGenerator generator=(ModelGenerator)
+					RegistryFactory.getRegistry().getExtension(
+							ModelGenerator.class, null);
+				
+				if (generator != null) {
+					generator.generate(targetRef, role, target,
+								lcm);
+					
+					generateRoleProject(projectName,
+								target.getESBConfiguration(),
+								lcm, target);
+				} else {
+					logger.severe("Unable to find model generator");
+				}
+			}
+		}
+	}
+	
+	protected void generateRoleProject(String projectName,
+			org.w3c.dom.Element esbConfig, ConversationModel localcm,
+			ESBLanguageModel model)	throws Exception {
+		
+		final IJavaProject jproj=createJavaProject(projectName);
+		
+		if (jproj != null && esbConfig != null) {
+			// Generate business object types for
+			// local conversation model
+			localcm.visit(new Visitor() {
+
+				public boolean visit(ModelObject obj) {
+					
+					if (obj instanceof Conversation) {
+						for (int i=0; i < m_conversationBasedGen.size(); i++) {
+							try {
+								m_conversationBasedGen.get(i).generate(jproj,
+									(Conversation)obj, getBuildSystem());
+							} catch(GeneratorException e) {
+								logger.log(java.util.logging.Level.SEVERE,
+										"Failed to generate conversation based artefact",
+										e);
+							}
+						}
+					}
+					
+					return true;
+				}	
+			});
+			
+			// Store ESB configuration
+			IPath esbConfigPath=jproj.getPath().append(
+					new Path(getBuildSystem().getESBConfigFilePath()));
+			
+			IFile esbConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(esbConfigPath);
+			GeneratorUtil.createParentFolder(esbConfigFile);
+			esbConfigFile.create(null, true,
+					new org.eclipse.core.runtime.NullProgressMonitor());
+			
+			String config=getText(esbConfig);
+			
+			if (config != null) {
+				esbConfigFile.setContents(new java.io.ByteArrayInputStream(
+						config.getBytes()), true, false,
+						new org.eclipse.core.runtime.NullProgressMonitor());
+			}
+			
+			for (int i=0; i < m_modelBasedGen.size(); i++) {
+				try {
+					m_modelBasedGen.get(i).generate(jproj, model,
+							getBuildSystem());
+				} catch(GeneratorException e) {
+					logger.log(java.util.logging.Level.SEVERE,
+							"Failed to generate model based artefact",
+							e);
+				}
+			}
+		}
+	}
+			
+	protected IJavaProject createJavaProject(String projectName)
+							throws Exception {
+		
+		// Create project
+		IProject project=m_file.getWorkspace().getRoot().getProject(projectName);
+		project.create(new org.eclipse.core.runtime.NullProgressMonitor());
+
+		IJavaProject jproj=JavaCore.create(project);
+		
+		project.open(new org.eclipse.core.runtime.NullProgressMonitor());
+		
+		IProjectDescription description = jproj.getProject().getDescription();
+		
+		// Update the project natures to include Java Nature
+		String[] prevNatures= description.getNatureIds();
+		String[] newNatures= new String[prevNatures.length + 1];
+		System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+		newNatures[prevNatures.length]= JavaCore.NATURE_ID;
+		description.setNatureIds(newNatures);
+		
+		// Setup project reference to CDM project
+		IProject[] prevProjects=description.getReferencedProjects();
+		IProject[] newProjects=new IProject[prevProjects.length+1];
+		System.arraycopy(prevProjects, 0, newProjects, 0, prevProjects.length);
+		newProjects[prevProjects.length] = m_file.getProject();
+		description.setReferencedProjects(newProjects);
+		
+		// Set the description
+		jproj.getProject().setDescription(description,
+				new org.eclipse.core.runtime.NullProgressMonitor());
+		
+		IPath outputLocation=jproj.getPath().append(new Path(OUTPUT_LOCATION));
+		IPath classpathLocation=jproj.getPath().append(new Path(CLASSPATH_FILENAME));
+		IPath sourceLocation=jproj.getPath().append(
+				new Path(getBuildSystem().getJavaSourcePath()));
+		
+		// create and set the output and source paths first
+		IFolder outputFolder= jproj.getProject().getWorkspace().getRoot().getFolder(outputLocation);
+		GeneratorUtil.createParentFolder(outputFolder);
+		outputFolder.create(true, true, new org.eclipse.core.runtime.NullProgressMonitor());
+		outputFolder.setDerived(true);		
+		
+		IFolder sourceFolder= jproj.getProject().getWorkspace().getRoot().getFolder(sourceLocation);
+		GeneratorUtil.createParentFolder(sourceFolder);
+		sourceFolder.create(true, true, new org.eclipse.core.runtime.NullProgressMonitor());
+		sourceFolder.setDerived(true);		
+		
+		IFile file=jproj.getProject().getWorkspace().getRoot().getFile(classpathLocation);
+		file.create(null, true, new org.eclipse.core.runtime.NullProgressMonitor());
+		file.setDerived(true);
+		
+		// Write empty contents, to overcome 'Resource '..' is not local' exception
+		String classpath="<classpath/>";
+		file.setContents(new java.io.ByteArrayInputStream(classpath.getBytes()), true,
+				false, new org.eclipse.core.runtime.NullProgressMonitor());
+			
+		IClasspathEntry[] classpaths=new IClasspathEntry[2];
+		
+		classpaths[0] = JavaCore.newContainerEntry(
+				new Path("org.eclipse.jdt.launching.JRE_CONTAINER"));
+					
+		classpaths[1] = JavaCore.newSourceEntry(sourceLocation);
+					
+		jproj.setRawClasspath(classpaths, outputLocation,
+				new org.eclipse.core.runtime.NullProgressMonitor());
+		
+		return(jproj);
+	}
+
+	/**
+	 * This class converts a DOM representation node to
+	 * text.
+	 * 
+	 * @param node The DOM node
+	 * @return The text
+	 * @throws Exception Failed to convert
+	 */
+	protected String getText(Node node) throws Exception {
+		String ret=null;
+			
+		try {
+			// Transform the DOM represent to text
+			java.io.ByteArrayOutputStream xmlstr=
+					new java.io.ByteArrayOutputStream();
+				
+			DOMSource source=new DOMSource();
+			source.setNode(node);
+			
+			StreamResult result=new StreamResult(xmlstr);
+			
+			Transformer trans=
+					TransformerFactory.newInstance().newTransformer();
+			trans.transform(source, result);
+			
+			xmlstr.close();
+			
+			ret = new String(xmlstr.toByteArray());
+			
+			if ((node instanceof org.w3c.dom.Document) == false) {
+				
+				// Strip off any <?xml> header
+				int index=ret.indexOf("<?xml");
+				if (index != -1) {
+					index = ret.indexOf("<", 1);
+					
+					if (index != -1) {
+						ret = ret.substring(index);
+					} else {
+						index = ret.indexOf("?>");
+						
+						if (index != -1) {
+							index += 2;
+							
+							// Remove any trailing whitespaces
+							// after XML header
+							while (index < ret.length() &&
+									Character.isWhitespace(ret.charAt(index))) {
+								index++;
+							}
+							
+							ret = ret.substring(index);
+						}
+					}
+				}
+			}
+
+		} catch(Exception e) {
+			throw new Exception("Failed to transform " +
+					"DOM representation into text", e);
+		}
+		
+		int pos=0;
+		int prevpos=0;
+		StringBuffer buf=new StringBuffer();
+		int level=0;
+		
+		while ((pos=ret.indexOf('<', prevpos)) != -1) {
+			
+			if (prevpos < pos &&
+					ret.substring(prevpos, pos).trim().length() > 0 &&
+					ret.charAt(prevpos-1) != '?') {
+				
+				if (ret.charAt(prevpos) == '\r' &&
+						ret.charAt(prevpos+1) == '\n') {
+					prevpos += 2;
+				}
+				for (int i=0; i < level; i++) {
+					buf.append("    ");
+				}
+				
+				buf.append(ret.substring(prevpos, pos).trim());
+				buf.append("\r\n");
+			}
+			
+			int endpos=ret.indexOf('>', pos);
+		
+			if (endpos > 0) {
+				boolean noreturn=false;
+				
+				if (pos > 0 && ret.charAt(pos+1) == '/') {
+					level--;
+				}
+				
+				for (int i=0; i < level; i++) {
+					buf.append("    ");
+				}
+				buf.append(ret.substring(pos, endpos+1));
+				
+				if (ret.charAt(endpos-1)== '?') {
+					//noreturn = true;
+					
+				} else if (ret.charAt(endpos-1) == '/') {
+					// Ignore
+				} else if (pos > 0 && ret.charAt(pos+1) == '/') {
+					// Ignore
+					
+				} else if (pos > 0 && ret.charAt(pos+1) == '!') {
+					// Ignore
+					
+				} else {
+					level++;
+				}
+							
+				if (noreturn == false) {
+					buf.append("\r\n");
+				}
+				
+				pos = endpos+1;
+			}
+			
+			prevpos = pos;
+		}
+		
+		if (prevpos != -1 &&
+				ret.substring(prevpos).trim().length() > 0) {
+			buf.append(ret.substring(prevpos));
+		}
+		
+		ret = buf.toString();
+		
+		return(ret);
+	}
+	
+	public BuildSystem getBuildSystem() {
+		return(m_buildSystem);
+	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.generator");
+
+	private IFile m_file=null;
+	private java.util.List<Role> m_roles=null;
+	private ConversationModel m_conversationModel=null;
+	private BuildSystem m_buildSystem=null;
+	private java.util.List<ConversationBasedGenerator> m_conversationBasedGen=
+		new java.util.Vector<ConversationBasedGenerator>();
+	private java.util.List<ModelBasedGenerator> m_modelBasedGen=
+		new java.util.Vector<ModelBasedGenerator>();
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorException.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorException.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorException.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+public class GeneratorException extends Exception {
+
+	private static final long serialVersionUID = -2263049447116467663L;
+	
+	/**
+	 * This constructor initializes the generator exception
+	 * with a message and the underlying exception that
+	 * caused the problem.
+	 * 
+	 * @param mesg The message
+	 * @param t The cause
+	 */
+	public GeneratorException(String mesg, Throwable t) {
+		super(mesg, t);
+	}
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorUtil.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/GeneratorUtil.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class GeneratorUtil {
+
+	/**
+	 * This method checks whether the parent folder exists,
+	 * and if not attempts to create it.
+	 * 
+	 * @param res The current resource
+	 */
+	public static void createParentFolder(IResource res) {
+		
+		if (res.getParent() instanceof IFolder) {
+			IFolder parent=(IFolder)res.getParent();
+			
+			if (parent.exists() == false) {
+				createParentFolder(parent);
+
+				try {
+					parent.create(true, true,
+							new org.eclipse.core.runtime.NullProgressMonitor());
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/JBMQConfigurationGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/JBMQConfigurationGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/JBMQConfigurationGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+import org.jboss.tools.overlord.jbossesb.model.ESBService;
+
+/**
+ * This class implements the model based generator to generate
+ * the JBMQ configuration.
+ */
+public class JBMQConfigurationGenerator implements ModelBasedGenerator {
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied model, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param model The model
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			ESBLanguageModel model, BuildSystem buildSystem)
+					throws GeneratorException {
+		IPath buildConfigPath=jproj.getPath().append(
+				new Path(buildSystem.getJBMQConfigFilePath()));
+		
+		IFile jbmqConfigFile=jproj.getProject().getWorkspace().getRoot().getFile(buildConfigPath);
+		GeneratorUtil.createParentFolder(jbmqConfigFile);
+		
+		try {
+			jbmqConfigFile.create(null, true,
+					new org.eclipse.core.runtime.NullProgressMonitor());
+			
+			StringBuffer buf=new StringBuffer();
+			buf.append("<server>\r\n");
+			
+			java.util.Iterator<ESBService> iter=model.getServices().iterator();
+			
+			while (iter.hasNext()) {
+				ESBService service=iter.next();
+				
+				String dest=model.getJMSDefinition(service.getJMSBusIdRef());
+				
+				if (dest != null) {
+					buf.append("\t<mbean code=\"org.jboss.mq.server.jmx.Queue\"\r\n");
+					buf.append("\t\t\tname=\""+service.getCategory()+".destination:service=Queue,name="+dest+"\">\r\n");
+					buf.append("\t\t<depends optional-attribute-name=\"DestinationManager\">\r\n");
+					buf.append("\t\t\tjboss.mq:service=DestinationManager\r\n");
+					buf.append("\t\t</depends>\r\n");
+					buf.append("\t</mbean>\r\n");
+				} else {
+					logger.severe("Failed to find destination for JMS bus id '"+
+							service.getJMSBusIdRef()+"'");
+				}
+			}
+			
+			buf.append("</server>\r\n");
+
+			jbmqConfigFile.setContents(new java.io.ByteArrayInputStream(
+					buf.toString().getBytes()), true, false,
+					new org.eclipse.core.runtime.NullProgressMonitor());
+		} catch(Exception e) {
+			throw new GeneratorException("Failed to save JBMQ configuration", e);
+		}
+	}
+
+	private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.jbossesb.generator");
+}

Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/MavenBuildSystem.java (from rev 223, cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/MavenBuildSystem.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/MavenBuildSystem.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/MavenBuildSystem.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class MavenBuildSystem implements BuildSystem {
+
+	private static final String BUILD_FILE = "pom.xml";
+	private static final String MAVEN = "Maven";
+	private static final String ESB_CONFIG_PATH = "src/main/resources/META-INF/jboss-esb.xml";
+	private static final String DEPLOYMENT_PATH = "src/main/resources/META-INF/deployment.xml";
+	private static final String JBMQ_CONFIG_PATH = "src/main/resources/jbmq-queue-service.xml";
+	private static final String JAVA_SOURCE_PATH = "src/main/java";
+
+	/**
+	 * This method represents the name of the build
+	 * system.
+	 * 
+	 * @return The name
+	 */
+	public String getName() {
+		return(MAVEN);
+	}
+	
+	/**
+	 * This method returns the build configuration file
+	 * path.
+	 * 
+	 * @return The build configuration file path
+	 */
+	public String getBuildFilePath() {
+		return(BUILD_FILE);
+	}
+	
+	/**
+	 * This method returns the contents for the build
+	 * configuration file.
+	 * 
+	 * @param projectName The project name
+	 * @return The build file contents
+	 */
+	public String getBuildFileContents(String projectName) {
+		StringBuffer ret=new StringBuffer();
+		
+		ret.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n");
+		ret.append("\t\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"); 
+		ret.append("\t\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\r\n");
+
+		ret.append("</project>\r\n");
+		
+		return(ret.toString());
+	}
+	
+	/**
+	 * This method returns the ESB configuration file
+	 * path.
+	 * 
+	 * @return The ESB configuration file path
+	 */
+	public String getESBConfigFilePath() {
+		return(ESB_CONFIG_PATH);
+	}
+	
+	/**
+	 * This method returns the deployment file
+	 * path.
+	 * 
+	 * @return The deployment file path
+	 */
+	public String getDeploymentFilePath() {
+		return(DEPLOYMENT_PATH);
+	}
+	
+	/**
+	 * This method returns the JBMQ configuration file
+	 * path.
+	 * 
+	 * @return The JBMQ configuration file path
+	 */
+	public String getJBMQConfigFilePath() {
+		return(JBMQ_CONFIG_PATH);
+	}
+	
+	/**
+	 * This method returns the Java source path.
+	 * 
+	 * @return The Java source path
+	 */
+	public String getJavaSourcePath() {
+		return(JAVA_SOURCE_PATH);
+	}
+	
+}


Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/MavenBuildSystem.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Messages.properties	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/Messages.properties	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,20 @@
+# /*
+#  * JBoss, Home of Professional Open Source
+#  * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+#  * by the @authors tag. All rights reserved.
+#  * See the copyright.txt in the distribution for a
+#  * full listing of individual contributors.
+#  * This copyrighted material is made available to anyone wishing to use,
+#  * modify, copy, or redistribute it subject to the terms and conditions
+#  * of the GNU Lesser General Public License, v. 2.1.
+#  * This program is distributed in the hope that it will be useful, but WITHOUT A
+#  * 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,
+#  * v.2.1 along with this distribution; if not, write to the Free Software
+#  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+#  * MA  02110-1301, USA.
+#  */
+
+_ACCESSOR_DESCRIPTION=The accessor method for variable '{0}'.
+_MODIFIER_DESCRIPTION=The modifier method for variable '{0}'.

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ModelBasedGenerator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ModelBasedGenerator.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/ModelBasedGenerator.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.overlord.jbossesb.model.ESBLanguageModel;
+
+/**
+ * This interface represents a module that generates artefacts
+ * based on the complete model.
+ */
+public interface ModelBasedGenerator {
+
+	/**
+	 * This method generates the relevant artefacts based on
+	 * the supplied model, within the specified Java project.
+	 * 
+	 * @param jproj The Java project
+	 * @param model The model
+	 * @param buildSystem The build system to use
+	 * @throws GeneratorException Failed to generate
+	 */
+	public void generate(IJavaProject jproj,
+			ESBLanguageModel model, BuildSystem buildSystem)
+					throws GeneratorException;
+	
+}

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/TypeMapper.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/TypeMapper.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/generator/TypeMapper.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+public class TypeMapper {
+
+	private static final String BOOLEAN_TYPE = "boolean";
+	private static final String STRING_TYPE = "string";
+	private static final String DECIMAL_TYPE = "decimal";
+	private static final String INTEGER_TYPE = "integer";
+	private static final String INT_TYPE = "int";
+	public static final String JAVA_PREFIX = "java:";
+	public static final String XSD_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
+	
+	/**
+	 * This method determines the appropriate Java type associated
+	 * with the supplied type namespace and localpart.
+	 * 
+	 * @param namespace The namespace
+	 * @param localpart The local part
+	 * @return The Java type
+	 */
+	public static String getJavaType(String namespace, String localpart) {
+		String ret=org.w3c.dom.Element.class.getName();
+		
+		if (namespace != null && localpart != null) {
+			
+			if (namespace.startsWith(JAVA_PREFIX)) {
+				ret = namespace.substring(JAVA_PREFIX.length())
+							+"."+localpart;
+			} else if (namespace.equals(XSD_NAMESPACE)) {
+				
+				if (localpart.equals(STRING_TYPE)) {
+					ret = String.class.getName();
+				} else if (localpart.equals(DECIMAL_TYPE) ||
+						localpart.equals(INTEGER_TYPE)) {
+					ret = INT_TYPE;
+				} else if (localpart.equals(BOOLEAN_TYPE)) {
+					ret = BOOLEAN_TYPE;
+				}
+			}
+		}
+		
+		return(ret);
+	}
+}

Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java	2008-08-19 11:53:13 UTC (rev 253)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/util/ConversationUtil.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -18,7 +18,6 @@
 package org.jboss.tools.overlord.jbossesb.model.util;
 
 import org.scribble.conversation.model.*;
-import org.scribble.model.Definition;
 import org.scribble.model.Model;
 
 /**
@@ -108,6 +107,19 @@
 	}
 	
 	/**
+	 * This method returns the business object type method variable
+	 * name for the supplied variable's name.
+	 * 
+	 * @param name The variable name
+	 * @return The member variable name
+	 */
+	public static String getMemberVariableName(String name) {
+		String ret="m_"+Character.toLowerCase(name.charAt(0))+name.substring(1);
+		
+		return(ret);
+	}
+	
+	/**
 	 * This method returns the service category associated with
 	 * the supplied conversation.
 	 * 

Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/generator/TypeMapperTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/generator/TypeMapperTest.java	                        (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/test/org/jboss/tools/overlord/jbossesb/generator/TypeMapperTest.java	2008-08-19 16:23:55 UTC (rev 254)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.generator;
+
+import junit.framework.TestCase;
+
+public class TypeMapperTest extends TestCase {
+
+	public void testGetJavaTypeCustomClass() {
+		String pack="org.acme.service";
+		String namespace=TypeMapper.JAVA_PREFIX+pack;
+		String localpart="Message";
+		String clsName=pack+"."+localpart;
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+	
+	public void testGetJavaTypeDOMElement() {
+		String namespace="http://www.jboss.org/example";
+		String localpart="Message";
+		String clsName=org.w3c.dom.Element.class.getName();
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+	
+	public void testGetJavaTypeXSDString() {
+		String namespace=TypeMapper.XSD_NAMESPACE;
+		String localpart="string";
+		String clsName=String.class.getName();
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+	
+	public void testGetJavaTypeXSDBoolean() {
+		String namespace=TypeMapper.XSD_NAMESPACE;
+		String localpart="boolean";
+		String clsName="boolean";
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+	
+	public void testGetJavaTypeXSDDecimal() {
+		String namespace=TypeMapper.XSD_NAMESPACE;
+		String localpart="decimal";
+		String clsName="int";
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+	
+	public void testGetJavaTypeXSDInteger() {
+		String namespace=TypeMapper.XSD_NAMESPACE;
+		String localpart="integer";
+		String clsName="int";
+		
+		String type=TypeMapper.getJavaType(namespace, localpart);
+		
+		if (type == null) {
+			fail("Type not returned");
+		}
+		
+		if (type.equals(clsName) == false) {
+			fail("Expecting '"+clsName+"', but got: "+type);
+		}
+	}
+}




More information about the overlord-commits mailing list