Hi Jesper and all!
On Oct 22, 2010, at 10:56 AM, Jesper Skov wrote:
> I don't know if this problem has already been addressed by someone
> else, but when I started looking at migrating my Wicket application
> from Glassfish to OpenEjb, the injection magic failed.
>
> I have hacked my way around that issue with the below code.
>
> It would need some TLC to be suitable for inclusion in the project.
> Maybe just make a new JavaEEComponentInjector clone class with the
> added magic, or extend the existing class to allow lookup properties
> to be provided!?!?!
>
> Anyway, use it as you see fit.
I don't really know Wicket at all -- to tell you the truth I'd have to look at
the website to tell you what it does :)
But in terms of better injection, we could probably give wicket components the
full Java EE treatment and injection capabilities that you can get in a
Servlet, EJB, or other type of managed component.
Any Wicket devs attending ApacheCon? Would love to sit down with someone and
see what kind of cool things we could do.
-David
>
> Cheers,
> Jesper Skov
>
>
> ---
> ../../../../wicket-contrib-javaee-orig/org/wicketstuff/javaee/JavaEEBeanLocator.java
> 2008-01-14
> 19:05:06.000000000 +0100
> +++ JavaEEBeanLocator.java 2010-07-14 22:13:58.000000000 +0200
> @@ -16,14 +16,19 @@
> */
> package org.wicketstuff.javaee;
>
> +import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> +import javax.naming.NameClassPair;
> +import javax.naming.NamingEnumeration;
>
> import org.apache.wicket.proxy.IProxyTargetLocator;
> import org.apache.wicket.util.lang.Objects;
>
> import org.wicketstuff.javaee.naming.IJndiNamingStrategy;
>
> +import java.util.Properties;
> +
> /**
> * Implementation of {...@link IProxyTargetLocator} to locate ejbs using Java
> EE 5
> * resource injection. To use this technique in a Wicket Page, annotate a
> @@ -138,7 +143,16 @@
> InitialContext ic;
> try
> {
> - ic = new InitialContext();
> + Properties properties = new Properties();
> + properties.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.openejb.client.LocalInitialContextFactory");
> + ic = new InitialContext(properties);
> +
> + try {
> + return ic.lookup(name + "Local");
> + } catch (Exception e) {
> + System.out.println("Lookup by Local name failed");
> + }
> +
> return ic.lookup(lookupName);
> } catch (NamingException e)
> {
>