Skip to content

Commit

Permalink
WELD-743
Browse files Browse the repository at this point in the history
  • Loading branch information
cpopetz authored and pmuir committed Oct 31, 2010
1 parent 1dce43c commit fffa1fa
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
Expand Up @@ -40,13 +40,14 @@ static abstract class WeldInjectionPointSerializationProxy<T, S> implements Seri

public WeldInjectionPointSerializationProxy(WeldInjectionPoint<T, S> injectionPoint)
{
this.declaringBeanId = Container.instance().services().get(ContextualStore.class).putIfAbsent(injectionPoint.getBean());
this.declaringBeanId =
injectionPoint.getBean() == null ? null : Container.instance().services().get(ContextualStore.class).putIfAbsent(injectionPoint.getBean());
this.declaringClass = injectionPoint.getDeclaringType().getJavaClass();
}

protected Bean<T> getDeclaringBean()
{
return Container.instance().services().get(ContextualStore.class).<Bean<T>, T>getContextual(declaringBeanId);
return declaringBeanId == null ? null : Container.instance().services().get(ContextualStore.class).<Bean<T>, T>getContextual(declaringBeanId);
}

protected WeldClass<?> getDeclaringWeldClass()
Expand Down
@@ -0,0 +1,28 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.tests.serialization.noncontextual;

import java.io.Serializable;
import javax.enterprise.event.Event;
import javax.inject.Inject;

public class NonContextual implements Serializable
{

@Inject Event<String> stringEvent;

}
@@ -0,0 +1,61 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.tests.serialization.noncontextual;

import static org.junit.Assert.fail;
import javax.inject.Inject;

import java.io.Serializable;
import java.io.*;

import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.context.spi.Contextual;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.BeanArchive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class SerializationTest
{

@Inject BeanManager beanManager;

@Deployment
public static Archive<?> deploy()
{
return ShrinkWrap.create(BeanArchive.class).addPackage(SerializationTest.class.getPackage());
}

/*
* description =
* "http://lists.jboss.org/pipermail/weld-dev/2010-February/002265.html"
*/
@Test
public void testSerializationOfEventInNonContextual() throws Exception
{

NonContextual instance = new NonContextual();
beanManager.createInjectionTarget(beanManager.createAnnotatedType(NonContextual.class)).inject(
instance, beanManager.createCreationalContext((Contextual<NonContextual>)null));
new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(instance);
}
}

0 comments on commit fffa1fa

Please sign in to comment.