Seam SVN: r11770 - modules.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-07 06:48:37 -0500 (Mon, 07 Dec 2009)
New Revision: 11770
Removed:
modules/dist/
Log:
removed dist module
15 years
Seam SVN: r11769 - modules.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-07 06:47:57 -0500 (Mon, 07 Dec 2009)
New Revision: 11769
Removed:
modules/debug/
Log:
removed debug module
15 years
Seam SVN: r11768 - modules/bpm/trunk/src/main/java.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-07 06:43:50 -0500 (Mon, 07 Dec 2009)
New Revision: 11768
Removed:
modules/bpm/trunk/src/main/java/org/
Log:
removed stale code
15 years
Seam SVN: r11767 - modules.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-07 06:40:12 -0500 (Mon, 07 Dec 2009)
New Revision: 11767
Removed:
modules/beans/
Log:
not required
15 years
Seam SVN: r11766 - in branches/community/Seam_2_2/src: remoting/org/jboss/seam/remoting/messaging and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-07 05:57:54 -0500 (Mon, 07 Dec 2009)
New Revision: 11766
Modified:
branches/community/Seam_2_2/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java
Log:
fix NPE
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-12-06 23:49:03 UTC (rev 11765)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-12-07 10:57:54 UTC (rev 11766)
@@ -79,11 +79,11 @@
List<Permission> permissions = permissionStore.listPermissions(target, action);
- String username = identity.getPrincipal().getName();
+ String username = identity.getPrincipal() != null ? identity.getPrincipal().getName() : null;
for (Permission permission : permissions)
{
- if (permission.getRecipient() instanceof SimplePrincipal &&
+ if (username != null && permission.getRecipient() instanceof SimplePrincipal &&
username.equals(permission.getRecipient().getName()))
{
return true;
Modified: branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java
===================================================================
--- branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java 2009-12-06 23:49:03 UTC (rev 11765)
+++ branches/community/Seam_2_2/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java 2009-12-07 10:57:54 UTC (rev 11766)
@@ -1,5 +1,6 @@
package org.jboss.seam.remoting.messaging;
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -10,7 +11,7 @@
@Name("org.jboss.seam.remoting.messaging.SubscriptionRegistry.userTokens")
@Scope(ScopeType.SESSION)
-public class UserTokens
+public class UserTokens implements Serializable
{
Set<String> tokens = new HashSet<String>();
15 years
Seam SVN: r11765 - in modules/remoting/trunk/examples/model: src/main/java/org/jboss/seam/remoting/examples/model and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-06 18:49:03 -0500 (Sun, 06 Dec 2009)
New Revision: 11765
Added:
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
Modified:
modules/remoting/trunk/examples/model/pom.xml
Log:
example classes
Modified: modules/remoting/trunk/examples/model/pom.xml
===================================================================
--- modules/remoting/trunk/examples/model/pom.xml 2009-12-06 23:05:29 UTC (rev 11764)
+++ modules/remoting/trunk/examples/model/pom.xml 2009-12-06 23:49:03 UTC (rev 11765)
@@ -44,6 +44,15 @@
<artifactId>seam-remoting</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+
</dependencies>
Added: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java 2009-12-06 23:49:03 UTC (rev 11765)
@@ -0,0 +1,79 @@
+package org.jboss.seam.remoting.examples.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * Customer entity bean. This class exposes a variety of property types for the
+ * purpose of the example.
+ *
+ * @author Shane Bryzak
+ */
+@Entity
+public class Customer implements Serializable
+{
+ private static final long serialVersionUID = 4289723352398788625L;
+
+ public enum Gender { male, female }
+
+ private Integer customerId;
+ private String firstName;
+ private String lastName;
+ private Date dateOfBirth;
+ private Gender gender;
+
+ @Id @GeneratedValue
+ public Integer getCustomerId()
+ {
+ return customerId;
+ }
+
+ public void setCustomerId(Integer customerId)
+ {
+ this.customerId = customerId;
+ }
+
+ public String getFirstName()
+ {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName)
+ {
+ this.firstName = firstName;
+ }
+
+ public String getLastName()
+ {
+ return lastName;
+ }
+
+ public void setLastName(String lastName)
+ {
+ this.lastName = lastName;
+ }
+
+ public Date getDateOfBirth()
+ {
+ return dateOfBirth;
+ }
+
+ public void setDateOfBirth(Date dateOfBirth)
+ {
+ this.dateOfBirth = dateOfBirth;
+ }
+
+ public Gender getGender()
+ {
+ return gender;
+ }
+
+ public void setGender(Gender gender)
+ {
+ this.gender = gender;
+ }
+}
Added: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java 2009-12-06 23:49:03 UTC (rev 11765)
@@ -0,0 +1,49 @@
+package org.jboss.seam.remoting.examples.model;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ConversationScoped
+public class CustomerAction implements Serializable
+{
+ private static final long serialVersionUID = 8350706339578435242L;
+
+ @Inject EntityManager entityManager;
+ @Inject Conversation conversation;
+
+ private Customer customer;
+
+ public void createCustomer()
+ {
+ conversation.begin();
+ customer = new Customer();
+ }
+
+ public void editCustomer(Integer customerId)
+ {
+ conversation.begin();
+ customer = entityManager.find(Customer.class, customerId);
+ }
+
+ public void saveCustomer()
+ {
+ if (customer.getCustomerId() == null)
+ {
+ entityManager.persist(customer);
+ }
+ else
+ {
+ customer = entityManager.merge(customer);
+ }
+ conversation.end();
+ }
+
+ public Customer getCustomer()
+ {
+ return customer;
+ }
+}
15 years
Seam SVN: r11764 - in modules/remoting/trunk/examples: model and 10 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-06 18:05:29 -0500 (Sun, 06 Dec 2009)
New Revision: 11764
Added:
modules/remoting/trunk/examples/model/
modules/remoting/trunk/examples/model/pom.xml
modules/remoting/trunk/examples/model/src/
modules/remoting/trunk/examples/model/src/main/
modules/remoting/trunk/examples/model/src/main/java/
modules/remoting/trunk/examples/model/src/main/java/org/
modules/remoting/trunk/examples/model/src/main/java/org/jboss/
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/
modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/
modules/remoting/trunk/examples/model/src/main/webapp/
modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/
modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/beans.xml
modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/web.xml
modules/remoting/trunk/examples/model/src/main/webapp/index.html
modules/remoting/trunk/examples/model/src/main/webapp/model.html
Log:
add skeleton for model example
Added: modules/remoting/trunk/examples/model/pom.xml
===================================================================
--- modules/remoting/trunk/examples/model/pom.xml (rev 0)
+++ modules/remoting/trunk/examples/model/pom.xml 2009-12-06 23:05:29 UTC (rev 11764)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.seam.examples</groupId>
+ <artifactId>seam-examples-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.seam.remoting.examples</groupId>
+ <artifactId>remoting-model</artifactId>
+ <packaging>war</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Seam Remoting Examples: Model</name>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus snapshot repository</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <!--dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency-->
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-remoting</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
+
Added: modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/beans.xml
===================================================================
Added: modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/web.xml 2009-12-06 23:05:29 UTC (rev 11764)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>Seam Remoting Model example</display-name>
+
+ <servlet>
+ <servlet-name>Remoting Servlet</servlet-name>
+ <servlet-class>org.jboss.seam.remoting.Remoting</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Remoting Servlet</servlet-name>
+ <url-pattern>/seam/resource/remoting/*</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
+
Added: modules/remoting/trunk/examples/model/src/main/webapp/index.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/index.html (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/index.html 2009-12-06 23:05:29 UTC (rev 11764)
@@ -0,0 +1,6 @@
+<html>
+ <head>
+ <meta http-equiv="Refresh" content="0; URL=model.html"/>
+ </head>
+</html>
+
Added: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2009-12-06 23:05:29 UTC (rev 11764)
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <title>Seam Remoting - Model Example</title>
+</head>
+
+<body>
+
+ <h1>Seam Remoting - Model Example</h1>
+
+ <script type="text/javascript" src="seam/resource/remoting/resource/remote.js"></script>
+
+ <script type="text/javascript">
+ //<![CDATA[
+
+
+ // ]]>
+ }
+ </script>
+
+
+</body>
+</html>
+
15 years
Seam SVN: r11763 - modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-06 18:00:19 -0500 (Sun, 06 Dec 2009)
New Revision: 11763
Modified:
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
references should be model scoped
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 2009-12-06 22:13:38 UTC (rev 11762)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-06 23:00:19 UTC (rev 11763)
@@ -9,7 +9,7 @@
var v = new b[i];
if (arguments.length > 1) {
v.__qualifiers = new Array();
- for (var j = 1; j < arguments.length; j++) {
+ for (var j = 1; j < arguments.length; j++) {
v.__qualifiers.push(arguments[j]);
}
}
@@ -64,7 +64,7 @@
var sid = null;
if (url.indexOf(';jsessionid=') >= 0) {
var qpos = url.indexOf('?');
- sid = url.substring(url.indexOf(';jsessionid=') + 12, qpos >= 0 ? qpos : url.length);
+ sid = url.substring(url.indexOf(';jsessionid=') + 12, qpos >= 0 ? qpos : url.length);
}
return sid;
}
@@ -77,7 +77,7 @@
Seam.Remoting.encodedSessionId = Seam.Remoting.extractEncodedSessionId(window.location.href);
Seam.Remoting.type = new Object(); // namespace
-Seam.Remoting.types = new Array();
+Seam.Remoting.types = new Array();
Seam.Remoting.debug = false;
Seam.Remoting.debugWindow = null;
@@ -108,7 +108,7 @@
Seam.Remoting.createNamespace = function(namespace) {
var p = namespace.split(".");
var b = Seam.Remoting.type;
-
+
for(var i = 0; i < p.length; i++) {
if (typeof b[p[i]] == "undefined") b[p[i]] = new Object();
b = b[p[i]];
@@ -354,18 +354,18 @@
var callId = "" + Seam.Remoting.__callId++;
if (!callback) callback = component.__callback[methodName];
- var d = "<call id=\"" + callId + "\">\n";
+ var d = "<call id=\"" + callId + "\">\n";
d += "<target>" + Seam.Remoting.getBeanType(component).__name + "</target>";
-
+
if (component.__qualifiers != null) {
- d += "<qualifiers>";
+ d += "<qualifiers>";
for (var i = 0; i < component.__qualifiers.length; i++) {
d += component.__qualifiers[i];
if (i < component.__qualifiers.length - 1) data += ",";
}
d += "</qualifiers>";
}
-
+
d += "<method>" + methodName + "</method>";
d += "<params>";
@@ -467,7 +467,7 @@
Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent)
{
Seam.Remoting.log("Request packet:\n" + envelope);
- if (!silent) Seam.Remoting.displayLoadingMessage();
+ if (!silent) Seam.Remoting.displayLoadingMessage();
var r;
if (window.XMLHttpRequest) {
r = new XMLHttpRequest();
@@ -479,21 +479,21 @@
r.onreadystatechange = function() {
if (r.readyState == 4) {
- var inScope = typeof(Seam) == "undefined" ? false : true;
+ var inScope = typeof(Seam) == "undefined" ? false : true;
if (inScope) Seam.Remoting.hideLoadingMessage();
-
+
if (r.status == 200) {
// We do this to avoid a memory leak
window.setTimeout(function() {
r.onreadystatechange = function() {};
- }, 0);
-
+ }, 0);
+
if (inScope) Seam.Remoting.log("Response packet:\n" + r.responseText);
-
+
if (callback) {
// The following code deals with a Firefox security issue. It reparses the XML
// response if accessing the documentElement throws an exception
- try {
+ try {
r.responseXML.documentElement;
callback(r.responseXML);
}
@@ -508,27 +508,27 @@
catch (e) {
// If that fails, use standards
var parser = new DOMParser();
- callback(parser.parseFromString(r.responseText, "text/xml"));
+ callback(parser.parseFromString(r.responseText, "text/xml"));
}
- }
+ }
}
}
else {
Seam.Remoting.displayError(r.status);
}
- }
+ }
}
if (Seam.Remoting.encodedSessionId) {
path += ';jsessionid=' + Seam.Remoting.encodedSessionId;
}
-
+
r.open("POST", Seam.Remoting.resourcePath + path, true);
r.send(envelope);
}
Seam.Remoting.displayError = function(code) {
- alert("There was an error processing your request. Error code: " + code);
+ alert("There was an error processing your request. Error code: " + code);
}
Seam.Remoting.setCallback = function(component, methodName, callback) {
@@ -539,8 +539,8 @@
var headerNode;
var bodyNode;
var inScope = typeof(Seam) == "undefined" ? false : true;
- if (!inScope) return;
-
+ if (!inScope) return;
+
var context = new Seam.Remoting.__Context;
if (doc.documentElement) {
@@ -604,12 +604,12 @@
for (var i = 0; i < c.length; i++) {
var tag = c.item(i).tagName;
if (tag == "message")
- msgNode = c.item(i);
+ msgNode = c.item(i);
}
-
+
var msg = Seam.Remoting.unmarshalValue(msgNode.firstChild);
var ex = new Seam.Remoting.Exception(msg);
- call.exceptionHandler(ex);
+ call.exceptionHandler(ex);
}
else {
var refs = new Array();
@@ -764,27 +764,27 @@
this.method = null;
this.params = new Array();
this.expression = null;
-
+
Seam.Remoting.Action.prototype.setBeanType = function(beanType) {
this.beanType = beanType;
return this;
}
-
+
Seam.Remoting.Action.prototype.setQualifiers = function(qualifiers) {
this.qualifiers = qualifiers;
return this;
}
-
- Seam.Remoting.Action.prototype.setMethod = function(method) {
+
+ Seam.Remoting.Action.prototype.setMethod = function(method) {
this.method = method;
return this;
}
-
+
Seam.Remoting.Action.prototype.addParam = function(param) {
this.params.push(param);
return this;
}
-
+
Seam.Remoting.Action.prototype.setExpression = function(expr) {
this.expression = expr;
return this;
@@ -794,34 +794,34 @@
Seam.Remoting.Model = function() {
this.expressions = new Array();
this.beans = new Array();
-
+
Seam.Remoting.Model.prototype.addExpression = function(alias, expr) {
this.expressions.push({alias: alias, expr: expr});
}
-
+
Seam.Remoting.Model.prototype.addBean = function(alias, bean, property) {
var q = null;
if (arguments.length > 3) {
q = new Array();
- for (var i = 3; i < arguments.length; i++) {
+ for (var i = 3; i < arguments.length; i++) {
q.push(arguments[i]);
}
}
this.beans.push({alias: alias, bean: bean, property: property, qualifiers: q});
}
-
+
Seam.Remoting.Model.prototype.fetch = function(action) {
var r = this.createFetchRequest(action);
var env = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), r.data);
Seam.Remoting.pendingCalls.put(r.id, r);
- Seam.Remoting.sendAjaxRequest(env, Seam.Remoting.PATH_MODEL, this.processFetchResponse, false);
+ Seam.Remoting.sendAjaxRequest(env, Seam.Remoting.PATH_MODEL, this.processFetchResponse, false);
}
-
+
Seam.Remoting.Model.prototype.createFetchRequest = function(a) { // a = action
var callId = "" + Seam.Remoting.__callId++;
var d = "<model operation=\"fetch\" callId=\"" + callId + ">";
var refs = new Array();
-
+
if (a) {
d += "<action>";
if (a.beanType) {
@@ -834,13 +834,22 @@
d += "<param>" + Seam.Remoting.serializeValue(a.params[i], null, refs) + "</param>";
}
d += "</params>";
- }
+ }
+ if (refs.length > 0) {
+ d += "<refs>";
+ for (var i = 0; i < refs.length; i++) {
+ d += "<ref id=\"" + i + "\">";
+ d += Seam.Remoting.serializeType(refs[i], refs);
+ d += "</ref>";
+ }
+ d += "</refs>";
+ }
}
else if (a.expression) {
d += "<target>" + a.expression + "</target>";
}
d += "</action>";
- }
+ }
if (this.beans.length > 0) {
for (var i = 0; i < this.beans.length; i++) {
var b = this.beans[i];
@@ -849,41 +858,32 @@
d += "<qualifiers>";
for (var j = 0; j < b.qualifiers.length; j++) {
d += (j > 0 ? "," : "") + b.qualifiers[j];
- }
+ }
d += "</qualifiers>";
}
- d += "<property>" + b.property + "</property></bean>";
+ d += "<property>" + b.property + "</property></bean>";
}
- }
+ }
if (this.expressions.length > 0) {
for (var i = 0; i < this.expressions.length; i++) {
var e = this.expressions[i];
d += "<expression alias=\"" + e.alias + "\">" + e.expr + "</expression>";
- }
- }
- if (refs.length > 0) {
- d += "<refs>";
- for (var i = 0; i < refs.length; i++) {
- d += "<ref id=\"" + i + "\">";
- d += Seam.Remoting.serializeType(refs[i], refs);
- d += "</ref>";
}
- d += "</refs>";
}
- d += "</model>";
-
+ d += "</model>";
+
return {data: d, id: callId};
}
-
+
Seam.Remoting.Model.prototype.processFetchResponse = function(doc) {
-
- }
-
+
+ }
+
Seam.Remoting.Model.prototype.applyUpdates = function(action) {
-
- }
-
-
+
+ }
+
+
}
/* Messaging API */
15 years
Seam SVN: r11762 - in modules/remoting/trunk/src/main/java/org/jboss/seam/remoting: model and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-06 17:13:38 -0500 (Sun, 06 Dec 2009)
New Revision: 11762
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
Log:
unmarshal the bean requests
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-06 20:35:02 UTC (rev 11761)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-06 22:13:38 UTC (rev 11762)
@@ -120,7 +120,7 @@
// First reconstruct all the references
Element refsNode = e.element("refs");
-
+
Iterator iter = refsNode.elementIterator("ref");
while (iter.hasNext())
{
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java 2009-12-06 20:35:02 UTC (rev 11761)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java 2009-12-06 22:13:38 UTC (rev 11762)
@@ -1,8 +1,8 @@
package org.jboss.seam.remoting.model;
import java.io.Serializable;
+import java.lang.annotation.Annotation;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -10,22 +10,38 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import org.jboss.seam.remoting.AnnotationsParser;
+import org.jboss.seam.remoting.Call;
+import org.jboss.seam.remoting.CallContext;
+
public class Model implements Serializable
{
private static final long serialVersionUID = 8318288750036758325L;
private BeanManager beanManager;
private String id;
- private Map<Integer,Object> refs;
+ private CallContext callContext;
- private Set<Bean<?>> beans;
+ private class BeanProperty
+ {
+ public Bean<?> bean;
+ public String propertyName;
+
+ public BeanProperty(Bean<?> bean, String propertyName)
+ {
+ this.bean = bean;
+ this.propertyName = propertyName;
+ }
+ }
+ private Map<String, BeanProperty> beanProperties;
+
public Model(BeanManager beanManager)
{
this.beanManager = beanManager;
id = UUID.randomUUID().toString();
- refs = new HashMap<Integer,Object>();
- beans = new HashSet<Bean<?>>();
+ callContext = new CallContext(beanManager);
+ beanProperties = new HashMap<String, BeanProperty>();
}
public String getId()
@@ -33,8 +49,44 @@
return id;
}
- public void addBean()
+ public CallContext getCallContext()
+ {
+ return callContext;
+ }
+ public void addBean(String alias, String beanName, String qualifiers, String propertyName)
+ {
+ Set<Bean<?>> beans = beanManager.getBeans(beanName);
+
+ if (beans.isEmpty())
+ {
+ try
+ {
+ Class<?> beanType = Class.forName(beanName);
+
+ Annotation[] q = qualifiers != null && !qualifiers.isEmpty() ?
+ new AnnotationsParser(beanType, qualifiers, beanManager).getAnnotations() :
+ Call.EMPTY_ANNOTATIONS;
+
+ beans = beanManager.getBeans(beanType, q);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Invalid bean class specified: " + beanName);
+ }
+
+ if (beans.isEmpty())
+ {
+ throw new IllegalArgumentException(
+ "Could not find bean with bean with type/name " + beanName +
+ ", qualifiers [" + qualifiers + "]");
+ }
+ }
+
+ Bean<?> bean = beans.iterator().next();
+ beanProperties.put(alias, new BeanProperty(bean, propertyName));
+ }
+
public void applyChanges(Set<ChangeSet> delta)
{
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java 2009-12-06 20:35:02 UTC (rev 11761)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java 2009-12-06 22:13:38 UTC (rev 11762)
@@ -1,8 +1,12 @@
package org.jboss.seam.remoting.model;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.StringReader;
-import java.util.Iterator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import javax.enterprise.context.Conversation;
import javax.enterprise.inject.spi.BeanManager;
@@ -21,6 +25,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Handles incoming model fetch/applyUpdate requests
+ *
+ * @author Shane Bryzak
+ */
public class ModelHandler implements RequestHandler
{
private static final Logger log = LoggerFactory.getLogger(ModelHandler.class);
@@ -30,6 +39,7 @@
@Inject Conversation conversation;
@Inject ModelRegistry registry;
+ @SuppressWarnings("unchecked")
public void handle(HttpServletRequest request, HttpServletResponse response)
throws Exception
{
@@ -58,59 +68,101 @@
conversationManager.beginOrRestoreConversation(ctx.getConversationId());
}
- Element modelElement = env.element("body").element("model");
+ Set<Model> models = new HashSet<Model>();
- String operation = modelElement.attributeValue("operation");
- String id = modelElement.attributeValue("id");
-
- if ("fetch".equals(operation))
- {
- Call action = null;
- if (modelElement.elements("action").size() > 0)
+ for (Element modelElement : (List<Element>) env.element("body").elements("model"))
+ {
+ String operation = modelElement.attributeValue("operation");
+ String id = modelElement.attributeValue("id");
+
+ if ("fetch".equals(operation))
{
- Element actionElement = modelElement.element("action");
- Element targetElement = actionElement.element("target");
- Element qualifiersElement = actionElement.element("qualifiers");
- Element methodElement = actionElement.element("method");
- Element paramsElement = actionElement.element("params");
- action = new Call(beanManager, id, targetElement.getTextTrim(),
- qualifiersElement.getTextTrim(), methodElement.getTextTrim());
+ Model model = registry.createModel();
- Element refsNode = modelElement.element("refs");
-
- Iterator<?> iter = refsNode.elementIterator("ref");
- while (iter.hasNext())
+ Call action = null;
+ if (modelElement.elements("action").size() > 0)
{
- action.getContext().createWrapperFromElement((Element) iter.next());
+ Element actionElement = modelElement.element("action");
+ Element targetElement = actionElement.element("target");
+ Element qualifiersElement = actionElement.element("qualifiers");
+ Element methodElement = actionElement.element("method");
+ Element paramsElement = actionElement.element("params");
+ Element refsElement = actionElement.element("refs");
+
+ action = new Call(beanManager, id, targetElement.getTextTrim(),
+ qualifiersElement.getTextTrim(), methodElement.getTextTrim());
+
+ for (Element refElement : (List<Element>) refsElement.elements("ref"))
+ {
+ action.getContext().createWrapperFromElement(refElement);
+ }
+
+ for (Wrapper w : action.getContext().getInRefs().values())
+ {
+ w.unmarshal();
+ }
+
+ for (Element paramElement : (List<Element>) paramsElement.elements("param"))
+ {
+ action.addParameter(action.getContext().createWrapperFromElement(
+ paramElement));
+ }
}
-
- for (Wrapper w : action.getContext().getInRefs().values())
+
+ for (Element beanElement : (List<Element>) modelElement.elements("bean"))
{
- w.unmarshal();
+ Element beanNameElement = beanElement.element("name");
+ Element beanQualifierElement = beanElement.element("qualifier");
+ Element beanPropertyElement = beanElement.element("property");
+
+ model.addBean(beanElement.attributeValue("alias"),
+ beanNameElement.getTextTrim(),
+ beanQualifierElement.getTextTrim(),
+ beanPropertyElement.getTextTrim());
}
-
- iter = paramsElement.elementIterator("param");
- while (iter.hasNext())
+
+ // TODO Unmarshal expressions - don't support this until security implications investigated
+ for (Element exprElement : (List<Element>) modelElement.elements("expression"))
{
- Element param = (Element) iter.next();
-
- action.addParameter(action.getContext().createWrapperFromElement(
- (Element) param.elementIterator().next()));
+
}
+
+ if (action != null)
+ {
+ action.execute();
+ }
}
-
- // Unmarshal beans
-
- // Unmarshal expressions
-
- if (action != null)
- {
- action.execute();
- }
-
}
- // Store the conversation ID in the outgoing context
- ctx.setConversationId(conversation.getId());
+ ctx.setConversationId(conversation.getId());
+ marshalResponse(models, ctx, response.getOutputStream());
}
+
+ private void marshalResponse(Set<Model> models, RequestContext ctx,
+ OutputStream out) throws IOException
+ {
+ out.write(ENVELOPE_TAG_OPEN);
+
+ if (ctx.getConversationId() != null)
+ {
+ out.write(HEADER_OPEN);
+ out.write(CONTEXT_TAG_OPEN);
+ out.write(CONVERSATION_ID_TAG_OPEN);
+ out.write(ctx.getConversationId().getBytes());
+ out.write(CONVERSATION_ID_TAG_CLOSE);
+ out.write(CONTEXT_TAG_CLOSE);
+ out.write(HEADER_CLOSE);
+ }
+
+ out.write(BODY_TAG_OPEN);
+
+ for (Model model : models)
+ {
+ //MarshalUtils.marshalResult(call, out);
+ }
+
+ out.write(BODY_TAG_CLOSE);
+ out.write(ENVELOPE_TAG_CLOSE);
+ out.flush();
+ }
}
15 years
Seam SVN: r11761 - in modules/remoting/trunk/src/main/java/org/jboss/seam/remoting: model and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-06 15:35:02 -0500 (Sun, 06 Dec 2009)
New Revision: 11761
Added:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Remoting.java
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestContext.java
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestHandler.java
Log:
added model handler
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-06 13:24:44 UTC (rev 11760)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-06 20:35:02 UTC (rev 11761)
@@ -18,6 +18,7 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jboss.seam.remoting.wrapper.Wrapper;
+import org.jboss.weld.conversation.ConversationManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,29 +30,17 @@
*/
public class ExecutionHandler implements RequestHandler
{
- private static final Logger log = LoggerFactory
- .getLogger(ExecutionHandler.class);
+ private static final Logger log = LoggerFactory.getLogger(ExecutionHandler.class);
- private static final byte[] HEADER_OPEN = "<header>".getBytes();
- private static final byte[] HEADER_CLOSE = "</header>".getBytes();
- private static final byte[] CONVERSATION_ID_TAG_OPEN = "<conversationId>"
- .getBytes();
- private static final byte[] CONVERSATION_ID_TAG_CLOSE = "</conversationId>"
- .getBytes();
-
- private static final byte[] CONTEXT_TAG_OPEN = "<context>".getBytes();
- private static final byte[] CONTEXT_TAG_CLOSE = "</context>".getBytes();
-
@Inject BeanManager beanManager;
+ @Inject ConversationManager conversationManager;
@Inject Conversation conversation;
/**
* The entry point for handling a request.
*
- * @param request
- * HttpServletRequest
- * @param response
- * HttpServletResponse
+ * @param request HttpServletRequest
+ * @param response HttpServletResponse
* @throws Exception
*/
public void handle(HttpServletRequest request,
@@ -78,12 +67,12 @@
SAXReader xmlReader = new SAXReader();
Document doc = xmlReader.read(new StringReader(requestData));
final Element env = doc.getRootElement();
- final RequestContext ctx = unmarshalContext(env);
+ final RequestContext ctx = new RequestContext(env.element("header"));
if (!ctx.getConversationId().isEmpty())
{
- // TODO restore the conversation if there is a conversation ID in the context
- //conversation.
+ // this is non portable ;/
+ conversationManager.beginOrRestoreConversation(ctx.getConversationId());
}
// Extract the calls from the request
@@ -103,35 +92,6 @@
}
/**
- * Unmarshals the context from the request envelope header.
- *
- * @param env
- * Element
- * @return RequestContext
- */
- private RequestContext unmarshalContext(Element env)
- {
- RequestContext ctx = new RequestContext();
-
- Element header = env.element("header");
- if (header != null)
- {
- Element context = header.element("context");
- if (context != null)
- {
-
- Element convId = context.element("conversationId");
- if (convId != null)
- {
- ctx.setConversationId(convId.getText());
- }
- }
- }
-
- return ctx;
- }
-
- /**
* Unmarshal the request into a list of Calls.
*
* @param env
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Remoting.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Remoting.java 2009-12-06 13:24:44 UTC (rev 11760)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/Remoting.java 2009-12-06 20:35:02 UTC (rev 11761)
@@ -33,9 +33,11 @@
//private static final String REQUEST_PATH_SUBSCRIPTION = "/subscription";
//private static final String REQUEST_PATH_POLL = "/poll";
private static final String REQUEST_PATH_INTERFACE = "/interface.js";
+ private static final String REQUEST_PATH_MODEL = "/model";
@Inject Instance<ExecutionHandler> executionHandlerInstance;
@Inject Instance<InterfaceGenerator> interfaceHandlerInstance;
+ @Inject Instance<ModelHandler> modelHandlerInstance;
public static final int DEFAULT_POLL_TIMEOUT = 10; // 10 seconds
public static final int DEFAULT_POLL_INTERVAL = 1; // 1 second
@@ -214,6 +216,10 @@
{
interfaceHandlerInstance.get().handle(request, response);
}
+ else if (REQUEST_PATH_MODEL.equals(pathInfo))
+ {
+ modelHandlerInstance.get().handle(request, response);
+ }
else
{
Matcher m = pathPattern.matcher(pathInfo);
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestContext.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestContext.java 2009-12-06 13:24:44 UTC (rev 11760)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestContext.java 2009-12-06 20:35:02 UTC (rev 11761)
@@ -1,11 +1,29 @@
package org.jboss.seam.remoting;
+import org.dom4j.Element;
+
/**
*
* @author Shane Bryzak
*/
public class RequestContext
{
+ public RequestContext(Element header)
+ {
+ if (header != null)
+ {
+ Element context = header.element("context");
+ if (context != null)
+ {
+ Element convId = context.element("conversationId");
+ if (convId != null)
+ {
+ setConversationId(convId.getText());
+ }
+ }
+ }
+ }
+
private String conversationId;
public String getConversationId()
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestHandler.java 2009-12-06 13:24:44 UTC (rev 11760)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/RequestHandler.java 2009-12-06 20:35:02 UTC (rev 11761)
@@ -18,7 +18,18 @@
static final byte[] REF_TAG_OPEN_START = "<ref id=\"".getBytes();
static final byte[] REF_TAG_OPEN_END = "\">".getBytes();
static final byte[] REF_TAG_CLOSE = "</ref>".getBytes();
+
+
+ static final byte[] HEADER_OPEN = "<header>".getBytes();
+ static final byte[] HEADER_CLOSE = "</header>".getBytes();
+ static final byte[] CONVERSATION_ID_TAG_OPEN = "<conversationId>"
+ .getBytes();
+ static final byte[] CONVERSATION_ID_TAG_CLOSE = "</conversationId>"
+ .getBytes();
+ static final byte[] CONTEXT_TAG_OPEN = "<context>".getBytes();
+ static final byte[] CONTEXT_TAG_CLOSE = "</context>".getBytes();
+
void handle(HttpServletRequest request, HttpServletResponse response)
throws Exception;
}
Added: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java (rev 0)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java 2009-12-06 20:35:02 UTC (rev 11761)
@@ -0,0 +1,116 @@
+package org.jboss.seam.remoting.model;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+import java.util.Iterator;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.jboss.seam.remoting.Call;
+import org.jboss.seam.remoting.RequestContext;
+import org.jboss.seam.remoting.RequestHandler;
+import org.jboss.seam.remoting.wrapper.Wrapper;
+import org.jboss.weld.conversation.ConversationManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ModelHandler implements RequestHandler
+{
+ private static final Logger log = LoggerFactory.getLogger(ModelHandler.class);
+
+ @Inject BeanManager beanManager;
+ @Inject ConversationManager conversationManager;
+ @Inject Conversation conversation;
+ @Inject ModelRegistry registry;
+
+ public void handle(HttpServletRequest request, HttpServletResponse response)
+ throws Exception
+ {
+ response.setContentType("text/xml");
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ byte[] buffer = new byte[256];
+ int read = request.getInputStream().read(buffer);
+ while (read != -1)
+ {
+ out.write(buffer, 0, read);
+ read = request.getInputStream().read(buffer);
+ }
+
+ String requestData = new String(out.toByteArray());
+ log.debug("Processing model request: " + requestData);
+
+ SAXReader xmlReader = new SAXReader();
+ Document doc = xmlReader.read(new StringReader(requestData));
+ final Element env = doc.getRootElement();
+ final RequestContext ctx = new RequestContext(env.element("header"));
+
+ if (!ctx.getConversationId().isEmpty())
+ {
+ conversationManager.beginOrRestoreConversation(ctx.getConversationId());
+ }
+
+ Element modelElement = env.element("body").element("model");
+
+ String operation = modelElement.attributeValue("operation");
+ String id = modelElement.attributeValue("id");
+
+ if ("fetch".equals(operation))
+ {
+ Call action = null;
+ if (modelElement.elements("action").size() > 0)
+ {
+ Element actionElement = modelElement.element("action");
+ Element targetElement = actionElement.element("target");
+ Element qualifiersElement = actionElement.element("qualifiers");
+ Element methodElement = actionElement.element("method");
+ Element paramsElement = actionElement.element("params");
+ action = new Call(beanManager, id, targetElement.getTextTrim(),
+ qualifiersElement.getTextTrim(), methodElement.getTextTrim());
+
+ Element refsNode = modelElement.element("refs");
+
+ Iterator<?> iter = refsNode.elementIterator("ref");
+ while (iter.hasNext())
+ {
+ action.getContext().createWrapperFromElement((Element) iter.next());
+ }
+
+ for (Wrapper w : action.getContext().getInRefs().values())
+ {
+ w.unmarshal();
+ }
+
+ iter = paramsElement.elementIterator("param");
+ while (iter.hasNext())
+ {
+ Element param = (Element) iter.next();
+
+ action.addParameter(action.getContext().createWrapperFromElement(
+ (Element) param.elementIterator().next()));
+ }
+ }
+
+ // Unmarshal beans
+
+ // Unmarshal expressions
+
+ if (action != null)
+ {
+ action.execute();
+ }
+
+ }
+
+ // Store the conversation ID in the outgoing context
+ ctx.setConversationId(conversation.getId());
+ }
+}
15 years