Author: pete.muir(a)jboss.org
Date: 2009-06-08 08:59:51 -0400 (Mon, 08 Jun 2009)
New Revision: 2780
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
Log:
implement serializable for all facades
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-06-08 12:14:12 UTC
(rev 2779)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-06-08 12:59:51 UTC
(rev 2780)
@@ -16,8 +16,11 @@
*/
package org.jboss.webbeans;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -32,20 +35,21 @@
*
* @param <T>
*/
-public abstract class FacadeImpl<T>
+public abstract class FacadeImpl<T> implements Serializable
{
+ private static final long serialVersionUID = 8710258788495459128L;
+
private static final Annotation[] EMPTY_BINDINGS = new Annotation[0];
// The binding types the helper operates on
- protected final Set<? extends Annotation> bindings;
+ private final Set<? extends Annotation> bindings;
// The Web Beans manager
private final ManagerImpl manager;
// The type of the operation
- protected final Type type;
+ private final Type type;
/**
- * Constructor
*
* @param type The event type
* @param manager The Web Beans manager
@@ -92,5 +96,22 @@
{
return manager.getCurrent();
}
+
+ protected static Set<Annotation> removeBindings(Set<Annotation> bindings,
Annotation...remove)
+ {
+ Set<Annotation> a = new HashSet<Annotation>(bindings);
+ a.removeAll(Arrays.asList(remove));
+ return a;
+ }
+
+ protected Set<? extends Annotation> getBindings()
+ {
+ return Collections.unmodifiableSet(bindings);
+ }
+
+ protected Type getType()
+ {
+ return type;
+ }
}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-06-08 12:14:12
UTC (rev 2779)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-06-08 12:59:51
UTC (rev 2780)
@@ -35,8 +35,9 @@
*/
public class InstanceImpl<T> extends FacadeImpl<T> implements
Instance<T>
{
-
+ private static final long serialVersionUID = -376721889693284887L;
+
public static <I> Instance<I> of(Type type, ManagerImpl manager,
Set<Annotation> annotations)
{
return new InstanceImpl<I>(type, manager, annotations);
@@ -66,7 +67,7 @@
public T get(Annotation... bindings)
{
Annotation[] annotations = mergeInBindings(bindings);
- return getManager().getInstanceByType(ResolvableAnnotatedClass.<T>of(type,
annotations), annotations);
+ return
getManager().getInstanceByType(ResolvableAnnotatedClass.<T>of(getType(),
annotations), annotations);
}
/**
@@ -77,13 +78,12 @@
@Override
public String toString()
{
- return "Obtainable instance for type " + type + " and binding types
" + bindings;
+ return "Obtainable instance for type " + getType() + " and binding
types " + getBindings();
}
public Iterator<T> iterator()
{
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException("Not yet implemented");
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-06-08
12:14:12 UTC (rev 2779)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-06-08
12:59:51 UTC (rev 2780)
@@ -97,6 +97,12 @@
{
// TODO Auto-generated method stub
}
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
/**
* Gets a set of annotation classes to ignore
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-06-08
12:14:12 UTC (rev 2779)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-06-08
12:59:51 UTC (rev 2780)
@@ -87,10 +87,4 @@
return "Built-in implicit javax.event.Event bean";
}
- @Override
- public boolean isSerializable()
- {
- return true;
- }
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-06-08
12:14:12 UTC (rev 2779)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-06-08
12:59:51 UTC (rev 2780)
@@ -16,7 +16,6 @@
*/
package org.jboss.webbeans.event;
-import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
@@ -37,11 +36,11 @@
* @param <T> The type of event being wrapped
* @see javax.event.Event
*/
-public class EventImpl<T> extends FacadeImpl<T> implements Event<T>,
Serializable
+public class EventImpl<T> extends FacadeImpl<T> implements Event<T>
{
- private static final long serialVersionUID = 8130060821283091287L;
-
+ private static final long serialVersionUID = 656782657242515455L;
+
public static <E> Event<E> of(Type eventType, ManagerImpl manager,
Set<Annotation> bindings)
{
return new EventImpl<E>(eventType, manager, bindings);
@@ -57,8 +56,7 @@
*/
public EventImpl(Type eventType, ManagerImpl manager, Set<Annotation> bindings)
{
- super(eventType, manager, bindings);
- this.bindings.remove(new AnyLiteral());
+ super(eventType, manager, removeBindings(bindings, new AnyLiteral()));
}
/**
@@ -88,8 +86,8 @@
{
StringBuilder buffer = new StringBuilder();
buffer.append("Observable Event:\n");
- buffer.append(" Event Type: " + type.toString() + "\n");
- buffer.append(Strings.collectionToString(" Event Bindings: ",
bindings));
+ buffer.append(" Event Type: " + getType().toString() + "\n");
+ buffer.append(Strings.collectionToString(" Event Bindings: ",
getBindings()));
return buffer.toString();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-06-08
12:14:12 UTC (rev 2779)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-06-08
12:59:51 UTC (rev 2780)
@@ -19,8 +19,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -31,7 +29,6 @@
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Reflections.HierarchyDiscovery;
/**