Overlord SVN: r255 - in cdl/trunk: assembly/jbossesb/src/main/resources and 8 other directories.
by overlord-commits@lists.jboss.org
Author: jeff.yuchang
Date: 2008-08-20 06:17:16 -0400 (Wed, 20 Aug 2008)
New Revision: 255
Added:
cdl/trunk/assembly/jbossesb/src/main/resources/overlord-cdl-jbossesb.cfg.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/EPRWrapper.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/HibernateObject.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Identity.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/IdentityType.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/JoinState.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/LogicalCourier.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/ScheduleItem.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Session.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionStatus.java
Removed:
cdl/trunk/assembly/jbossesb/src/main/resources/hibernate.cfg.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/conversation/
Modified:
cdl/trunk/assembly/jbossesb/pom.xml
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/CreateSessionAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml
cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/jboss-esb.xml
Log:
* SOAG-45.
* Update the default hibernate.cfg.xml to overlord-cdl-jbossesb.cfg.xml.
* Update the package name for Session and other classes.
Modified: cdl/trunk/assembly/jbossesb/pom.xml
===================================================================
--- cdl/trunk/assembly/jbossesb/pom.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/assembly/jbossesb/pom.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -50,7 +50,7 @@
</dependencies>
<build>
- <finalName>cdl-jbossesb</finalName>
+ <finalName>overlord-cdl-jbossesb</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Deleted: cdl/trunk/assembly/jbossesb/src/main/resources/hibernate.cfg.xml
===================================================================
--- cdl/trunk/assembly/jbossesb/src/main/resources/hibernate.cfg.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/assembly/jbossesb/src/main/resources/hibernate.cfg.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -1,64 +0,0 @@
-<!DOCTYPE hibernate-configuration SYSTEM
-"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-<!--
- JBoss, Home of Professional Open Source
- Copyright 2008, JBoss Inc., 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.
-
- (C) 2008,
- @author JBoss Inc.
--->
-<hibernate-configuration>
- <session-factory>
- <!--property name="hibernate.connection.driver_class">
- org.hsqldb.jdbcDriver
- </property>
- <property name="hibernate.connection.url">
- jdbc:hsqldb:hsql://localhost
- </property>
- <property name="hibernate.connection.username">
- sa
- </property-->
-
- <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
-
- <!-- DataSource properties (begin) === -->
- <property name="hibernate.connection.datasource">java:/cdlDS</property>
- <!-- ==== DataSource properties (end) -->
-
-
- <!-- Use the C3P0 connection pool provider -->
- <property name="hibernate.c3p0.min_size">5</property>
- <property name="hibernate.c3p0.max_size">20</property>
- <property name="hibernate.c3p0.timeout">300</property>
- <property name="hibernate.c3p0.max_statements">50</property>
- <property name="hibernate.c3p0.idle_test_period">3000</property>
-
- <property name="current_session_context_class">thread</property>
- <property name="hibernate.connection.isolation">4</property>
-
- <!-- Show and print nice SQL on stdout -->
- <property name="show_sql">false</property>
- <property name="format_sql">true</property>
-
- <!-- List of annotationed classes (Internal conversation class)-->
- <mapping class="org.jboss.soa.overlord.conversation.Session" />
- <mapping class="org.jboss.soa.overlord.conversation.ScheduleItem"/>
- <mapping class="org.jboss.soa.overlord.conversation.JoinState"/>
- <mapping class="org.jboss.soa.overlord.conversation.Identity"/>
- <mapping class="org.jboss.soa.overlord.conversation.EPRWrapper"/>
-
- </session-factory>
-</hibernate-configuration>
Added: cdl/trunk/assembly/jbossesb/src/main/resources/overlord-cdl-jbossesb.cfg.xml
===================================================================
--- cdl/trunk/assembly/jbossesb/src/main/resources/overlord-cdl-jbossesb.cfg.xml (rev 0)
+++ cdl/trunk/assembly/jbossesb/src/main/resources/overlord-cdl-jbossesb.cfg.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,64 @@
+<!DOCTYPE hibernate-configuration SYSTEM
+"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2008, JBoss Inc., 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.
+
+ (C) 2008,
+ @author JBoss Inc.
+-->
+<hibernate-configuration>
+ <session-factory>
+ <!--property name="hibernate.connection.driver_class">
+ org.hsqldb.jdbcDriver
+ </property>
+ <property name="hibernate.connection.url">
+ jdbc:hsqldb:hsql://localhost
+ </property>
+ <property name="hibernate.connection.username">
+ sa
+ </property-->
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+
+ <!-- DataSource properties (begin) === -->
+ <property name="hibernate.connection.datasource">java:/cdlDS</property>
+ <!-- ==== DataSource properties (end) -->
+
+
+ <!-- Use the C3P0 connection pool provider -->
+ <property name="hibernate.c3p0.min_size">5</property>
+ <property name="hibernate.c3p0.max_size">20</property>
+ <property name="hibernate.c3p0.timeout">300</property>
+ <property name="hibernate.c3p0.max_statements">50</property>
+ <property name="hibernate.c3p0.idle_test_period">3000</property>
+
+ <property name="current_session_context_class">thread</property>
+ <property name="hibernate.connection.isolation">4</property>
+
+ <!-- Show and print nice SQL on stdout -->
+ <property name="show_sql">false</property>
+ <property name="format_sql">true</property>
+
+ <!-- List of annotationed classes (Internal conversation class)-->
+ <mapping class="org.jboss.soa.overlord.jbossesb.Session" />
+ <mapping class="org.jboss.soa.overlord.jbossesb.ScheduleItem"/>
+ <mapping class="org.jboss.soa.overlord.jbossesb.JoinState"/>
+ <mapping class="org.jboss.soa.overlord.jbossesb.Identity"/>
+ <mapping class="org.jboss.soa.overlord.jbossesb.EPRWrapper"/>
+
+ </session-factory>
+</hibernate-configuration>
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/EPRWrapper.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/EPRWrapper.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/EPRWrapper.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author jeffyu
+ *
+ */
+@Entity
+@Table(name="CDL_EPRS")
+public class EPRWrapper implements Serializable{
+
+ private static final long serialVersionUID = 1111L;
+
+ @Id
+ @GeneratedValue
+ @Column(name="ID")
+ private long id;
+
+ @ManyToOne
+ @JoinColumn(name="SESSION_ID")
+ private Session session;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="EPR")
+ @Lob
+ private String value;
+
+ public EPRWrapper() {
+
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/HibernateObject.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/HibernateObject.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/HibernateObject.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import java.io.Serializable;
+
+/**
+ * @author jeffyu
+ */
+public interface HibernateObject extends Serializable {
+
+ public long getId();
+
+ public void setId(long id);
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Identity.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Identity.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Identity.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author gary
+ * @author jeffyu
+ */
+
+
+@Entity
+@Table(name="CDL_IDENTITY")
+public class Identity implements HibernateObject {
+
+ private static final long serialVersionUID = 1112L;
+
+ @Id @GeneratedValue
+ @Column(name="ID")
+ private long id;
+
+ @ManyToOne
+ @JoinColumn(name="SESSION_ID", nullable = false)
+ private Session session;
+
+ @Column(name="TYPE")
+ @Enumerated(EnumType.STRING)
+ private IdentityType type;
+
+ @Column(name="PROPERTY_VALUE")
+ private String propertyValues;
+
+ @Column(name="SERVICE_NAME")
+ private String serviceName;
+
+ public Identity() {
+
+ }
+
+ public IdentityType getType() {
+ return type;
+ }
+
+ public void setType(IdentityType type) {
+ this.type = type;
+ }
+
+ public Map<String, String> getProperties() {
+ Map<String, String> properties = new HashMap<String, String>();
+ StringTokenizer st = new StringTokenizer(propertyValues, ",");
+ for(String value = st.nextToken(); st.hasMoreTokens();) {
+ int equalIndex = value.indexOf("=");
+ String key = value.substring(0, equalIndex);
+ String thevalue = value.substring(equalIndex);
+ properties.put(key, thevalue);
+ }
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties) {
+ StringBuffer sbuffer = new StringBuffer();
+ Iterator<String> keys = properties.keySet().iterator();
+
+ while(keys.hasNext()) {
+ String key = keys.next();
+ String value = properties.get(key);
+ sbuffer.append(key);
+ sbuffer.append("=");
+ sbuffer.append(value);
+ if (keys.hasNext()) {
+ sbuffer.append(",");
+ }
+ }
+
+ this.propertyValues = sbuffer.toString();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof Identity) {
+ Identity id = (Identity) o;
+ if (this.getType().equals(id.getType()) && this.propertyValues.equalsIgnoreCase(id.getPropertyValues())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String toString() {
+ return "Type is: " + this.type + ": Properties :" + this.propertyValues;
+ }
+
+ public String getPropertyValues() {
+ return propertyValues;
+ }
+
+ public void setPropertyValues(String propertyValues) {
+ this.propertyValues = propertyValues;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/IdentityType.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/IdentityType.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/IdentityType.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+public enum IdentityType {
+ Primary,
+ Association,
+ Alternate,
+ Derived;
+
+ public static IdentityType toIdentityType(String string) {
+ if ("Primary".equalsIgnoreCase(string)) {
+ return Primary;
+ } else if ("Association".equalsIgnoreCase(string)) {
+ return Association;
+ } else if ("Alternate".equalsIgnoreCase(string)) {
+ return Alternate;
+ } else if ("Derived".equalsIgnoreCase(string)) {
+ return Derived;
+ }
+ return null;
+ }
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/JoinState.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/JoinState.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/JoinState.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author jeffyu
+ *
+ */
+@Entity
+@Table(name="CDL_JOIN_STATES")
+public class JoinState implements HibernateObject {
+
+ private static final long serialVersionUID = 1113L;
+
+ @Id @GeneratedValue
+ @Column(name="ID")
+ private long id;
+
+ @ManyToOne
+ @JoinColumn(name="SESSION_ID")
+ private Session session;
+
+ @Column(name="CATEGORY", nullable = false)
+ private String category ;
+
+ @Column(name="NAME", nullable = false)
+ private String name ;
+
+ @Column(name="ITEM_COUNT")
+ private int spawnPath= 0 ;
+
+ public JoinState() {
+
+ }
+
+ public JoinState(String category, String name, int count) {
+ this.category = category;
+ this.name = name;
+ this.spawnPath = count;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getSpawnPath() {
+ return spawnPath;
+ }
+
+ public void setSpawnPath(int spawnPath) {
+ this.spawnPath = spawnPath;
+ }
+
+ public synchronized void join() {
+ this.spawnPath--;
+ }
+
+ public String toString() {
+ return (category+"/"+name + ": spawned path count is [" + this.spawnPath + "]");
+ }
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/LogicalCourier.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/LogicalCourier.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/LogicalCourier.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.addressing.eprs.*;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+
+/**
+ * This class providers the courier implementation associated
+ * with a LogicalEPR.
+ */
+public class LogicalCourier implements org.jboss.soa.esb.couriers.Courier {
+
+ private ServiceInvoker serviceInvoker=null;
+
+ /**
+ * The constructor, supplied the logical EPR represented
+ * by the courier.
+ *
+ * @param epr The logical EPR
+ * @throws MessageDeliverException
+ */
+ public LogicalCourier(LogicalEPR epr)
+ throws MessageDeliverException {
+ serviceInvoker = epr.getServiceInvoker();
+ }
+
+ /**
+ * This method delivers the supplied message to the EPR
+ * associated with the logical courier.
+ *
+ * @param mesg The message
+ */
+ public boolean deliver(Message mesg) throws CourierException,
+ MalformedEPRException {
+
+ try {
+ serviceInvoker.deliverAsync(mesg);
+ } catch(MessageDeliverException e) {
+ throw new CourierException("Failed to deliver message", e);
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method cleans up after the courier implementation
+ * is no longer required.
+ */
+ public void cleanup() {
+ serviceInvoker = null;
+ }
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/ScheduleItem.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/ScheduleItem.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/ScheduleItem.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+
+@Entity
+@Table(name="CDL_SCHEDULE_ITEM")
+public class ScheduleItem implements HibernateObject {
+
+ private static final long serialVersionUID = 1114L;
+
+ @Id @GeneratedValue
+ @Column(name="ID")
+ private long id;
+
+ @ManyToOne
+ @JoinColumn(name="SESSION_ID")
+ private Session session;
+
+ @Column(name="CATEGORY", nullable = false)
+ private String category ;
+
+ @Column(name="NAME", nullable = false)
+ private String name ;
+
+ public ScheduleItem() {
+
+ }
+
+ public ScheduleItem(String category, String name) {
+ this.category = category;
+ this.name = name;
+ }
+
+ public String getCategory() {
+ return(category);
+ }
+
+ public String getName() {
+ return(name);
+ }
+
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof ScheduleItem) {
+ ScheduleItem si=(ScheduleItem)other;
+ if (si.category.equals(category) && si.name.equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String toString() {
+ StringBuffer sbuffer = new StringBuffer();
+ sbuffer.append("id=" + id +",");
+ sbuffer.append("category=" + category + ",");
+ sbuffer.append("name=" + name + ",");
+ sbuffer.append("session=" + session);
+ return sbuffer.toString();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Session.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Session.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/Session.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,409 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+
+@Entity
+@Table(name="CDL_SESSION")
+public class Session implements HibernateObject {
+
+ private static final long serialVersionUID = 1115L;
+
+ private static Logger logger = Logger.getLogger(Session.class);
+
+ @Id @GeneratedValue
+ @Column(name="SESSION_ID")
+ private long id;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name="PARENT_ID", nullable=true)
+ private Session parent;
+
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "STATUS")
+ private SessionStatus status=SessionStatus.Initialized;
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @JoinColumn(name="SESSION_ID")
+ private List<EPRWrapper> eprWrappers = new ArrayList<EPRWrapper>();
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @JoinColumn(name="SESSION_ID")
+ private List<ScheduleItem> scheduleItems=new ArrayList<ScheduleItem>();
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @JoinColumn(name = "SESSION_ID")
+ private List<JoinState> joinStates=new ArrayList<JoinState>();
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @JoinColumn(name="SESSION_ID")
+ private List<Identity> identities=new ArrayList<Identity>();
+
+ @Column(name = "POJO_CLASS")
+ private String pojoClass;
+
+ @Column(name="SERVICE_NAME")
+ private String serviceName;
+
+ @Column(name="CONVERSATION_TYPE")
+ private String conversationType;
+
+ @Transient
+ private Object businessObject;
+
+ @Lob
+ @Column(name="Business_OBJECT")
+ private byte[] serializedObject;
+
+ public Session() {
+ }
+
+ public Session(Session parent) {
+ this.parent = parent;
+ }
+
+ public void setStatus(SessionStatus status) {
+ this.status = status;
+ }
+
+ public SessionStatus getStatus() {
+ return this.status;
+ }
+
+ public void setEPR(String name, EPR epr) throws Exception{
+ try {
+ EPRWrapper theEPRWrapper = null;
+ for(EPRWrapper eprWrapper : eprWrappers) {
+ if (name.equals(eprWrapper.getName())) {
+ theEPRWrapper = eprWrapper;
+ }
+ }
+
+ if (theEPRWrapper != null) {
+ eprWrappers.remove(theEPRWrapper);
+ SessionManager.removeObject(theEPRWrapper);
+ }
+
+ EPRWrapper eprWrapper = new EPRWrapper();
+ eprWrapper.setSession(this);
+ eprWrapper.setName(name);
+ eprWrapper.setValue(EPRHelper.toXMLString(epr));
+ eprWrappers.add(eprWrapper);
+ SessionManager.saveObject(eprWrapper);
+ } catch (Exception e) {
+ throw new Exception("Error in storing EPR!!" + e, e);
+ }
+ }
+
+ public EPR getEPR(String name) throws Exception{
+
+ for(EPRWrapper epr : eprWrappers) {
+ if (name.equals(epr.getName()))
+ {
+ return EPRHelper.fromXMLString(epr.getValue());
+ }
+ }
+
+ return null;
+ }
+
+ public void schedule(String category, String name, Message message) throws Exception {
+
+ ScheduleItem si=new ScheduleItem(category, name);
+ si.setSession(this);
+
+ logger.debug("Scheduling: " + si + " by thread of " + Thread.currentThread().getName());
+
+ synchronized(joinStates) {
+ JoinState joinState = getJoinStateByScheduleItem(si);
+ if (joinState != null) {
+ joinState.join();
+ SessionManager.updateObject(joinState);
+ logger.debug("Join State is: " + joinState);
+ if (joinState.getSpawnPath() <= 0) {
+ joinStates.remove(joinState);
+ SessionManager.removeObject(joinState);
+
+ logger.info("Deliver the Join State of: " + joinState);
+
+ ServiceInvoker invoker= new ServiceInvoker(category, name);
+ invoker.deliverAsync(message);
+ } else {
+ logger.info("Don't join yet: "+ joinState);
+ return;
+ }
+ }
+ }
+
+ synchronized(scheduleItems) {
+ // Check if already exists
+ if (scheduleItems.contains(si)) {
+ throw new Exception("Schedule already contains item for " + si);
+ }
+
+ scheduleItems.add(si);
+ SessionManager.saveObject(si);
+
+ logger.debug("Finished scheduling "+si +"' by thread of " + Thread.currentThread().getName());
+ }
+
+ }
+
+ public void unschedule(String category, String name) throws Exception {
+
+ logger.debug("Unscheduling: '"+category+"/"+name+"' by thread of " + Thread.currentThread().getName() );
+
+ synchronized(joinStates) {
+ if (isScheduleItemInJoinState(category, name)) {
+ throw new Exception("Unable to enact join state, converging paths have still not completed");
+ }
+ }
+
+ synchronized(scheduleItems) {
+ ScheduleItem si = getScheduleItem(category, name);
+ if (si.getId() == 0) {
+ throw new Exception("The scheduleItem of " + si + " is not existed !");
+ }
+
+ scheduleItems.remove(si);
+ SessionManager.removeObject(si);
+ logger.debug("Finished unscheduling: " + si +"' by thread of " + Thread.currentThread().getName());
+ }
+ }
+
+ protected boolean isScheduleItemInJoinState(String category, String name) {
+ for(JoinState joinState : joinStates) {
+ if (name.equals(joinState.getName()) && category.equals(joinState.getCategory())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ protected synchronized JoinState getJoinStateByScheduleItem(ScheduleItem si) {
+ for(JoinState joinState : joinStates) {
+ if (si.getName().equals(joinState.getName()) && si.getCategory().equals(joinState.getCategory())) {
+ return joinState;
+ }
+ }
+ return null;
+ }
+
+ protected ScheduleItem getScheduleItem(String category, String name) {
+ for(ScheduleItem si : scheduleItems) {
+ if (category.equals(si.getCategory()) && name.equals(si.getName())) {
+ si.setSession(this);
+ return si;
+ }
+ }
+ ScheduleItem item = new ScheduleItem(category, name);
+ item.setSession(this);
+ return item;
+ }
+
+ public void join(String category, String name, int count) throws Exception {
+ JoinState joinState=new JoinState(category, name, count);
+ joinState.setSession(this);
+ if (joinStates.contains(joinState)) {
+ throw new Exception("The '"+category+ "/"+name+"' of JoinState is already existed.");
+ }
+ joinStates.add(joinState);
+ SessionManager.saveObject(joinState);
+ logger.debug("Added Join State: " + joinState);
+ }
+
+ public void assimulateIdentities(java.util.List<Identity> ids) throws Exception {
+
+ List<Identity> newIds = new ArrayList<Identity>();
+
+ if (identities.size() == 0) {
+ newIds.addAll(ids);
+ } else {
+ for(int i =0; i< ids.size(); i++) {
+ Identity theID = ids.get(i);
+ if (theID.getType() == IdentityType.Primary ||
+ theID.getType() == IdentityType.Association) {
+ if (!identities.contains(theID)) {
+ newIds.add(theID);
+ } else {
+ logger.debug("IDENTITY CONFIRMED:" + theID);
+ }
+ } else {
+ newIds.add(theID);
+ }
+ }
+ }
+
+ List<Identity> result = new ArrayList<Identity>();
+ for(Identity id : newIds) {
+ id.setSession(this);
+ id.setServiceName(this.serviceName);
+ result.add(id);
+ }
+
+ SessionManager.saveCollection(result);
+ identities.addAll(result);
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Session getParent() {
+ return parent;
+ }
+
+ public void setParent(Session parent) {
+ this.parent = parent;
+ }
+
+ public List<ScheduleItem> getScheduleItems() {
+ return scheduleItems;
+ }
+
+ public void setScheduleItems(List<ScheduleItem> scheduleItems) {
+ this.scheduleItems = scheduleItems;
+ }
+
+ public List<Identity> getIdentities() {
+ return identities;
+ }
+
+ public void setIdentities(List<Identity> identities) {
+ this.identities = identities;
+ }
+
+ public String getPojoClass() {
+ return pojoClass;
+ }
+
+ public void setPojoClass(String pojoClass) {
+ this.pojoClass = pojoClass;
+ }
+
+ public Object getBusinessObject() {
+ ByteArrayInputStream bais = new ByteArrayInputStream(serializedObject);
+ try {
+ ObjectInputStream in = new ObjectInputStream(bais);
+ businessObject = in.readObject();
+ in.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Error in reading Object", e);
+ }
+ return businessObject;
+ }
+
+ public void setBusinessObject(Object businessObject) {
+ this.businessObject = businessObject;
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream out;
+
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(this.businessObject);
+ out.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Error in setting business object of " + businessObject, e);
+ }
+ this.serializedObject = bos.toByteArray();
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getConversationType() {
+ return conversationType;
+ }
+
+ public void setConversationType(String conversationType) {
+ this.conversationType = conversationType;
+ }
+
+ public List<EPRWrapper> getEprWrappers() {
+ return eprWrappers;
+ }
+
+ public void setEprWrappers(List<EPRWrapper> eprWrappers) {
+ this.eprWrappers = eprWrappers;
+ }
+
+ public List<JoinState> getJoinStates() {
+ return joinStates;
+ }
+
+ public void setJoinStates(List<JoinState> joinStates) {
+ this.joinStates = joinStates;
+ }
+
+ public byte[] getSerializedObject() {
+ return serializedObject;
+ }
+
+ public void setSerializedObject(byte[] serializedObject) {
+ this.serializedObject = serializedObject;
+ }
+
+ public String toString() {
+ StringBuffer sbuffer = new StringBuffer();
+ sbuffer.append("[ Session id: " + id);
+ sbuffer.append(" serviceName: " + serviceName);
+ sbuffer.append(" business state object: " + businessObject);
+ sbuffer.append("]");
+ return sbuffer.toString();
+ }
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionManager.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.jbossesb.actions.MessageProperties;
+import org.jboss.soa.overlord.jbossesb.actions.Service;
+import org.jboss.soa.overlord.jbossesb.util.ClassLoaderUtil;
+import org.jboss.soa.overlord.jbossesb.util.HibernateUtil;
+import org.mvel.MVEL;
+
+/**
+ * This component is responsible for managing the persistence and retrieval
+ * of sessions.
+ */
+public class SessionManager {
+
+ private static Logger logger = Logger.getLogger(SessionManager.class);
+
+ public static Session createSession(String sessionName) throws Exception {
+
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ Class<?> pojoclass= ClassLoaderUtil.loadClass(sessionName);
+ Object businessState = pojoclass.newInstance();
+
+ Session conversationSession = new Session();
+ conversationSession.setPojoClass(sessionName);
+ conversationSession.setStatus(SessionStatus.Active);
+ conversationSession.setBusinessObject(businessState);
+
+ Service service = pojoclass.getAnnotation(Service.class);
+ if (service != null) {
+ conversationSession.setServiceName(service.name());
+ conversationSession.setConversationType(service.conversationType());
+ }
+
+ hibernateSession.save(conversationSession);
+
+ return conversationSession;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Session createSubSession(String sessionName, String sessionKey, Message message) throws Exception {
+
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ Session parentSession = (Session)hibernateSession.load(Session.class, Long.valueOf(sessionKey));
+ Class<?> pojoclass= ClassLoaderUtil.loadClass(sessionName);
+ Object businessState = pojoclass.newInstance();
+
+ Map<String, Object> boundVariables = (Map<String, Object>)message.getProperties().
+ getProperty(MessageProperties.BOUND_VARIABLE_KEY);
+ for(String key : boundVariables.keySet()) {
+ MVEL.setProperty(businessState, key, boundVariables.get(key));
+ logger.info("bound to " + key);
+ }
+
+ Session conversationSession = new Session();
+ conversationSession.setPojoClass(sessionName);
+ conversationSession.setStatus(SessionStatus.Active);
+ conversationSession.setBusinessObject(businessState);
+ conversationSession.setParent(parentSession);
+
+ Service service = pojoclass.getAnnotation(Service.class);
+ if (service != null) {
+ conversationSession.setServiceName(service.name());
+ conversationSession.setConversationType(service.conversationType());
+ } else {
+ conversationSession.setServiceName(parentSession.getServiceName());
+ conversationSession.setConversationType(parentSession.getConversationType());
+ }
+
+ hibernateSession.save(conversationSession);
+
+ return conversationSession;
+ }
+
+ public static Session retrieveSession(String sessionKey, java.util.List<Identity> ids) throws Exception {
+
+ if (sessionKey == null && ids == null) {
+ return null;
+ }
+
+ if (sessionKey != null) {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ Session session = (Session) hibernateSession.load(Session.class, Long.valueOf(sessionKey));
+ return session;
+ }
+
+ for (Identity id : ids) {
+ if (IdentityType.Primary.equals(id.getType())) {
+ return getSessionByIdentity(id);
+ }
+ }
+
+ return null;
+ }
+
+ public static Object saveObject(Object obj) throws Exception {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ hibernateSession.save(obj);
+ return obj;
+ }
+
+
+ public static Object getObject(long id, Class<?> cls) throws Exception {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ return hibernateSession.load(cls, id);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Collection saveCollection(Collection col) throws Exception {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+
+ for(Iterator it = col.iterator(); it.hasNext();) {
+ Object o = it.next();
+ hibernateSession.save(o);
+ }
+
+ return col;
+ }
+
+ public static void updateObject(Object obj) {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ hibernateSession.update(obj);
+ }
+
+ public static void removeObject(Object obj) {
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ hibernateSession.delete(obj);
+ }
+
+
+ public static Session getSessionByIdentity(Identity id) throws Exception{
+ org.hibernate.Session hibernateSession = HibernateUtil.currentSession();
+ String query = "select b from Identity b where b.type =:type and b.propertyValues =:propertyValues and b.serviceName =:serviceName";
+ List<?> results = hibernateSession.createQuery(query)
+ .setParameter("type", id.getType())
+ .setParameter("propertyValues", id.getPropertyValues())
+ .setParameter("serviceName", id.getServiceName())
+ .list();
+ if (results.size() < 1) {
+ return null;
+ }
+
+ Identity theID = null;
+ for (int i=0; i< results.size(); i++) {
+ Identity identity = (Identity)results.get(i);
+ if (SessionStatus.Active.equals(identity.getSession().getStatus())) {
+ theID = identity;
+ break;
+ }
+ }
+
+ if (theID == null) {
+ return null;
+ }
+
+ Session session = theID.getSession();
+ logger.debug("Get Session of " + session + " by using identity of " + id);
+
+ return session;
+ }
+
+
+}
Added: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionStatus.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionStatus.java (rev 0)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/SessionStatus.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., 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.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb;
+
+public enum SessionStatus {
+
+ Initialized,
+ Active,
+ Completed,
+ CLOSED
+}
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -31,12 +31,12 @@
import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Identity;
-import org.jboss.soa.overlord.conversation.IdentityType;
-import org.jboss.soa.overlord.conversation.ScheduleItem;
-import org.jboss.soa.overlord.conversation.Session;
-import org.jboss.soa.overlord.conversation.SessionManager;
-import org.jboss.soa.overlord.conversation.SessionStatus;
+import org.jboss.soa.overlord.jbossesb.Identity;
+import org.jboss.soa.overlord.jbossesb.IdentityType;
+import org.jboss.soa.overlord.jbossesb.ScheduleItem;
+import org.jboss.soa.overlord.jbossesb.Session;
+import org.jboss.soa.overlord.jbossesb.SessionManager;
+import org.jboss.soa.overlord.jbossesb.SessionStatus;
import org.jboss.soa.overlord.jbossesb.util.ClassLoaderUtil;
import org.jboss.soa.overlord.jbossesb.util.HibernateUtil;
import org.jboss.soa.overlord.jbossesb.util.MessageUtil;
@@ -73,6 +73,14 @@
return(ret);
}
+ /**
+ *
+ * @param message
+ * @param serviceDescriptionName
+ * @param ct
+ * @return
+ * @throws Exception
+ */
protected List<Identity> getIdentities(Message message, String serviceDescriptionName, ConfigTree ct) throws Exception {
ConfigTree[] children=ct.getAllChildren();
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/CreateSessionAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/CreateSessionAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/CreateSessionAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,8 +22,8 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
-import org.jboss.soa.overlord.conversation.SessionManager;
+import org.jboss.soa.overlord.jbossesb.Session;
+import org.jboss.soa.overlord.jbossesb.SessionManager;
/**
* @author gary
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/IfAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/MessageRouterAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -26,9 +26,9 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Identity;
-import org.jboss.soa.overlord.conversation.ScheduleItem;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Identity;
+import org.jboss.soa.overlord.jbossesb.ScheduleItem;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* @author jeffyu
@@ -49,13 +49,20 @@
logger.info("The received message type is [" + messageType + "]");
boolean routerFlag = false;
+ String svcDesc = getConfig().getAttribute(ActionProperties.SERVICE_DESCRIPTION_NAME);
for (ConfigTree ct : children) {
ConfigTree[] msgNodes = ct.getChildren("message");
- String msgType = msgNodes[0].getAttribute("type");
- if (routerFlag == false && messageType.equals(msgType)) {
- String svcDesc = ct.getAttribute(ActionProperties.SERVICE_DESCRIPTION_NAME);
- List<Identity> ids = getIdentities(message, svcDesc, ct);
+
+ ConfigTree selectedMsgConfig = null;
+ for (ConfigTree msgConfig : msgNodes) {
+ if (messageType.equals(msgConfig.getAttribute("type"))) {
+ selectedMsgConfig = msgConfig;
+ }
+ }
+
+ if (routerFlag == false && (selectedMsgConfig != null)) {
+ List<Identity> ids = getIdentities(message, svcDesc, selectedMsgConfig);
Session session = getSession(message, ids);
String serviceCategory = ct.getAttribute(ActionProperties.SERVICE_CATEGORY);
String serviceName = ct.getAttribute(ActionProperties.SERVICE_NAME);
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ParallelAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action represents a parallel construct.
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/PerformAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -25,7 +25,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ReceiveMessageAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -23,8 +23,8 @@
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Identity;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Identity;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* Receive activity.
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/RetrieveSessionAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -24,8 +24,8 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Identity;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Identity;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action creates a new session.
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ScheduleStateAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* Schedule state activity.
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SendMessageAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -31,9 +31,9 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.jboss.soa.overlord.conversation.Identity;
-import org.jboss.soa.overlord.conversation.LogicalCourier;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Identity;
+import org.jboss.soa.overlord.jbossesb.LogicalCourier;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetMessageAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,8 +22,8 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
-import org.jboss.soa.overlord.conversation.SessionManager;
+import org.jboss.soa.overlord.jbossesb.Session;
+import org.jboss.soa.overlord.jbossesb.SessionManager;
import org.jboss.soa.overlord.jbossesb.util.XMLUtils;
import org.mvel.MVEL;
import org.w3c.dom.Element;
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SwitchAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
/**
* This action represents a choice between a set of specified paths
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhenAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/WhileAction.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -22,7 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.jbossesb.Session;
import org.mvel.MVEL;
/**
Modified: cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java
===================================================================
--- cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/util/HibernateUtil.java 2008-08-20 10:17:16 UTC (rev 255)
@@ -36,7 +36,7 @@
static {
try {
- sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
+ sessionFactory = new AnnotationConfiguration().configure("/overlord-cdl-jbossesb.cfg.xml").buildSessionFactory();
} catch (Throwable t) {
throw new ExceptionInInitializerError(t);
}
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -1,5 +1,5 @@
<jbossesb-deployment>
- <depends>jboss.esb:deployment=cdl-jbossesb.esb</depends>
+ <depends>jboss.esb:deployment=overlord-cdl-jbossesb.esb</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker_reply</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker1</depends>
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -75,23 +75,29 @@
<actions mep="OneWay">
<action class="org.jboss.soa.overlord.jbossesb.actions.MessageRouterAction"
process="process" name="s0-1">
+ <property name="serviceDescriptionName" value="{http://www.jboss.org/overlord/loanBroker}Broker" />
<property name="paths">
<route service-category="ESBBroker.BrokerParticipant"
service-name="ESBBrokerProcess.main"
initiate="true">
- <identity type="primary" >
- <token name="id" locator="//@id" />
- </identity>
- <message type="enquiry" />
+ <message type="enquiry">
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ </identity>
+ </message>
</route>
<route service-category="ESBBroker.BrokerParticipant"
- service-name="ESBBrokerProcess.main.5"
- serviceDescriptionName="{http://www.jboss.org/overlord/loanBroker}Broker" >
- <identity type="primary" >
- <token name="id" locator="//@id" />
- </identity>
- <message type="buy" />
- <message type="cancel" />
+ service-name="ESBBrokerProcess.main.5">
+ <message type="buy">
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ </identity>
+ </message>
+ <message type="cancel" >
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ </identity>
+ </message>
</route>
</property>
</action>
Modified: cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/deployment.xml
===================================================================
--- cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/deployment.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/creditAgency/src/main/resources/META-INF/deployment.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -1,5 +1,5 @@
<jbossesb-deployment>
- <depends>jboss.esb:deployment=cdl-jbossesb.esb</depends>
+ <depends>jboss.esb:deployment=overlord-cdl-jbossesb.esb</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency1</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-creditAgency2</depends>
Modified: cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/deployment.xml
===================================================================
--- cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/deployment.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/purchasing/src/main/resources/META-INF/deployment.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -1,5 +1,5 @@
<jbossesb-deployment>
- <depends>jboss.esb:deployment=cdl-jbossesb.esb</depends>
+ <depends>jboss.esb:deployment=overlord-cdl-jbossesb.esb</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-broker</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-broker_reply</depends>
<depends>jboss.esb.gen.destination:service=Queue,name=esb-broker1</depends>
Modified: cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/deployment.xml
===================================================================
--- cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/deployment.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/deployment.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -1,5 +1,5 @@
<jbossesb-deployment>
- <depends>jboss.esb:deployment=cdl-jbossesb.esb</depends>
+ <depends>jboss.esb:deployment=overlord-cdl-jbossesb.esb</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-supplier1</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-supplier11</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-supplier12</depends>
Modified: cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/jboss-esb.xml 2008-08-19 16:23:55 UTC (rev 254)
+++ cdl/trunk/samples/jbossesb/supplier/src/main/resources/META-INF/jboss-esb.xml 2008-08-20 10:17:16 UTC (rev 255)
@@ -33,20 +33,22 @@
<route service-category="ESBBroker.Suppliers"
service-name="Supplier1.main.1"
initiate="true">
- <identity type="primary" >
- <token name="id" locator="//@id" />
- <token name="supplierDesc" locator="//@supplierDesc" />
- </identity>
- <message type="requestForQuote" />
+ <message type="requestForQuote">
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ <token name="supplierDesc" locator="//@supplierDesc" />
+ </identity>
+ </message>
</route>
<route service-category="ESBBroker.Suppliers"
service-name="Supplier1.main.2"
initiate="true">
- <identity type="primary" >
- <token name="id" locator="//@id" />
- <token name="supplierDesc" locator="//@supplierDesc" />
- </identity>
- <message type="orderConfirmed" />
+ <message type="orderConfirmed">
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ <token name="supplierDesc" locator="//@supplierDesc" />
+ </identity>
+ </message>
</route>
</property>
</action>
15 years, 8 months
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.
by overlord-commits@lists.jboss.org
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);
+ }
+ }
+}
15 years, 8 months
Overlord SVN: r253 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb: dialogs and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2008-08-19 07:53:13 -0400 (Tue, 19 Aug 2008)
New Revision: 253
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/dialogs/GenerateDialog.java
Log:
Guard against generating jboss-esb.xml when choreography has errors, and also use default project names that contain the choreography name.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java 2008-08-14 10:23:27 UTC (rev 252)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java 2008-08-19 11:53:13 UTC (rev 253)
@@ -17,14 +17,8 @@
*/
package org.jboss.tools.overlord.jbossesb.actions;
-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.action.IAction;
@@ -35,14 +29,9 @@
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
-import org.scribble.conversation.model.ConversationModel;
-import org.scribble.extensions.RegistryFactory;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.w3c.dom.Node;
+import org.scribble.osgi.util.*;
import org.jboss.tools.overlord.jbossesb.dialogs.*;
-import org.jboss.tools.overlord.jbossesb.model.*;
/**
* This class implements the action to generate the choreography
@@ -50,6 +39,7 @@
*/
public class GenerateAction implements IObjectActionDelegate {
+ private static final String CANNOT_GENERATE = "Choreography has errors, so cannot generate";
public GenerateAction() {
}
@@ -66,7 +56,7 @@
if (res instanceof IFile) {
- if (true) {
+ if (ResourceUtil.hasErrors(res) == false) {
GenerateDialog dialog=
new GenerateDialog(m_targetPart.getSite().getShell(),
(IFile)res);
@@ -74,226 +64,17 @@
try {
dialog.open();
} catch(Throwable e) {
- e.printStackTrace();
+ logger.log(java.util.logging.Level.SEVERE,
+ "Failed to open generate dialog", e);
}
} else {
- generate((IFile)res);
+ warn(CANNOT_GENERATE);
}
}
}
}
- protected void generate(IFile res) {
- 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) {
- ConversationModel cm=(ConversationModel)model;
-
- java.util.List<Role> roles=cm.getRoles();
-
- for (int i=0; i < roles.size(); i++) {
-
- generateRole(cm, roles.get(i));
- }
- }
- }
- }
- }
-
- protected void generateRole(ConversationModel cm, Role role) {
-
- if (logger.isLoggable(Level.FINEST)) {
- logger.finest("Generate role '"+role+"' for: "+cm);
- }
-
- // 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(cm,
- 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);
- } else {
- logger.severe("Unable to find model generator");
- }
-
- try {
- System.out.println("------------------------------");
- System.out.println("ROLE="+role.getName());
- System.out.println("ESB Configuration:\r\n"+
- getText(target.getESBConfiguration()));
- } 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 indicates that the selection has changed.
*
* @param action The action
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-14 10:23:27 UTC (rev 252)
+++ 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)
@@ -177,8 +177,15 @@
});
Text projectName=new Text(group, SWT.NONE);
- projectName.setText(m_roles.get(i).getName());
+ 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;
@@ -319,6 +326,8 @@
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));
}
15 years, 8 months
Overlord SVN: r252 - sam/tags.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 06:23:27 -0400 (Thu, 14 Aug 2008)
New Revision: 252
Added:
sam/tags/sam-0.1.0/
Log:
Tag first version
Copied: sam/tags/sam-0.1.0 (from rev 251, sam/trunk)
15 years, 9 months
Overlord SVN: r251 - sam.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 06:21:38 -0400 (Thu, 14 Aug 2008)
New Revision: 251
Added:
sam/tags/
Log:
create tags directory
15 years, 9 months
Overlord SVN: r250 - sam/trunk/modules/core/src/main/java/org/jboss/sam/internal/drools.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 06:20:21 -0400 (Thu, 14 Aug 2008)
New Revision: 250
Modified:
sam/trunk/modules/core/src/main/java/org/jboss/sam/internal/drools/SAMAdapter.java
Log:
Pass on SQLExceptin to drools
Modified: sam/trunk/modules/core/src/main/java/org/jboss/sam/internal/drools/SAMAdapter.java
===================================================================
--- sam/trunk/modules/core/src/main/java/org/jboss/sam/internal/drools/SAMAdapter.java 2008-08-14 10:19:58 UTC (rev 249)
+++ sam/trunk/modules/core/src/main/java/org/jboss/sam/internal/drools/SAMAdapter.java 2008-08-14 10:20:21 UTC (rev 250)
@@ -105,9 +105,8 @@
}
}
catch(SQLException e)
- {
- // todo: exeception handling? (Goes back into drools)
- e.printStackTrace();
+ {
+ throw new RuntimeException("Failed to execute SQL", e);
}
finally
{
15 years, 9 months
Overlord SVN: r249 - sam/trunk/modules/core/src/main/java/org/jboss/sam/config.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 06:19:58 -0400 (Thu, 14 Aug 2008)
New Revision: 249
Modified:
sam/trunk/modules/core/src/main/java/org/jboss/sam/config/ConfigurationDef.java
Log:
Added runtime-configuration element
Modified: sam/trunk/modules/core/src/main/java/org/jboss/sam/config/ConfigurationDef.java
===================================================================
--- sam/trunk/modules/core/src/main/java/org/jboss/sam/config/ConfigurationDef.java 2008-08-14 09:18:41 UTC (rev 248)
+++ sam/trunk/modules/core/src/main/java/org/jboss/sam/config/ConfigurationDef.java 2008-08-14 10:19:58 UTC (rev 249)
@@ -121,7 +121,7 @@
this.outputs = outputs;
}
- @XmlElementWrapper(name = "properties")
+ @XmlElementWrapper(name = "runtime-configuration")
@XmlElement(name="property")
public List<PropertyDef> getProps()
{
15 years, 9 months
Overlord SVN: r248 - sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 05:18:41 -0400 (Thu, 14 Aug 2008)
New Revision: 248
Modified:
sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java
Log:
Added docs and comments to DatabaseTestCase
Modified: sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java
===================================================================
--- sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java 2008-08-14 09:12:19 UTC (rev 247)
+++ sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java 2008-08-14 09:18:41 UTC (rev 248)
@@ -26,7 +26,7 @@
import org.jboss.test.sam.SamTestSetup;
/**
- * Test esper database integration patterns
+ * Test database integration patterns
*
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -72,7 +72,8 @@
}
/**
- * Fire a event to trigger the SQL query
+ * Fire a event to trigger the SQL query
+ * (Constraints applied to SQL statement)
*/
public void testSQLQuery() throws Exception
{
@@ -92,6 +93,11 @@
dump(eventMessages);
}
+ /**
+ * Join SQL data into event processing
+ * (Constraints applied to working memory)
+ * @throws Exception
+ */
public void testSQLJoin() throws Exception
{
// setup
15 years, 9 months
Overlord SVN: r247 - in sam/trunk/modules/core/src/test: resources/database and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 05:12:19 -0400 (Thu, 14 Aug 2008)
New Revision: 247
Added:
sam/trunk/modules/core/src/test/resources/database/sampleJoin.drl
sam/trunk/modules/core/src/test/resources/database/triggerPull.drl
Removed:
sam/trunk/modules/core/src/test/resources/database/test.drl
Modified:
sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java
sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/Query.java
Log:
Added SQL join sample
Modified: sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java
===================================================================
--- sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java 2008-08-14 07:47:10 UTC (rev 246)
+++ sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/DatabaseTestCase.java 2008-08-14 09:12:19 UTC (rev 247)
@@ -60,7 +60,7 @@
db.update("INSERT INTO quotes (symbol, name, price) VALUES('RHT', 'Red Hat', 22.82)");
db.update("INSERT INTO quotes (symbol, name, price) VALUES('ORCL', 'Oracle', 22.85)");
db.update("INSERT INTO quotes (symbol, name, price) VALUES('JAVA', 'Sun', 12.42)" );
- db.update("INSERT INTO quotes (symbol, name, price) VALUES('GOOG', 'Goole', 572.51)");
+ db.update("INSERT INTO quotes (symbol, name, price) VALUES('GOOG', 'Google', 572.51)");
// database dump
//db.query("SELECT symbol, price FROM quotes");
@@ -74,55 +74,50 @@
/**
* Fire a event to trigger the SQL query
*/
- public void testTriggeredSQLQuery() throws Exception
+ public void testSQLQuery() throws Exception
{
// setup
- String epl = getDRLFromResource("database/test.drl");
+ String epl = getDRLFromResource("database/triggerPull.drl");
+ eventProcessor.registerBoundStatement("InVM","TriggerSQL", epl);
- eventProcessor.registerBoundStatement("InVM","PullSQL", epl);
-
// trigger
- generateInVMEvent( new Query("%") );
+ Query queryMessage = new Query("%");
+ generateInVMEvent(queryMessage);
// evaluate
assertTrue("Listener not invoked", bufferedOutput.isInvoked());
EventMessage[] eventMessages = bufferedOutput.getLastNewData();
assertEquals(7, eventMessages.length);
- for(EventMessage event : eventMessages)
- {
- System.out.println(event.getProperty("symbol") + " -> " + event.getProperty("price") );
- }
+ dump(eventMessages);
}
- public void testEsperPullAPI() throws Exception
+ public void testSQLJoin() throws Exception
{
- System.out.println("FIXME: testPullAPI on database queries");
+ // setup
+ String epl = getDRLFromResource("database/sampleJoin.drl");
+ eventProcessor.registerBoundStatement("InVM","SQLJoin", epl);
- /*See http://jira.codehaus.org/browse/ESPER-254
+ // trigger
+ Query queryEvent = new Query();
+ queryEvent.setThreshold(100.00);
- String aggregateStmt = "insert into NewQuotes " +
- "select symbol, price from " +
- "pattern [every timer:interval(1 sec)], "+
- "sql:SamTestDB ['select symbol, price from quotes']";
+ generateInVMEvent(queryEvent);
- String pullStmt = "select * from NewQuotes.win:keepall()";
+ // evaluate
+ assertTrue("Listener not invoked", bufferedOutput.isInvoked());
+ EventMessage[] eventMessages = bufferedOutput.getLastNewData();
+ assertEquals(3, eventMessages.length);
- // create two views
- eventProcessor.registerStatement("PullAPI", aggregateStmt);
- ProcessingStatement stmt = eventProcessor.registerStatement("QuotestPull", pullStmt);
+ dump(eventMessages);
+ }
- boolean receivedData = false;
- Iterator<EventBean> it = ((EsperProcessingStatement)stmt).getUnderlying().iterator();
- while(it.hasNext())
+ private void dump(EventMessage[] eventMessages)
+ {
+ for(EventMessage event : eventMessages)
{
- EventBean event = it.next();
- System.out.println("symbol/price -> " + event.get("symbol") + "/" + event.get("price"));
- receivedData = true;
+ System.out.println(event.getProperty("symbol") + " -> " + event.getProperty("price") );
}
-
- assertTrue("Pull API failed, no data received", receivedData);
-
- */
}
+
}
Modified: sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/Query.java
===================================================================
--- sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/Query.java 2008-08-14 07:47:10 UTC (rev 246)
+++ sam/trunk/modules/core/src/test/java/org/jboss/test/sam/database/Query.java 2008-08-14 09:12:19 UTC (rev 247)
@@ -27,7 +27,13 @@
public class Query
{
public String criteria;
+ public double threshold = 0.00;
+ public Query()
+ {
+ this("%");
+ }
+
public Query(String criteria)
{
this.criteria = criteria;
@@ -43,4 +49,14 @@
{
this.criteria = criteria;
}
+
+ public double getThreshold()
+ {
+ return threshold;
+ }
+
+ public void setThreshold(double threshold)
+ {
+ this.threshold = threshold;
+ }
}
Added: sam/trunk/modules/core/src/test/resources/database/sampleJoin.drl
===================================================================
--- sam/trunk/modules/core/src/test/resources/database/sampleJoin.drl (rev 0)
+++ sam/trunk/modules/core/src/test/resources/database/sampleJoin.drl 2008-08-14 09:12:19 UTC (rev 247)
@@ -0,0 +1,15 @@
+package org.jboss.test.sam.database;
+
+import java.util.*;
+
+global org.jboss.sam.internal.drools.SAMAdapter SAM;
+
+rule "Pull any quote for certain threshold"
+when
+ $query: Query(threshold>99);
+ $sqlStream: ArrayList() from collect (
+ Map(this['price']>$query.threshold) from SAM.query("hsqlDB", "SELECT symbol, price FROM quotes")
+ );
+then
+ SAM.getListener("InVM").update($sqlStream);
+end
\ No newline at end of file
Deleted: sam/trunk/modules/core/src/test/resources/database/test.drl
===================================================================
--- sam/trunk/modules/core/src/test/resources/database/test.drl 2008-08-14 07:47:10 UTC (rev 246)
+++ sam/trunk/modules/core/src/test/resources/database/test.drl 2008-08-14 09:12:19 UTC (rev 247)
@@ -1,15 +0,0 @@
-package org.jboss.test.sam.database;
-
-import java.util.*;
-
-global org.jboss.sam.internal.drools.SAMAdapter SAM;
-
-rule "Simple SQL pull"
-when
- $query: Query();
- $sqlStream: ArrayList() from collect (
- Map() from SAM.query("hsqlDB", "SELECT symbol, price FROM quotes WHERE symbol like ('"+$query.criteria+"')")
- );
-then
- SAM.getListener("InVM").update($sqlStream);
-end
\ No newline at end of file
Copied: sam/trunk/modules/core/src/test/resources/database/triggerPull.drl (from rev 246, sam/trunk/modules/core/src/test/resources/database/test.drl)
===================================================================
--- sam/trunk/modules/core/src/test/resources/database/triggerPull.drl (rev 0)
+++ sam/trunk/modules/core/src/test/resources/database/triggerPull.drl 2008-08-14 09:12:19 UTC (rev 247)
@@ -0,0 +1,15 @@
+package org.jboss.test.sam.database;
+
+import java.util.*;
+
+global org.jboss.sam.internal.drools.SAMAdapter SAM;
+
+rule "Pull any quote by symbol"
+when
+ $query: Query(threshold==0.00);
+ $sqlStream: ArrayList() from collect (
+ Map() from SAM.query("hsqlDB", "SELECT symbol, price FROM quotes WHERE symbol like ('"+$query.criteria+"')")
+ );
+then
+ SAM.getListener("InVM").update($sqlStream);
+end
15 years, 9 months
Overlord SVN: r246 - sam/trunk/modules/core/src/test/resources/database.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-08-14 03:47:10 -0400 (Thu, 14 Aug 2008)
New Revision: 246
Modified:
sam/trunk/modules/core/src/test/resources/database/test.drl
Log:
Restore triggerSQL test case
Modified: sam/trunk/modules/core/src/test/resources/database/test.drl
===================================================================
--- sam/trunk/modules/core/src/test/resources/database/test.drl 2008-08-14 07:43:37 UTC (rev 245)
+++ sam/trunk/modules/core/src/test/resources/database/test.drl 2008-08-14 07:47:10 UTC (rev 246)
@@ -8,7 +8,7 @@
when
$query: Query();
$sqlStream: ArrayList() from collect (
- Map() from SAM.query("hsqlDB", "SELECT * FROM quotes")
+ Map() from SAM.query("hsqlDB", "SELECT symbol, price FROM quotes WHERE symbol like ('"+$query.criteria+"')")
);
then
SAM.getListener("InVM").update($sqlStream);
15 years, 9 months