I am trying to do away with xml-based spring configuration and replace it with 
java-based spring configuration.  Has anyone succeeded with this?  I've 
succeeded in doing so with everything I've tried EXCEPT Restlet.  The only 
thing I'm stuck on is converting the SpringRouter config to java.  I've tried 
many different ways to do it and none of them work.  There may be a bug 
somewhere because no matter what (xml or java config) spring complains about 
the SpringRouter setAttachments(...) call being ambiguous.  I've seen this 
mentioned in other discussions.

My environment:
Spring 3.0.6.RELEASE
Restlet 2.0.9
Java 1.6

Sample SpringRouter xml config (which works fine):

<bean id="springRouter" class="org.restlet.ext.spring.SpringRouter" >
 <property name="attachments">
   <map>
     <entry key="/incident">
       <bean class="org.restlet.ext.spring.SpringFinder">
         <lookup-method name="create" bean="incidentResource" />
       </bean>
     </entry>
    </map>
  </property>
</bean>

Sample java configs (none working):

@Bean(name="springRouter",autowire=Autowire.BY_NAME)
@DependsOn({"incidentResource"})
public SpringRouter getSpringRouter() 
{
   if(springRouter == null)
   {
     springRouter = new SpringRouter();
     springRouter.setFinderClass(SpringFinder.class);
     Map<String,Object> routes = new HashMap<String,Object>(); 
     routes.put("/incident",IncidentResource.class);
     springRouter.setAttachments(routes);
   }
                
   return springRouter;
}

This attaches the resources but doesn't inject dependencies.

@Bean(name="springRouter",autowire=Autowire.BY_NAME)
@DependsOn({"incidentResource"})
public SpringRouter getSpringRouter() 
{
   if(springRouter == null)
   {
     springRouter = new SpringRouter();
     springRouter.setFinderClass(SpringFinder.class);
     Map<String,Object> routes = new HashMap<String,Object>(); 
     routes.put("/incident",getIncidentResource());
     springRouter.setAttachments(routes);
   }
                
   return springRouter;
}

This doesn't attach the resource.

@Bean(name="springRouter",autowire=Autowire.BY_NAME)
@DependsOn({"incidentResource"})
public SpringRouter getSpringRouter() 
{
   if(springRouter == null)
   {
     springRouter = new SpringRouter();
     springRouter.setFinderClass(SpringFinder.class);
     Map<String,Object> routes = new HashMap<String,Object>();
     SpringFinder springFinder = new SpringFinder();   
springFinder.setTargetClass(IncidentResource.class); 
     routes.put("/incident",springFinder.create());
     springRouter.setAttachments(routes);
   }
                
   return springRouter;
}

This doesn't attach the resource.


Hopefully someone has done this and can help.  I'm losing my mind!

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2850450

Reply via email to