Author: shane.bryzak(a)jboss.com
Date: 2010-01-23 21:06:41 -0500 (Sat, 23 Jan 2010)
New Revision: 11987
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java
modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
fix variable scope issue
Modified:
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java
===================================================================
---
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java 2010-01-22
21:22:04 UTC (rev 11986)
+++
modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/wrapper/BagWrapper.java 2010-01-24
02:06:41 UTC (rev 11987)
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -16,7 +18,6 @@
import javax.enterprise.inject.spi.BeanManager;
import org.dom4j.Element;
-import org.hibernate.collection.PersistentCollection;
/**
* Wrapper for collections, arrays, etc.
@@ -48,15 +49,28 @@
@SuppressWarnings("unchecked")
public void marshal(OutputStream out) throws IOException
{
- // Fix to prevent uninitialized lazy loading in Hibernate
- if (value instanceof PersistentCollection && !loadLazy)
+ try
{
- if (!((PersistentCollection) value).wasInitialized())
+ Class cls =
Class.forName("org.hibernate.collection.PersistentCollection");
+
+ // Fix to prevent uninitialized lazy loading in Hibernate
+ if (cls.isInstance(value) && !loadLazy)
{
- out.write(UNDEFINED_TAG);
- return;
- }
+ try
+ {
+ Method m = cls.getMethod("wasInitialized");
+ if (((Boolean) m.invoke(value)).booleanValue() == false)
+ {
+ out.write(UNDEFINED_TAG);
+ return;
+ }
+ }
+ catch (NoSuchMethodException ex) {}
+ catch (InvocationTargetException ex) {}
+ catch (IllegalAccessException ex) {}
+ }
}
+ catch (ClassNotFoundException ex) {}
out.write(BAG_TAG_OPEN);
Modified: modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-22
21:22:04 UTC (rev 11986)
+++ modules/remoting/trunk/src/main/resources/org/jboss/seam/remoting/remote.js 2010-01-24
02:06:41 UTC (rev 11987)
@@ -44,6 +44,18 @@
return function() { return this[fieldName]; };
};
+Seam.createBeanFunction = function(methodName, paramCount) {
+ return function() {
+ var p = [];
+ for (var i=0; i<paramCount; i++) {
+ p[i] = arguments[i];
+ }
+ var c = (arguments.length > paramCount) ? arguments[paramCount] : undefined;
+ var eh = (arguments.length > (paramCount + 1)) ? arguments[paramCount + 1] :
undefined;
+ return Seam.execute(this, methodName, p, c, eh);
+ }
+}
+
Seam.registerBean = function(name, metadata, methods) {
if (Seam.isBeanRegistered(name)) return;
var t = function() {};
@@ -59,16 +71,7 @@
t.__metadata = m;
} else {
for (var m in methods) {
- var pc = methods[m];
- t.prototype[m] = function() {
- var p = [];
- 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);
- };
+ t.prototype[m] = Seam.createBeanFunction(m, methods[m]);
}
}
Seam.beans[name] = t;
Show replies by date