[EJB 3.0 Development] New message: "Re: Lookup to java:comp/EJBContext during postconstruction"
by jaikiran pai
JBoss development,
A new message was posted in the thread "Lookup to java:comp/EJBContext during postconstruction":
http://community.jboss.org/message/530932#530932
Author : jaikiran pai
Profile : http://community.jboss.org/people/jaikiran
Message:
--------------------------------------------------------------
> marius.bogoevici wrote:
>
>
> public class MilkMan implements MessageListener
> {
>
> @PostConstruct
> public void doAfterConstruction()
> {
> try
> {
> Context context = ((Context) new InitialContext().lookup("java:comp/EJBContext"));
> }
> catch (NamingException e)
> {
> e.printStackTrace();
> }
> }
>
>
> }
>
>
>
> Now, I would really like to know whether this assessment is corect and if that is something that is essentially expected to happen given the circumstances. If this is expected behaviour, then I think that we could work around this by treating EJBContext distinctly when injecting resources, but if not, then what would you think that would be the appropriate solution for doing a correct lookup for the purposes of CDI/Weld integration?
It shouldn't fail. If it's failing, then it's a bug (looks like similar to the one we just fixed for EAP-4.x version). And i don't think it's specific to the EJBContext. I guess it will fail for anything under java:comp for that bean. Can you give a quick try by looking up something else under java:comp from within the @Postconstruct of MDB?
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/530932#530932
16 years
[EJB 3.0 Development] New message: "Lookup to java:comp/EJBContext during postconstruction"
by Marius Bogoevici
JBoss development,
A new message was posted in the thread "Lookup to java:comp/EJBContext during postconstruction":
http://community.jboss.org/message/530930#530930
Author : Marius Bogoevici
Profile : http://community.jboss.org/people/marius.bogoevici
Message:
--------------------------------------------------------------
I will just refer to the problem indicated in http://seamframework.org/Community/TheMessageDrivenBeanSagaContinues
While a CDI problem per se, it seems like doing this:
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/testQueue")
})
public class MilkMan implements MessageListener
{
@PostConstruct
public void doAfterConstruction()
{
try
{
Context context = ((Context) new InitialContext().lookup("java:comp/EJBContext"));
}
catch (NamingException e)
{
e.printStackTrace();
}
}
@Inject Control control;
public void onMessage(Message message)
{
try
{
control.setMessageDelivered(((TextMessage) message).getText().equals(EJBTest.MESSAGE));
}
catch (JMSException e)
{
throw new RuntimeException(e);
}
}
}
will cause the deployment to fail, since doing that lookup from within the postconstructor does not get all the expected interceptors applied. Of course, this is not how exactly we intent to use this from Weld, but doing injection of resources during postconstruction has a similar effect.
Now, I would really like to know whether this assessment is corect and if that is something that is essentially expected to happen given the circumstances. If this is expected behaviour, then I think that we could work around this by treating EJBContext distinctly when injecting resources, but if not, then what would you think that would be the appropriate solution for doing a correct lookup for the purposes of CDI/Weld integration?
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/530930#530930
16 years
[JBoss Microcontainer Development] New message: "Re: JBREFLECT-5 - Implementing generics in JavassistClassInfo"
by Kabir Khan
JBoss development,
A new message was posted in the thread "JBREFLECT-5 - Implementing generics in JavassistClassInfo":
http://community.jboss.org/message/530850#530850
Author : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com
Message:
--------------------------------------------------------------
> mailto:kabir.khan@jboss.com wrote:
>
>
> 3) When accessing generics from the return type of a method, e.g.
>
> Collection<String> getStringCollection(){}
>
>
>
> we get hold of this method using normal reflection (A) and construct the TypeInfo for that using the ParameterizedType (B1+2) for which I extended the Javassist TypeInfo factory:
>
> *private* *void* assertComponentType(String methodName, Class<?> expected) *throws* Exception
> {
> Method method = ClassInfoGenericClassTest.class.getMethod(methodName, (Class[]) *null*); //A
> Type type = method.getGenericReturnType(); //B1
> assertComponentType(type, expected);
> }
>
> *private* *void* assertComponentType(Type type, Class<?> expected) *throws* Exception
> {
> TypeInfoFactory factory = getTypeInfoFactory();
> TypeInfo typeInfo = factory.getTypeInfo(type); //B2
> ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
> assertTrue(classInfo.isCollection());
>
> TypeInfo expectedInfo = factory.getTypeInfo(expected);
> assertEquals(expectedInfo, classInfo.getComponentType());
> }
>
>
> However, that is probably not what will happen in real life, we would have a ClassInfo, get hold of the MethodInfo in question, and then get the return type which should contain the actualTypeArguments. This needs implementing and is not being tested at the moment, and the same goes for parameters and field types.
Looking properly, I think what is there at the moment is correct. In reflect we have these additional methods:
Type[] Method.getGenericExceptionTypes()
Type[] Constructor.getGenericExceptionTypes()
Type[] Method.getGenericParameterTypes()
Type[] Constructor.getGenericParameterTypes()
Type Method.getGenericReturnType()
Type Field.getGenericType()
The normal non-generic methods (as getReturnType()) simply return a Class. So, I think that MethodInfo.getReturnType() should just return a plain TypeInfo as it does at the moment.
I'll concentrate on 1,2 and 4 for now, and see if 3 is needed, although I don't think so since it is not present in the reflect implementation either.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/530850#530850
16 years