package com.ada.wuliu.front.web.base;
import java.io.IOException;
import java.io.Writer;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.Node;
public class VmSession extends Directive{
private static AdwlFrontBaseAction adwlFrontBaseAction =new AdwlFrontBaseAction() {};
public void setAdwlFrontBaseAction(
AdwlFrontBaseAction adwlFrontBaseAction) {
this.adwlFrontBaseAction = adwlFrontBaseAction;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return "getUserState";
}
@Override
public int getType() {
// TODO Auto-generated method stub
return LINE;
}
@Override
public boolean render(InternalContextAdapter contextAdapter, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException,
MethodInvocationException {
try{
// TODO Auto-generated method stub
System.out.println("测试velocity自定义命令..........................");
String str=adwlFrontBaseAction.getUserIDFromSession();
System.out.println("测试velocity自定义命令..........................");
contextAdapter.put("sso_pin", str);
contextAdapter.put("test", "这是vmsession自定义指令加载进来的数据");
System.out.println("测试velocity自定义命令..........................");
}catch(Exception e){
e.printStackTrace();
}
return true;
}
}