示例#1
0
        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);
        }
示例#2
0
        public static SpringMvcMappings mapCommandClass_using_XRefs(this SpringMvcMappings mvcMappings, JavaMetadata_XRefs xRefs)
        {
            var controllers_by_JavaClass = mvcMappings.controllers_by_JavaClass();

            foreach (var controller in mvcMappings.Controllers)
            {
                controller.mapCommandClass(xRefs);
                if (controller.CommandName.notNull() && controller.CommandClass.isNull())
                {
                    "CommandClass not found but CommandName exists: {0}".debug(controller);
                    if (xRefs.Classes_by_Signature.hasKey(controller.JavaClass))
                    {
                        "Found XRefs for Class: {0}".debug(controller.JavaClass);
                        var javaClass = xRefs.Classes_by_Signature[controller.JavaClass];
                        controller.mapCommandClass(javaClass.SuperClass, xRefs);
                    }
                }
            }
            return(mvcMappings);
        }
示例#3
0
        public static SpringMvcMappings springMvcMappings(this String xmlFile)
        {
            var mvcMappings = new SpringMvcMappings(xmlFile);

            //**** Step 1: map the controlers that have an name that starts with an URL, for example:
            //             <bean name="/shop/viewItem.do"

            var urlBeans = mvcMappings.springBeans.urlBeans();

            foreach (var urlBean in urlBeans)
            {
                mvcMappings.map_ControllerBean(urlBean.name, urlBean);
            }

            //**** Step 2: map items defined in the SimpleUrlHandlerMapping
            var simpleUrlHandlerMappings = (from bean in mvcMappings.springBeans.bean
                                            where bean.@class == "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
                                            select bean).toList();
            //simpleUrlHandlerMappings[0].details();
            var entries = from simpleUrlHandlerMapping in simpleUrlHandlerMappings
                          from property in simpleUrlHandlerMapping.property
                          from map in property.map
                          from entry in map.entry
                          where property.name == "urlMap"
                          select entry;

            var mappedBeans = from bean in mvcMappings.springBeans.bean
                              from entry in entries
                              where entry.valueref == bean.id
                              select new { url = entry.key, bean = bean };

            foreach (var mappedBean in mappedBeans)
            {
                mvcMappings.map_ControllerBean(mappedBean.url, mappedBean.bean);
            }


            return(mvcMappings);
        }
示例#4
0
        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);
        }
示例#5
0
        public static Dictionary <string, List <SpringMvcController> > controllers_by_CommandClass(this SpringMvcMappings mvcMappings)
        {
            var byCommandClass = new Dictionary <string, List <SpringMvcController> >();

            foreach (var controller in mvcMappings.Controllers)
            {
                if (controller.CommandClass.valid())
                {
                    byCommandClass.add(controller.CommandClass, controller);
                }
                //var commandClass= controller.CommandClass ?? "[no commandName]";
                //byCommandClass.add(commandClass, controller);
            }
            return(byCommandClass);
        }
示例#6
0
        public static Dictionary <string, SpringMvcController> controllers_by_JavaClass(this SpringMvcMappings mvcMappings)
        {
            var controllers_by_JavaClass = new Dictionary <string, SpringMvcController>();

            foreach (var controller in mvcMappings.Controllers)
            {
                controllers_by_JavaClass.add(controller.JavaClass, controller);
            }
            return(controllers_by_JavaClass);
        }
示例#7
0
        public static SpringMvcMappings mapCommandClass_using_XRefs(this SpringMvcMappings mvcMappings, string classFiles)
        {
            var xRefs = classFiles.javaMetadata().get_XRefs();

            return(mvcMappings.mapCommandClass_using_XRefs(xRefs));
        }
示例#8
0
    	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;
    	}
示例#9
0
    	public static SpringMvcMappings springMvcMappings(this String xmlFile)
    	{
    		var mvcMappings = new SpringMvcMappings(xmlFile);

			//**** Step 1: map the controlers that have an name that starts with an URL, for example:
			// 			   <bean name="/shop/viewItem.do"
			
			var urlBeans = mvcMappings.springBeans.urlBeans(); 			
			foreach(var urlBean in urlBeans)			 
				mvcMappings.map_ControllerBean(urlBean.name, urlBean);
			
			//**** Step 2: map items defined in the SimpleUrlHandlerMapping
			var simpleUrlHandlerMappings = (from bean in mvcMappings.springBeans.bean
	   							where bean.@class == "org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"
								select bean).toList();
			//simpleUrlHandlerMappings[0].details(); 
			var entries =  from simpleUrlHandlerMapping in simpleUrlHandlerMappings
						   from property in simpleUrlHandlerMapping.property
						   from map in property.map
						   from entry in map.entry			   
						   where property.name == "urlMap" 
						   select entry;
						   
			var mappedBeans = from bean in mvcMappings.springBeans.bean
							  from entry in entries
							  where entry.valueref == bean.id
							  select new {url = entry.key , bean = bean};
			foreach(var mappedBean in mappedBeans)				  
				mvcMappings.map_ControllerBean(mappedBean.url, mappedBean.bean);
				  
			
			return mvcMappings;
		}