1 16 package com.jdon.container.access; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 import com.jdon.bussinessproxy.TargetMetaDef; 21 import com.jdon.bussinessproxy.config.TargetMetaDefLoader; 22 import com.jdon.container.ContainerWrapper; 23 import com.jdon.container.finder.ComponentKeys; 24 import com.jdon.container.finder.ServletContainerFinder; 25 import com.jdon.container.visitor.ComponentVisitor; 26 import com.jdon.container.visitor.VisitorFactory; 27 import com.jdon.util.Debug; 28 29 33 public class UserTargetMetaDefFactory { 34 private final static String module = UserTargetMetaDefFactory.class.getName(); 35 36 private static ServletContainerFinder servletContainerFinder = new ServletContainerFinder(); 37 38 public static TargetMetaDef getTargetMetaDef(String name, ContainerWrapper cw){ 39 TargetMetaDefLoader targetMetaDefLoader = (TargetMetaDefLoader) cw.lookup(ComponentKeys.SERVICE_METALOADER_NAME); 40 TargetMetaDef targetMetaDef = targetMetaDefLoader.getTargetMetaDef(name); 41 if (targetMetaDef == null){ 42 Debug.logError("[JdonFramework] not found service definition in jdonframework.xml for " + name, module); 43 return null; 44 } 45 return targetMetaDef; 46 } 47 48 56 public static TargetMetaRequest create(TargetMetaDef targetMetaDef, 57 HttpServletRequest request){ 58 ContainerWrapper containerWrapper = servletContainerFinder.findContainer(request); 59 TargetMetaRequest targetMetaRequest = new TargetMetaRequest(targetMetaDef); 60 VisitorFactory visitorFactory = (VisitorFactory)containerWrapper.lookup(ComponentKeys.VISITOR_FACTORY); 61 ComponentVisitor cm = visitorFactory.getVisitor(request, targetMetaRequest.getTargetMetaDef()); 62 targetMetaRequest.setComponentVisitor(cm); 63 return targetMetaRequest; 64 } 65 66 67 } 68 | Popular Tags |