According to the documentation:

constructedType is a concrete class with an @Inject-annotated constructor. In addition to injector-supplied parameters, the constructor should have parameters that match each of the factory method's parameters. Each factory-supplied parameter requires an @Assisted annotation.


You have your @Asissted annotation on a field.
Try and add a parameter with type Domain to the constructor of TodoResource which is annotated with @Assisted and pass it to the super constructor of DomainResource

Hope this works




On 02/05/2014 09:36 PM, Rama Krishna Gollapudi wrote:
Hello is there any solution to my problem ?

On Tuesday, 4 February 2014 12:39:29 UTC-6, Rama Krishna Gollapudi wrote:
Here is my abstract class

public abstract class DomainResource {

    @Inject
    @Assisted
    private Domain target;

    @Inject
    private LinkHelper helper;

    /**
     * Accessor for the domain resource, will return domain information and links to domain scoped resources
     * @param info the uri information
     * @return a Map representing the returned json
     */
    @GET
    @Produces(APPLICATION_JSON)
    @SuppressWarnings("nls")
    public Map<String, Object> get(@Context final UriInfo info) {
        
        return "Implement your stuff";
    }
}


Implementaion

public class TodoResource extends DomainResource {
    @Inject
    private Domain domain;
    @Inject
    private ScopedResourceFactory factory;
    @Inject
    private LinkHelper helper;

    @GET
    @Produces(APPLICATION_JSON)
    public Map<String, Object> getTypes(@Context final UriInfo uriInfo) {
        return helper.indexMapResponse();
    }

    /**
     * @param info uriInfo object used to extract matrix params
     * @return the encounters resource
     */
    @Path("todos")
    public Object getEncounters(@Context final UriInfo info) {
        return " implement Your Stuff.";
    }
}


Factory :
public interface ScopedResourceFactory {

    DomainResource domainResource(Domain target);
}



And as per your suggestion i'm binding like this.  
install(new FactoryModuleBuilder().implement(DomainResource.class, TodoResource.class).build(
                    ScopedResourceFactory.class));

But still i'm getting exception. Please find below. 



com.rama.util.jaxrs.DomainResource is abstract, not a concrete class.  Unable to create AssistedInject factory.
  while locating com.cerner.iaware.util.jaxrs.DomainResource
  at com.rama.util.guice.ScopedResourceFactory.domainResource(ScopedResourceFactory.java:1)

1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:448)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
at com.rama.todo.guice.GuiceConfigurationInitializer.getInjector(GuiceConfigurationInitializer.java:49)
at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

















On Tuesday, 4 February 2014 12:09:47 UTC-6, Sam Berlin wrote:
The assisted inject docs describe how to do this.  The example in the doc reads:

 install(new FactoryModuleBuilder()
     .implement(Payment.class, RealPayment.class)
     .build(PaymentFactory.class));

You'd just substitute Payment for DomainResource, RealPayment for TodoResource, and PaymentFactory for your assistedinject factory.

 sam


On Tue, Feb 4, 2014 at 12:38 PM, Rama Krishna Gollapudi <kitt...@gmail.com> wrote:
Hello,
          I'm having  a problem of binding an abstract class with it's implementation using Guice . I'm getting the following exception.

com.rama.util.jaxrs.DomainResource is abstract, not a concrete class.  Unable to create AssistedInject factory.

And  i did binding like this.  bind(DomainResource.class).to(TodoResource.class);

DomainResoruce is an abstract class and TodoResource is an implementation. 

Thanks,
Rama.
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to