public static SpringMvcController mapCommandClass(this SpringMvcController controller, string javaClass, JavaMetadata_XRefs xRefs) { if (controller.CommandClass.isNull() && controller.JavaClass.valid()) { var _class = xRefs.JavaMetadata.java_Classes().signature(javaClass); if (_class.notNull()) { if (controller.CommandName.isNull()) { var initMethod = _class.java_Methods().name("<init>"); foreach (var methodRef in initMethod.methodRefs(_class)) { if (methodRef.Signature.contains("setCommandName")) { var location = methodRef.AtLocations[0]; var instructions_byPc = initMethod.instructions_byPc(); var targetIndex = instructions_byPc[location.Pc - 2].Target_Index; controller.CommandName = _class.constantsPool_byIndex()[targetIndex].str(); "resolved command name for {0} = {1}".info(controller.JavaClass, controller.CommandName); break; } } } //try to find it via the return value of the formBackingObject if (controller.CommandClass.isNull()) { var formBackingObject = _class.java_Methods().name("formBackingObject"); if (formBackingObject.notNull()) { var numberOfInstructions = formBackingObject.Instructions.size(); if (formBackingObject.Instructions[numberOfInstructions - 3].OpCode == "__aload" && formBackingObject.Instructions[numberOfInstructions - 2].OpCode == "__areturn") { var variablesByIndex = formBackingObject.variables_byIndex(); var variableIndex = formBackingObject.Instructions[numberOfInstructions - 3].Target_Index; if (variablesByIndex[variableIndex].size() > 0) { controller.CommandClass = variablesByIndex[variableIndex].last().Descriptor.removeFirstChar().removeLastChar(); "resolved CommandClass for CommandName {0} -> {1}".info(controller.CommandName, controller.CommandClass); } } } } //try to find CommandClass via CommandName if (controller.CommandName.notNull() && controller.CommandClass.isNull()) { foreach (var @class in xRefs.Classes_by_Signature) { if (@class.Value.Name == controller.CommandName.upperCaseFirstLetter()) { controller.CommandClass = @class.Value.Signature; "resolved CommandClass for CommandName {0} -> {1}".info(controller.CommandName, controller.CommandClass); break; } } } } } return(controller); }
public static SpringMvcMappings springMvcMappings(this String xmlFile) { var mvcMappings = new SpringMvcMappings(xmlFile); var urlBeans = mvcMappings.springBeans.urlBeans(); var beans_byId = mvcMappings.springBeans.beans_byId(); foreach (var urlBean in urlBeans) { var controller = new SpringMvcController() { HttpRequestUrl = urlBean.name, JavaClass = urlBean.@class }; foreach (var _property in urlBean.property) { controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "")); } if (controller.JavaClass.inValid() && beans_byId.hasKey(urlBean.parent)) { controller.JavaClass = beans_byId[urlBean.parent].@class; foreach (var _property in beans_byId[urlBean.parent].property) { controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "")); } } if (controller.JavaClass.valid()) { controller.FileName = "{0}.java".format(controller.JavaClass.replace(".", "\\")); } controller.CommandName = controller.Properties["commandName"]; controller.CommandClass = controller.Properties["commandClass"]; mvcMappings.Controllers.Add(controller); } return(mvcMappings); }
public static SpringMvcMappings map_ControllerBean(this SpringMvcMappings mvcMappings, string httpRequestUrl, beans.beanLocalType urlBean) { var controller = new SpringMvcController() { HttpRequestUrl = httpRequestUrl, JavaClass = urlBean.@class }; foreach (var _property in urlBean.property) { controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "")); } //not used in the current case //var beans_byId = mvcMappings.springBeans.beans_byId(); /* if (controller.JavaClass.inValid() && beans_byId.hasKey(urlBean.parent)) * { * controller.JavaClass = beans_byId[urlBean.parent].@class; * foreach(var _property in beans_byId[urlBean.parent].property) * controller.Properties.add(_property.name, _property.value + * (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" )); * * } */ if (controller.JavaClass.valid()) { controller.FileName = "{0}.java".format(controller.JavaClass.replace(".", "\\")); } controller.CommandName = controller.Properties["commandName"]; controller.CommandClass = controller.Properties["commandClass"]; mvcMappings.Controllers.Add(controller); return(mvcMappings); }
public static SpringMvcController mapCommandClass(this SpringMvcController controller, JavaMetadata_XRefs xRefs) { return(controller.mapCommandClass(controller.JavaClass, xRefs)); }
public static SpringMvcMappings springMvcMappings(this String xmlFile) { var mvcMappings = new SpringMvcMappings(xmlFile); var urlBeans = mvcMappings.springBeans.urlBeans(); var beans_byId = mvcMappings.springBeans.beans_byId(); foreach(var urlBean in urlBeans) { var controller = new SpringMvcController() { HttpRequestUrl = urlBean.name, JavaClass = urlBean.@class }; foreach(var _property in urlBean.property) controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" )); if (controller.JavaClass.inValid() && beans_byId.hasKey(urlBean.parent)) { controller.JavaClass = beans_byId[urlBean.parent].@class; foreach(var _property in beans_byId[urlBean.parent].property) controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" )); } if (controller.JavaClass.valid()) controller.FileName = "{0}.java".format(controller.JavaClass.replace(".","\\")); controller.CommandName = controller.Properties["commandName"]; controller.CommandClass= controller.Properties["commandClass"]; mvcMappings.Controllers.Add(controller); } return mvcMappings; }
public static SpringMvcMappings map_ControllerBean(this SpringMvcMappings mvcMappings, string httpRequestUrl, beans.beanLocalType urlBean) { var controller = new SpringMvcController() { HttpRequestUrl = httpRequestUrl, JavaClass = urlBean.@class }; foreach(var _property in urlBean.property) controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" )); //not used in the current case //var beans_byId = mvcMappings.springBeans.beans_byId(); /* if (controller.JavaClass.inValid() && beans_byId.hasKey(urlBean.parent)) { controller.JavaClass = beans_byId[urlBean.parent].@class; foreach(var _property in beans_byId[urlBean.parent].property) controller.Properties.add(_property.name, _property.value + (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" )); } */ if (controller.JavaClass.valid()) controller.FileName = "{0}.java".format(controller.JavaClass.replace(".","\\")); controller.CommandName = controller.Properties["commandName"]; controller.CommandClass= controller.Properties["commandClass"]; mvcMappings.Controllers.Add(controller); return mvcMappings; }