Author: objectiser
Date: 2008-12-17 12:35:58 -0500 (Wed, 17 Dec 2008)
New Revision: 452
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.project
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.settings/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.settings/org.eclipse.jdt.core.prefs
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/Copyright.txt
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/build.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/plugin.xml
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AbstractBuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AntBuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/BuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ConversationBasedGenerator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorException.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/MavenBuildSystem.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ModelBasedGenerator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Ant.template
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Maven.template
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELNotation.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java
Log:
Initial version of Overlord CDL BPEL plugin. Setup initial structure to be similar to the
ESB actions plugin - may refactor later to extract common functionality into a shared
plugin, which may also be dependent upon how the deployment framework is implemented.
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath
(rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.classpath 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.project
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.project
(rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.project 2008-12-17 17:35:58
UTC (rev 452)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.overlord.cdl.bpel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/.settings/org.eclipse.jdt.core.prefs 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,7 @@
+#Wed Dec 17 14:25:40 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/Copyright.txt
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/Copyright.txt
(rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/Copyright.txt 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/META-INF/MANIFEST.MF 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Overlord CDL BPEL Plug-in
+Bundle-SymbolicName: org.jboss.tools.overlord.cdl.bpel;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.overlord.cdl.bpel.eclipse.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.scribble.conversation.model,
+ org.scribble.core,
+ org.scribble.lang.model,
+ org.eclipse.core.resources,
+ org.scribble.osgi,
+ org.eclipse.jdt.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor:
www.jboss.org
+Scribble-Extensions: org.jboss.tools.overlord.cdl.bpel.parser.BPELParser,
+ org.jboss.tools.overlord.cdl.bpel.parser.BPELNotation
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/build.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/build.properties
(rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/build.properties 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,5 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/plugin.xml
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/plugin.xml
(rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/plugin.xml 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.jboss.tools.overlord.cdl.bpel.object.contribution"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.cdm">
+ <menu
+ id="org.jboss.tools.overlord.menu"
+ label="Overlord"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <menu
+ id="generate.menu"
+ label="Generate"
+ path="org.jboss.tools.overlord.menu/additions">
+ <separator name="group2"/>
+ </menu>
+ <action
+ label="WS-BPEL"
+ class="org.jboss.tools.overlord.cdl.bpel.actions.GenerateAction"
+ menubarPath="org.jboss.tools.overlord.menu/generate.menu/group2"
+ enablesFor="1"
+ id="org.jboss.tools.overlord.cdl.bpel.actions.GenerateAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/actions/GenerateAction.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,117 @@
+/*
+ * 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.cdl.bpel.actions;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.scribble.osgi.util.*;
+
+import org.jboss.tools.overlord.cdl.bpel.dialogs.*;
+
+/**
+ * This class implements the action to generate the choreography
+ * as a BPEL process.
+ */
+public class GenerateAction implements IObjectActionDelegate {
+
+ private static final String CANNOT_GENERATE = "Choreography has errors, so cannot
generate";
+
+ public GenerateAction() {
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ if (res instanceof IFile) {
+
+ if (ResourceUtil.hasErrors(res) == false) {
+ GenerateDialog dialog=
+ new GenerateDialog(m_targetPart.getSite().getShell(),
+ (IFile)res);
+
+ try {
+ dialog.open();
+ } catch(Throwable e) {
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to open generate dialog", e);
+ }
+ } else {
+ warn(CANNOT_GENERATE);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+
+ /**
+ * This method is used to report a warning.
+ *
+ * @param mesg The warning message
+ */
+ public void warn(String mesg) {
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_WARNING|SWT.OK);
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.actions");
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/dialogs/GenerateDialog.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,380 @@
+/*
+ * 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.cdl.bpel.dialogs;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+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.cdl.bpel.generator.*;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelRepository;
+
+/**
+ * This class provides the dialog for generating BPEL
+ * artefacts.
+ */
+public class GenerateDialog extends org.eclipse.jface.dialogs.Dialog {
+
+ /**
+ * This is the constructor for the generate dialog.
+ *
+ * @param shell The shell
+ */
+ public GenerateDialog(Shell shell, IFile file) {
+ super(shell);
+
+ m_file = file;
+
+ m_buildSystems.add(new AntBuildSystem());
+ m_buildSystems.add(new MavenBuildSystem());
+
+ initialize(m_file);
+ }
+
+ /**
+ * This method initializes the conversation model associated
+ * with the supplied file resource.
+ *
+ * @param res The file
+ */
+ protected void initialize(IFile res) {
+ ModelReference ref=
+ org.scribble.osgi.model.admin.OSGIModelRepository.createReference(res);
+
+ if (ref != null) {
+ ModelRepository mrep=(ModelRepository)
+ RegistryFactory.getRegistry().getExtension(
+ ModelRepository.class, null);
+
+ if (mrep != null) {
+ java.util.List<ModelInfo> models=mrep.getModels(ref,
+ new DefaultModelListener());
+
+ for (int i=0; m_conversationModel == null &&
+ i < models.size(); i++) {
+ if (models.get(i).getModel() instanceof ConversationModel) {
+ m_conversationModel = (ConversationModel)
+ models.get(i).getModel();
+
+ m_roles = m_conversationModel.getRoles();
+ }
+ }
+ }
+ }
+
+ if (m_conversationModel == null) {
+ error("Unable to load model used to generate " +
+ "the BPEL artefacts", null);
+ }
+ }
+
+ /**
+ * This method creates the dialog details.
+ *
+ * @param parent The parent control
+ * @return The control containing the dialog components
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite=(Composite)super.createDialogArea(parent);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+
+ GridData gd=null;
+
+ Group group=new Group(composite, SWT.H_SCROLL|SWT.V_SCROLL);
+
+ gd=new GridData();
+ gd.horizontalAlignment = SWT.FILL;
+ gd.horizontalSpan = 1;
+ gd.widthHint = 500;
+ gd.grabExcessHorizontalSpace = true;
+ group.setLayoutData(gd);
+
+ layout = new GridLayout();
+ layout.numColumns = 4;
+ group.setLayout(layout);
+
+ // Labels
+ Label label=new Label(group, SWT.NONE);
+ label.setText("Service Role");
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 150;
+ label.setLayoutData(gd);
+
+ label = new Label(group, SWT.NONE);
+ label.setText("Project Name");
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 150;
+ label.setLayoutData(gd);
+
+ if (m_conversationModel != null) {
+
+ for (int i=0; i < m_roles.size(); i++) {
+
+ Button button=new Button(group, SWT.CHECK);
+ button.setText(m_roles.get(i).getName());
+ button.setSelection(true);
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 150;
+ button.setLayoutData(gd);
+
+ m_roleButtons.add(button);
+
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ checkStatus();
+ }
+ });
+
+ Text projectName=new Text(group, SWT.NONE);
+
+ String prjName=m_roles.get(i).getName();
+
+ if (m_conversationModel.getModelName() != null) {
+ prjName = m_conversationModel.getModelName().getName()+"-"+prjName;
+ }
+
+ projectName.setText(prjName);
+
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 300;
+ projectName.setLayoutData(gd);
+
+ m_projectNames.add(projectName);
+
+ projectName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ checkStatus();
+ }
+ });
+
+ }
+ }
+
+ Button button=new Button(group, SWT.NONE);
+ button.setText("Check All");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ button.setLayoutData(gd);
+
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ m_roleButtons.get(i).setSelection(true);
+ }
+ checkStatus();
+ }
+ });
+
+ button=new Button(group, SWT.NONE);
+ button.setText("Clear All");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ button.setLayoutData(gd);
+
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ m_roleButtons.get(i).setSelection(false);
+ }
+ checkStatus();
+ }
+ });
+
+ label = new Label(group, SWT.RIGHT);
+ label.setText("Build: ");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ label.setLayoutData(gd);
+
+ m_build=new Combo(group, SWT.DROP_DOWN);
+
+ for (int i=0; i < m_buildSystems.size(); i++) {
+ m_build.add(m_buildSystems.get(i).getName());
+ }
+
+ m_build.select(0);
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 100;
+ m_build.setLayoutData(gd);
+
+ return(composite);
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control ret=super.createButtonBar(parent);
+
+ checkStatus();
+
+ return(ret);
+ }
+
+ protected void checkStatus() {
+ int selected=0;
+ boolean f_error=false;
+
+ for (int i=0; i < m_roleButtons.size(); i++) {
+ if (m_roleButtons.get(i).getSelection()) {
+ selected++;
+
+ m_projectNames.get(i).setEnabled(true);
+
+ // Check project name
+ String projectName=m_projectNames.get(i).getText();
+
+ if (isProjectNameValid(projectName) == false) {
+ f_error = true;
+
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+ } else {
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ }
+ } else {
+ m_projectNames.get(i).setEnabled(false);
+ m_projectNames.get(i).setBackground(
+ Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+ }
+ }
+
+ if (f_error || selected == 0) {
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ } else {
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+ }
+
+ protected boolean isProjectNameValid(String name) {
+ boolean ret=true;
+
+ if (name == null || name.trim().length() == 0) {
+ ret = false;
+ } else if (m_file.getWorkspace().getRoot().getProject(name).exists()) {
+ ret = false;
+ } else {
+ for (int i=0; ret && i < name.length(); i++) {
+ if (i == 0) {
+ ret = Character.isJavaIdentifierStart(name.charAt(i));
+ } else if ("-.".indexOf(name.charAt(i)) != -1) {
+ ret = true;
+ } else {
+ ret = Character.isJavaIdentifierPart(name.charAt(i));
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * The ok button has been pressed.
+ */
+ 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()) {
+ generator.generateRole(m_roles.get(i),
+ m_projectNames.get(i).getText());
+ }
+ }
+
+ super.okPressed();
+ } catch(Exception e) {
+ error("Failed to generate BPEL artefacts", e);
+ }
+ }
+
+ protected BuildSystem getSelectedBuildSystem() {
+ return(m_buildSystems.get(m_build.getSelectionIndex()));
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ * @param ex The exception
+ */
+ public void error(String mesg, Exception ex) {
+
+ org.jboss.tools.overlord.cdl.bpel.eclipse.Activator.logError(mesg, ex);
+
+ MessageBox mbox=new MessageBox(getShell(),
+ 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.cdl.runtime.jbossesb.dialogs");
+
+ private IFile m_file=null;
+ private ConversationModel m_conversationModel=null;
+ private java.util.List<Role> m_roles=null;
+ private java.util.List<Button> m_roleButtons=new
java.util.Vector<Button>();
+ private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
+ private Combo m_build=null;
+ private java.util.List<BuildSystem> m_buildSystems=new
java.util.Vector<BuildSystem>();
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/eclipse/Activator.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,74 @@
+package org.jboss.tools.overlord.cdl.bpel.eclipse;
+
+import java.util.logging.Logger;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.overlord.cdl.bpel";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * This method logs an error against the plugin.
+ *
+ * @param mesg The error message
+ * @param t The optional exception
+ */
+ public static void logError(String mesg, Throwable t) {
+
+ if (getDefault() != null) {
+ Status status=new Status(IStatus.ERROR,
+ PLUGIN_ID, 0, mesg, t);
+
+ getDefault().getLog().log(status);
+ }
+
+ logger.severe("LOG ERROR: "+mesg+
+ (t == null ? "" : ": "+t));
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.eclipse");
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/export/BPELLanguageModelStreamExportRule.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,207 @@
+/*
+ * 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.cdl.bpel.export;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+import org.scribble.export.*;
+import org.scribble.export.stream.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.*;
+import org.w3c.dom.Node;
+
+/**
+ * This class implements the stream based export rule for the
+ * BPELLanguageModel entity.
+ */
+(a)RegistryInfo(extension=ExportRule.class,notation=BPELLanguageModel.BPEL_NOTATION)
+public class BPELLanguageModelStreamExportRule extends DefaultModelStreamExportRule {
+
+ /**
+ * This method determines whether the exporter rule is appropriate
+ * for the supplied model object and format.
+ *
+ * @param modelObject The model object
+ * @param format The format
+ * @return Whether the rule is appropriate for the model object and
+ * format
+ */
+ public boolean isSupported(ModelObject modelObject, Formatter format) {
+ return(super.isSupported(modelObject, format) &&
+ BPELLanguageModel.class.isAssignableFrom(modelObject.getClass()));
+ }
+
+ /**
+ * This method exports the model object.
+ *
+ * @param modelObject The model object
+ * @param context The context
+ * @throws IOException Failed to record export information
+ */
+ public void export(ModelObject modelObject, ExporterContext context)
+ throws java.io.IOException {
+ BPELLanguageModel model=(BPELLanguageModel)modelObject;
+
+ try {
+ String text=getText(model.getBPELProcess());
+
+ context.getFormatter().record(text.getBytes());
+
+ } catch(Exception e) {
+ throw new java.io.IOException("Failed to get BPEL process text");
+ }
+ }
+
+ /**
+ * 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);
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AbstractBuildSystem.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AbstractBuildSystem.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AbstractBuildSystem.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,58 @@
+/*
+ * 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.cdl.bpel.generator;
+
+/**
+ * This class represents an abstract build system.
+ */
+public abstract class AbstractBuildSystem implements BuildSystem {
+
+ private static final String TEMPLATE_SUFFIX = ".template";
+ private static final String TEMPLATE_PREFIX = "template/";
+
+ /**
+ * 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) {
+ String ret=null;
+
+ java.io.InputStream is=
+ AbstractBuildSystem.class.getResourceAsStream(
+ TEMPLATE_PREFIX+getName()+TEMPLATE_SUFFIX);
+
+ if (is != null) {
+
+ try {
+ byte[] b=new byte[is.available()];
+ is.read(b);
+
+ ret = new String(b);
+
+ ret = ret.replaceAll("%PROJECT%", projectName);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return(ret);
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AntBuildSystem.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AntBuildSystem.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/AntBuildSystem.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,101 @@
+/*
+ * 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.cdl.bpel.generator;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class AntBuildSystem extends AbstractBuildSystem {
+
+ 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";
+ private static final String LIBRARY_PATH = "src/lib";
+
+ /**
+ * 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 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);
+ }
+
+ /**
+ * This method returns the library path.
+ *
+ * @return The library path
+ */
+ public String getLibraryPath() {
+ return(LIBRARY_PATH);
+ }
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/BuildSystem.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/BuildSystem.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/BuildSystem.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,89 @@
+/*
+ * 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.cdl.bpel.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();
+
+ /**
+ * This method returns the library path.
+ *
+ * @return The library path, or null if not required
+ */
+ public String getLibraryPath();
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ConversationBasedGenerator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ConversationBasedGenerator.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ConversationBasedGenerator.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -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.cdl.bpel.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.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,461 @@
+/*
+ * 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.cdl.bpel.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.cdl.bpel.generator.BuildSystem;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DefaultModelListener;
+import org.scribble.model.admin.ModelRepository;
+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.admin.OSGIModelRepository.createReference(res);
+
+ if (ref != null) {
+ ModelRepository mrep=(ModelRepository)
+ RegistryFactory.getRegistry().getExtension(
+ ModelRepository.class, null);
+
+ if (mrep != null) {
+ java.util.List<ModelInfo> models=mrep.getModels(ref,
+ new DefaultModelListener());
+
+ for (int i=0; m_conversationModel == null &&
+ i < models.size(); i++) {
+ if (models.get(i).getModel() instanceof ConversationModel) {
+ m_conversationModel = (ConversationModel)
+ models.get(i).getModel();
+
+ 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(BPELLanguageModel.BPEL_NOTATION);
+
+ DefaultBPELLanguageModel target=
+ new DefaultBPELLanguageModel(targetRef);
+
+ ModelGenerator generator=(ModelGenerator)
+ RegistryFactory.getRegistry().getExtension(
+ ModelGenerator.class, null);
+
+ if (generator != null) {
+ generator.generate(targetRef, role, target,
+ lcm);
+
+ generateRoleProject(projectName,
+ target.getBPELProcess(),
+ lcm, target);
+ } else {
+ logger.severe("Unable to find model generator");
+ }
+ }
+ }
+ }
+
+ protected void generateRoleProject(String projectName,
+ org.w3c.dom.Element esbConfig, ConversationModel localcm,
+ BPELLanguageModel 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()));
+ IPath libLocation=null;
+
+ if (getBuildSystem().getLibraryPath() != null) {
+ libLocation=jproj.getPath().append(new Path(getBuildSystem().getLibraryPath()));
+ }
+
+ // 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);
+
+ if (libLocation != null) {
+ IFolder libFolder=
jproj.getProject().getWorkspace().getRoot().getFolder(libLocation);
+ GeneratorUtil.createParentFolder(libFolder);
+ libFolder.create(true, true, new org.eclipse.core.runtime.NullProgressMonitor());
+ libFolder.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.cdl.runtime.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.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorException.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorException.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorException.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -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.cdl.bpel.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.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorUtil.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorUtil.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -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.cdl.bpel.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.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/MavenBuildSystem.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/MavenBuildSystem.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/MavenBuildSystem.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,101 @@
+/*
+ * 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.cdl.bpel.generator;
+
+/**
+ * This class represents the Ant build system.
+ */
+public class MavenBuildSystem extends AbstractBuildSystem {
+
+ 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";
+ private static final String LIBRARY_PATH = null;
+
+ /**
+ * 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 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);
+ }
+
+ /**
+ * This method returns the library path.
+ *
+ * @return The library path
+ */
+ public String getLibraryPath() {
+ return(LIBRARY_PATH);
+ }
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ModelBasedGenerator.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ModelBasedGenerator.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/ModelBasedGenerator.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -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.cdl.bpel.generator;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ * 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,
+ BPELLanguageModel model, BuildSystem buildSystem)
+ throws GeneratorException;
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Ant.template
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Ant.template
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Ant.template 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,44 @@
+<project name="%PROJECT%" basedir="." default="deploy"
>
+ <property name="build.dir" value="${basedir}/target" />
+ <property name="classes" value="${build.dir}/classes" />
+ <property name="lib" value="src/lib" />
+ <property name="src" value="src/java" />
+ <property name="conf" value="src/conf" />
+
+ <path id="compile-classpath">
+ <fileset dir="${lib}" includes="*.jar" />
+ </path>
+
+ <target name="init" depends="clean">
+ <mkdir dir="${build.dir}" />
+ </target>
+
+ <target name="clean">
+ <delete dir="${build.dir}" />
+ </target>
+
+ <target name="compile" depends="init">
+ <mkdir dir="${classes}" />
+ <javac srcdir="${src}" destdir="${classes}"
debug="true" deprecation="true">
+ <classpath refid="compile-classpath" />
+ </javac>
+ <copy todir="${classes}">
+ <fileset dir="${conf}" includes="**/*.xml"/>
+ </copy>
+ </target>
+
+ <target name="esbjar" depends="compile">
+ <jar destfile="${build.dir}/${ant.project.name}.esb">
+ <fileset dir="${classes}" />
+ <fileset dir="${build.dir}"
includes="*.jar,*.war"/>
+ <fileset dir="${classes}"
includes="deployment.xml"/>
+ <fileset dir="${classes}"
includes="META-INF/**" />
+ <fileset dir="${lib}" includes="*.jar"/>
+ </jar>
+ </target>
+
+ <target name="deploy" depends="esbjar">
+ <copy todir="${org.jboss.esb.server.deploy.dir}"
+ file="${build.dir}/${ant.project.name}.esb"/>
+ </target>
+</project>
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Maven.template
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Maven.template
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/template/Maven.template 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,54 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.soa.overlord.cdl.project</groupId>
+ <artifactId>%PROJECT%</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jboss-esb</packaging>
+ <name>%PROJECT%</name>
+ <
url>http://www.jboss.org/overlord</url>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.soa.overlord.cdl</groupId>
+ <artifactId>runtime-jbossesb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>%PROJECT%</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-packaging-maven-plugin</artifactId>
+ <version>2.0-20080130.110241-9</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots/>
+ <id>jboss-plugin-snapshots</id>
+ <name>JBoss Snapshot Plugin Repository</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+</project>
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,63 @@
+/*
+ * 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.cdl.bpel.model;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a BPEL model.
+ *
+ * @author gary
+ */
+public interface BPELLanguageModel {
+
+ public static final String BPEL_NOTATION = "bpel";
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l);
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference();
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getOriginalContents();
+
+
+ /**
+ * This method returns the reference to the DOM
+ * representation of the BPEL process.
+ *
+ * @return The BPEL process
+ */
+ public org.w3c.dom.Element getBPELProcess();
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,212 @@
+/*
+ * 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.cdl.bpel.model;
+
+import java.util.logging.Logger;
+
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.model.*;
+import org.scribble.model.admin.DependencyType;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.*;
+
+/**
+ * This class represents a BPEL model.
+ *
+ * @author gary
+ */
+public class DefaultBPELLanguageModel extends org.scribble.lang.model.LanguageModel
+ implements BPELLanguageModel {
+
+
+ public static final String BPEL_NOTATION = "bpel";
+
+ /**
+ * This constructor is initialized with the BPEL description.
+ *
+ * @param source The model reference for the BPEL source
+ * @param elem The BPEL document
+ * @param contents The textual contents
+ */
+ public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
+ String contents) {
+ m_source = source;
+ m_bpelProcess = elem;
+ m_contents = contents;
+
+ // Extract service action pipelines
+ initializeExistingConfig();
+ }
+
+ /**
+ * This constructor initializes a new BPEL process.
+ *
+ * @param source The model reference for the BPEL description
+ */
+ public DefaultBPELLanguageModel(ModelReference source) {
+ m_source = source;
+
+ initializeNewConfig();
+ }
+
+ /**
+ * This method creates a new BPEL process.
+ */
+ protected void initializeNewConfig() {
+
+ org.w3c.dom.Document doc=null;
+
+ // Create an empty document
+ try {
+ doc = javax.xml.parsers.DocumentBuilderFactory.
+ newInstance().newDocumentBuilder().newDocument();
+
+ m_bpelProcess = doc.createElement("process");
+
+ } catch(Exception e) {
+ logger.severe("Failed to create initial BPEL document: "+e);
+ }
+
+ }
+
+ /**
+ * This method initializes the ESB Model.
+ */
+ protected void initializeExistingConfig() {
+
+ // Needs to establish dependency to conversation
+ }
+
+ @Override
+ public String getNotation() {
+ return(BPEL_NOTATION);
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference() {
+ return(m_source);
+ }
+
+ /**
+ * Generate a key for use in accessing the service related to
+ * the supplied category and name.
+ *
+ * @param category The category
+ * @param name The service name
+ * @return The key
+ */
+ protected String getKey(String category, String name) {
+ return(category+"/"+name);
+ }
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ }
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getOriginalContents() {
+ return(m_contents);
+ }
+
+ /**
+ * This method returns the reference to the DOM
+ * representation of the BPEL process.
+ *
+ * @return The BPEL Process
+ */
+ public org.w3c.dom.Element getBPELProcess() {
+ return(m_bpelProcess);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.model");
+
+ private ModelReference m_source=null;
+ private org.w3c.dom.Element m_bpelProcess=null;
+ private String m_contents=null;
+
+ public class InnerModelListener implements ModelListener {
+
+ public InnerModelListener(ModelListener l) {
+ m_listener = l;
+ }
+
+ public void error(ModelIssue issue) {
+
+ /*
+ issue.getProperties().put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+ issue.getModelObject().getSource().getStartPosition());
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+ issue.getModelObject().getSource().getEndPosition());
+ if (issue.getModelObject().getSource().getComponentURI() != null) {
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ */
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_source);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.error(issue);
+ }
+
+ public void warning(ModelIssue issue) {
+ /*
+ issue.getProperties().put(ModelListener.RESOLUTIONS,
ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+ issue.getModelObject().getSource().getStartPosition());
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+ issue.getModelObject().getSource().getEndPosition());
+ if (issue.getModelObject().getSource().getComponentURI() != null) {
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ */
+
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_source);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.warning(issue);
+ }
+
+ private ModelListener m_listener=null;
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELNotation.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELNotation.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELNotation.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,72 @@
+/*
+ * 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.cdl.bpel.parser;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+
+/**
+ *
+ *
+ * @author gary
+ */
+(a)RegistryInfo(extension=org.scribble.parser.Notation.class)
+public class BPELNotation implements org.scribble.parser.Notation {
+
+ /**
+ * This method returns the code for the notation.
+ *
+ * @return The notation code
+ */
+ public String getCode() {
+ return(BPELLanguageModel.BPEL_NOTATION);
+ }
+
+ /**
+ * This method returns the name of the notation.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return("BPEL");
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method determines whether the Scribble editor should
+ * be used for editing the notation.
+ *
+ * @return Whether the Scribble editor should be used
+ */
+ public boolean useScribbleEditor() {
+ return(false);
+ }
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/parser/BPELParser.java 2008-12-17
17:35:58 UTC (rev 452)
@@ -0,0 +1,90 @@
+/*
+ * 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.cdl.bpel.parser;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+import org.scribble.extensions.*;
+import org.scribble.parser.Parser;
+
+/**
+ * This BPEL implementation of the Parser interface.
+ *
+ * @author gary
+ */
+(a)RegistryInfo(extension=Parser.class,notation=BPELLanguageModel.BPEL_NOTATION)
+public class BPELParser implements Parser {
+
+ /**
+ * This method parses the source located using the supplied
+ * scribble reference, to return a model. If any
+ * errors are detected, they will be reported to the parser
+ * listener.
+ *
+ * @param ref The scribble source reference
+ * @param is The input stream
+ * @param l The model listener
+ * @return The model, or null if not found
+ */
+ public Model parse(ModelReference ref, InputStream is,
+ ModelListener l) {
+ DefaultBPELLanguageModel ret=null;
+
+ try {
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+
+ byte[] b=new byte[is.available()];
+ is.read(b);
+
+ // Need to load original input stream and then
+ // provide a second input stream, as some input stream
+ // implementations don't support 'reset' operation,
+ // and therefore this was the only way to extract the
+ // content and also provide the stream to the XML
+ // document builder.
+ java.io.ByteArrayInputStream bais=new java.io.ByteArrayInputStream(b);
+
+ org.w3c.dom.Document doc=builder.parse(bais);
+
+ // Identify the model associated with the
+ // changed resource
+ ret = new DefaultBPELLanguageModel(ref, doc.getDocumentElement(),
+ new String(b));
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load model", e);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger =
Logger.getLogger("org.jboss.tools.overlord.cdl.bpel.parser");
+}