0 Replies Latest reply on Jun 17, 2010 1:52 AM by eskape.esk.ngs.ru

    Any chances Component.checkNonAbstract() to be protected?

    eskape.esk.ngs.ru

      Hi,


      I'm trying to inject RestEasy client interfaces as Seam components. While it's pretty straightforward with @Unwrap pattern, using IoCComponent approach appears to be a bit tricky.


      I can instantiate the bean using resteasy ProxyFactory and inject it into Application context, but for now I have to pass Object.class and thus Component.getInstance(Class c) call is not available.


      This is my interface:


      @ResteasyClient(seamName="basicClient1")
      public interface BasicClient {
      
           @POST
           @Path("search/ClientSearchService.svc/GetAllBy")
           @Produces("application/json")
           @Consumes("application/json")
           List<Customer> getAllBy(String data);
      
      }



      This is component wrapper from Seam-IOC:




      @Name("org.jboss.seam.resteasyclient.bootstrap")
      @Scope(ScopeType.APPLICATION)
      @Startup
      @AutoCreate
      @Install(precedence = BUILT_IN, classDependencies = "org.jboss.resteasy.spi.ResteasyProviderFactory")
      public class ResteasyClientBootstrap {
      
           @Create
           public void init() {
      
      // blah-blah-blah class scanning and initialisation skipped
      
                  Contexts.getApplicationContext().set(
                     componentName + Initialization.COMPONENT_SUFFIX,
      *               new RestEasyClientComponent(Object.class, // GOTCHA!*
                       componentName, ScopeType.STATELESS, beanClass));
                 }
      
      }
      



      And RestEasyClientComponent looks like this:



      public class RestEasyClientComponent extends IoCComponent {
      
           private Class interfaceClass;
      
           public RestEasyClientComponent(Class clazz, String name, ScopeType scope, Class interfaceClass) {
                super(clazz, name, scope);
                this.interfaceClass = interfaceClass;
           }
      
           @Override
           protected Object instantiateIoCBean() throws Exception {
                return ProxyFactory.create(interfaceClass, "http://localhost/rest/");
           }
      
           @Override
           protected String getIoCName() {
                return null;
           }
      
      }