Skip to content

Commit

Permalink
WBRI-122, tests for passivation and associated fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1287 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jan 29, 2009
1 parent f688096 commit 123d286
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
27 changes: 13 additions & 14 deletions dist/readme.txt
@@ -1,14 +1,14 @@
Web Beans RI
Web Beans
------------

Web Beans (JSR-299) is a new Java standard for dependency injection and
contextual lifecycle management.
Java Contexts and Dependency Injection (JSR-299) is a new Java standard for
dependency injection and contextual lifecycle management. Web Beans is the
reference implementation of JSR-299.

This distribution, as a whole, is licensed under the terms of the FSF Lesser Gnu
Public License (see lgpl.txt). Parts of it are licensed under the Apache Public
License (see apl.txt). In particular, the Web Beans API and the Web Beans RI
runtimes are licensed under the APL. At least these parts are licensed under the
APL:
License (see apl.txt). In particular, the API and the Web Beans runtime are
licensed under the APL. At least these parts are licensed under the APL:

* src/webbeans-ri/main/**/*
* src/webbeans-api/main/**/*
Expand All @@ -20,12 +20,12 @@ APL:
This distribution consists of:

doc/
-- The Web Beans Reference guide, take a look at doc/en/html/index.html for
getting started using Web Beans and the Web Beans RI
-- The Reference guide, take a look at doc/en/html/index.html for getting
started using Web Beans and the facilities offered by JSR-299.

examples/
-- The Web Beans RI examples, the examples are described in more detail in
the reference guide
-- The Web Beans examples, the examples are described in more detail in the
reference guide

jboss-as/
-- Installer for JBoss AS, change into this directory, and run ant update
Expand All @@ -35,9 +35,8 @@ lib/
-- Libraries for building the examples

lib/webbeans
-- The Web Beans RI and API jars, for use outside of JBoss AS
-- The Web Beans and API jars, for use outside of JBoss AS

src/
-- The sources of the Web Beans RI, including src/webbeans-api,
src/webbeans-ri and src/reference. To build the sources, just type mvn in
the subdirectory.
-- The sources of Web Beans, including src/webbeans-api, src/webbeans-ri and
src/reference. To build the sources, just type mvn in the subdirectory.
Expand Up @@ -17,6 +17,7 @@

package org.jboss.webbeans.bean;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Arrays;
Expand Down Expand Up @@ -109,6 +110,8 @@ public static Class<? extends Annotation> getDeploymentType(List<Class<? extends
// The Web Beans manager
protected ManagerImpl manager;

protected boolean _serializable;

/**
* Constructor
*
Expand Down Expand Up @@ -145,6 +148,7 @@ protected void init()
checkDeploymentType();
initScopeType();
initTypes();
initSerializable();
initProxyable();
checkRequiredTypesImplemented();
}
Expand Down Expand Up @@ -507,8 +511,12 @@ public boolean isPrimitive()
@Override
public boolean isSerializable()
{
// TODO: OK?
return true;
return _serializable;
}

protected void initSerializable()
{
_serializable = isPrimitive() || getTypes().contains(Serializable.class);
}

/**
Expand Down
Expand Up @@ -204,7 +204,7 @@ protected void checkReturnValue(T instance)
{
if (injectionPoint.getMember() instanceof Field)
{
if (!Reflections.isTransient(injectionPoint.getMember()) || !isSerializable())
if (!Reflections.isTransient(injectionPoint.getMember()) && !Reflections.isSerializable(instance.getClass()))
{
throw new IllegalProductException("Dependent scoped producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\n\nProducer: " + this.toString() + "\nInjection Point: " + injectionPoint.toString());
}
Expand Down Expand Up @@ -280,6 +280,12 @@ else if (deploymentTypes.size() == 1)
return;
}
}

@Override
protected void initSerializable()
{
_serializable = true;
}

/**
* Gets the receiver of the product
Expand Down
Expand Up @@ -555,7 +555,7 @@ public static boolean isBindingType(Annotation bindingType)

public static boolean isSerializable(Class<?> clazz)
{
return getTypeHierachy(clazz).contains(Serializable.class);
return getTypeHierachy(clazz).contains(Serializable.class) || clazz.isPrimitive();
}

}
@@ -0,0 +1 @@
package org.jboss.webbeans.test.unit.implementation.proxy;import java.io.Serializable;import javax.annotation.Named;import javax.context.RequestScoped;@Named@RequestScopedclass Foo implements Serializable{ public String getMsg() { return "Hi"; } }
Expand Down
@@ -0,0 +1,16 @@
package org.jboss.webbeans.test.unit.implementation.proxy;

import org.jboss.webbeans.test.unit.AbstractTest;
import org.testng.annotations.Test;

public class ProxyTest extends AbstractTest
{

@Test(description="WBRI-122")
public void testImplementationClassImplementsSerializable()
{
deployBeans(Foo.class);
manager.getInstanceByName("foo");
}

}
2 changes: 2 additions & 0 deletions webbeans-ri/unit-tests.xml
Expand Up @@ -39,6 +39,8 @@
<package name="org.jboss.webbeans.test.unit.definition" />
<package name="org.jboss.webbeans.test.unit.event" />
<package name="org.jboss.webbeans.test.unit.implementation" />
<package name="org.jboss.webbeans.test.unit.implementation.proxy" />
<package name="org.jboss.webbeans.test.unit.implementation.exceptions" />
<package name="org.jboss.webbeans.test.unit.lookup" />
<package name="org.jboss.webbeans.test.unit.lookup.circular" />
</packages>
Expand Down

0 comments on commit 123d286

Please sign in to comment.