0

I'm using Netbenas Java 1.8 to build the project. I have a ServiceManager class, and a ServiceManagerFactory class, but having trouble binding the factory class. Sample code as follows:

       public class ServiceManagerFactory
          implements Factory<ServiceManager>
        {
          
          @Override
          public ServiceManager provide()
          {
            return initServiceManager();
        
          }
        
          @Override
          public void dispose(ServiceManager t)
          {
            // DO Nothing
          }
    }


@ApplicationPath("")
public class MyResourceConfig
  extends ResourceConfig
{
  public MyResourceConfig()
  {
    register(MyResource.class);

    register(new AbstractBinder()
    {
      @Override
      protected void configure()
      {
        bindFactory(ServiceManagerFactory.class) // Compile Errors 
          .to(ServiceManager.class);

      }
    });
    
  }
}

The error messages are as follows:

no suitable method found for bindFactory(Class<ServiceManagerFactory>)
    method AbstractBinder.<T#1>bindFactory(Class<? extends Supplier<T#1>>,Class<? extends Annotation>) is not applicable
      (cannot infer type-variable(s) T#1
        (actual and formal argument lists differ in length))
    method AbstractBinder.<T#2>bindFactory(Class<? extends Supplier<T#2>>) is not applicable
      (cannot infer type-variable(s) T#2
        (argument mismatch; Class<ServiceManagerFactory> cannot be converted to Class<? extends Supplier<T#2>>))
    method AbstractBinder.<T#3>bindFactory(Supplier<T#3>) is not applicable
      (cannot infer type-variable(s) T#3
        (argument mismatch; Class<ServiceManagerFactory> cannot be converted to Supplier<T#3>))
  where T#1,T#2,T#3 are type-variables:
    T#1 extends Object declared in method <T#1>bindFactory(Class<? extends Supplier<T#1>>,Class<? extends Annotation>)
    T#2 extends Object declared in method <T#2>bindFactory(Class<? extends Supplier<T#2>>)
    T#3 extends Object declared in method <T#3>bindFactory(Supplier<T#3>)
yadan
  • 13
  • 4

0 Answers0