Changeset 763
- Timestamp:
- 17/11/08 13:28:21 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/modules/kauri-routing/kauri-routing-impl/src/main/java/org/kauriproject/routing/impl/RoutingServiceImpl.java
r651 r763 5 5 import org.kauriproject.routing.impl.routing.KauriRouter; 6 6 import org.kauriproject.runtime.rapi.KauriModule; 7 import org.kauriproject.runtime.module.Module;8 import org.kauriproject.runtime.module.restservice.RestserviceFacet;9 7 import org.restlet.Restlet; 10 8 import org.restlet.Context; 11 9 12 10 public class RoutingServiceImpl implements RoutingService { 13 private RestserviceFacet restserviceFacet;11 private KauriModule routingModule; 14 12 15 13 public RoutingServiceImpl(KauriModule kauriModule) { 16 restserviceFacet = ((Module)kauriModule.getImplementation()).getRestserviceFacet();14 this.routingModule = kauriModule; 17 15 } 18 16 … … 22 20 23 21 public Restlet createRouter(Context context, KauriModule module, RoutingConfig routingConfig) { 24 // Shielding the restlet is necessary in order for the ContextClassloader to switch, which is25 // needed for the JAX-RS implementation to be found26 22 if (routingConfig == null) 27 23 routingConfig = new RoutingConfig(); 28 24 29 return restserviceFacet.shieldRestlet(new KauriRouter(context, module, routingConfig));25 return new KauriRouter(context, module, routingConfig, routingModule); 30 26 } 31 27 } trunk/modules/kauri-routing/kauri-routing-impl/src/main/java/org/kauriproject/routing/impl/routing/KauriRouter.java
r748 r763 27 27 private ApplicationContext applicationContext; 28 28 private ReloadableResource reloadableResource; 29 private KauriModule routingModule; 29 30 30 public KauriRouter(Context context, KauriModule module, RoutingConfig routingConfig ) {31 public KauriRouter(Context context, KauriModule module, RoutingConfig routingConfig, KauriModule routingModule) { 31 32 super(context); 32 33 … … 34 35 this.module = module; 35 36 this.routingConfig = routingConfig; 37 this.routingModule = routingModule; 36 38 37 39 this.applicationContext = ((Module)module.getImplementation()).getApplicationContext(); … … 47 49 48 50 private ReloadableResource.Result build() { 51 // During building, set the context classloader to the classloader of the routing module implementation. 52 // This e.g. helps the JAX-RS RuntimeDelegate to find its implementation. 53 ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader(); 54 Thread.currentThread().setContextClassLoader(routingModule.getClassLoader()); 49 55 try { 50 56 log.debug("Rebuilding routing setup."); … … 74 80 }, Collections.<DisposableRoutingComponent>emptyList()); 75 81 return new ReloadableResource.Result(routerData, t); 82 } finally { 83 Thread.currentThread().setContextClassLoader(oldContextClassLoader); 76 84 } 77 85 }
