Seam SVN: r11919 - in modules/remoting/trunk: src/main/resources/org/jboss/seam/remoting and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-01-06 22:28:27 -0500 (Wed, 06 Jan 2010)
New Revision: 11919
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
fix model delta marshalling issue
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-07 02:37:42 UTC (rev 11918)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-07 03:28:27 UTC (rev 11919)
@@ -12,7 +12,7 @@
<h1>Seam Remoting - Model Example</h1>
- <script type="text/javascript" src="seam/resource/remoting/resource/remote.js?compress=true"></script>
+ <script type="text/javascript" src="seam/resource/remoting/resource/remote.js"></script>
<script type="text/javascript" src="seam/resource/remoting/interface.js?personSearch"></script>
<script type="text/javascript">
@@ -130,6 +130,24 @@
model.applyUpdates();
}
+ function createDeleteAddressLink(address, div) {
+ var link = document.createElement("a");
+ link.href = "#";
+ link.onclick = function() {
+ var addresses = model.getValue("person").addresses;
+ for (var i = 0; i < addresses.length; i++) {
+ if (addresses[i] == address) {
+ addresses.splice(i, 1);
+ break;
+ }
+ };
+
+ document.getElementById("addresses").removeChild(div);
+ };
+ link.appendChild(document.createTextNode("Delete address"));
+ return link;
+ }
+
function createAddressEditor(address) {
var addressDiv = document.createElement("div");
addressDiv.className = "addressContainer";
@@ -152,6 +170,7 @@
row3.appendChild(createLabel("Country"));
row3.appendChild(createBoundInput(address, "country"));
+ row3.appendChild(createDeleteAddressLink(address, addressDiv));
return addressDiv;
}
Modified: modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-07 02:37:42 UTC (rev 11918)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-07 03:28:27 UTC (rev 11919)
@@ -911,7 +911,7 @@
Seam.Delta.prototype.buildRefs = function() {
var refs = [];
for (var i=0; i<this.refs.elements.length; i++) {
- refs.push(this.refs.elements[i]);
+ if (this.refs.elements[i].value) refs.push(this.refs.elements[i]);
}
return refs;
};
@@ -1077,7 +1077,7 @@
if (v instanceof Seam.Changeset) {
for (var j=0; j<v.propertyChange.elements.length; j++) {
d += "<member name=\"" + v.propertyChange.elements[j].key + "\">";
- d += Seam.serializeValue(v.propertyChange.elements[j].value, null, refs);
+ d += Seam.serializeValue(v.propertyChange.elements[j].value, null, this.workingRefs);
d += "</member>";
}
} else {
14 years, 11 months
Seam SVN: r11918 - in modules/remoting/trunk/examples/model/src/main: webapp and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-01-06 21:37:42 -0500 (Wed, 06 Jan 2010)
New Revision: 11918
Added:
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/PersonSearch.java
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
modules/remoting/trunk/examples/model/src/main/webapp/style.css
Log:
first pass at updated example, still need address add/remove function and to apply person changes
Added: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/PersonSearch.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/PersonSearch.java (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/PersonSearch.java 2010-01-07 02:37:42 UTC (rev 11918)
@@ -0,0 +1,26 @@
+package org.jboss.seam.remoting.examples.model;
+
+import java.util.List;
+
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.remoting.annotations.WebRemote;
+
+/**
+ * Returns a list of all the Person entities
+ *
+ * @author Shane Bryzak
+ */
+@Named("personSearch")
+public class PersonSearch
+{
+ @PersistenceContext EntityManager entityManager;
+
+ @WebRemote @SuppressWarnings("unchecked")
+ public List<Person> listPeople()
+ {
+ return entityManager.createQuery("select p from Person p").getResultList();
+ }
+}
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-06 18:55:53 UTC (rev 11917)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-07 02:37:42 UTC (rev 11918)
@@ -8,11 +8,12 @@
<link href="tree.css" rel="stylesheet" type="text/css"/>
</head>
-<body>
+<body onload="loadPeople()">
<h1>Seam Remoting - Model Example</h1>
<script type="text/javascript" src="seam/resource/remoting/resource/remote.js?compress=true"></script>
+ <script type="text/javascript" src="seam/resource/remoting/interface.js?personSearch"></script>
<script type="text/javascript">
//<![CDATA[
@@ -20,219 +21,183 @@
// Turn on debug logging so we can see the request and response packets
Seam.debug = true;
- var model = null;
+ var model = null;
+ function clearElement(e) {
+ while (e.hasChildNodes()) {
+ e.removeChild(e.firstChild);
+ }
+ }
+
+ function createLinkRow(text, onclick) {
+ var link = document.createElement("a");
+ link.href = "#";
+ if (onclick) link.setAttribute("onclick", onclick);
+ link.appendChild(document.createTextNode(text));
+ var div = document.createElement("div");
+ div.appendChild(link);
+ return div;
+ }
+
+ function loadPeople() {
+ var personList = document.getElementById("personList");
+
+ var callback = function(people) {
+ for (var i = 0; i < people.length; i++) {
+ personList.appendChild(createLinkRow(
+ people[i].firstName + " " + people[i].lastName,
+ "editPerson(" + people[i].personId + ")"));
+ }
+ };
+
+ clearElement(personList);
+ Seam.createBean("personSearch").listPeople(callback);
+ }
+
// A helper function that returns the value of an element
function getElementValue(elementName) {
var value = document.getElementById(elementName).value;
return (value.trim().length > 0) ? value : null;
- }
+ }
- // Fetch the model
- function fetch() {
- var fetchActionBean = getElementValue("fetchActionBean");
- var fetchActionQualifiers = getElementValue("fetchActionQualifiers");
- var fetchActionMethod = getElementValue("fetchActionMethod");
- var fetchActionParams = getElementValue("fetchActionParams");
+ function editPerson(personId) {
+ var action = new Seam.Action()
+ .setBeanType("org.jboss.seam.remoting.examples.model.PersonAction")
+ .setMethod("editPerson")
+ .addParam(personId);
- var action = null;
-
- if (fetchActionBean) {
- action = new Seam.Action();
- action.setBeanType(fetchActionBean);
- if (fetchActionQualifiers) action.setQualifiers(fetchActionQualifiers);
- action.setMethod(fetchActionMethod);
- if (fetchActionParams) {
- var params = fetchActionParams.split(",");
- for (var i = 0; i < params.length; i++) {
- action.addParam(params[i].trim());
- }
- }
- }
-
model = new Seam.Model();
+ model.addBeanProperty("person", "org.jboss.seam.remoting.examples.model.PersonAction", "person");
+ model.fetch(action, fetchCallback);
+ }
- var alias = getElementValue("valueAlias1");
- var bean = getElementValue("valueBean1");
- var property = getElementValue("valueProperty1");
- if (alias && bean && property) model.addBeanProperty(alias, bean, property);
-
- // TODO make this less "hard coded"
- alias = getElementValue("valueAlias2");
- bean = getElementValue("valueBean2");
- property = getElementValue("valueProperty2");
- if (alias && bean && property) model.addBeanProperty(alias, bean, property);
+ function fetchCallback(model) {
+ var person = model.getValue("person");
+ document.getElementById("firstName").value = person.getFirstName();
+ document.getElementById("lastName").value = person.getLastName();
+ document.getElementById("dob").value = person.getDateOfBirth();
- alias = getElementValue("valueAlias3");
- bean = getElementValue("valueBean3");
- property = getElementValue("valueProperty3");
- if (alias && bean && property) model.addBeanProperty(alias, bean, property);
+ var addressDiv = document.getElementById("addresses");
+ clearElement(addressDiv);
+ addressDiv.appendChild(createLinkRow("Load addresses", "loadAddresses()"));
- if (action)
- model.fetch(action, fetchCallback);
- else
- model.fetch(fetchCallback);
+ document.getElementById("applyChanges").disabled = false;
}
+
+ function loadAddresses() {
+ model.expand(model.getValue("person"), "addresses", loadAddressesCallback);
+ }
+
+ function loadAddressesCallback() {
+ var addressDiv = document.getElementById("addresses");
+ clearElement(addressDiv);
- function fetchCallback(model) {
-
- for (var i = 0; i < model.values.length; i++) {
-
+ var addresses = model.getValue("person").getAddresses();
+ if (addresses.length > 0) {
+ var header = document.createElement("div");
+ header.className = "sectionHeader";
+ header.appendChild(document.createTextNode("Addresses"));
+ addressDiv.appendChild(header);
+
+ for (var i = 0; i < addresses.length; i++) {
+ addressDiv.appendChild(createAddressEditor(addresses[i]));
+ }
+ } else {
+ addressDiv.appendChild(document.createTextNode("No addresses found"));
}
}
- function renderValueNode(parentNode, value, alias) {
- var beanType = Seam.getBeanType(value);
- var meta = Seam.getBeanMetadata(value);
+ function createLabel(text) {
+ var lbl = document.createElement("label");
+ lbl.appendChild(document.createTextNode(text));
+ return lbl;
+ }
+
+ function createBoundInput(obj, propertyName, className) {
+ var input = document.createElement("input");
+ input.type = "text";
+ input.value = obj[propertyName];
+ input.onchange = function(event) { obj[propertyName] = event.target.value;}
+ if (className) input.className = className;
+ return input;
+ }
+
+ function apply() {
+ document.getElementById("applyChanges").disabled = true;
- var valueNode = new xw.controls.TreeNode((alias ? alias + ":" : "") + beanType.__name, false, value);
- parentNode.add(valueNode);
-
- for (var j = 0; j < meta.length; j++) {
- var fieldName = meta[j].field;
- var fieldType = meta[j].type;
- var leaf = fieldType != "bag" && fieldType != "map" && fieldType != "bean";
- var node = new xw.controls.TreeNode(fieldName + ":" + value[fieldName], leaf);
- if (!leaf) node.canExpand = true;
- valueNode.add(node);
-
- if (!leaf && value[fieldName]) renderValueNode(valueNode, value[fieldName]);
- }
+ // TODO apply person changes here
+
+ model.applyUpdates();
}
-
- // Apply changes to the model
- function apply() {
- var applyActionBean = getElementValue("applyActionBean");
- var applyActionQualifiers = getElementValue("applyActionQualifiers");
- var applyActionMethod = getElementValue("applyActionMethod");
- var applyActionParams = getElementValue("applyActionParams");
+
+ function createAddressEditor(address) {
+ var addressDiv = document.createElement("div");
+ addressDiv.className = "addressContainer";
+ var row1 = document.createElement("div");
+ var row2 = document.createElement("div");
+ var row3 = document.createElement("div");
+ addressDiv.appendChild(row1);
+ addressDiv.appendChild(row2);
+ addressDiv.appendChild(row3);
- var action = null;
+ row1.appendChild(createLabel("Street No"));
+ row1.appendChild(createBoundInput(address, "streetNo", "streetNo"));
+ row1.appendChild(createLabel("Street Name"));
+ row1.appendChild(createBoundInput(address, "streetName"));
- if (applyActionBean) {
- action = new Seam.Action();
- action.setBeanType(applyActionBean);
- if (applyActionQualifiers) action.setQualifiers(applyActionQualifiers);
- action.setMethod(applyActionMethod);
- if (applyActionParams) {
- var params = applyActionParams.split(",");
- for (var i = 0; i < params.length; i++) {
- action.addParam(params[i].trim());
- }
- }
- }
+ row2.appendChild(createLabel("Suburb"));
+ row2.appendChild(createBoundInput(address, "suburb"));
+ row2.appendChild(createLabel("Postcode/Zip"));
+ row2.appendChild(createBoundInput(address, "postCode", "postCode"));
- var callback = function(model) { alert("model updates applied"); };
-
- if (action)
- model.applyUpdates(action, callback);
- else
- model.applyUpdates(callback);
- }
+ row3.appendChild(createLabel("Country"));
+ row3.appendChild(createBoundInput(address, "country"));
- /*
- function expandModel() {
- var callback = function(model) { alert("Got addresses: " + model.getValue("person").getAddresses().length); };
-
- model.expand(model.getValue("person"), "addresses", callback);
+ return addressDiv;
}
- */
-
+
// ]]>
</script>
- <div class="section">
- <div class="sectionHeader">Fetch model action</div>
- <div class="sectionForm">
- <div class="formRow">
- <label for="fetchActionBean">Bean</label>
- <input type="text" id="fetchActionBean" value="org.jboss.seam.remoting.examples.model.PersonAction"/>
- </div>
- <div class="formRow">
- <label for="fetchActionQualifiers">Qualifiers</label>
- <input type="text" id="fetchActionQualifiers"/>
- </div>
- <div class="formRow">
- <label for="fetchActionMethod">Method</label>
- <input type="text" id="fetchActionMethod" value="editPerson"/>
- </div>
- <div class="formRow">
- <label for="fetchActionParams">Params</label>
- <input type="text" id="fetchActionParams" value="1"/>
- </div>
- </div>
+ <div class="listContainer">
+ <div class="sectionHeader">People</div>
- <div class="sectionCommand">
- <button onclick="javascript:fetch()">Fetch</button>
- </div>
+ <div id="personList"></div>
- <br class="clear"/>
+ <div>
+ <a href="#" onclick="javascript:alert('new person')">Create new person</a>
+ </div>
</div>
- <div class="section">
- <div class="sectionHeader">Apply model action</div>
- <div class="sectionForm">
- <div class="formRow">
- <label for="applyActionBean">Bean</label>
- <input type="text" id="applyActionBean" value="org.jboss.seam.remoting.examples.model.PersonAction"/>
- </div>
- <div class="formRow">
- <label for="applyActionQualifiers">Qualifiers</label>
- <input type="text" id="applyActionQualifiers"/>
- </div>
- <div class="formRow">
- <label for="applyActionMethod">Method</label>
- <input type="text" id="applyActionMethod" value="savePerson"/>
- </div>
- <div class="formRow">
- <label for="applyActionParams">Params</label>
- <input type="text" id="applyActionParams"/>
- </div>
+ <div class="personDetail">
+ <div class="sectionHeader">Details</div>
+
+ <div class="formRow">
+ <label for="firstName">First name</label>
+ <input type="text" id="firstName"/>
</div>
- <div class="sectionCommand">
- <button onclick="javascript:apply()">Apply</button>
- </div>
+ <div class="formRow">
+ <label for="lastName">Last name</label>
+ <input type="text" id="lastName"/>
+ </div>
+
+ <div class="formRow">
+ <label for="dob">Date of birth</label>
+ <input type="text" id="dob"/>
+ </div>
+ <div id="addresses">
+
+ </div>
+
+ <div class="personAction">
+ <button id="applyChanges" onclick="apply()" disabled="true">Apply changes</button>
+ </div>
+
<br class="clear"/>
</div>
-
- <div class="section">
- <div class="sectionHeader">Model properties</div>
- <table cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td>Alias</td>
- <td>Bean</td>
- <td>Property</td>
- </tr>
- <tr>
- <td><input type="text" class="short" id="valueAlias1" value="person"/></td>
- <td><input type="text" class="long" id="valueBean1" value="org.jboss.seam.remoting.examples.model.PersonAction"/></td>
- <td><input type="text" class="short" id="valueProperty1" value="person"/></td>
- </tr>
- <tr>
- <td><input type="text" class="short" id="valueAlias2"/></td>
- <td><input type="text" class="long" id="valueBean2"/></td>
- <td><input type="text" class="short" id="valueProperty2"/></td>
- </tr>
- <tr>
- <td><input type="text" class="short" id="valueAlias3"/></td>
- <td><input type="text" class="long" id="valueBean3"/></td>
- <td><input type="text" class="short" id="valueProperty3"/></td>
- </tr>
- </table>
- <br class="clear"/>
- </div>
-
- <div id="treeContainer" style="position:absolute;left:10px;width:450px;height:400px;border:1px solid #999999;overflow:auto"></div>
-
- <script type="text/javascript">
- //<![CDATA[
- var t = new xw.controls.Tree("treeContainer");
- t.setRootVisible(true);
- // ]]>
- </script>
-
+
</body>
</html>
Modified: modules/remoting/trunk/examples/model/src/main/webapp/style.css
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/style.css 2010-01-06 18:55:53 UTC (rev 11917)
+++ modules/remoting/trunk/examples/model/src/main/webapp/style.css 2010-01-07 02:37:42 UTC (rev 11918)
@@ -5,30 +5,29 @@
color: #663009;
}
+div.listContainer {
+ float: left;
+ width: 200px;
+}
+
+#personList {
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
.sectionHeader {
font-size: 12px;
font-weight: bold;
}
-div.section {
+div.personDetail {
+ margin-left: 4px;
background-color: #eeeeee;
- margin: 6px;
- padding: 4px;
-}
-
-div.sectionForm {
float: left;
- width: 390px;
padding: 4px;
- border-right: 1px solid #cccccc;
+ width: 400px;
}
-div.sectionCommand {
- float: left;
- width: 120px;
- padding: 4px;
-}
-
div.formRow {
padding: 2px 4px 2px 2px;
clear: both;
@@ -41,7 +40,7 @@
}
div.formRow input[type='text'] {
- width: 300px;
+ width: 200px;
}
.clear {
@@ -49,11 +48,22 @@
font-size: 0px;
}
+div.addressContainer {
+ margin-top: 4px;
+ margin-bottom: 4px;
+ border-top: 1px solid #cccccc;
+ padding: 4px;
+}
-.short {
- width: 80px;
+input.streetNo {
+ width: 60px;
+ margin-right: 8px;
}
-.long {
- width: 300px;
+input.postCode {
+ width: 60px;
+}
+
+.personAction {
+ float: right;
}
\ No newline at end of file
14 years, 11 months
Seam SVN: r11917 - modules/drools/trunk/src/main/java/org/jboss/seam/drools.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-01-06 13:55:53 -0500 (Wed, 06 Jan 2010)
New Revision: 11917
Added:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeSessionManager.java
Modified:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java
Log:
Drools 5 integration.
Modified: modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java 2010-01-06 18:29:52 UTC (rev 11916)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java 2010-01-06 18:55:53 UTC (rev 11917)
@@ -139,9 +139,8 @@
addEventListener(kbase, eventListener);
}
}
- }
+ }
-
private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
try {
@SuppressWarnings("unchecked")
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeSessionManager.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeSessionManager.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeSessionManager.java 2010-01-06 18:55:53 UTC (rev 11917)
@@ -0,0 +1,39 @@
+package org.jboss.seam.drools;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.drools.KnowledgeBase;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Manager component for a Drools Knowledge Sessions.
+ *
+ * @author Tihomir Surdilovic
+ */
+@Dependent
+public class KnowledgeSessionManager
+{
+ private static final Logger log = LoggerFactory.getLogger(KnowledgeSessionManager.class);
+
+ @Inject
+ BeanManager manager;
+
+ @Inject
+ KnowledgeBase kbase;
+
+ @Produces
+ public StatefulKnowledgeSession getStatefulSession() {
+ return null; // for now
+ }
+
+ @Produces
+ public StatelessKnowledgeSession getStatelessSession() {
+ return null; // for now
+ }
+}
14 years, 11 months
Seam SVN: r11916 - modules/drools/trunk/src/main/java/org/jboss/seam/drools.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-01-06 13:29:52 -0500 (Wed, 06 Jan 2010)
New Revision: 11916
Modified:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
Log:
Drools 5 integration.
Modified: modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-01-06 18:27:58 UTC (rev 11915)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-01-06 18:29:52 UTC (rev 11916)
@@ -7,7 +7,6 @@
* Interface for template data providers.
*
* @author Tihomir Surdilovic
- *
*/
public interface TemplateDataProvider
{
14 years, 11 months
Seam SVN: r11915 - modules/drools/trunk/src/main/java/org/jboss/seam/drools.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-01-06 13:27:58 -0500 (Wed, 06 Jan 2010)
New Revision: 11915
Added:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java
Removed:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java
Log:
Drools 5 integration.
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java 2010-01-06 15:56:52 UTC (rev 11914)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java 2010-01-06 18:27:58 UTC (rev 11915)
@@ -1,252 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.util.Properties;
-import java.util.regex.Pattern;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-import javax.security.auth.login.Configuration;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.drools.KnowledgeBaseConfiguration;
-import org.drools.builder.KnowledgeBuilderConfiguration;
-import org.drools.KnowledgeBaseFactory;
-import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
-import org.drools.builder.KnowledgeBuilderFactory;
-import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderError;
-import org.drools.builder.KnowledgeBuilderErrors;
-import org.drools.builder.ResourceType;
-import org.drools.io.ResourceFactory;
-import org.drools.template.ObjectDataCompiler;
-import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
-import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-
-/**
- * Manager component for a Drools KnowledgeBase.
- *
- * @author Tihomir Surdilovic
- */
-@ApplicationScoped
-public class KnowledgeBase implements Serializable
-{
- private static final long serialVersionUID = 8165645910387861887L;
-
- private static final Logger log = LoggerFactory.getLogger(org.jboss.seam.drools.KnowledgeBase.class);
-
- private static final Pattern DIVIDER = Pattern.compile(";");
- private static final int RESOURCE_PATH = 0;
- private static final int RESOURCE = 1;
- private static final int RESOURCE_TYPE = 2;
- private static final int RESOURCE_TEMPLATE_DATA = 3;
- private static final String RESOURCE_TYPE_URL = "url";
- private static final String RESOURCE_TYPE_FILE = "file";
- private static final String RESOURCE_TYPE_CLASSPATH = "classpath";
-
- private String knowledgeBuilderConfig;
- private String knowledgeBaseConfig;
- private String[] ruleResources;
- private String[] eventListeners;
- private org.drools.KnowledgeBase kbase;
-
- @Inject BeanManager manager;
-
- @Produces org.drools.KnowledgeBase getKnowledgeBase() {
- return kbase;
- }
-
- public void dispose(@Disposes org.drools.KnowledgeBase kbase) {
- kbase = null;
- }
-
-
- // @Inject
- public void create() throws Exception
- {
- KnowledgeBuilderConfiguration kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
- // Only allow resource for .properties files
- if (knowledgeBuilderConfig != null && knowledgeBuilderConfig.endsWith(".properties"))
- {
- Properties kbuilderProp = new Properties();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBuilderConfig);
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBuilderConfig: " + knowledgeBuilderConfig);
- }
- kbuilderProp.load(in);
- in.close();
- kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
- log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfig);
- }
-
- KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderconfig);
-
- if (ruleResources != null)
- {
- for (String nextResource : ruleResources)
- {
- addResource(kbuilder, nextResource);
- }
- }
-
- KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
- if (kbuildererrors.size() > 0)
- {
- for (KnowledgeBuilderError kbuildererror : kbuildererrors)
- {
- log.error(kbuildererror.getMessage());
- }
- manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
- }
-
- KnowledgeBaseConfiguration kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
-
- // Only allow resource for .properties files
- if (knowledgeBaseConfig != null && knowledgeBaseConfig.endsWith(".properties"))
- {
- Properties kbaseProp = new Properties();
- InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBaseConfig);
- if (in == null)
- {
- throw new IllegalStateException("Could not locate knowledgeBaseConfig: " + knowledgeBaseConfig);
- }
- kbaseProp.load(in);
- in.close();
- kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
- log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfig);
- }
-
- kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseconfig);
- kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
-
- if(eventListeners != null) {
- for(String eventListener : eventListeners) {
- addEventListener(kbase, eventListener);
- }
- }
- }
-
- protected void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
- try {
- Class eventListenerClass = Class.forName(eventListener);
- Object eventListenerObject = eventListenerClass.newInstance();
-
- if(eventListenerObject instanceof KnowledgeBaseEventListener) {
- kbase.addEventListener((KnowledgeBaseEventListener) eventListenerObject);
- } else {
- log.debug("Event Listener " + eventListener + " is not of type KnowledgeBaseEventListener");
- }
- } catch(Exception e) {
- log.error("Error adding event listener " + e.getMessage());
- }
- }
-
- protected void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
- {
- String[] resourceParts = DIVIDER.split(resource.trim());
-
- if (resourceParts.length < 3)
- {
- log.error("Invalid resource definition: " + resource);
- }
- else
- {
- ResourceType resourceType = ResourceType.getResourceType(resourceParts[RESOURCE_TYPE]);
-
- if (resourceParts.length == 4)
- {
- @SuppressWarnings("unchecked")
- Bean<TemplateDataProvider> templateDataProviderBean = (Bean<TemplateDataProvider>) manager.getBeans(resourceParts[RESOURCE_TEMPLATE_DATA]).iterator().next();
-
- TemplateDataProvider templateDataProvider = (TemplateDataProvider) manager.getReference(templateDataProviderBean, Configuration.class, manager.createCreationalContext(templateDataProviderBean));
-
- InputStream templateStream = this.getClass().getClassLoader().getResourceAsStream(resourceParts[RESOURCE]);
- if (templateStream == null)
- {
- throw new IllegalStateException("Could not locate rule resource: " + resourceParts[RESOURCE]);
- }
-
- ObjectDataCompiler converter = new ObjectDataCompiler();
- String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
- templateStream.close();
- log.debug("Generated following DRL from template: " + drl);
- Reader rdr = new StringReader(drl);
-
- kbuilder.add(ResourceFactory.newReaderResource(rdr), resourceType);
- }
- else
- {
- if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_URL))
- {
- kbuilder.add(ResourceFactory.newUrlResource(resourceParts[RESOURCE]), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
- }
- else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_FILE))
- {
- kbuilder.add(ResourceFactory.newFileResource(resourceParts[RESOURCE]), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
- }
- else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_CLASSPATH))
- {
- kbuilder.add(ResourceFactory.newClassPathResource(resourceParts[RESOURCE]), resourceType);
- manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
- }
- else
- {
- log.error("Invalid resource path: " + resourceParts[RESOURCE_PATH]);
- }
- }
- }
- }
-
- public String getKnowledgeBuilderConfig()
- {
- return knowledgeBuilderConfig;
- }
-
- public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig)
- {
- this.knowledgeBuilderConfig = knowledgeBuilderConfig;
- }
-
- public String getKnowledgeBaseConfig()
- {
- return knowledgeBaseConfig;
- }
-
- public void setKnowledgeBaseConfig(String knowledgeBaseConfig)
- {
- this.knowledgeBaseConfig = knowledgeBaseConfig;
- }
-
- public String[] getRuleResources()
- {
- return ruleResources;
- }
-
- public void setRuleResources(String[] ruleResources)
- {
- this.ruleResources = ruleResources;
- }
-
- public String[] getEventListeners()
- {
- return eventListeners;
- }
-
- public void setEventListeners(String[] eventListeners)
- {
- this.eventListeners = eventListeners;
- }
-
-}
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBaseManager.java 2010-01-06 18:27:58 UTC (rev 11915)
@@ -0,0 +1,264 @@
+package org.jboss.seam.drools;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.security.auth.login.Configuration;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.builder.KnowledgeBuilderError;
+import org.drools.builder.KnowledgeBuilderErrors;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
+import org.drools.io.ResourceFactory;
+import org.drools.template.ObjectDataCompiler;
+import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
+import org.jboss.seam.drools.events.RuleResourceAddedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Manager component for a Drools KnowledgeBase.
+ *
+ * @author Tihomir Surdilovic
+ */
+@Dependent
+public class KnowledgeBaseManager
+{
+ private static final Logger log = LoggerFactory.getLogger(KnowledgeBaseManager.class);
+
+ private static final Pattern DIVIDER = Pattern.compile(";");
+ private static final int RESOURCE_PATH = 0;
+ private static final int RESOURCE = 1;
+ private static final int RESOURCE_TYPE = 2;
+ private static final int RESOURCE_TEMPLATE_DATA = 3;
+ private static final String RESOURCE_TYPE_URL = "url";
+ private static final String RESOURCE_TYPE_FILE = "file";
+ private static final String RESOURCE_TYPE_CLASSPATH = "classpath";
+
+ private String knowledgeBuilderConfig;
+ private String knowledgeBaseConfig;
+ private String[] ruleResources;
+ private String[] eventListeners;
+ private KnowledgeBase kbase;
+
+ @Inject
+ BeanManager manager;
+
+ @Produces
+ @ApplicationScoped
+ public KnowledgeBase getKBase()
+ {
+ return kbase;
+ }
+
+ public void disposeKBase(@Disposes KnowledgeBase kbase)
+ {
+ kbase = null;
+ }
+
+ @PostConstruct
+ private void createKBase() throws Exception
+ {
+ KnowledgeBuilderConfiguration kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ // Only allow resource for .properties files
+ if (knowledgeBuilderConfig != null && knowledgeBuilderConfig.endsWith(".properties"))
+ {
+ Properties kbuilderProp = new Properties();
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBuilderConfig);
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate knowledgeBuilderConfig: " + knowledgeBuilderConfig);
+ }
+ kbuilderProp.load(in);
+ in.close();
+ kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
+ log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfig);
+ }
+
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderconfig);
+
+ if (ruleResources != null)
+ {
+ for (String nextResource : ruleResources)
+ {
+ addResource(kbuilder, nextResource);
+ }
+ }
+
+ KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
+ if (kbuildererrors.size() > 0)
+ {
+ for (KnowledgeBuilderError kbuildererror : kbuildererrors)
+ {
+ log.error(kbuildererror.getMessage());
+ }
+ manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
+ }
+
+ KnowledgeBaseConfiguration kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+
+ // Only allow resource for .properties files
+ if (knowledgeBaseConfig != null && knowledgeBaseConfig.endsWith(".properties"))
+ {
+ Properties kbaseProp = new Properties();
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBaseConfig);
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate knowledgeBaseConfig: " + knowledgeBaseConfig);
+ }
+ kbaseProp.load(in);
+ in.close();
+ kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
+ log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfig);
+ }
+
+ kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseconfig);
+ kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+
+ if (eventListeners != null)
+ {
+ for (String eventListener : eventListeners)
+ {
+ addEventListener(kbase, eventListener);
+ }
+ }
+ }
+
+
+ private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
+ try {
+ @SuppressWarnings("unchecked")
+ Class eventListenerClass = Class.forName(eventListener);
+ Object eventListenerObject = eventListenerClass.newInstance();
+
+ if(eventListenerObject instanceof KnowledgeBaseEventListener) {
+ kbase.addEventListener((KnowledgeBaseEventListener) eventListenerObject);
+ } else {
+ log.debug("Event Listener " + eventListener + " is not of type KnowledgeBaseEventListener");
+ }
+ } catch(Exception e) {
+ log.error("Error adding event listener " + e.getMessage());
+ }
+ }
+
+ protected void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
+ {
+ String[] resourceParts = DIVIDER.split(resource.trim());
+
+ if (resourceParts.length < 3)
+ {
+ log.error("Invalid resource definition: " + resource);
+ }
+ else
+ {
+ ResourceType resourceType = ResourceType.getResourceType(resourceParts[RESOURCE_TYPE]);
+
+ if (resourceParts.length == 4)
+ {
+ @SuppressWarnings("unchecked")
+ Bean<TemplateDataProvider> templateDataProviderBean = (Bean<TemplateDataProvider>) manager.getBeans(resourceParts[RESOURCE_TEMPLATE_DATA]).iterator().next();
+
+ TemplateDataProvider templateDataProvider = (TemplateDataProvider) manager.getReference(templateDataProviderBean, Configuration.class, manager.createCreationalContext(templateDataProviderBean));
+
+ InputStream templateStream = this.getClass().getClassLoader().getResourceAsStream(resourceParts[RESOURCE]);
+ if (templateStream == null)
+ {
+ throw new IllegalStateException("Could not locate rule resource: " + resourceParts[RESOURCE]);
+ }
+
+ ObjectDataCompiler converter = new ObjectDataCompiler();
+ String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
+ templateStream.close();
+ log.debug("Generated following DRL from template: " + drl);
+ Reader rdr = new StringReader(drl);
+
+ kbuilder.add(ResourceFactory.newReaderResource(rdr), resourceType);
+ }
+ else
+ {
+ if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_URL))
+ {
+ kbuilder.add(ResourceFactory.newUrlResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_FILE))
+ {
+ kbuilder.add(ResourceFactory.newFileResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_CLASSPATH))
+ {
+ kbuilder.add(ResourceFactory.newClassPathResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else
+ {
+ log.error("Invalid resource path: " + resourceParts[RESOURCE_PATH]);
+ }
+ }
+ }
+ }
+
+ public String getKnowledgeBuilderConfig()
+ {
+ return knowledgeBuilderConfig;
+ }
+
+ @Inject
+ public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig)
+ {
+ this.knowledgeBuilderConfig = knowledgeBuilderConfig;
+ }
+
+ public String getKnowledgeBaseConfig()
+ {
+ return knowledgeBaseConfig;
+ }
+
+ @Inject
+ public void setKnowledgeBaseConfig(String knowledgeBaseConfig)
+ {
+ this.knowledgeBaseConfig = knowledgeBaseConfig;
+ }
+
+ public String[] getRuleResources()
+ {
+ return ruleResources;
+ }
+
+ @Inject
+ public void setRuleResources(String[] ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+ public String[] getEventListeners()
+ {
+ return eventListeners;
+ }
+
+ @Inject
+ public void setEventListeners(String[] eventListeners)
+ {
+ this.eventListeners = eventListeners;
+ }
+
+
+}
14 years, 11 months
Seam SVN: r11914 - branches/community/Seam_2_2/src/main/org/jboss/seam/bpm.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-01-06 10:56:52 -0500 (Wed, 06 Jan 2010)
New Revision: 11914
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/bpm/JbpmELResolver.java
Log:
JBSEAM-3703
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/bpm/JbpmELResolver.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/bpm/JbpmELResolver.java 2010-01-06 10:01:33 UTC (rev 11913)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/bpm/JbpmELResolver.java 2010-01-06 15:56:52 UTC (rev 11914)
@@ -27,8 +27,9 @@
public Object getValue(ELContext context, Object base, Object property)
{
if ( base==null && property!=null )
- {
- return resolver.resolveVariable( (String) base );
+ {
+ context.setPropertyResolved(true);
+ return resolver.resolveVariable( (String) property );
}
else
{
14 years, 11 months
Seam SVN: r11913 - modules/remoting/trunk/examples/model/src/main/webapp.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-01-06 05:01:33 -0500 (Wed, 06 Jan 2010)
New Revision: 11913
Removed:
modules/remoting/trunk/examples/model/src/main/webapp/tree.css
modules/remoting/trunk/examples/model/src/main/webapp/tree.js
modules/remoting/trunk/examples/model/src/main/webapp/tree_images/
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
modules/remoting/trunk/examples/model/src/main/webapp/style.css
Log:
remove tree stuff, let's do this differently...
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-05 17:47:57 UTC (rev 11912)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2010-01-06 10:01:33 UTC (rev 11913)
@@ -13,7 +13,6 @@
<h1>Seam Remoting - Model Example</h1>
<script type="text/javascript" src="seam/resource/remoting/resource/remote.js?compress=true"></script>
- <script type="text/javascript" src="tree.js"></script>
<script type="text/javascript">
//<![CDATA[
@@ -52,16 +51,55 @@
}
model = new Seam.Model();
- var callback = function(model) { alert("model fetched"); };
-
- model.addBeanProperty("person", "org.jboss.seam.remoting.examples.model.PersonAction", "person");
+ var alias = getElementValue("valueAlias1");
+ var bean = getElementValue("valueBean1");
+ var property = getElementValue("valueProperty1");
+ if (alias && bean && property) model.addBeanProperty(alias, bean, property);
+
+ // TODO make this less "hard coded"
+ alias = getElementValue("valueAlias2");
+ bean = getElementValue("valueBean2");
+ property = getElementValue("valueProperty2");
+ if (alias && bean && property) model.addBeanProperty(alias, bean, property);
+
+ alias = getElementValue("valueAlias3");
+ bean = getElementValue("valueBean3");
+ property = getElementValue("valueProperty3");
+ if (alias && bean && property) model.addBeanProperty(alias, bean, property);
+
if (action)
- model.fetch(action, callback);
+ model.fetch(action, fetchCallback);
else
- model.fetch(callback);
+ model.fetch(fetchCallback);
}
+
+ function fetchCallback(model) {
+
+ for (var i = 0; i < model.values.length; i++) {
+
+ }
+ }
+ function renderValueNode(parentNode, value, alias) {
+ var beanType = Seam.getBeanType(value);
+ var meta = Seam.getBeanMetadata(value);
+
+ var valueNode = new xw.controls.TreeNode((alias ? alias + ":" : "") + beanType.__name, false, value);
+ parentNode.add(valueNode);
+
+ for (var j = 0; j < meta.length; j++) {
+ var fieldName = meta[j].field;
+ var fieldType = meta[j].type;
+ var leaf = fieldType != "bag" && fieldType != "map" && fieldType != "bean";
+ var node = new xw.controls.TreeNode(fieldName + ":" + value[fieldName], leaf);
+ if (!leaf) node.canExpand = true;
+ valueNode.add(node);
+
+ if (!leaf && value[fieldName]) renderValueNode(valueNode, value[fieldName]);
+ }
+ }
+
// Apply changes to the model
function apply() {
var applyActionBean = getElementValue("applyActionBean");
@@ -92,27 +130,14 @@
model.applyUpdates(callback);
}
+ /*
function expandModel() {
var callback = function(model) { alert("Got addresses: " + model.getValue("person").getAddresses().length); };
model.expand(model.getValue("person"), "addresses", callback);
}
+ */
- function modifyPerson() {
- model.getValue("person").setFirstName("bob");
- }
-
- var tm = new xw.controls.TreeModel(new xw.controls.TreeNode("Root"));
- var abc = new xw.controls.TreeNode("ABC");
- tm.getRoot().add(abc);
- abc.add(new xw.controls.TreeNode("123", true));
- abc.add(new xw.controls.TreeNode("456", true));
- var def = new xw.controls.TreeNode("DEF");
- tm.getRoot().add(def);
- def.add(new xw.controls.TreeNode("xxx", true));
- def.add(new xw.controls.TreeNode("yyy", true));
- def.add(new xw.controls.TreeNode("zzz", true));
-
// ]]>
</script>
@@ -166,7 +191,7 @@
</div>
<div class="sectionCommand">
- <button onclick="javascript:fetch()">Apply</button>
+ <button onclick="javascript:apply()">Apply</button>
</div>
<br class="clear"/>
@@ -174,25 +199,37 @@
<div class="section">
<div class="sectionHeader">Model properties</div>
-
-
-
+ <table cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td>Alias</td>
+ <td>Bean</td>
+ <td>Property</td>
+ </tr>
+ <tr>
+ <td><input type="text" class="short" id="valueAlias1" value="person"/></td>
+ <td><input type="text" class="long" id="valueBean1" value="org.jboss.seam.remoting.examples.model.PersonAction"/></td>
+ <td><input type="text" class="short" id="valueProperty1" value="person"/></td>
+ </tr>
+ <tr>
+ <td><input type="text" class="short" id="valueAlias2"/></td>
+ <td><input type="text" class="long" id="valueBean2"/></td>
+ <td><input type="text" class="short" id="valueProperty2"/></td>
+ </tr>
+ <tr>
+ <td><input type="text" class="short" id="valueAlias3"/></td>
+ <td><input type="text" class="long" id="valueBean3"/></td>
+ <td><input type="text" class="short" id="valueProperty3"/></td>
+ </tr>
+ </table>
<br class="clear"/>
</div>
-
-
+ <div id="treeContainer" style="position:absolute;left:10px;width:450px;height:400px;border:1px solid #999999;overflow:auto"></div>
-
- <button onclick="javascript:expandModel()">expand model</button>
- <button onclick="javascript:modifyPerson()">Modify person</button>
-
- <div id="tree" style="position:absolute;left:10px;width:300px;height:400px;border:1px solid #999999;overflow:auto"></div>
-
<script type="text/javascript">
//<![CDATA[
- var t = new xw.controls.Tree("tree", tm);
- t.paint();
+ var t = new xw.controls.Tree("treeContainer");
+ t.setRootVisible(true);
// ]]>
</script>
Modified: modules/remoting/trunk/examples/model/src/main/webapp/style.css
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/style.css 2010-01-05 17:47:57 UTC (rev 11912)
+++ modules/remoting/trunk/examples/model/src/main/webapp/style.css 2010-01-06 10:01:33 UTC (rev 11913)
@@ -38,7 +38,7 @@
float: left;
width: 70px;
padding: 2px 2px 2px 2px;
-}
+}
div.formRow input[type='text'] {
width: 300px;
@@ -47,4 +47,13 @@
.clear {
clear: both;
font-size: 0px;
+}
+
+
+.short {
+ width: 80px;
+}
+
+.long {
+ width: 300px;
}
\ No newline at end of file
Deleted: modules/remoting/trunk/examples/model/src/main/webapp/tree.css
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/tree.css 2010-01-05 17:47:57 UTC (rev 11912)
+++ modules/remoting/trunk/examples/model/src/main/webapp/tree.css 2010-01-06 10:01:33 UTC (rev 11913)
@@ -1,116 +0,0 @@
-div.treePlusStart {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/plus_middle.gif') no-repeat left top;
-}
-
-div.treePlusMiddle {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/plus_middle.gif') no-repeat left top;
-}
-
-div.treePlusEnd {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/plus_end.gif') no-repeat left top;
-}
-
-div.treePlusNone {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/plus_none.gif') no-repeat left top;
-}
-
-div.treeMinusStart {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/minus_start.gif') no-repeat left top;
-}
-
-div.treeMinusMiddle {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/minus_middle.gif') no-repeat left top;
-}
-
-div.treeMinusEnd {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/minus_end.gif') no-repeat left top;
-}
-
-div.treeMinusNone {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/minus_none.gif') no-repeat left top;
-}
-
-div.treeLeaf {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/leafnode.png') no-repeat left top;
-}
-
-div.treeFolderOpen {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/folder-open.png') no-repeat left top;
-}
-
-div.treeFolderClosed {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/folder-closed.png') no-repeat left top;
-}
-
-div.treeLineMiddle {
- width: 18px;
- height: 100%;
- position: static;
- border: 0px;
- background: url('tree_images/line_middle.gif') repeat-y left top;
-}
-
-div.treeLineBranch {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/line_branch.gif') no-repeat left top;
-}
-
-div.treeLineEnd {
- width: 18px;
- height: 18px;
- position: static;
- background: url('tree_images/line_end.gif') no-repeat left top;
-}
-
-span.selected {
- font-family: helvetica;
- font-size: x-small;
- padding-top: 0px;
- margin-top: 0px;
- color: #ffffff;
- background-color: #000077;
- text-align: left;
-}
-
-span.unselected {
- font-family: helvetica;
- font-size: x-small;
- padding-top: 0px;
- margin-top: 0px;
- text-align: left;
-}
Deleted: modules/remoting/trunk/examples/model/src/main/webapp/tree.js
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/tree.js 2010-01-05 17:47:57 UTC (rev 11912)
+++ modules/remoting/trunk/examples/model/src/main/webapp/tree.js 2010-01-06 10:01:33 UTC (rev 11913)
@@ -1,710 +0,0 @@
-/**
- * Tree control
- *
- * @author Shane Bryzak
- */
-
-//Package("xw.controls");
-xw = new Object();
-xw.controls = new Object();
-
-// TODO - fully qualified naming is way too verbose, make it shorter somehow
-
-xw.controls.TreeModel = function(rootNode)
-{
- this.rootNode = rootNode;
- this.rootNode.setModel(this);
- this.tree = null;
- var p = xw.controls.TreeModel.prototype;
-
- p.getChild = function(parent, index)
- {
- return parent.getChildAt(index);
- }
-
- p.getChildCount = function(parent)
- {
- return parent.getChildCount();
- }
-
- p.getIndexOfChild = function(parent, child)
- {
- return parent.getIndex(child);
- }
-
- p.getRoot = function()
- {
- return this.rootNode;
- }
-
- p.isLeaf = function(node)
- {
- return node.isLeaf();
- }
-
- p.setTree = function(tree)
- {
- this.tree = tree;
- }
-
- p.findNodeByObject = function(object)
- {
- return xw.controls.TreeModel.searchChildrenForObject(this.rootNode, object);
- }
-
- xw.controls.TreeModel.searchChildrenForObject = function(node, object)
- {
- for (var i = 0; i < node.getChildCount(); i++)
- {
- var childNode = node.getChildAt(i);
- if (childNode.getUserObject() == object)
- return childNode;
- else if (childNode.getChildCount() > 0)
- {
- grandChild = xw.controls.TreeModel.searchChildrenForObject(childNode, object);
- if (grandChild != null)
- return grandChild;
- }
- }
- return null;
- }
-}
-
-xw.controls.TreeNode = function(value, leaf, userObject)
-{
- this.value = value;
- this.leaf = leaf ? leaf : false;
- this.userObject = userObject ? userObject : null;
- this.children = new Array();
- this.parent = null;
- this.expanded = false;
- this.model = null;
-
- xw.controls.TreeNode.prototype.getUserObject = function()
- {
- return this.userObject;
- }
-
- xw.controls.TreeNode.prototype.setUserObject = function(obj)
- {
- this.userObject = obj;
- }
-
- xw.controls.TreeNode.prototype.setModel = function(model)
- {
- this.model = model;
- }
-
- xw.controls.TreeNode.prototype.add = function(node)
- {
- node.parent = this;
- this.children.push(node);
- node.setModel(this.model);
- }
-
- xw.controls.TreeNode.prototype.children = function()
- {
- return this.children;
- }
-
- xw.controls.TreeNode.prototype.getChildAt = function(index)
- {
- return this.children[index];
- }
-
- xw.controls.TreeNode.prototype.getChildCount = function()
- {
- return this.children.length;
- }
-
- xw.controls.TreeNode.prototype.getIndex = function(node)
- {
- for (var i = 0; i < this.children.length; i++)
- {
- if (this.children[i] == node)
- return i;
- }
- return -1;
- }
-
- xw.controls.TreeNode.prototype.getParent = function()
- {
- return this.parent;
- }
-
- xw.controls.TreeNode.prototype.isLeaf = function()
- {
- return this.leaf;
- }
-
- xw.controls.TreeNode.prototype.remove = function(node)
- {
- var found = false;
- for (var i = 0; i < this.children.length; i++)
- {
- if (this.children[i] == node)
- found = true;
- if (found && i < this.children.length - 1)
- this.children[i] = this.children[i + 1];
- }
- if (found)
- {
- this.children.length = this.children.length - 1;
- this.model.tree.renderer.removeNode(node);
- }
- }
-}
-
-xw.controls.Tree = function(container, model)
-{
- this.container = (typeof(container) == "object") ? container : document.getElementById(container);
- this.rootVisible = false;
- this.model = model;
- model.setTree(this);
- this.renderer = new xw.controls.DefaultCellRenderer();
- this.onSelect = null;
- this.onDragDrop = null;
- this.selectedNode = null;
-
- xw.controls.Tree.prototype.isRootVisible = function()
- {
- return this.rootVisible;
- }
-
- xw.controls.Tree.prototype.setRootVisible = function(visible)
- {
- this.rootVisible = visible;
- }
-
- xw.controls.Tree.prototype.paint = function()
- {
- this.renderer.render(this.container, this.model.getRoot(), true);
- }
-
- xw.controls.Tree.prototype.repaintNode = function(node)
- {
- this.renderer.render(null, node, true);
- }
-
- xw.controls.Tree.prototype.getModel = function()
- {
- return this.model;
- }
-
- xw.controls.Tree.prototype.selectNode = function(node)
- {
- if (this.selectedNode)
- this.renderer.renderSelected(this.selectedNode, false);
- this.selectedNode = node;
- this.renderer.renderSelected(node, true);
- if (this.onSelect)
- this.onSelect(node);
- }
-
- xw.controls.Tree.prototype.initiateDragDrop = function(sourceNode, targetNode)
- {
- if ((this.onDragDrop && this.onDragDrop(sourceNode, targetNode)) || !this.onDragDrop)
- this.moveNode(sourceNode, targetNode);
- }
-
- xw.controls.Tree.prototype.moveNode = function(sourceNode, targetNode)
- {
- var sourceParent = sourceNode.getParent();
- if (sourceParent != targetNode)
- {
- sourceParent.remove(sourceNode);
-
- targetNode.add(sourceNode);
-
- targetNode.childrenCell.appendChild(sourceNode.tableCtl);
- this.repaintNode(sourceParent);
-
- targetNode.expanded = true;
- this.repaintNode(targetNode);
- }
- }
-}
-
-xw.controls.Tree.mouseDownNode = null;
-xw.controls.Tree.draggedNode = null;
-xw.controls.Tree.mouseDownStartPos = null;
-xw.controls.Tree.dragThreshold = 5;
-xw.controls.Tree.dragDiv = null;
-xw.controls.Tree.targetNode = null;
-
-xw.controls.Tree.util = new Object();
-xw.controls.Tree.util.addEvent = function(ctl, event, func)
-{
- if (navigator.userAgent.indexOf("MSIE") != -1)
- ctl.attachEvent("on" + event, func);
- else
- ctl.addEventListener(event, func, true);
-}
-
-xw.controls.Tree.util.removeEvent = function(ctl, event, func)
-{
- if (navigator.userAgent.indexOf("MSIE") != -1)
- ctl.detachEvent("on" + event, func);
- else
- ctl.removeEventListener(event, func, true);
-}
-
-xw.controls.Tree.util.cancelEventBubble = function(event)
-{
- if (navigator.userAgent.indexOf("MSIE") != -1)
- {
- window.event.cancelBubble = true;
- window.event.returnValue = false;
- }
- else
- event.preventDefault();
-}
-
-xw.controls.Tree.util.setOpacity = function(ctl, percent)
-{
- if (navigator.userAgent.indexOf("MSIE") != -1)
- ctl.style.filter = "alpha(opacity=" + percent + ")";
- else
- ctl.style.MozOpacity = percent / 100;
-}
-
-xw.controls.Tree.util.fades = new Array();
-xw.controls.Tree.util.fading = false;
-
-xw.controls.Tree.util.startFade = function(fade)
-{
- fade.valid = true;
-
- if (fade.value == 0)
- fade.control.style.display = "";
-
- xw.controls.Tree.util.fades.push(fade);
-
- if (!xw.controls.Tree.util.fading)
- xw.controls.Tree.util.processFades();
-}
-
-xw.controls.Tree.util.fadeIn = function(ctl, step)
-{
- xw.controls.Tree.util.setOpacity(ctl, 0);
- xw.controls.Tree.util.startFade({control:ctl,value:0,step:step});
-}
-
-xw.controls.Tree.util.fadeOut = function(ctl, step, onComplete)
-{
- xw.controls.Tree.util.setOpacity(ctl, 100);
- xw.controls.Tree.util.startFade({control:ctl,value:100,step:-1 * step,onComplete:onComplete});
-}
-
-xw.controls.Tree.util.processFades = function()
-{
- xw.controls.Tree.util.fading = true;
-
- for (var i = 0; i < xw.controls.Tree.util.fades.length; i++)
- {
- var fade = xw.controls.Tree.util.fades[i];
- var done = false;
-
- if (fade.step < 0) // Fade out
- {
- xw.controls.Tree.util.setOpacity(fade.control, Math.max(fade.value, 0));
- if (fade.value < 0)
- done = true;
- }
- else if (fade.step > 0) // Fade in
- {
- xw.controls.Tree.util.setOpacity(fade.control, Math.min(fade.value, 100));
- if (fade.value > 100)
- done = true;
- }
-
- if (done)
- {
- xw.controls.Tree.util.fades.splice(i, 1);
- if (fade.onComplete)
- fade.onComplete();
- }
- fade.value += fade.step;
- }
-
- if (xw.controls.Tree.util.fades.length > 0)
- setTimeout("xw.controls.Tree.util.processFades()", 50);
- else
- xw.controls.Tree.util.fading = false;
-}
-
-xw.controls.Tree.util.getMousePos = function(event)
-{
- var x, y;
- if (navigator.userAgent.indexOf("MSIE") != -1)
- {
- x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
- y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
- }
- else
- {
- x = event.clientX + window.scrollX;
- y = event.clientY + window.scrollY;
- }
- return { x:x, y:y };
-};
-
-xw.controls.Tree.util.calcDistance = function(pos1, pos2)
-{
- var deltaX = Math.abs(pos1.x - pos2.x);
- var deltaY = Math.abs(pos1.y - pos2.y);
- return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
-}
-
-xw.controls.Tree.onMouseDown = function(event, node)
-{
- xw.controls.Tree.mouseDownStartPos = xw.controls.Tree.util.getMousePos(event);
- xw.controls.Tree.mouseDownNode = node;
- xw.controls.Tree.util.addEvent(document, "mousemove", xw.controls.Tree.onMouseMove);
- xw.controls.Tree.util.addEvent(document, "mouseup", xw.controls.Tree.onMouseUp);
-
- xw.controls.Tree.util.cancelEventBubble(event);
-}
-
-xw.controls.Tree.onMouseMove = function(event)
-{
- if (xw.controls.Tree.draggedNode == null)
- {
- var distance = xw.controls.Tree.util.calcDistance(xw.controls.Tree.util.getMousePos(event), xw.controls.Tree.mouseDownStartPos);
- if (distance > xw.controls.Tree.dragThreshold)
- {
- xw.controls.Tree.draggedNode = xw.controls.Tree.mouseDownNode;
- if (xw.controls.Tree.dragDiv == null)
- {
- xw.controls.Tree.targetNode = null;
- xw.controls.Tree.dragDiv = document.createElement("div");
- xw.controls.Tree.dragDiv.style.position = "absolute";
- xw.controls.Tree.util.setOpacity(xw.controls.Tree.dragDiv, 40);
- window.document.body.appendChild(xw.controls.Tree.dragDiv);
- }
-
- xw.controls.Tree.draggedNode.renderer.renderClone(xw.controls.Tree.dragDiv, xw.controls.Tree.draggedNode);
- xw.controls.Tree.dragDiv.style.display = "";
- var pos = xw.controls.Tree.util.getMousePos(event);
- xw.controls.Tree.dragDiv.style.left = (pos.x + 10) + "px";
- xw.controls.Tree.dragDiv.style.top = pos.y + "px";
- }
- }
- else
- {
- var pos = xw.controls.Tree.util.getMousePos(event);
- xw.controls.Tree.dragDiv.style.left = (pos.x + 10) + "px";
- xw.controls.Tree.dragDiv.style.top = pos.y + "px";
- }
-}
-
-xw.controls.Tree.onMouseUp = function(event)
-{
- xw.controls.Tree.util.removeEvent(document, "mousemove", xw.controls.Tree.onMouseMove);
- xw.controls.Tree.util.removeEvent(document, "mouseup", xw.controls.Tree.onMouseUp);
-
- xw.controls.Tree.mouseDownStartPos = null;
-
- if (xw.controls.Tree.dragDiv)
- xw.controls.Tree.dragDiv.style.display = "none";
-
- if (xw.controls.Tree.targetNode)
- {
- xw.controls.Tree.targetNode.renderer.renderSelected(xw.controls.Tree.targetNode, false);
- xw.controls.Tree.draggedNode.model.tree.initiateDragDrop(xw.controls.Tree.draggedNode, xw.controls.Tree.targetNode);
- }
- else if (xw.controls.Tree.mouseDownNode.model && xw.controls.Tree.mouseDownNode.model.tree && !xw.controls.Tree.draggedNode)
- xw.controls.Tree.mouseDownNode.model.tree.selectNode(xw.controls.Tree.mouseDownNode);
-
- xw.controls.Tree.targetNode = null;
- xw.controls.Tree.draggedNode = null;
-
- xw.controls.Tree.util.cancelEventBubble(event);
-}
-
-xw.controls.Tree.onMouseOver = function(event, node)
-{
- if (xw.controls.Tree.draggedNode && xw.controls.Tree.draggedNode != node && !node.isLeaf() && xw.controls.Tree.draggedNode.getParent() != node)
- {
- node.renderer.renderSelected(node, true);
- xw.controls.Tree.targetNode = node;
- }
-}
-
-xw.controls.Tree.onMouseOut = function(event, node)
-{
- if (xw.controls.Tree.draggedNode && xw.controls.Tree.draggedNode != node && !node.isLeaf())
- {
- node.renderer.renderSelected(node, false);
- if (xw.controls.Tree.targetNode == node)
- xw.controls.Tree.targetNode = null;
- }
-}
-
-xw.controls.DefaultCellRenderer = function()
-{
- this.plusStartClass = "treePlusStart";
- this.plusMiddleClass = "treePlusMiddle";
- this.plusEndClass = "treePlusEnd";
- this.plusNoneClass = "treePlusNone";
-
- this.minusStartClass = "treeMinusStart";
- this.minusMiddleClass = "treeMinusMiddle";
- this.minusEndClass = "treeMinusEnd";
- this.minusNoneClass = "treeMinusNone";
-
- this.lineMiddleClass = "treeLineMiddle";
- this.lineEndClass = "treeLineEnd";
- this.lineBranchClass = "treeLineBranch";
-
- this.leafClass = "treeLeaf";
- this.folderOpenClass = "treeFolderOpen";
- this.folderClosedClass = "treeFolderClosed";
-
- this.onRender = false;
-
- xw.controls.DefaultCellRenderer.prototype.removeNode = function(node)
- {
- node.parent.childrenCell.removeChild(node.tableCtl);
- }
-
- xw.controls.DefaultCellRenderer.prototype.render = function(container, node, renderChildren)
- {
- if (!node.tableCtl)
- {
- node.renderer = this;
-
- node.tableCtl = document.createElement("table");
- node.tableCtl.cellSpacing = 0;
- node.tableCtl.cellPadding = 0;
-
- node.headerRow = node.tableCtl.insertRow(-1);
-
- node.branchCell = node.headerRow.insertCell(-1);
- node.iconCell = node.headerRow.insertCell(-1);
- node.contentCell = node.headerRow.insertCell(-1);
-
- node.contentCell.style.textAlign = "left";
- node.contentCell.style.whiteSpace = "nowrap";
- node.contentCell.style.cursor = "pointer";
- node.contentCell.style.verticalAlign = "middle";
-
- node.branchDiv = document.createElement("div");
-
- var toggleFunction = function(event) { node.expanded = !node.expanded; node.renderer.toggle(node); };
-
- xw.controls.Tree.util.addEvent(node.branchDiv, "mousedown", toggleFunction);
-
- node.branchCell.appendChild(node.branchDiv);
-
- node.iconDiv = document.createElement("div");
- node.iconDiv.style.position = "static";
-
- node.iconCell.style.width = "1px";
- node.iconCell.appendChild(node.iconDiv);
-
- node.content = document.createElement("span");
- node.content.className = "unselected";
- node.contentText = document.createTextNode(node.value);
- node.content.appendChild(node.contentText);
-
- node.contentCell.appendChild(node.content);
-
- node.childrenRow = node.tableCtl.insertRow(-1);
- node.childBranchCell = node.childrenRow.insertCell(-1);
-
- node.childBranchDiv = document.createElement("div");
- node.childBranchCell.appendChild(node.childBranchDiv);
-
- node.childrenCell = node.childrenRow.insertCell(-1);
- node.childrenCell.colSpan = 2;
-
- var mouseDownFunction = function(event) { xw.controls.Tree.onMouseDown(event, node); };
- xw.controls.Tree.util.addEvent(node.iconDiv, "mousedown", mouseDownFunction);
- xw.controls.Tree.util.addEvent(node.contentCell, "mousedown", mouseDownFunction);
-
- var mouseOverFunction = function(event) { xw.controls.Tree.onMouseOver(event, node); };
- xw.controls.Tree.util.addEvent(node.iconDiv, "mouseover", mouseOverFunction);
- xw.controls.Tree.util.addEvent(node.contentCell, "mouseover", mouseOverFunction);
-
- var mouseOutFunction = function(event) { xw.controls.Tree.onMouseOut(event, node); };
- xw.controls.Tree.util.addEvent(node.iconDiv, "mouseout", mouseOutFunction);
- xw.controls.Tree.util.addEvent(node.contentCell, "mouseout", mouseOutFunction);
- }
-
- node.contentText.nodeValue = node.value;
-
- if (container)
- {
- var inContainer = false;
- for (var i = 0; i < container.childNodes.length; i++)
- {
- if (container.childNodes[i] == node.tableCtl)
- {
- inContainer = true;
- break;
- }
- }
-
- if (!inContainer)
- container.appendChild(node.tableCtl);
- }
-
- if (!node.isLeaf() && renderChildren)
- {
- for (var i = 0; i < node.getChildCount(); i++)
- this.render(node.childrenCell, node.getChildAt(i), true);
- }
-
- // Reset the child branch div height
- node.childBranchDiv.style.height = "100%";
-
- var expanded = node.expanded && (node.getChildCount() > 0);
-// node.childrenRow.style.display = expanded ? "" : "none";
-
- if (node.isLeaf())
- {
- if (node.getParent() == null)
- node.branchDiv.className = this.lineBranchClass;
- else if (node.getParent().getIndex(node) == node.getParent().getChildCount() - 1)
- node.branchDiv.className = this.lineEndClass;
- else
- node.branchDiv.className = this.lineBranchClass;
-
- node.iconDiv.className = this.leafClass;
- }
- else
- {
- if (node.getParent() == null)
- {
- if (node.getChildCount() > 0)
- node.branchDiv.className = expanded ? this.minusNoneClass : this.plusNoneClass;
- else
- node.branchDiv.className = "";
- }
- else if (node.getParent().getIndex(node) == node.getParent().getChildCount() - 1)
- {
- if (node.getChildCount() > 0)
- {
- node.branchDiv.className = expanded ? this.minusEndClass : this.plusEndClass;
- node.childBranchDiv.className = "";
- node.childBranchDiv.style.width = "100%";
- }
- else
- node.branchDiv.className = this.lineEndClass;
- }
- else
- {
- if (node.getChildCount() > 0)
- {
- node.childBranchDiv.className = this.lineMiddleClass;
- node.childBranchDiv.style.height = node.childBranchCell.offsetHeight + "px";
-
- node.branchDiv.className = expanded ? this.minusMiddleClass : this.plusMiddleClass;
- }
- else
- node.branchDiv.className = this.lineBranchClass;
- }
- node.iconDiv.className = expanded ? this.folderOpenClass : this.folderClosedClass;
- }
-
- if (node.getParent())
- node.renderer.render(null, node.getParent());
-
- if (this.onRender)
- this.onRender(node);
-
- node.childrenRow.style.display = expanded ? "" : "none";
- }
-
- xw.controls.DefaultCellRenderer.prototype.toggle = function(node)
- {
- if (node.expanded)
- {
- // Reset the child branch div height
- node.childrenRow.style.display = "";
- xw.controls.Tree.util.fadeIn(node.childrenCell, 25);
- this.decorateNode(node, true);
- }
- else
- {
- this.decorateNode(node, false);
- var onComplete = function() { node.childrenRow.style.display = "none"; node.renderer.decorateNode(node, true); };
- xw.controls.Tree.util.fadeOut(node.childrenCell, 34, onComplete);
- }
- }
-
- xw.controls.DefaultCellRenderer.prototype.decorateNode = function(node, recurseUp)
- {
- node.childBranchDiv.style.height = "0px";
-
- if (node.isLeaf())
- {
- if (node.getParent() == null)
- node.branchDiv.className = this.lineBranchClass;
- else if (node.getParent().getIndex(node) == node.getParent().getChildCount() - 1)
- node.branchDiv.className = this.lineEndClass;
- else
- node.branchDiv.className = this.lineBranchClass;
-
- node.iconDiv.className = this.leafClass;
- }
- else
- {
- if (node.getParent() == null)
- {
- if (node.getChildCount() > 0)
- node.branchDiv.className = node.expanded ? this.minusNoneClass : this.plusNoneClass;
- else
- node.branchDiv.className = "";
- }
- else if (node.getParent().getIndex(node) == node.getParent().getChildCount() - 1)
- {
- if (node.getChildCount() > 0)
- {
- node.branchDiv.className = node.expanded ? this.minusEndClass : this.plusEndClass;
- node.childBranchDiv.className = "";
- node.childBranchDiv.style.width = "100%";
- }
- else
- node.branchDiv.className = this.lineEndClass;
- }
- else
- {
- if (node.getChildCount() > 0)
- {
- node.childBranchDiv.className = this.lineMiddleClass;
- node.childBranchDiv.style.height = node.childBranchCell.offsetHeight + "px";
-
- node.branchDiv.className = node.expanded ? this.minusMiddleClass : this.plusMiddleClass;
- }
- else
- node.branchDiv.className = this.lineBranchClass;
- }
- node.iconDiv.className = node.expanded ? this.folderOpenClass : this.folderClosedClass;
- }
-
- if (node.getParent() && recurseUp)
- node.renderer.decorateNode(node.getParent(), true);
- }
-
- xw.controls.DefaultCellRenderer.prototype.renderSelected = function(node, selected)
- {
- node.content.className = selected ? "selected" : "unselected";
- }
-
- xw.controls.DefaultCellRenderer.prototype.renderClone = function(container, node)
- {
- var tbl = document.createElement("table");
- tbl.cellSpacing = 0;
- tbl.cellPadding = 0;
- var row = tbl.insertRow(-1);
- row.appendChild(node.iconCell.cloneNode(true));
- row.appendChild(node.contentCell.cloneNode(true));
-
- if (container.firstChild)
- container.replaceChild(tbl, container.firstChild);
- else
- container.appendChild(tbl);
- }
-}
14 years, 11 months
Seam SVN: r11912 - dist/trunk.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-01-05 12:47:57 -0500 (Tue, 05 Jan 2010)
New Revision: 11912
Modified:
dist/trunk/pom.xml
Log:
Added drools-templates dependency.
Modified: dist/trunk/pom.xml
===================================================================
--- dist/trunk/pom.xml 2010-01-05 17:45:59 UTC (rev 11911)
+++ dist/trunk/pom.xml 2010-01-05 17:47:57 UTC (rev 11912)
@@ -65,6 +65,12 @@
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-templates</artifactId>
+ <version>${drools.version}</version>
+ </dependency>
<dependency>
<groupId>dom4j</groupId>
14 years, 12 months
Seam SVN: r11911 - in modules/drools/trunk: src/main/java/org/jboss/seam/drools and 1 other directories.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-01-05 12:45:59 -0500 (Tue, 05 Jan 2010)
New Revision: 11911
Added:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/
modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java
Removed:
modules/drools/trunk/src/main/java/org/jboss/seam/drools/Decision.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsHandler.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleAgent.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleBase.java
modules/drools/trunk/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
Modified:
modules/drools/trunk/pom.xml
Log:
Drools 5 Integration.
Modified: modules/drools/trunk/pom.xml
===================================================================
--- modules/drools/trunk/pom.xml 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/pom.xml 2010-01-05 17:45:59 UTC (rev 11911)
@@ -13,7 +13,7 @@
<version>3.0.0-SNAPSHOT</version>
<name>Seam Drools</name>
- <!-- Snapshots repo to get parent -->
+ <!-- Snapshots repo to get parent -->
<repositories>
<repository>
<id>oss.sonatype.org/jboss-snapshots</id>
@@ -35,13 +35,7 @@
<dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
+ <dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<scope>provided</scope>
@@ -51,8 +45,19 @@
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-templates</artifactId>
+ </dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<scope>provided</scope>
@@ -63,6 +68,14 @@
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
+
+ <!-- non portable dependency -->
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/Decision.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/Decision.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/Decision.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,21 +0,0 @@
-package org.jboss.seam.drools;
-
-/**
- * API for setting the result of a decision from rules in
- * a Drools decision handler.
- *
- */
-public class Decision
-{
- private String outcome;
-
- public String getOutcome()
- {
- return outcome;
- }
-
- public void setOutcome(String outcome)
- {
- this.outcome = outcome;
- }
-}
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,30 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.util.List;
-
-//import org.jbpm.graph.def.ActionHandler;
-//import org.jbpm.graph.exe.ExecutionContext;
-
-/**
- * A jBPM ActionHandler that delegates to a Drools WorkingMemory
- * held in a Seam context variable.
- *
- * @author Jeff Delong
- * @author Gavin King
- *
- */
-public class DroolsActionHandler extends DroolsHandler //implements ActionHandler
-{
- private static final long serialVersionUID = 7752070876220597913L;
-
- public List<String> assertObjects;
- public String workingMemoryName;
-
- //public void execute(ExecutionContext executionContext) throws Exception
- //{
- // Disabled BPM support for now
-
- //getWorkingMemory(workingMemoryName, assertObjects, executionContext).fireAllRules();
- //}
-
-}
\ No newline at end of file
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,35 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.util.List;
-
-import org.drools.WorkingMemory;
-//import org.jbpm.graph.exe.ExecutionContext;
-//import org.jbpm.taskmgmt.def.AssignmentHandler;
-//import org.jbpm.taskmgmt.exe.Assignable;
-
-/**
- * A jBPM AssignmentHandler that delegates to a Drools WorkingMemory
- * held in a Seam context variable.
- *
- * @author Jeff Delong
- * @author Gavin King
- *
- */
-public class DroolsAssignmentHandler extends DroolsHandler //implements AssignmentHandler
-{
- private static final long serialVersionUID = -7114640047036854546L;
-
- public String workingMemoryName;
- public List<String> assertObjects;
-
- //public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception
- //{
- // Disabled BPM support for now
- /*
- WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
- workingMemory.setGlobal( "assignable", assignable );
- workingMemory.fireAllRules();
- */
- //}
-
-}
\ No newline at end of file
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,37 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.util.List;
-
-import org.drools.WorkingMemory;
-//import org.jbpm.graph.exe.ExecutionContext;
-//import org.jbpm.graph.node.DecisionHandler;
-
-/**
- * A jBPM DecisionHandler that delegates to a Drools WorkingMemory
- * held in a Seam context variable. The decision outcome is returned
- * by setting the outcome attribute of the global named "decision".
- *
- * @author Gavin King
- *
- */
-public class DroolsDecisionHandler extends DroolsHandler //implements DecisionHandler
-{
- private static final long serialVersionUID = -8900810376838166513L;
-
- public List<String> assertObjects;
- public String workingMemoryName;
-
- //public String decide(ExecutionContext executionContext) throws Exception
- //{
- // Disabled BPM support for now
- /*
- WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
- workingMemory.setGlobal( "decision", new Decision() );
- workingMemory.fireAllRules();
- return ( (Decision) workingMemory.getGlobal("decision") ).getOutcome();
- */
-
- // return null;
- //}
-
-}
\ No newline at end of file
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsHandler.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,62 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.util.List;
-
-import org.drools.FactHandle;
-import org.drools.WorkingMemory;
-//import org.jbpm.graph.exe.ExecutionContext;
-//import org.jbpm.jpdl.el.ELException;
-
-/**
- * Common functionality for jBPM handlers for Drools.
- *
- * @author Jeff Delong
- * @author Gavin King
- *
- */
-public class DroolsHandler
-{
- // Disabled BPM support for now
-
- /*
- protected WorkingMemory getWorkingMemory(String workingMemoryName, List<String> expressions, ExecutionContext executionContext)
- throws ELException
- {
- WorkingMemory workingMemory = (WorkingMemory) Component.getInstance(workingMemoryName, true);
-
- for (String objectName: expressions)
- {
- Object object = Expressions.instance().createValueExpression(objectName).getValue();
-
- // assert the object into the rules engine
- if (object instanceof Iterable)
- {
- for (Object element: (Iterable) object)
- {
- assertObject(workingMemory, element);
- }
- }
- else
- {
- assertObject(workingMemory, object);
- }
- }
-
- workingMemory.insert(Actor.instance());
-
- return workingMemory;
- }*/
-
- private void assertObject(WorkingMemory workingMemory, Object element)
- {
- FactHandle fact = workingMemory.getFactHandle(element);
- if (fact==null)
- {
- workingMemory.insert(element);
- }
- else
- {
- workingMemory.update(fact, element);
- }
- }
-}
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/KnowledgeBase.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -0,0 +1,252 @@
+package org.jboss.seam.drools;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.security.auth.login.Configuration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.event.knowledgebase.KnowledgeBaseEventListener;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderError;
+import org.drools.builder.KnowledgeBuilderErrors;
+import org.drools.builder.ResourceType;
+import org.drools.io.ResourceFactory;
+import org.drools.template.ObjectDataCompiler;
+import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
+import org.jboss.seam.drools.events.RuleResourceAddedEvent;
+
+/**
+ * Manager component for a Drools KnowledgeBase.
+ *
+ * @author Tihomir Surdilovic
+ */
+@ApplicationScoped
+public class KnowledgeBase implements Serializable
+{
+ private static final long serialVersionUID = 8165645910387861887L;
+
+ private static final Logger log = LoggerFactory.getLogger(org.jboss.seam.drools.KnowledgeBase.class);
+
+ private static final Pattern DIVIDER = Pattern.compile(";");
+ private static final int RESOURCE_PATH = 0;
+ private static final int RESOURCE = 1;
+ private static final int RESOURCE_TYPE = 2;
+ private static final int RESOURCE_TEMPLATE_DATA = 3;
+ private static final String RESOURCE_TYPE_URL = "url";
+ private static final String RESOURCE_TYPE_FILE = "file";
+ private static final String RESOURCE_TYPE_CLASSPATH = "classpath";
+
+ private String knowledgeBuilderConfig;
+ private String knowledgeBaseConfig;
+ private String[] ruleResources;
+ private String[] eventListeners;
+ private org.drools.KnowledgeBase kbase;
+
+ @Inject BeanManager manager;
+
+ @Produces org.drools.KnowledgeBase getKnowledgeBase() {
+ return kbase;
+ }
+
+ public void dispose(@Disposes org.drools.KnowledgeBase kbase) {
+ kbase = null;
+ }
+
+
+ // @Inject
+ public void create() throws Exception
+ {
+ KnowledgeBuilderConfiguration kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ // Only allow resource for .properties files
+ if (knowledgeBuilderConfig != null && knowledgeBuilderConfig.endsWith(".properties"))
+ {
+ Properties kbuilderProp = new Properties();
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBuilderConfig);
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate knowledgeBuilderConfig: " + knowledgeBuilderConfig);
+ }
+ kbuilderProp.load(in);
+ in.close();
+ kbuilderconfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(kbuilderProp, null);
+ log.debug("KnowledgeBuilderConfiguration loaded: " + knowledgeBuilderConfig);
+ }
+
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderconfig);
+
+ if (ruleResources != null)
+ {
+ for (String nextResource : ruleResources)
+ {
+ addResource(kbuilder, nextResource);
+ }
+ }
+
+ KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
+ if (kbuildererrors.size() > 0)
+ {
+ for (KnowledgeBuilderError kbuildererror : kbuildererrors)
+ {
+ log.error(kbuildererror.getMessage());
+ }
+ manager.fireEvent(new KnowledgeBuilderErrorsEvent(kbuildererrors));
+ }
+
+ KnowledgeBaseConfiguration kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+
+ // Only allow resource for .properties files
+ if (knowledgeBaseConfig != null && knowledgeBaseConfig.endsWith(".properties"))
+ {
+ Properties kbaseProp = new Properties();
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(knowledgeBaseConfig);
+ if (in == null)
+ {
+ throw new IllegalStateException("Could not locate knowledgeBaseConfig: " + knowledgeBaseConfig);
+ }
+ kbaseProp.load(in);
+ in.close();
+ kbaseconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(kbaseProp, null);
+ log.debug("KnowledgeBaseConfiguration loaded: " + knowledgeBaseConfig);
+ }
+
+ kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseconfig);
+ kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
+
+ if(eventListeners != null) {
+ for(String eventListener : eventListeners) {
+ addEventListener(kbase, eventListener);
+ }
+ }
+ }
+
+ protected void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
+ try {
+ Class eventListenerClass = Class.forName(eventListener);
+ Object eventListenerObject = eventListenerClass.newInstance();
+
+ if(eventListenerObject instanceof KnowledgeBaseEventListener) {
+ kbase.addEventListener((KnowledgeBaseEventListener) eventListenerObject);
+ } else {
+ log.debug("Event Listener " + eventListener + " is not of type KnowledgeBaseEventListener");
+ }
+ } catch(Exception e) {
+ log.error("Error adding event listener " + e.getMessage());
+ }
+ }
+
+ protected void addResource(KnowledgeBuilder kbuilder, String resource) throws Exception
+ {
+ String[] resourceParts = DIVIDER.split(resource.trim());
+
+ if (resourceParts.length < 3)
+ {
+ log.error("Invalid resource definition: " + resource);
+ }
+ else
+ {
+ ResourceType resourceType = ResourceType.getResourceType(resourceParts[RESOURCE_TYPE]);
+
+ if (resourceParts.length == 4)
+ {
+ @SuppressWarnings("unchecked")
+ Bean<TemplateDataProvider> templateDataProviderBean = (Bean<TemplateDataProvider>) manager.getBeans(resourceParts[RESOURCE_TEMPLATE_DATA]).iterator().next();
+
+ TemplateDataProvider templateDataProvider = (TemplateDataProvider) manager.getReference(templateDataProviderBean, Configuration.class, manager.createCreationalContext(templateDataProviderBean));
+
+ InputStream templateStream = this.getClass().getClassLoader().getResourceAsStream(resourceParts[RESOURCE]);
+ if (templateStream == null)
+ {
+ throw new IllegalStateException("Could not locate rule resource: " + resourceParts[RESOURCE]);
+ }
+
+ ObjectDataCompiler converter = new ObjectDataCompiler();
+ String drl = converter.compile(templateDataProvider.getTemplateData(), templateStream);
+ templateStream.close();
+ log.debug("Generated following DRL from template: " + drl);
+ Reader rdr = new StringReader(drl);
+
+ kbuilder.add(ResourceFactory.newReaderResource(rdr), resourceType);
+ }
+ else
+ {
+ if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_URL))
+ {
+ kbuilder.add(ResourceFactory.newUrlResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_FILE))
+ {
+ kbuilder.add(ResourceFactory.newFileResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else if (resourceParts[RESOURCE_PATH].equals(RESOURCE_TYPE_CLASSPATH))
+ {
+ kbuilder.add(ResourceFactory.newClassPathResource(resourceParts[RESOURCE]), resourceType);
+ manager.fireEvent(new RuleResourceAddedEvent(resourceParts[RESOURCE]));
+ }
+ else
+ {
+ log.error("Invalid resource path: " + resourceParts[RESOURCE_PATH]);
+ }
+ }
+ }
+ }
+
+ public String getKnowledgeBuilderConfig()
+ {
+ return knowledgeBuilderConfig;
+ }
+
+ public void setKnowledgeBuilderConfig(String knowledgeBuilderConfig)
+ {
+ this.knowledgeBuilderConfig = knowledgeBuilderConfig;
+ }
+
+ public String getKnowledgeBaseConfig()
+ {
+ return knowledgeBaseConfig;
+ }
+
+ public void setKnowledgeBaseConfig(String knowledgeBaseConfig)
+ {
+ this.knowledgeBaseConfig = knowledgeBaseConfig;
+ }
+
+ public String[] getRuleResources()
+ {
+ return ruleResources;
+ }
+
+ public void setRuleResources(String[] ruleResources)
+ {
+ this.ruleResources = ruleResources;
+ }
+
+ public String[] getEventListeners()
+ {
+ return eventListeners;
+ }
+
+ public void setEventListeners(String[] eventListeners)
+ {
+ this.eventListeners = eventListeners;
+ }
+
+}
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,126 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.ConversationScoped;
-import javax.inject.Inject;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.drools.RuleBase;
-import org.drools.StatefulSession;
-import org.drools.rule.Rule;
-import org.drools.spi.GlobalResolver;
-import org.jboss.seam.el.Expressions.ValueExpression;
-
-/**
- * A conversation-scoped Drools WorkingMemory for a named RuleBase
- *
- * @author Gavin King
- *
- */
-@ConversationScoped
-//TODO implement mutable
-public class ManagedWorkingMemory implements /*Mutable, */Serializable
-{
- private static final long serialVersionUID = -1746942080571374743L;
-
- private String ruleBaseName;
- private StatefulSession statefulSession;
- private ValueExpression<RuleBase> ruleBase;
-
- @Inject BeanManager manager;
-
- public boolean clearDirty()
- {
- return true;
- }
-
- /**
- * The name of a Seam context variable holding an
- * instance of org.drools.RuleBase
- *
- * @return a context variable name
- * @deprecated
- */
- public String getRuleBaseName()
- {
- return ruleBaseName;
- }
-
- /**
- * The name of a Seam context variable holding an
- * instance of org.drools.RuleBase
- *
- * @param ruleBaseName a context variable name
- * @deprecated
- */
- public void setRuleBaseName(String ruleBaseName)
- {
- this.ruleBaseName = ruleBaseName;
- }
-
- @Produces
- public StatefulSession getStatefulSession()
- {
- if (statefulSession==null)
- {
- statefulSession = getRuleBaseFromValueBinding().newStatefulSession();
- statefulSession.setGlobalResolver( createGlobalResolver( statefulSession.getGlobalResolver() ) );
- }
- return statefulSession;
- }
-
- protected RuleBase getRuleBaseFromValueBinding()
- {
- RuleBase ruleBase = null;
- if (this.ruleBase!=null)
- {
- ruleBase = this.ruleBase.getValue();
- }
- else if (ruleBaseName!=null)
- {
- Set<Bean<?>> beans = manager.getBeans(ruleBaseName);
- if (beans.size() == 1) {
- //deprecated stuff
- Bean<?> bean = beans.iterator().next();
- ruleBase = (RuleBase) manager.getReference(bean, RuleBase.class, manager.createCreationalContext(bean));
- }
- }
- else
- {
- throw new IllegalStateException("No RuleBase");
- }
-
- if (ruleBase==null)
- {
- throw new IllegalStateException("RuleBase not found: " + ruleBaseName);
- }
- return ruleBase;
- }
-
- protected GlobalResolver createGlobalResolver(GlobalResolver delegate)
- {
- return new SeamGlobalResolver(delegate);
- }
-
- @PreDestroy
- public void destroy()
- {
- statefulSession.dispose();
- }
-
- public ValueExpression<RuleBase> getRuleBase()
- {
- return ruleBase;
- }
-
- public void setRuleBase(ValueExpression<RuleBase> ruleBase)
- {
- this.ruleBase = ruleBase;
- }
-
-}
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleAgent.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleAgent.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleAgent.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,161 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.enterprise.inject.Produces;
-
-import org.jboss.seam.resources.ResourceLoader;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
-
-/**
- * Manager component for a rule base loaded from a drools RulesAgent
- */
-@ApplicationScoped
-public class RuleAgent
-{
- @Logger Log log;
-
- @Inject ResourceLoader resourceLoader;
-
- private org.drools.agent.RuleAgent agent;
- private String configurationFile;
-
- private String newInstance;
- private String files;
- private String url;
- private String localCacheDir;
- private String poll;
- private String configName;
-
- @Inject
- public void createAgent() throws Exception
- {
- Properties properties = new Properties();
-
- loadFromPath(properties, configurationFile);
- setLocalProperties(properties);
-
- agent = org.drools.agent.RuleAgent.newRuleAgent(properties);
- log.debug("Creating new rules agent");
- }
-
- protected void setLocalProperties(Properties properties)
- {
- if (newInstance != null) {
- properties.setProperty(org.drools.agent.RuleAgent.NEW_INSTANCE, newInstance);
- }
- if (files != null) {
- properties.setProperty(org.drools.agent.RuleAgent.FILES, files);
- }
- if (url != null) {
- properties.setProperty(org.drools.agent.RuleAgent.URLS, url);
- }
- if (localCacheDir != null) {
- properties.setProperty(org.drools.agent.RuleAgent.LOCAL_URL_CACHE, localCacheDir);
- }
- if (poll != null) {
- properties.setProperty(org.drools.agent.RuleAgent.POLL_INTERVAL, poll);
- }
- if (configName != null) {
- properties.setProperty(org.drools.agent.RuleAgent.CONFIG_NAME, configName);
- }
-
- }
-
- protected void loadFromPath(Properties properties, String configurationFile)
- throws IOException
- {
- if (configurationFile != null) {
- InputStream inputStream = resourceLoader.getResourceAsStream(configurationFile);
- if (inputStream != null) {
- try {
- properties.load(inputStream);
- } finally {
- inputStream.close();
- }
- }
- }
- }
-
- @Produces
- public org.drools.RuleBase getRuleBase()
- {
- return agent.getRuleBase();
- }
-
- public String getNewInstance()
- {
- return newInstance;
- }
-
- public void setNewInstance(String newInstance)
- {
- this.newInstance = newInstance;
- }
-
- public String getFiles()
- {
- return files;
- }
-
- public void setFiles(String files)
- {
- this.files = files;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl(String url)
- {
- this.url = url;
- }
-
- public String getLocalCacheDir()
- {
- return localCacheDir;
- }
-
- public void setLocalCacheDir(String localCacheDir)
- {
- this.localCacheDir = localCacheDir;
- }
-
- public String getPoll()
- {
- return poll;
- }
-
- public void setPoll(String poll)
- {
- this.poll = poll;
- }
-
- public String getConfigName()
- {
- return configName;
- }
-
- public void setConfigName(String name)
- {
- this.configName = name;
- }
-
- public String getConfigurationFile()
- {
- return configurationFile;
- }
-
- public void setConfigurationFile(String brmsConfig)
- {
- this.configurationFile = brmsConfig;
- }
-
-}
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleBase.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleBase.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/RuleBase.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,120 +0,0 @@
-package org.jboss.seam.drools;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.enterprise.inject.Produces;
-
-import org.drools.RuleBaseFactory;
-import org.drools.compiler.DroolsError;
-import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.PackageBuilderConfiguration;
-import org.drools.compiler.RuleError;
-import org.jboss.seam.resources.ResourceLoader;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
-
-/**
- * Manager component for a Drools RuleBase
- *
- * @author Gavin King
- *
- */
-@ApplicationScoped
-public class RuleBase
-{
- @Logger Log log;
-
- @Inject ResourceLoader resourceLoader;
-
- private String[] ruleFiles;
- private String dslFile;
- private org.drools.RuleBase ruleBase;
-
- @Inject
- public void compileRuleBase() throws Exception
- {
- PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
- PackageBuilder builder = new PackageBuilder(conf);
-
- if (ruleFiles!=null)
- {
- for (String ruleFile: ruleFiles)
- {
- log.info("parsing rules: " + ruleFile);
- InputStream stream = getResourceAsStream(ruleFile);
- if (stream==null)
- {
- throw new IllegalStateException("could not locate rule file: " + ruleFile);
- }
- // read in the source
- Reader drlReader = new InputStreamReader(stream);
-
- if (dslFile==null)
- {
- builder.addPackageFromDrl(drlReader);
- }
- else
- {
- Reader dslReader = new InputStreamReader( getResourceAsStream(dslFile) );
- builder.addPackageFromDrl(drlReader, dslReader);
- }
-
- if ( builder.hasErrors() )
- {
- log.error("errors parsing rules in: " + ruleFile);
- for ( DroolsError error: builder.getErrors().getErrors() )
- {
- if (error instanceof RuleError)
- {
- RuleError ruleError = (RuleError) error;
- log.error( ruleError.getMessage() + " (" + ruleFile + ':' + ruleError.getLine() + ')' );
- }
- else
- {
- log.error( error.getMessage() + " (" + ruleFile + ')' );
- }
- }
- }
- }
- }
-
- // add the package to a rulebase
- ruleBase = RuleBaseFactory.newRuleBase();
- ruleBase.addPackage( builder.getPackage() );
- }
-
- @Produces
- public org.drools.RuleBase getRuleBase()
- {
- return ruleBase;
- }
-
- public String[] getRuleFiles()
- {
- return ruleFiles;
- }
-
- public void setRuleFiles(String[] ruleFiles)
- {
- this.ruleFiles = ruleFiles;
- }
-
- public String getDslFile()
- {
- return dslFile;
- }
-
- public void setDslFile(String dslFile)
- {
- this.dslFile = dslFile;
- }
-
- public InputStream getResourceAsStream(String resource)
- {
- return resourceLoader.getResourceAsStream(resource);
- }
-}
Deleted: modules/drools/trunk/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2010-01-05 11:43:52 UTC (rev 11910)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -1,56 +0,0 @@
-package org.jboss.seam.drools;
-
-import org.drools.spi.GlobalResolver;
-
-/**
- * Resolves Seam context variables as Drools globals
- *
- * @author Gavin King
- *
- */
-public class SeamGlobalResolver implements GlobalResolver
-{
- private static final long serialVersionUID = -2274336299784922069L;
-
- private GlobalResolver delegate;
-
- public SeamGlobalResolver(GlobalResolver delegate)
- {
- this.delegate = delegate;
- }
-
- public void setGlobal(String name, Object value)
- {
- //TODO: is this the right thing to do??
- //or: Contexts.getConversationContext().set(name, value);
- delegate.setGlobal(name, value);
- }
-
- public Object resolveGlobal(String name)
- {
- return delegate.resolveGlobal(name);
-
- // TODO enable contextual variable resolution
- /*
- if ( !Contexts.isApplicationContextActive() )
- {
- return delegate.resolveGlobal(name);
- }
- else
- {
- Object instance = Component.getInstance(name);
- if (instance==null)
- {
- instance = delegate.resolveGlobal(name);
- return instance==null ?
- Init.instance().getRootNamespace().getChild(name) :
- instance;
- }
- else
- {
- return instance;
- }
- }
- */
- }
-}
\ No newline at end of file
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/TemplateDataProvider.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -0,0 +1,15 @@
+package org.jboss.seam.drools;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Interface for template data providers.
+ *
+ * @author Tihomir Surdilovic
+ *
+ */
+public interface TemplateDataProvider
+{
+ public Collection<Map<String, Object>> getTemplateData();
+}
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/KnowledgeBuilderErrorsEvent.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -0,0 +1,29 @@
+package org.jboss.seam.drools.events;
+
+import org.drools.builder.KnowledgeBuilderErrors;
+
+/**
+ * This event is fires in case of KnowledgeBuilder errors.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class KnowledgeBuilderErrorsEvent
+{
+ private KnowledgeBuilderErrors errors;
+
+ public KnowledgeBuilderErrorsEvent(KnowledgeBuilderErrors errors)
+ {
+ this.errors = errors;
+ }
+
+ public KnowledgeBuilderErrors getErrors()
+ {
+ return errors;
+ }
+
+ public void setErrors(KnowledgeBuilderErrors errors)
+ {
+ this.errors = errors;
+ }
+
+}
Added: modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java
===================================================================
--- modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java (rev 0)
+++ modules/drools/trunk/src/main/java/org/jboss/seam/drools/events/RuleResourceAddedEvent.java 2010-01-05 17:45:59 UTC (rev 11911)
@@ -0,0 +1,26 @@
+package org.jboss.seam.drools.events;
+
+/**
+ * This event is fires when a rule resource is added.
+ *
+ * @author Tihomir Surdilovic
+ */
+public class RuleResourceAddedEvent
+{
+ String resource;
+
+ public RuleResourceAddedEvent(String resource)
+ {
+ this.resource = resource;
+ }
+
+ public String getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(String resource)
+ {
+ this.resource = resource;
+ }
+}
14 years, 12 months
Seam SVN: r11910 - branches/community/Seam_2_2/src/test/ftest.
by seam-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-01-05 06:43:52 -0500 (Tue, 05 Jan 2010)
New Revision: 11910
Modified:
branches/community/Seam_2_2/src/test/ftest/ftest.properties
Log:
jboss.home changed back to empty property
Modified: branches/community/Seam_2_2/src/test/ftest/ftest.properties
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/ftest.properties 2010-01-04 12:58:34 UTC (rev 11909)
+++ branches/community/Seam_2_2/src/test/ftest/ftest.properties 2010-01-05 11:43:52 UTC (rev 11910)
@@ -29,6 +29,7 @@
#selenium.browser=*iexploreproxy
selenium.browser.port=8080
selenium.browser.url=http://127.0.0.1:8080
+selenium.browser.url.cluster=http://127.0.0.1:8180
selenium.speed=0
selenium.timeout=120000
selenium.icefaces.wait.time=2000
@@ -54,7 +55,7 @@
# container locations - must be set
# independent from ${seam.dir}/build.properties
jboss4.home=
-jboss5.home=/home/mgencur/Java/jboss-5.1.0.GA
+jboss5.home=
tomcat6.home=
jboss-embedded.home=
14 years, 12 months