Seam SVN: r11875 - in modules/remoting/trunk: src/main/java/org/jboss/seam/remoting and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-23 05:22:55 -0500 (Wed, 23 Dec 2009)
New Revision: 11875
Modified:
modules/remoting/trunk/examples/helloworld/src/main/webapp/helloworld.xhtml
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
dynamic component definition
Modified: modules/remoting/trunk/examples/helloworld/src/main/webapp/helloworld.xhtml
===================================================================
--- modules/remoting/trunk/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-22 09:21:03 UTC (rev 11874)
+++ modules/remoting/trunk/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-23 10:22:55 UTC (rev 11875)
@@ -42,6 +42,8 @@
<script type="text/javascript">
//<![CDATA[
+ Seam.debug = true;
+
function getRadioValue(options)
{
for (var i = 0; i < options.length; i++)
Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java 2009-12-22 09:21:03 UTC (rev 11874)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java 2009-12-23 10:22:55 UTC (rev 11875)
@@ -22,7 +22,6 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -286,8 +285,6 @@
private void appendBeanSource(OutputStream out, Class<?> beanClass, Set<Type> types)
throws IOException
{
- StringBuilder componentSrc = new StringBuilder();
-
Set<Class<?>> componentTypes = new HashSet<Class<?>>();
// Check if any of the methods are annotated with @WebRemote, and if so
@@ -325,19 +322,7 @@
String name = beanManager.getBeans(beanClass).iterator().next().getName();
String beanName = name != null ? name : beanClass.getName();
- if (beanName.contains("."))
- {
- componentSrc.append("Seam.createNamespace('");
- componentSrc.append(beanName.substring(0, beanName.lastIndexOf('.')));
- componentSrc.append("');\n");
- }
-
- componentSrc.append("Seam.type.");
- componentSrc.append(beanName);
- componentSrc.append(" = function() {\n");
- componentSrc.append(" this.__callback = new Object();\n");
-
for (Class<?> type : componentTypes)
{
if (types.contains(type))
@@ -348,68 +333,42 @@
{
types.add(type);
+ // Build the bean stub
+ StringBuilder componentSrc = new StringBuilder();
+ componentSrc.append("Seam.registerBean(\"");
+ componentSrc.append(beanName);
+ componentSrc.append("\", null, {");
+
+ boolean first = true;
for (Method m : type.getDeclaredMethods())
{
if (m.getAnnotation(WebRemote.class) == null)
continue;
+ if (!first)
+ {
+ componentSrc.append(", ");
+ }
+ else
+ {
+ first = false;
+ }
+
// Append the return type to the source block
appendTypeSource(out, m.getGenericReturnType(), types);
-
- componentSrc.append(" Seam.type.");
- componentSrc.append(beanName);
- componentSrc.append(".prototype.");
+
componentSrc.append(m.getName());
- componentSrc.append(" = function(");
+ componentSrc.append(": ");
+ componentSrc.append(m.getGenericParameterTypes().length);
- // Insert parameters p0..pN
for (int i = 0; i < m.getGenericParameterTypes().length; i++)
{
appendTypeSource(out, m.getGenericParameterTypes()[i], types);
-
- if (i > 0)
- {
- componentSrc.append(", ");
- }
- componentSrc.append("p");
- componentSrc.append(i);
- }
-
- if (m.getGenericParameterTypes().length > 0)
- componentSrc.append(", ");
-
- componentSrc.append("callback, exceptionHandler) {\n");
- componentSrc.append(" return Seam.execute(this, \"");
- componentSrc.append(m.getName());
- componentSrc.append("\", [");
-
- for (int i = 0; i < m.getParameterTypes().length; i++)
- {
- if (i > 0)
- componentSrc.append(", ");
- componentSrc.append("p");
- componentSrc.append(i);
- }
-
- componentSrc.append("], callback, exceptionHandler);\n");
- componentSrc.append(" }\n");
+ }
}
+ componentSrc.append("});\n");
+ out.write(componentSrc.toString().getBytes());
}
- componentSrc.append("}\n");
-
- // Set the component name
- componentSrc.append("Seam.type.");
- componentSrc.append(beanName);
- componentSrc.append(".__name = \"");
- componentSrc.append(beanName);
- componentSrc.append("\";\n\n");
-
- // Register the component
- componentSrc.append("Seam.registerBean(Seam.type.");
- componentSrc.append(beanName);
- componentSrc.append(");\n\n");
-
- out.write(componentSrc.toString().getBytes());
}
}
@@ -477,25 +436,12 @@
return;
}
- StringBuilder typeSource = new StringBuilder();
-
- // Determine whether this class is a component; if so, use its name
- // otherwise use its class name.
Bean<?> bean = beanManager.getBeans(classType).iterator().next();
String componentName = bean.getName();
if (componentName == null)
componentName = classType.getName();
- String typeName = componentName.replace('.', '$');
-
- typeSource.append("Seam.type.");
- typeSource.append(typeName);
- typeSource.append(" = function() {\n");
-
- StringBuilder fields = new StringBuilder();
- StringBuilder accessors = new StringBuilder();
- StringBuilder mutators = new StringBuilder();
Map<String, String> metadata = new HashMap<String, String>();
String getMethodName = null;
@@ -606,78 +552,28 @@
if (getMethodName != null || setMethodName != null)
{
metadata.put(propertyName, getFieldType(propertyType));
-
- fields.append(" this.");
- fields.append(propertyName);
- fields.append(" = undefined;\n");
-
- if (getMethodName != null)
- {
- accessors.append(" Seam.type.");
- accessors.append(typeName);
- accessors.append(".prototype.");
- accessors.append(getMethodName);
- accessors.append(" = function() { return this.");
- accessors.append(propertyName);
- accessors.append("; }\n");
- }
-
- if (setMethodName != null)
- {
- mutators.append(" Seam.type.");
- mutators.append(typeName);
- mutators.append(".prototype.");
- mutators.append(setMethodName);
- mutators.append(" = function(");
- mutators.append(propertyName);
- mutators.append(") { this.");
- mutators.append(propertyName);
- mutators.append(" = ");
- mutators.append(propertyName);
- mutators.append("; }\n");
- }
}
}
- typeSource.append(fields);
- typeSource.append(accessors);
- typeSource.append(mutators);
-
- typeSource.append("}\n\n");
-
- // Append the type name
- typeSource.append("Seam.type.");
- typeSource.append(typeName);
- typeSource.append(".__name = \"");
+ StringBuilder typeSource = new StringBuilder();
+ typeSource.append("Seam.registerBean(\"");
typeSource.append(componentName);
- typeSource.append("\";\n");
+ typeSource.append("\", {");
- // Append the metadata
- typeSource.append("Seam.type.");
- typeSource.append(typeName);
- typeSource.append(".__metadata = [\n");
-
boolean first = true;
-
for (String key : metadata.keySet())
{
if (!first)
- typeSource.append(",\n");
-
- typeSource.append(" {field: \"");
+ typeSource.append(", ");
typeSource.append(key);
- typeSource.append("\", type: \"");
+ typeSource.append(": \"");
typeSource.append(metadata.get(key));
- typeSource.append("\"}");
-
+ typeSource.append("\"");
first = false;
- }
+ }
+
+ typeSource.append("});\n");
- typeSource.append("];\n\n");
- typeSource.append("Seam.registerBean(Seam.type.");
- typeSource.append(typeName);
- typeSource.append(");\n\n");
-
out.write(typeSource.toString().getBytes());
}
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-22 09:21:03 UTC (rev 11874)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-23 10:22:55 UTC (rev 11875)
@@ -1,5 +1,4 @@
var Seam = {
- type: {},
beans: new Array(),
debug: false,
debugWindow: null,
@@ -39,15 +38,43 @@
return t ? t.__name : undefined;
}
-Seam.registerBean = function(bean) {
+Seam.registerBean = function(name, metadata, methods) {
+ var t = function() {};
+ t.__name = name;
+
+ if (metadata) {
+ var m = new Array();
+ for (var f in metadata) {
+ var s = f.substring(0,1).toUpperCase() + f.substring(1);
+ t.prototype["set" + s] = function(value) { this[f] = value; };
+ t.prototype["get" + s] = function() { return this[f]; };
+ m.push({field:f, type:metadata[f]});
+ }
+ t.__metadata = m;
+ }
+ else {
+ for (var m in methods) {
+ var pc = methods[m];
+ t.prototype[m] = function() {
+ var p = new Array();
+ for (var i=0; i<pc; i++) {
+ p[i] = arguments[i];
+ }
+ var c = (arguments.length > pc) ? arguments[pc] : undefined;
+ var eh = (arguments.length > (pc + 1)) ? arguments[pc + 1] : undefined;
+ return Seam.execute(this, m, p, c, eh);
+ };
+ }
+ }
+
var b = Seam.beans;
for (var i=0; i<b.length; i++) {
- if (b[i].__name == bean.__name) {
- b[i] = bean;
+ if (b[i].__name == name) {
+ b[i] = t;
return;
}
}
- b.push(bean);
+ b.push(t);
}
Seam.isBeanRegistered = function(name) {
@@ -106,15 +133,6 @@
}
}
-Seam.createNamespace = function(namespace) {
- var p = namespace.split(".");
- var b = Seam.type;
- for(var i=0; i<p.length; i++) {
- if (typeof b[p[i]] == "undefined") b[p[i]] = new Object();
- b = b[p[i]];
- }
-}
-
Seam.Context = function() {
this.conversationId = null;
Seam.Context.prototype.setConversationId = function(conversationId) {
15 years
Seam SVN: r11874 - 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: 2009-12-22 04:21:03 -0500 (Tue, 22 Dec 2009)
New Revision: 11874
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
fixed conversation management stuff, now we just need a transaction...
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-22 02:19:09 UTC (rev 11873)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java 2009-12-22 09:21:03 UTC (rev 11874)
@@ -9,7 +9,6 @@
import java.util.Set;
import javax.enterprise.context.Conversation;
-import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
@@ -24,7 +23,6 @@
import org.jboss.seam.remoting.RequestContext;
import org.jboss.seam.remoting.RequestHandler;
import org.jboss.seam.remoting.wrapper.Wrapper;
-import org.jboss.seam.remoting.wrapper.WrapperFactory;
import org.jboss.weld.Container;
import org.jboss.weld.context.ContextLifecycle;
import org.jboss.weld.context.ConversationContext;
@@ -45,7 +43,7 @@
@Inject BeanManager beanManager;
@Inject ConversationManager conversationManager;
@Inject ModelRegistry registry;
- @Inject Instance<Conversation> conversationInstance;
+ @Inject Conversation conversation;
@SuppressWarnings("unchecked")
public void handle(HttpServletRequest request, HttpServletResponse response)
@@ -73,19 +71,21 @@
ConversationContext conversationContext = null;
try
- {
+ {
// Initialize the conversation context
conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
- conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
- conversationContext.setActive(true);
if (ctx.getConversationId() != null && !ctx.getConversationId().isEmpty())
{
+ conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
+ conversationContext.setActive(true);
conversationManager.beginOrRestoreConversation(ctx.getConversationId());
}
else
{
- conversationManager.beginOrRestoreConversation(null);
+ conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(),
+ ((org.jboss.weld.conversation.ConversationImpl) conversation).getUnderlyingId()));
+ conversationContext.setActive(true);
}
Set<Model> models = new HashSet<Model>();
@@ -109,13 +109,13 @@
{
if (model.getAction() != null && model.getAction().getException() != null)
{
- out.write(ENVELOPE_TAG_OPEN);
- out.write(BODY_TAG_OPEN);
+ response.getOutputStream().write(ENVELOPE_TAG_OPEN);
+ response.getOutputStream().write(BODY_TAG_OPEN);
MarshalUtils.marshalException(model.getAction().getException(),
- model.getAction().getContext(), out);
- out.write(BODY_TAG_CLOSE);
- out.write(ENVELOPE_TAG_CLOSE);
- out.flush();
+ model.getAction().getContext(), response.getOutputStream());
+ response.getOutputStream().write(BODY_TAG_CLOSE);
+ response.getOutputStream().write(ENVELOPE_TAG_CLOSE);
+ response.getOutputStream().flush();
return;
}
}
@@ -125,12 +125,12 @@
model.evaluate();
}
- Conversation conversation = conversationInstance.get();
- ctx.setConversationId(conversation.getId());
+ ctx.setConversationId(conversation.isTransient() ? null : conversation.getId());
marshalResponse(models, ctx, response.getOutputStream());
}
finally
{
+ conversationManager.cleanupConversation();
if (conversationContext != null)
{
conversationContext.setBeanStore(null);
@@ -217,6 +217,7 @@
throws Exception
{
Model model = registry.getModel(modelElement.attributeValue("uid"));
+ models.add(model);
model.setCallId(callId);
model.setAction(null);
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-22 02:19:09 UTC (rev 11873)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-22 09:21:03 UTC (rev 11874)
@@ -472,10 +472,9 @@
var contextNode = cn(headerNode, "context");
if (contextNode) {
Seam.unmarshalContext(contextNode, ctx);
- if (ctx.getConversationId() && Seam.context.getConversationId() == null)
- Seam.context.setConversationId(ctx.getConversationId());
}
}
+ Seam.context.setConversationId(ctx.getConversationId() ? ctx.getConversationId() : null);
if (bodyNode) {
var n = cn(bodyNode, "result");
if (n) {
15 years
Seam SVN: r11873 - in modules/remoting/trunk: src/main/java/org/jboss/seam/remoting/model and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-12-21 21:19:09 -0500 (Mon, 21 Dec 2009)
New Revision: 11873
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
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
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
server side handling for model apply updates
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2009-12-22 00:31:37 UTC (rev 11872)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2009-12-22 02:19:09 UTC (rev 11873)
@@ -38,8 +38,13 @@
model.getValue("customer").setFirstName("bob");
}
- function applyModel() {
- model.applyUpdates();
+ function applyUpdates() {
+ var callback = function(model) { alert("updates applied"); };
+
+ model.applyUpdates(new Seam.Action()
+ .setBeanType("org.jboss.seam.remoting.examples.model.CustomerAction")
+ .setMethod("saveCustomer"),
+ callback);
}
// ]]>
@@ -49,7 +54,7 @@
<button onclick="javascript:loadCustomer()">Load customer</button>
<button onclick="javascript:modifyCustomer()">Modify customer</button>
- <button onclick="javascript:applyModel()">Apply changes</button>
+ <button onclick="javascript:applyUpdates()">Apply updates</button>
</body>
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-22 00:31:37 UTC (rev 11872)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/Model.java 2009-12-22 02:19:09 UTC (rev 11873)
@@ -3,6 +3,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -16,6 +17,8 @@
import org.jboss.seam.remoting.AnnotationsParser;
import org.jboss.seam.remoting.Call;
import org.jboss.seam.remoting.CallContext;
+import org.jboss.seam.remoting.wrapper.ConversionException;
+import org.jboss.seam.remoting.wrapper.Wrapper;
/**
* Manages a model request
@@ -30,6 +33,7 @@
private String id;
private String callId;
private CallContext callContext;
+ private Call action;
public class BeanProperty implements Serializable
{
@@ -189,8 +193,70 @@
beanProperties.put(alias, new BeanProperty(bean, propertyName));
}
+ public void setModelProperty(int refId, String name, Wrapper wrapper)
+ {
+ Wrapper outRef = callContext.getOutRefs().get(refId);
+
+ try
+ {
+ Field f = outRef.getValue().getClass().getField(name);
+ if (wrapper.conversionScore(f.getType()).getScore() > 0)
+ {
+ // found a match
+ boolean accessible = f.isAccessible();
+ try
+ {
+ if (!f.isAccessible()) f.setAccessible(true);
+ f.set(outRef.getValue(), wrapper.convert(f.getType()));
+ }
+ catch (ConversionException ex)
+ {
+ throw new RuntimeException("Exception converting model property value", ex);
+ }
+ catch (IllegalAccessException ex)
+ {
+ throw new RuntimeException("Exception setting model property", ex);
+ }
+ finally
+ {
+ f.setAccessible(accessible);
+ }
+ }
+ }
+ catch (NoSuchFieldException ex)
+ {
+ String methodName = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
+ for (Method m : outRef.getValue().getClass().getMethods())
+ {
+ if (m.getName().equals(methodName) && m.getParameterTypes().length == 1 &&
+ wrapper.conversionScore(m.getParameterTypes()[0]).getScore() > 0)
+ {
+ try
+ {
+ m.invoke(outRef.getValue(), wrapper.convert(m.getParameterTypes()[0]));
+ break;
+ }
+ catch (Exception ex2)
+ {
+ throw new RuntimeException("Exception converting model property value", ex2);
+ }
+ }
+ }
+ }
+ }
+
public void applyChanges(Set<ChangeSet> delta)
{
}
+
+ public void setAction(Call action)
+ {
+ this.action = action;
+ }
+
+ public Call getAction()
+ {
+ return action;
+ }
}
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-22 00:31:37 UTC (rev 11872)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java 2009-12-22 02:19:09 UTC (rev 11873)
@@ -4,13 +4,12 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
@@ -20,10 +19,12 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jboss.seam.remoting.Call;
+import org.jboss.seam.remoting.CallContext;
import org.jboss.seam.remoting.MarshalUtils;
import org.jboss.seam.remoting.RequestContext;
import org.jboss.seam.remoting.RequestHandler;
import org.jboss.seam.remoting.wrapper.Wrapper;
+import org.jboss.seam.remoting.wrapper.WrapperFactory;
import org.jboss.weld.Container;
import org.jboss.weld.context.ContextLifecycle;
import org.jboss.weld.context.ConversationContext;
@@ -43,8 +44,8 @@
@Inject BeanManager beanManager;
@Inject ConversationManager conversationManager;
- @Inject Conversation conversation;
@Inject ModelRegistry registry;
+ @Inject Instance<Conversation> conversationInstance;
@SuppressWarnings("unchecked")
public void handle(HttpServletRequest request, HttpServletResponse response)
@@ -70,116 +71,196 @@
final Element env = doc.getRootElement();
final RequestContext ctx = new RequestContext(env.element("header"));
- // Initialize the conversation context
- ConversationContext conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
- conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
- conversationContext.setActive(true);
-
- if (ctx.getConversationId() != null && !ctx.getConversationId().isEmpty())
- {
- conversationManager.beginOrRestoreConversation(ctx.getConversationId());
- }
- else
+ ConversationContext conversationContext = null;
+ try
{
- conversationManager.beginOrRestoreConversation(null);
- }
-
- Set<Model> models = new HashSet<Model>();
- Call action = null;
-
- for (Element modelElement : (List<Element>) env.element("body").elements("model"))
- {
- String operation = modelElement.attributeValue("operation");
- String callId = modelElement.attributeValue("callId");
+ // Initialize the conversation context
+ conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
+ conversationContext.setBeanStore(new ConversationBeanStore(request.getSession(), ctx.getConversationId()));
+ conversationContext.setActive(true);
- if ("fetch".equals(operation))
+ if (ctx.getConversationId() != null && !ctx.getConversationId().isEmpty())
+ {
+ conversationManager.beginOrRestoreConversation(ctx.getConversationId());
+ }
+ else
{
- Model model = registry.createModel();
- models.add(model);
- model.setCallId(callId);
+ conversationManager.beginOrRestoreConversation(null);
+ }
+
+ Set<Model> models = new HashSet<Model>();
+
+ for (Element modelElement : (List<Element>) env.element("body").elements("model"))
+ {
+ String operation = modelElement.attributeValue("operation");
+ String callId = modelElement.attributeValue("callId");
- if (modelElement.elements("action").size() > 0)
+ 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");
- Element refsElement = actionElement.element("refs");
-
- action = new Call(beanManager, callId, targetElement.getTextTrim(),
- qualifiersElement != null ? qualifiersElement.getTextTrim() : null,
- methodElement != null ? methodElement.getTextTrim() : null);
-
- if (refsElement != null)
- {
- for (Element refElement : (List<Element>) refsElement.elements("ref"))
- {
- action.getContext().createWrapperFromElement(refElement);
- }
-
- for (Wrapper w : action.getContext().getInRefs().values())
- {
- w.unmarshal();
- }
- }
-
- if (paramsElement != null)
- {
- for (Element paramElement : (List<Element>) paramsElement.elements("param"))
- {
- action.addParameter(action.getContext().createWrapperFromElement(
- (Element) paramElement.elements().get(0)));
- }
- }
+ processFetchRequest(modelElement, models, callId);
}
-
- for (Element beanElement : (List<Element>) modelElement.elements("bean"))
+ else if ("apply".equals(operation))
{
- Element beanNameElement = beanElement.element("name");
- Element beanQualifierElement = beanElement.element("qualifier");
- Element beanPropertyElement = beanElement.element("property");
-
- model.addBean(beanElement.attributeValue("alias"),
- beanNameElement.getTextTrim(),
- beanQualifierElement != null ? beanQualifierElement.getTextTrim() : null,
- beanPropertyElement != null ? beanPropertyElement.getTextTrim() : null);
+ processApplyRequest(modelElement, models, callId);
}
-
- // TODO Unmarshal expressions - don't support this until security implications investigated
- for (Element exprElement : (List<Element>) modelElement.elements("expression"))
+ }
+
+ for (Model model : models)
+ {
+ if (model.getAction() != null && model.getAction().getException() != null)
{
-
+ out.write(ENVELOPE_TAG_OPEN);
+ out.write(BODY_TAG_OPEN);
+ MarshalUtils.marshalException(model.getAction().getException(),
+ model.getAction().getContext(), out);
+ out.write(BODY_TAG_CLOSE);
+ out.write(ENVELOPE_TAG_CLOSE);
+ out.flush();
+ return;
}
-
- if (action != null)
- {
- action.execute();
- }
}
- }
-
- if (action != null && action.getException() != null)
- {
- out.write(ENVELOPE_TAG_OPEN);
- out.write(BODY_TAG_OPEN);
- MarshalUtils.marshalException(action.getException(), action.getContext(), out);
- out.write(BODY_TAG_CLOSE);
- out.write(ENVELOPE_TAG_CLOSE);
- out.flush();
- }
- else
- {
+
for (Model model : models)
{
model.evaluate();
}
+ Conversation conversation = conversationInstance.get();
ctx.setConversationId(conversation.getId());
marshalResponse(models, ctx, response.getOutputStream());
}
+ finally
+ {
+ if (conversationContext != null)
+ {
+ conversationContext.setBeanStore(null);
+ conversationContext.setActive(false);
+ }
+ }
}
+ @SuppressWarnings({ "unchecked" })
+ private void processFetchRequest(Element modelElement, Set<Model> models, String callId)
+ throws Exception
+ {
+ Model model = registry.createModel();
+ models.add(model);
+ model.setCallId(callId);
+
+ if (modelElement.elements("action").size() > 0)
+ {
+ unmarshalAction(modelElement.element("action"), model, callId);
+ }
+
+ for (Element beanElement : (List<Element>) modelElement.elements("bean"))
+ {
+ Element beanNameElement = beanElement.element("name");
+ Element beanQualifierElement = beanElement.element("qualifier");
+ Element beanPropertyElement = beanElement.element("property");
+
+ model.addBean(beanElement.attributeValue("alias"),
+ beanNameElement.getTextTrim(),
+ beanQualifierElement != null ? beanQualifierElement.getTextTrim() : null,
+ beanPropertyElement != null ? beanPropertyElement.getTextTrim() : null);
+ }
+
+ // TODO Unmarshal expressions - don't support this until security implications investigated
+ for (Element exprElement : (List<Element>) modelElement.elements("expression"))
+ {
+
+ }
+
+ if (model.getAction() != null)
+ {
+ model.getAction().execute();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void unmarshalAction(Element actionElement, Model model, String callId)
+ {
+ 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");
+
+ model.setAction(new Call(beanManager, callId, targetElement.getTextTrim(),
+ qualifiersElement != null ? qualifiersElement.getTextTrim() : null,
+ methodElement != null ? methodElement.getTextTrim() : null));
+
+ if (refsElement != null)
+ {
+ for (Element refElement : (List<Element>) refsElement.elements("ref"))
+ {
+ model.getAction().getContext().createWrapperFromElement(refElement);
+ }
+
+ for (Wrapper w : model.getAction().getContext().getInRefs().values())
+ {
+ w.unmarshal();
+ }
+ }
+
+ if (paramsElement != null)
+ {
+ for (Element paramElement : (List<Element>) paramsElement.elements("param"))
+ {
+ model.getAction().addParameter(model.getAction().getContext().createWrapperFromElement(
+ (Element) paramElement.elements().get(0)));
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void processApplyRequest(Element modelElement, Set<Model> models, String callId)
+ throws Exception
+ {
+ Model model = registry.getModel(modelElement.attributeValue("uid"));
+ model.setCallId(callId);
+ model.setAction(null);
+
+ CallContext ctx = new CallContext(beanManager);
+
+ Element refsElement = modelElement.element("refs");
+ for (Element ref : (List<Element>) refsElement.elements("ref"))
+ {
+ ctx.createWrapperFromElement(ref);
+ }
+
+ Element delta = modelElement.element("delta");
+ if (delta != null)
+ {
+ List<Element> changesets = delta.elements("changeset");
+ for (Element changeset : changesets)
+ {
+ int refId = Integer.parseInt(changeset.attributeValue("refid"));
+
+ if (changeset.elements("member").size() > 0)
+ {
+ for (Element member : (List<Element>) changeset.elements("member"))
+ {
+ String name = member.attributeValue("name");
+ Wrapper w = model.getCallContext().createWrapperFromElement(
+ (Element) member.elementIterator().next());
+ model.setModelProperty(refId, name, w);
+ }
+ }
+
+ }
+ }
+
+ if (modelElement.elements("action").size() > 0)
+ {
+ unmarshalAction(modelElement.element("action"), model, callId);
+ }
+
+ if (model.getAction() != null)
+ {
+ model.getAction().execute();
+ }
+ }
+
private void marshalResponse(Set<Model> models, RequestContext ctx,
OutputStream out) throws IOException
{
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-22 00:31:37 UTC (rev 11872)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-22 02:19:09 UTC (rev 11873)
@@ -928,7 +928,7 @@
Seam.Model.prototype.createApplyRequest = function(a, delta) {
var callId = "" + Seam.__callId++;
- var d = "<model operation=\"apply\" callId=\"" + callId + "\">";
+ var d = "<model uid=\"" + this.id + "\" operation=\"apply\" callId=\"" + callId + "\">";
var refs = delta.buildRefs();
if (a) {
d += "<action>";
15 years
Seam SVN: r11872 - build/trunk/module-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-12-21 19:31:37 -0500 (Mon, 21 Dec 2009)
New Revision: 11872
Modified:
build/trunk/module-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml
Log:
whitespace
Modified: build/trunk/module-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml
===================================================================
--- build/trunk/module-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml 2009-12-22 00:24:38 UTC (rev 11871)
+++ build/trunk/module-archetype/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml 2009-12-22 00:31:37 UTC (rev 11872)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- The contents of this file is permitted to be empty. The schema
- definition is provided for your convenience.
- -->
+<!--
+ The contents of this file is permitted to be empty.
+ The schema definition is provided for your convenience.
+-->
<beans 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
15 years
Seam SVN: r11871 - in modules/persistence/trunk/src/test/java/org: jboss and 3 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-12-21 19:24:38 -0500 (Mon, 21 Dec 2009)
New Revision: 11871
Added:
modules/persistence/trunk/src/test/java/org/jboss/
modules/persistence/trunk/src/test/java/org/jboss/seam/
modules/persistence/trunk/src/test/java/org/jboss/seam/persistence/
Removed:
modules/persistence/trunk/src/test/java/org/seamframework/persistence/
Modified:
modules/persistence/trunk/src/test/java/org/jboss/seam/persistence/PersistenceContextExtensionTest.java
Log:
switch to package org.jboss.seam
Copied: modules/persistence/trunk/src/test/java/org/jboss/seam/persistence (from rev 11869, modules/persistence/trunk/src/test/java/org/seamframework/persistence)
Modified: modules/persistence/trunk/src/test/java/org/jboss/seam/persistence/PersistenceContextExtensionTest.java
===================================================================
--- modules/persistence/trunk/src/test/java/org/seamframework/persistence/PersistenceContextExtensionTest.java 2009-12-21 14:32:48 UTC (rev 11869)
+++ modules/persistence/trunk/src/test/java/org/jboss/seam/persistence/PersistenceContextExtensionTest.java 2009-12-22 00:24:38 UTC (rev 11871)
@@ -1,4 +1,4 @@
-package org.seamframework.persistence;
+package org.jboss.seam.persistence;
import org.jboss.weld.test.AbstractWeldTest;
import org.testng.annotations.Test;
15 years
Seam SVN: r11870 - in modules/persistence/trunk/src/main: java/org/jboss and 4 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-12-21 19:23:17 -0500 (Mon, 21 Dec 2009)
New Revision: 11870
Added:
modules/persistence/trunk/src/main/java/org/jboss/
modules/persistence/trunk/src/main/java/org/jboss/seam/
modules/persistence/trunk/src/main/java/org/jboss/seam/persistence/
Removed:
modules/persistence/trunk/src/main/java/org/seamframework/persistence/
Modified:
modules/persistence/trunk/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
modules/persistence/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Log:
switch package to org.jboss.seam
Copied: modules/persistence/trunk/src/main/java/org/jboss/seam/persistence (from rev 11869, modules/persistence/trunk/src/main/java/org/seamframework/persistence)
Modified: modules/persistence/trunk/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/src/main/java/org/seamframework/persistence/PersistenceContextExtension.java 2009-12-21 14:32:48 UTC (rev 11869)
+++ modules/persistence/trunk/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java 2009-12-22 00:23:17 UTC (rev 11870)
@@ -1,4 +1,4 @@
-package org.seamframework.persistence;
+package org.jboss.seam.persistence;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@@ -194,4 +194,4 @@
{
abd.addBean(emfBean);
}
-}
\ No newline at end of file
+}
Modified: modules/persistence/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- modules/persistence/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2009-12-21 14:32:48 UTC (rev 11869)
+++ modules/persistence/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2009-12-22 00:23:17 UTC (rev 11870)
@@ -1 +1 @@
-org.seamframework.persistence.PersistenceContextExtension
\ No newline at end of file
+org.jboss.seam.persistence.PersistenceContextExtension
15 years
Seam SVN: r11869 - in branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest: seamgen and 2 other directories.
by seam-commits@lists.jboss.org
Author: oskutka(a)redhat.com
Date: 2009-12-21 09:32:48 -0500 (Mon, 21 Dec 2009)
New Revision: 11869
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
Log:
JBQA-2923: Backporting JBSEAM-4445
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-12-21 13:35:18 UTC (rev 11868)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/ftest.properties 2009-12-21 14:32:48 UTC (rev 11869)
@@ -80,4 +80,4 @@
action.package=com.example
test.package=com.example.test
richfaces.skin=classic
-
+# ant.exec=/usr/bin/ant
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml 2009-12-21 13:35:18 UTC (rev 11868)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/build.xml 2009-12-21 14:32:48 UTC (rev 11869)
@@ -40,9 +40,6 @@
<!-- common path setup -->
<path id="classpath.build">
- <fileset dir="${root.lib.dir}">
- <include name="gen/ant.jar"/>
- </fileset>
<fileset dir="${ftest.lib.dir}" includes="**/*.jar" />
</path>
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-12-21 13:35:18 UTC (rev 11868)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-12-21 14:32:48 UTC (rev 11869)
@@ -53,6 +53,7 @@
protected static String SEAMGEN_BUILDFILE;
protected static String SEAMGEN_PROPERTIES_FILE;
protected static String WORKSPACE;
+ protected static String ANT_EXECUTABLE;
// container specific properties
protected static String CONTAINER;
@@ -115,7 +116,7 @@
setSeamGenProperties();
- seamGen = new SeamGenAdapter(SEAMGEN_BUILDFILE);
+ seamGen = new SeamGenAdapter(ANT_EXECUTABLE, SEAMGEN_BUILDFILE);
seamGen.setExplode(explode);
}
@@ -139,6 +140,7 @@
ftestProperties.load(new FileInputStream(SEAM_FTEST_PROPERTIES_FILE));
WORKSPACE = ftestProperties.getProperty("workspace.home");
+ ANT_EXECUTABLE = ftestProperties.getProperty("ant.exec", "ant");
// container specific
CONTAINER = ftestProperties.getProperty("container", "jboss");
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-12-21 13:35:18 UTC (rev 11868)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-12-21 14:32:48 UTC (rev 11869)
@@ -21,15 +21,13 @@
*/
package org.jboss.seam.test.functional.seamgen.utils;
-import java.io.File;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.PrintStream;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DefaultLogger;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.input.InputHandler;
-import org.apache.tools.ant.input.InputRequest;
+import org.jboss.seam.test.functional.seamgen.SeamGenTest;
/**
* This class wraps seam-gen ant script in order to be easily usable from Java.
@@ -43,60 +41,84 @@
public class SeamGenAdapter
{
- private String buildfile;
- private DefaultLogger log;
- private boolean explode = true;
+ protected String buildfile;
+ protected boolean explode = true;
+ protected PrintStream out, err;
+ protected String antExecutable;
- public SeamGenAdapter(String buildfile)
+ public SeamGenAdapter(String antExecutable, String buildfile)
{
- this(buildfile, System.out, System.err);
+ this(antExecutable, buildfile, System.out, System.err);
}
- public SeamGenAdapter(String buildfile, PrintStream out, PrintStream err)
+ public SeamGenAdapter(String antExecutable, String buildfile, PrintStream out, PrintStream err)
{
+ this.antExecutable = antExecutable;
this.buildfile = buildfile;
- log = new DefaultLogger();
- log.setOutputPrintStream(out);
- log.setErrorPrintStream(err);
- log.setMessageOutputLevel(Project.MSG_INFO);
+ this.err = err;
+ this.out = out;
}
- public Project getAntCall()
+ private String getAntCommand(String task)
{
- Project ant = new Project();
- ant.init();
- ProjectHelper.configureProject(ant, new File(buildfile));
- ant.addBuildListener(log);
- return ant;
+ return antExecutable + " -f " + buildfile + " " + task;
}
+ protected void executeAntTarget(String task)
+ {
+ executeAntTarget(task, null);
+ }
+
+ protected void executeAntTarget(String task, String[] properties)
+ {
+ try
+ {
+ OutputStreamFeeder feeder = null;
+ String antCommand = getAntCommand(task);
+ out.print(antCommand);
+ Process process = Runtime.getRuntime().exec((antCommand));
+ if (properties != null && properties.length > 0)
+ {
+ feeder = new OutputStreamFeeder(process.getOutputStream(), out, properties);
+ feeder.start();
+ }
+ // Associate the stdout InputStreamEater with the properties feeder to
+ // have the feeder type in a line from the properties whenever the eater
+ // encounters an input challenge.
+ (new InputStreamEater(process.getInputStream(), out, feeder)).start();
+ (new InputStreamEater(process.getErrorStream(), err, null)).start();
+ process.waitFor();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.toString());
+ }
+ }
+
public void createProject()
{
- getAntCall().executeTarget("create-project");
+ executeAntTarget("create-project");
}
public void deleteProject()
{
- getAntCall().executeTarget("delete-project");
+ executeAntTarget("delete-project");
}
public void newAction(String[] properties)
{
- Project project = getAntCall();
- project.setInputHandler(getInputHandler(properties));
- project.executeTarget("new-action");
+ executeAntTarget("new-action", properties);
}
public void newForm(String[] properties)
{
- Project project = getAntCall();
- project.setInputHandler(getInputHandler(properties));
- project.executeTarget("new-form");
+ executeAntTarget("new-form", properties);
}
public void generateEntities()
{
- getAntCall().executeTarget("generate-entities");
+ executeAntTarget("generate");
}
/**
@@ -107,11 +129,11 @@
{
if (explode)
{
- getAntCall().executeTarget("explode");
+ executeAntTarget("explode");
}
else
{
- getAntCall().executeTarget("deploy");
+ executeAntTarget("deploy");
}
}
@@ -123,11 +145,11 @@
{
if (explode)
{
- getAntCall().executeTarget("unexplode");
+ executeAntTarget("unexplode");
}
else
{
- getAntCall().executeTarget("undeploy");
+ executeAntTarget("undeploy");
}
}
@@ -135,7 +157,7 @@
{
if (explode)
{
- getAntCall().executeTarget("explode");
+ executeAntTarget("explode");
}
else
{
@@ -145,53 +167,14 @@
public void restart()
{
- if (explode)
- {
- getAntCall().executeTarget("restart");
- } else {
- getAntCall().executeTarget("deploy");
- }
+ executeAntTarget("restart");
}
public void addIdentityManagement()
{
- getAntCall().executeTarget("add-identity-management");
+ executeAntTarget("add-identity-management");
}
- private InputHandler getInputHandler(final String[] properties)
- {
- return new InputHandler()
- {
- public void handleInput(InputRequest request) throws BuildException
- {
- if (request.getPrompt().contains("Enter the Seam component name"))
- {
- request.setInput(properties[0]);
- }
- else if (request.getPrompt().contains("Enter the local interface name"))
- {
- request.setInput(properties[1]);
- }
- else if (request.getPrompt().contains("Enter the bean class name"))
- {
- request.setInput(properties[2]);
- }
- else if (request.getPrompt().contains("Enter the action method name"))
- {
- request.setInput(properties[3]);
- }
- else if (request.getPrompt().contains("Enter the page name"))
- {
- request.setInput(properties[4]);
- }
- else
- {
- throw new RuntimeException("Unexpected prompt " + request.getPrompt());
- }
- }
- };
- }
-
public boolean isExplode()
{
return explode;
@@ -206,4 +189,95 @@
this.explode = explode;
}
+ /**
+ * EatInputStreamData class is used for handling InputStream (stdout, stderr)
+ * of an ant sub-process. When it encounters an input challenge, it notifies
+ * the associated {@link OutputStreamFeeder} to provide the input.
+ *
+ */
+ class InputStreamEater extends Thread
+ {
+ private static final String INPUT_CHALLENGE = "[input]";
+ private BufferedReader stream;
+ private OutputStreamFeeder feederToNotify;
+ private PrintStream out;
+
+ public InputStreamEater(InputStream stream, PrintStream out, OutputStreamFeeder feederToNotify)
+ {
+ this.stream = new BufferedReader(new InputStreamReader(stream));
+ this.out = out;
+ this.feederToNotify = feederToNotify;
+ setDaemon(true);
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ String line;
+ while ((line = stream.readLine()) != null)
+ {
+ out.println(line);
+ if (feederToNotify != null && line.contains(INPUT_CHALLENGE))
+ {
+ // notify OutputStreamFeeder to send an input
+ feederToNotify.feed();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ /**
+ * OutputStreamFeeder class is used for feeding OutputStream (stdin) of an
+ * ant sub-process with appropriate inputs. It waits for a notification from
+ * the associated {@link InputStreamEater} object.
+ *
+ */
+ class OutputStreamFeeder extends Thread
+ {
+
+ PrintStream stream, out;
+ String[] food;
+
+ public OutputStreamFeeder(OutputStream stream, PrintStream out, String[] food)
+ {
+ this.stream = new PrintStream(stream);
+ this.food = food;
+ this.out = out;
+ setDaemon(true);
+ }
+
+ @Override
+ public synchronized void run()
+ {
+ try
+ {
+ for (int i = 0; i < food.length; i++)
+ {
+ // wait for a notification from EatInputStreamData
+ wait();
+ stream.println(food[i]);
+ stream.flush();
+ out.println("Typed: " + food[i]);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public synchronized void feed()
+ {
+ this.notify();
+ }
+
+ }
}
15 years
Seam SVN: r11868 - branches/enterprise/JBPAPP_4_2_CP01.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-12-21 08:35:18 -0500 (Mon, 21 Dec 2009)
New Revision: 11868
Modified:
branches/enterprise/JBPAPP_4_2_CP01/build.xml
Log:
JBPAPP-3294
Modified: branches/enterprise/JBPAPP_4_2_CP01/build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_2_CP01/build.xml 2009-12-21 12:18:55 UTC (rev 11867)
+++ branches/enterprise/JBPAPP_4_2_CP01/build.xml 2009-12-21 13:35:18 UTC (rev 11868)
@@ -1515,5 +1515,88 @@
<delete file="${tomcat.home}/webapps/${example.name}.war"/>
<delete dir="${tomcat.home}/webapps/${example.name}"/>
</target>
-
+
+ <target name="eap.testall" depends="eap.testcore" description="Run EAP unit and integration testsuite">
+ <!-- Run integration tests -->
+ <ant dir="examples/booking" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/dvdstore" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/hibernate" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/messages" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/numberguess" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/registration" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/todo" target="eap.testexample" inheritall="false" />
+ <ant dir="examples/blog" target="eap.testexample" inheritall="false" />
+
+ <!-- Create a report -->
+ <mkdir dir="report" />
+ <junitreport todir="./report">
+ <fileset dir=".">
+ <include name="**/test-output/*.xml" />
+ <exclude name="**/testng-failures.xml" />
+ </fileset>
+ <report format="frames" todir="./report" />
+ </junitreport>
+
+ <echo>Report available at ${basedir}/report/index.html</echo>
+ </target>
+
+ <target name="eap.testcore">
+
+ <path id="eap.test.classpath">
+ <path refid="test.classpath" />
+ <fileset dir="${imported.basedir}">
+ <include name="jboss-seam.jar" />
+ </fileset>
+ </path>
+
+ <mkdir dir="${build.dir}/test" />
+
+ <!-- Compile core tests -->
+ <javac source="1.5" target="1.5" destdir="${build.dir}/test" classpathref="build.classpath" debug="${javac.debug}" deprecation="${javac.deprecation}" nowarn="on">
+ <src path="${src.test.dir}" />
+ <classpath>
+ <fileset dir="${imported.basedir}">
+ <include name="jboss-seam-remoting.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+
+ <copy todir="${build.dir}/test">
+ <fileset dir="${src.java.dir}">
+ <include name="META-INF/*.xml" />
+ </fileset>
+ </copy>
+
+ <taskdef resource="testngtasks" classpath="${testng.jar}" />
+
+ <!-- Run core tests -->
+ <testng>
+ <classpath refid="eap.test.classpath" />
+ <xmlfileset dir="${src.test.dir}" includes="**/*.xml" />
+ </testng>
+ </target>
+
+ <target name="eap.testexample" depends="compile">
+
+ <taskdef resource="testngtasks" classpath="${testng.jar}" />
+
+ <copy todir="${build.dir}/test">
+ <fileset dir="${classes.dir}" includes="**/*.*" />
+ <fileset refid="example.resources" />
+ </copy>
+
+ <delete dir="test-output" />
+
+ <testng outputdir="test-output">
+ <classpath path="${example.coverage.dir}/classes" />
+ <!-- TODO: ugly! -->
+ <classpath path="${build.dir}/test" />
+ <classpath path="${mc.conf.dir}" />
+ <classpath refid="${test.classpath}" />
+ <classpath refid="eap.test.classpath" />
+ <xmlfileset dir="${src.test.dir}" includes="**/*.xml" />
+ </testng>
+
+ </target>
+
</project>
15 years
Seam SVN: r11867 - branches/enterprise/JBPAPP_4_3_FP01.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2009-12-21 07:18:55 -0500 (Mon, 21 Dec 2009)
New Revision: 11867
Modified:
branches/enterprise/JBPAPP_4_3_FP01/build.xml
Log:
JBPAPP-3294
Modified: branches/enterprise/JBPAPP_4_3_FP01/build.xml
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/build.xml 2009-12-21 01:51:21 UTC (rev 11866)
+++ branches/enterprise/JBPAPP_4_3_FP01/build.xml 2009-12-21 12:18:55 UTC (rev 11867)
@@ -945,6 +945,70 @@
</eclipseClasspath>
</target>
+ <!-- EAP 4.3 testing targets -->
+ <target name="eap.testall" depends="initpoms" description="Run the core tests">
+ <init classesdir="${classes.test.dir}" srcdir="${src.unit.test.dir}" modulename="core" pom="${core.pom}" scope="test" message="" />
+ <path id="eap.test.compile.path">
+ <path refid="test.core.path" />
+ <fileset dir="${seam.dir}/lib">
+ <include name="jboss-seam.jar" />
+ <include name="jboss-seam-remoting.jar" />
+ </fileset>
+ </path>
+
+ <path id="eap.test.run.path">
+ <path path="${seam.dir}/bootstrap" />
+ <fileset dir="${seam.dir}/lib/test">
+ <include name="*.jar" />
+ </fileset>
+ <path refid="eap.test.compile.path"/>
+ <path path="${classes.test.dir}"/>
+ </path>
+
+ <!-- Compile tests -->
+ <mkdir dir="${classes.test.dir}"/>
+ <compile classesdir="${classes.test.dir}" srcdir="${src.unit.test.dir}" classpath="eap.test.compile.path" />
+
+ <!-- Run unit tests -->
+ <taskdef resource="testngtasks" classpathref="eap.test.run.path" />
+ <testng outputdir="${test.dir}">
+ <jvmarg line="-Xmx800M" />
+ <jvmarg line="-Djava.awt.headless=true" />
+ <jvmarg line="-Demma.coverage.out.file=${coverage.ec}" />
+ <jvmarg line="-Djava.endorsed.dirs=${endorsed.dir}" />
+ <!--added for JDK6 compatibility with JBoss embedded-->
+ <jvmarg line="-Dsun.lang.ClassLoader.allowArraySyntax=true"/>
+ <jvmarg line="${testng.jvmargs}" />
+ <classpath refid="eap.test.run.path"/>
+ <xmlfileset dir="${src.unit.test.dir}" includes="**/testng.xml" />
+ </testng>
+
+ <!-- Run integration tests -->
+ <testexample name="integration" path="${seam.dir}/src/test/integration"/>
+ <testexample name="booking" />
+ <testexample name="nestedbooking" />
+ <testexample name="dvdstore" />
+ <testexample name="messages" />
+ <testexample name="numberguess" />
+ <testexample name="contactlist" />
+ <testexample name="registration" />
+ <testexample name="todo" />
+ <testexample name="blog" />
+ <testexample name="seamdiscs" />
+ <testexample name="seambay" />
+ <testexample name="seamspace" />
+ <testexample name="drools" />
+ <testexample name="mail" />
+ <testexample name="seampay" />
+ <testexample name="itext" />
+ <testexample name="hibernate" />
+ <testexample name="jpa" />
+ <testexample name="quartz" />
+
+
+ <echo>You can increase the logging by editing bootstrap/log4j.xml</echo>
+ </target>
+
</project>
15 years
Seam SVN: r11866 - 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: 2009-12-20 20:51:21 -0500 (Sun, 20 Dec 2009)
New Revision: 11866
Modified:
modules/remoting/trunk/examples/model/src/main/webapp/model.html
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
added apply changes logic, fixed script errors
Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html 2009-12-17 18:50:09 UTC (rev 11865)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html 2009-12-21 01:51:21 UTC (rev 11866)
@@ -17,11 +17,13 @@
//<![CDATA[
Seam.debug = true;
+
+ var model = null;
function loadCustomer() {
var customerId = document.getElementById("customerId").value;
- var model = new Seam.Model();
+ model = new Seam.Model();
var callback = function(model) { alert(model.getValue("customer").getFirstName()); };
@@ -31,6 +33,14 @@
.setMethod("editCustomer")
.addParam(customerId), callback);
}
+
+ function modifyCustomer() {
+ model.getValue("customer").setFirstName("bob");
+ }
+
+ function applyModel() {
+ model.applyUpdates();
+ }
// ]]>
</script>
@@ -38,6 +48,8 @@
<label for="customerId">Customer ID</label><input type="text" id="customerId" value="1"/>
<button onclick="javascript:loadCustomer()">Load customer</button>
+ <button onclick="javascript:modifyCustomer()">Modify customer</button>
+ <button onclick="javascript:applyModel()">Apply changes</button>
</body>
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-17 18:50:09 UTC (rev 11865)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-21 01:51:21 UTC (rev 11866)
@@ -515,7 +515,7 @@
Seam.unmarshalRefs = function(refsNode) {
if (!refsNode) return;
- var refs = {};
+ var refs = new Array();
var objs = new Array();
var cn = Seam.Xml.childNodes(refsNode, "ref");
for (var i=0; i<cn.length; i++) {
@@ -593,7 +593,7 @@
return c;
}
else if (obj instanceof Date) {
- new Date(obj.getTime())
+ return new Date(obj.getTime())
}
var t = Seam.getBeanType(obj);
var c = (t == undefined) ? new Object() : new t();
@@ -705,14 +705,14 @@
if (v1 instanceof Date) {
return (v2 instanceof Date) && v1.getTime() == v2.getTime();
}
- else if (Seam.getBeanType(v1) {
+ else if (Seam.getBeanType(v1)) {
return this.getSourceObject(v1) == v2;
}
else if (v1 instanceof Array) {
if (!(v2 instanceof Array)) return false;
if (v1.length != v2.length) return false;
for (var i=0; i<v1.length; i++) {
- if (!eq(v1[i], v2[i]) return false;
+ if (!eq(v1[i], v2[i])) return false;
}
return true;
}
@@ -722,7 +722,7 @@
for (var i=0; i<v1.size(); i++) {
var e = v1.elements[i];
if (Seam.getBeanType(e.key) && eq(e.value, v2.get(this.getSourceObject(e.key)))) break;
- if (eq(e.value, v2.get(e.key)) && (e.value != null || v2.contains(e.key)) break;
+ if (eq(e.value, v2.get(e.key)) && (e.value != null || v2.contains(e.key))) break;
return false;
}
return true;
@@ -779,11 +779,19 @@
}
Seam.Delta.prototype.getSourceObject = function(obj) {
- for (var i=0;i<this.model.workingRefs; i++) {
+ for (var i=0;i<this.model.workingRefs.length; i++) {
if (obj == this.model.workingRefs[i]) return this.model.sourceRefs[i];
}
return null;
}
+
+ Seam.Delta.prototype.buildRefs = function() {
+ var refs = new Array();
+ for (var i=0; i<this.refs.elements.length; i++) {
+ refs.push(this.refs.elements[i]);
+ }
+ return refs;
+ }
}
Seam.Model = function() {
@@ -907,10 +915,79 @@
if (this.callback) this.callback(this);
}
- Seam.Model.prototype.applyUpdates = function(action) {
- var delta = new Seam.Delta(this);
+ Seam.Model.prototype.applyUpdates = function(a) {
+ var d = new Seam.Delta(this);
for (var i=0; i<this.values.length; i++) {
- delta.scanForChanges(this.values[i].value);
+ d.scanForChanges(this.values[i].value);
}
+ var r = this.createApplyRequest(a, d);
+ var env = Seam.createEnvelope(Seam.createHeader(), r.data);
+ Seam.pendingCalls.put(r.id, r);
+ Seam.sendAjaxRequest(env, Seam.PATH_MODEL, Seam.processResponse, false);
}
-}
+
+ Seam.Model.prototype.createApplyRequest = function(a, delta) {
+ var callId = "" + Seam.__callId++;
+ var d = "<model operation=\"apply\" callId=\"" + callId + "\">";
+ var refs = delta.buildRefs();
+ if (a) {
+ d += "<action>";
+ if (a.beanType) {
+ d += "<target>" + a.beanType + "</target>";
+ if (a.qualifiers) d += "<qualifiers>" + a.qualifiers + "</qualifiers>";
+ if (a.method) d += "<method>" + a.method + "</method>";
+ if (a.params.length > 0) {
+ d += "<params>";
+ for (var i=0; i<a.params.length; i++) {
+ d += "<param>" + Seam.serializeValue(a.params[i], null, refs) + "</param>";
+ }
+ d += "</params>";
+ }
+ }
+ else if (a.expression) {
+ d += "<target>" + a.expression + "</target>";
+ }
+ d += "</action>";
+ }
+ d += "<delta>";
+ for (var i=0; i<delta.refs.elements.length; i++) {
+ var k = delta.refs.elements[i].key;
+ var v = delta.refs.elements[i].value;
+ var refId = this.getRefId(k);
+ if (v) {
+ d += "<changeset refid=\"" + refId + "\">";
+ 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 += "</member>";
+ }
+ }
+ else {
+ d += Seam.serializeValue(k, null, refs);
+ }
+ d += "</changeset>";
+ }
+ }
+ d += "</delta>";
+ if (refs.length > 0) {
+ d += "<refs>";
+ var idx = this.workingRefs.length;
+ for (var i=0; i<refs.length; i++) {
+ if (this.getRefId(refs[i]) != -1) {
+ d += "<ref id=\"" + ++idx + "\">" + Seam.serializeType(refs[i], refs) + "</ref>";
+ }
+ }
+ d += "</refs>";
+ }
+ d += "</model>";
+ return {data:d, id:callId, model:this};
+ }
+
+ Seam.Model.prototype.getRefId = function(v) {
+ for (var i=0; i<this.workingRefs.length; i++) {
+ if (this.workingRefs[i] == v) return i;
+ }
+ return -1;
+ }
+}
\ No newline at end of file
15 years