All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.webpieces.devrouter.impl.DevLoader Maven / Gradle / Ivy

Go to download

Library that swaps out specific http-router components to be able to compile code on any request that has changed for use in development servers

There is a newer version: 2.1.1
Show newest version
package org.webpieces.devrouter.impl;

import javax.inject.Inject;

import org.webpieces.router.api.controller.actions.Action;
import org.webpieces.router.api.routes.MethodMeta;
import org.webpieces.router.impl.hooks.MetaLoaderProxy;
import org.webpieces.router.impl.hooks.ServiceCreationInfo;
import org.webpieces.router.impl.loader.AbstractLoader;
import org.webpieces.router.impl.loader.LoadedController;
import org.webpieces.router.impl.loader.MetaLoader;
import org.webpieces.router.impl.loader.ResolvedMethod;
import org.webpieces.util.filters.Service;

import com.google.inject.Injector;

public class DevLoader extends AbstractLoader implements MetaLoaderProxy {

	private DevClassForName classLoader;

	@Inject
	public DevLoader(MetaLoader loader, DevClassForName classLoader) {
		super(loader);
		this.classLoader = classLoader;
	}
	
	protected Object createController(Injector injector, String controllerClassFullName) {
		Class clazz = classLoader.clazzForName(controllerClassFullName);
		return injector.getInstance(clazz);
	}
	
	@Override
	public LoadedController loadControllerIntoMeta(Injector injector, ResolvedMethod method,
			boolean isInitializingAllControllers) {
		if(isInitializingAllControllers)
			return null; //skip on startup
		
		return super.loadRouteImpl(injector, method);
	}

	@Override
	public Service createServiceFromFilters(ServiceCreationInfo info, boolean isInitializingAllFilters) {
		if(isInitializingAllFilters)
			return null; //skip on startup
		
		return super.createServiceFromFiltersImpl(info);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy