That's the basic idea, but I wanted to be able to write something like
this in my module:

    bindRemoted(MyService.class).to(MyServiceImpl.class);

and have the methods of MyService (only) remoted without special
annotations on MyService or MyServiceImpl.

--tim

On Oct 29, 6:34 pm, Pavel <[email protected]> wrote:
> That's how I did it.
>
> *dwr.xml*
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
> "http://getahead.org/dwr/dwr20.dtd";>
> <dwr>
>    <init>
>       <creator id="guice" class="com.my.web.dwr.GuiceCreator" />
>    </init>
>    <allow>
>       <create creator="guice" javascript="MyBean">
>          <param name="class" value="com.my.web.dwr.MyBean" />
>       </create>
>       <!-- ... -->
>     </allow>
> </dwr>
>
> *com.my.web.drw.GuiceCreator*:
>
> package com.my.web.dwr;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.directwebremoting.create.AbstractCreator;
>
> import com.google.inject.Guice;
> import com.google.inject.Injector;
>
> import com.my.guice.MyModule;
>
> public class GuiceCreator extends AbstractCreator {
>
>     private static Log log = LogFactory.getLog(GuiceCreator.class);
>
>     /**
>      * What sort of class do we create?
>      * @param classname The name of the class
>      */
>     public void setClass(String classname)
>     {
>         try
>         {
>             clazz = Class.forName(classname);
>         }
>         catch (ClassNotFoundException ex)
>         {
>             throw new RuntimeException("Creator.ClassNotFound " + classname,
> ex);
>         }
>     }
>
>     @SuppressWarnings("unchecked")
>     public Class getType()
>     {
>         return clazz;
>     }
>
>     private static Injector injector = Guice.createInjector(new MyModule());
>
>     @SuppressWarnings("unchecked")
>     public Object getInstance() throws InstantiationException {
>         log.debug("Object getInstance()");
>         try {
>             return injector.getInstance(getType()) ;
>         } catch (Exception e) {
>             throw new InstantiationException(e.getMessage());
>         }
>     }
>
>     /**
>      * Sets the class name to create.
>      * @param className The name of the class to create
>      */
>     public void setClassName(String className)
>     {
>         setClass(className);
>     }
>
>     /**
>      * Gets the name of the class to create.
>      * @return The name of the class to create
>      */
>     public String getClassName()
>     {
>         return getType().getName();
>     }
>
>     /**
>      * The type of the class that we are creating
>      */
>     @SuppressWarnings("unchecked")
>     private Class clazz;
>
> }
>
> Pavel
>
> On Tue, Oct 27, 2009 at 7:31 AM, Patrick Lightbody 
> <[email protected]>wrote:
>
>
>
>
>
> > Anyone doing this? The DWR integration code is still on Guice 1.0 and
> > when I tried upgrading I got quite a few errors. Before I dive in to
> > this and send the DWR guys a patch, just wanted to check if others
> > have already tackled this problem.
>
> > Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to