com.github.yoojia.halo.actions.ActionManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of halo-core Show documentation
Show all versions of halo-core Show documentation
A FAST && THIN && HIGH SCALABLE Java web framework
package com.github.yoojia.halo.actions;
import com.github.yoojia.halo.supports.CachedManager;
import com.github.yoojia.halo.utils.Scanner;
import com.github.yoojia.halo.utils.URIs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.util.List;
/**
* @author Yoojia.Chen ([email protected])
*/
final class ActionManager extends CachedManager implements Scanner.PrepareHandler {
private final Logger mLogger = LoggerFactory.getLogger(ActionManager.class);
ActionProcessor findMatched(String method, List urlResource){
for (ActionProcessor p : getProcessors()){
if(p.isMatchedMethod(method) && p.isMatchedResource(urlResource)){
return p;
}
}
return null;
}
@Override
protected void ordering(List from, List to) {
to.addAll(mWeightOrdering.sortedCopy(from));
mLogger.trace("HTTP Action processors: {}", to.size());
}
@Override
public void prepare(String root, Handle config, Class> hostType, Method invoker) {
final String methodName = config.method().toUpperCase(); // !! UpperCase
final String uri = URIs.combined(root, config.path());
final ActionProcessor processor = new ActionProcessor(uri, methodName, invoker, hostType, this);
mLogger.trace("Config: Method={}, Uri={}", methodName, uri);
addProcessor(processor);
}
}