ã¯ããã«
ãJavaã®ãªã¼ãã³ã½ã¼ã¹ãã¬ã¼ã ã¯ã¼ã¯ã«ãSpring Frameworkãã¨ãããã®ãããã¾ããDIã³ã³ããã¨AOPã®æ©è½ãæä¾ãããã¬ã¼ã ã¯ã¼ã¯ã§ãä¸çä¸ã§åºãå©ç¨ããã¦ãã¾ãã
ãä»åã¯ãããã.NETã«ç§»æ¤ãããSpring.NETãã¨ãããã¬ã¼ã ã¯ã¼ã¯ãç´¹ä»ãã¾ããç¾å¨ã®ææ°ãã¼ã¸ã§ã³ã¯ã1.0.0ãã§ããã2005å¹´æ«ã«ãªãªã¼ã¹äºå®ã®ã1.1ãã®ãã¬ãã¥ã¼çãSpring 1.1 Web Preview ãã§ãSpring.Webã使ç¨ããæ©è½ãç´¹ä»ãã¾ããSpring.Webã«ã¯ãASP.NETã§ã®éçºãå¼·åã«ãµãã¼ãããæ©è½ãå¤ãå«ã¾ãã¦ãã¾ãã
対象èªè
- .NETã§éçºããã¦ããæ¹
- TDDï¼ãã¹ãé§ååéçºï¼ã«èå³ãæã£ã¦ããæ¹
- ã¢ããªã±ã¼ã·ã§ã³ã»ã¢ã¼ããã¯ãã£ã«èå³ãæã£ã¦ããæ¹
å¿ è¦ãªç°å¢
ãMicrosoft Visual Studio .NET 2003ä¸ã§åä½ç¢ºèªãã¦ãã¾ãã
Spring.NETã®å ¥æã¨ã»ããã¢ãã
ãSpring 1.1 Web Previewçãã¤ã³ã¹ãã¼ã«ãã¾ãã
return new CultureInfo(context.Request.UserLanguages[0]);
return CultureInfo.CreateSpecificCulture(
context.Request.UserLanguages[0]);
ãVisual Studioã§ãã«ããããã¡ã¤ã«ã¯ããã¤ã³ã¹ãã¼ã«å \build\VS.Net\ã以ä¸ã«ä½æããã¾ãã
Spring.NETã«ããã¡ãªãã
ããS2Container.NETã®DIã¨AOPãæ´»ç¨ãçç£æ§ã®é«ãã·ã¹ãã ãæ§ç¯ãããã§ãç´¹ä»ããã¦ãã¾ãããDIã®ã¡ãªããã¯ãã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨å®è£ ãåé¢ãã¦å¤æ´å®¹ææ§ã大ããåä¸ãããã¨ã§ããã¾ãã¯ã©ã¹éã®ä¾åãã³ã¼ãããåãé¤ããã¨ã§ãMockã®ä½¿ç¨ã容æã«ãã¾ããããã¯ãTDDï¼ãã¹ãé§ååéçºï¼ã«ã¯å¤§ããªåãçºæ®ãã¾ãã
ãä¾ã¨ãã¦ãDBã¢ã¯ã»ã¹ã¨éä¿¡å¦çãããã¢ããªã±ã¼ã·ã§ã³ã§èãã¾ããDBã¢ã¯ã»ã¹ãã¸ãã¯ã®ãã¹ãã¯ãDBã®åæåãªã©éãå¦çãå¿ è¦ã«ãªãã¾ããããã§ããªãã¨ãèªååãããã¨ãã§ãã¾ããããããéä¿¡ãã¸ãã¯ã¯ãå¤é¨ç°å¢ã«å®å ¨ã«ä¾åãã¦ãã¾ãããããã¹ãã®èªååã¯å¤§å¤å°é£ã§ãã両ã¯ã©ã¹ãå¼ã³åºããµã¼ãã¹ã¯ã©ã¹ããéä¿¡ãã¸ãã¯ã¸ç´æ¥ä¾åãã¦ãã¾ãããããã¹ãã®èªååãã§ããªããªãã¾ãã
ãDIã§ã¯ããã®åé¡ã解決ãããã¨ãã§ãã¾ãããµã¼ãã¹ã¯ã©ã¹ã¨ãDBã¢ã¯ã»ã¹ã¯ã©ã¹ãéä¿¡ãã¸ãã¯ã¯ã©ã¹ã¨ã®ä¾åãå¤é¨ã³ã³ããï¼DIã³ã³ããï¼ã«ä»»ãããã¨ã«ãããéä¿¡ãã¸ãã¯ä»¥å¤ãèªåãã¹ããããã¨ãå¯è½ã«ãªãã¾ãã
ã以ä¸ã®ããã«DIã使ç¨ãããã¨ã§ãã¹ãã®èªååã容æã«ããã¢ããªã±ã¼ã·ã§ã³éçºã®å®å®ã«å¤§ããªåãçºæ®ãããã¨ãã§ãã¾ãã
ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³
ããSpringWebSampleãã¯ãWebä¸ããã¢ã«ãã ã®è³¼å ¥ãè¡ãç°¡åãªWebã¢ããªã±ã¼ã·ã§ã³ã§ãã
ããã®ãµã³ãã«ã«ã¯ãé常ã®DIãAOPã®ä»ã«ãWebãã¼ã¸ã®DIããã¹ã¿ã¼ãã¼ã¸ãªã©ãSpring.NETã®ç¹å¾´ãè²ã ã¨åãå ¥ãã¦ãã¾ãã
ãå®è¡ããã«ã¯ããSpringWebSampleãããã¦ã³ãã¼ããããã®ä¸ã«ãããSpring.Example.Webããã©ã«ããä»®æ³ãã£ã¬ã¯ããªã«è¨å®ãã¦ãã ãããã¹ã¿ã¼ããã¼ã¸ã¯ãSpring.Example.Web\Page\AlbumListPage.aspxãã§ãã
ãã¾ããæ¬ãµã³ãã«ã«å«ã¾ãã¦ããSpring.NETã¢ã»ã³ããªã¯ãå ã«èª¬æããä¿®æ£ãè¡ã£ã¦ãã¾ãã
ãã¸ãã¯é¨ã®ä½æ
ããã¼ã¿ã¹ãã¢ãããã¢ã«ãã ä¸è¦§ãåå¾ããã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨æ³¨æãæ ¼ç´ããã¤ã³ã¿ã¼ãã§ã¼ã¹ãä½æãã¾ãã
/// <summary>製åãã¼ã¿ã¢ã¯ã»ã¹</summary> public interface IProductDao { /// <summary>å ¨ã¢ã«ãã ãåå¾ãã</summary> /// <returns>ã¢ã«ãã ã®ãªã¹ã</returns> IList GetAlbums(); }
/// <summary>注æãã¼ã¿ã¢ã¯ã»ã¹</summary> public interface IOrderDao { /// <summary>æ ¼ç´ãã</summary> /// <param name="sale">販売</param> /// <returns>注æID</returns> int Store( Sale sale ); }
ã次ã«ããããã®ãã¼ã¿ã¢ã¯ã»ã¹ã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ç¨ãã注æãµã¼ãã¹ã¯ã©ã¹ãå®è£ ãã¾ãã
/// <summary>注æãµã¼ãã¹</summary> public class OrderService : IOrderService { IOrderDao _orderDao; IProductDao _productDao; // ã³ã³ã¹ãã©ã¯ã¿ã¤ã³ã¸ã§ã¯ã·ã§ã³ public OrderService( IOrderDao orderDao, IProductDao productDao ) { _orderDao = orderDao; _productDao = productDao; } public IList GetAlbums() { return _productDao.GetAlbums(); } public SaleConfirmation Order( Sale sale ) { int ID = _orderDao.Store( sale ); SaleConfirmation confirmation = new SaleConfirmation( sale, ID.ToString( "00000000" ) ); return confirmation; } }
ãIOrderDao
ã¨IProductDao
ã®å®è£
ã¯ã©ã¹ãã³ã³ãããã注å
¥ããããããå®è£
ã®æèããã«OrderService
ã¯ã©ã¹ãä½æãããã¨ãã§ãã¾ãã
ãã¾ããã¹ãã«ã¯ãIOrderDao
ãIProductDao
ããããã¢ãã¯ã¯ã©ã¹ã容æã«è¨å®ãããã¨ãã§ãã¾ãã
ãã¸ãã¯é¨ã®ãªãã¸ã§ã¯ãå®ç¾©ãã¡ã¤ã«
ãä¸è¨ã¯ã©ã¹ã®è¨å®ï¼IOrderDao
ã®å®è£
ã¨IProductDao
ã®å®è£
ãã³ã³ã¹ãã©ã¯ã¿å¼æ°ã«æå®ããï¼ãXMLãã¡ã¤ã«ã§è¨è¿°ã§ãã¾ãã
<objects> <!-- 製åDAOï¼IProductDaoã®å®è£ ã¯ã©ã¹ï¼--> <object id="productDao" type="Spring.Example.Core.Data. Impl.MemoryProductDao,Spring.Example.Core"/> <!-- 注æDAOï¼IOrderDaoã®å®è£ ã¯ã©ã¹ï¼--> <object id="orderDao" type="Spring.Example.Core.Data.Impl. MemoryOrderDao,Spring.Example.Core"/> </objects>
ã<objects>
ã¿ã°ã®ä¸ã«<object>
ã¿ã°ã§ãªãã¸ã§ã¯ããç»é²ãã¾ãã<onject>
ã¿ã°ã«ã¯ã主ã«ä»¥ä¸ã®å±æ§ãæå®ãããã¨ãã§ãã¾ãã
å±æ§å | å 容 |
id | ãªãã¸ã§ã¯ãã®ID |
type | ã¯ã©ã¹å,ã¢ã»ã³ããªå |
singleton | ã·ã³ã°ã«ãã³ã§çæï¼"true" ,"false" ï¼ |
parent | è¨å®ãå¼ãç¶ã親ãªãã¸ã§ã¯ãã®ID |
abstract | ãªãã¸ã§ã¯ãã®çæãæå¦ï¼"true" ,"false" ï¼ |
ãããã¦ããData.xmlãã§è¨å®ãããªãã¸ã§ã¯ããOrderServiceã«æ³¨å ¥ãã¾ãã
<objects> <!-- 注æãµã¼ãã¹ï¼IOrderServiceã®å®è£ ã¯ã©ã¹ï¼ --> <object id="orderService" type="Spring.Example.Core.Service. OrderService,Spring.Example.Core"> <!-- ã³ã³ã¹ãã©ã¯ã¿ã¤ã³ã¸ã§ã¯ã·ã§ã³ --> <constructor-arg index="0" ref="orderDao" /> <constructor-arg index="1" ref="productDao" /> </object> </objects>
ãDIã®æ¹æ³ã¨ãã¦ãç¾å¨Spring.NETã¯ãã³ã³ã¹ãã©ã¯ã¿ã¤ã³ã¸ã§ã¯ã·ã§ã³ã¨ã»ãã¿ã¼ã¤ã³ã¸ã§ã¯ã·ã§ã³ã®2種é¡ããµãã¼ããã¦ã¾ããä¸è¨ä¾ã§ã¯ãã³ã³ã¹ãã©ã¯ã¿ã¤ã³ã¸ã§ã¯ã·ã§ã³(<constructor-arg>
ã¿ã°)ã使ç¨ãã¦ãã¾ãã
ãref
å±æ§ã§æ³¨å
¥ãããªãã¸ã§ã¯ãIDãè¨å®ãã¾ããã¾ããä¾ã§ã¯index
å±æ§ã§ã¿ã¼ã²ãããæå®ãã¦ãã¾ãããä»ã«name
å±æ§ã§å¼æ°åãæå®ããæ¹æ³ãããã¾ãã
AOPã®è¨å®
ãSpring.NETã«ã¯ãã¡ã½ããã®æ»ãå¤ããã£ãã·ã¥ããAOPãæä¾ãã¦ãã¾ããCacheAttribute
å±æ§ã使ç¨ãã¦ã対象ã¨ãªãã¡ã½ããããã¼ãã³ã°ãããã¨ãã§ãã¾ãã
// 60ç§éãã£ãã·ã¥ãã [ Cache( TimeToLive = 60, SlidingExpiration = true, Priority = CachePriority.Low ) ] public IList GetAlbums() { return _productDao.GetAlbums(); }
ã次ã«ãå®éã«ãã£ãã·ã¥å¦çãè¡ãAOPãXMLãã¡ã¤ã«ã«å®ç¾©ãã¾ãã
<!-- ASP.NET ãã£ãã·ã¥ --> <object id="aspNetCacheAdvice" type="Spring.Web.Advice.AspNetCacheAdvice, Spring.Web"/> <!-- ãã£ãã·ã¥ã¢ã¹ãã¯ã --> <object id="cacheAspect" type="Spring.Aop.Support.DefaultPointcutAdvisor, Spring.Aop"> <property name="Pointcut"> <!-- CacheAttributeå±æ§ããã¼ã¯ããã¦ããã¡ã½ããã対象ã¨ãã --> <object type="Spring.Aop.Support.AttributeMatchMethodPointcut, Spring.Aop"> <property name="Attribute" value="Spring.Attributes.CacheAttribute, Spring.Core"/> </object> </property> <!-- ASP.NETãã£ãã·ã¥ã使ç¨ãã --> <property name="Advice" ref="aspNetCacheAdvice"/> </object>
ãä¸è¨è¨å®ã®å
容ã¯ãASP.NETã®ãã£ãã·ã¥ã«ä¿åããAspNetCacheAdvice
ã¯ã©ã¹ããCacheAttribute
å±æ§ããã¼ã¯ããã¦ããã¡ã½ããã«ã¤ã³ã¿ã¼ã»ãããããã¨ãããã®ã§ãã
ãããã¦ãOrderService
ã¯ã©ã¹ã®è¨å®å
容ã以ä¸ã«ä¿®æ£ãã¾ãã
<!-- 注æãµã¼ãã¹ --> <object id="orderServiceTarget" type="Spring.Example.Core.Service.OrderService,Spring.Example.Core"> <constructor-arg index="0" ref="orderDao" /> <constructor-arg index="1" ref="productDao" /> </object> <!-- 注æãµã¼ãã¹ ãããã· --> <object id="orderService" type="Spring.Aop.Framework.ProxyFactoryObject" > <property name="target" ref="orderServiceTarget" /> <!-- cacheAspectãã¤ã³ã¿ã¼ã»ããããã--> <property name="interceptorNames" value="cacheAspect" /> </object>
ãProxyFactoryObject
ã¨ããã¯ã©ã¹ã使ç¨ãã¦ããããã·ãä½æãããã¨ãã§ãã¾ãã
ãä¸è¨ã®è¨å®ã§ã¯ãOrderService
ã¯ã©ã¹ã®ãããã·ï¼ãã£ãã·ã³ã°ããæ©è½ã追å ããã¦ããï¼ãçæãã¦ãã¾ãã
ãç¾ç¶ããã®æ©è½ã¯ASP.NETã®ãã£ãã·ã¥ã使ç¨ããæ¹æ³ããããã¾ãããã次åãªãªã¼ã¹ããã¯ãEnterpriseLibraryã®ãCaching Application Blockãã使ç¨ããæ¹æ³ããµãã¼ããããäºå®ã§ãã
ã¤ã³ã¿ã¼ã»ããã®ç¨®é¡
ããã¡ãããã«ã¹ã¿ã ã®AOPãä½æãããã¨ãã§ãã¾ããProxyFactoryObject
ã®interceptorNames
ããããã£ã«ã以ä¸ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®è£
ããã¯ã©ã¹ãè¨å®ãã¾ãã
ã¤ã³ã¿ã¼ãã§ã¼ã¹å | å 容 |
IMethodInterceptor | ã¡ã½ããå¼ã³åºãã®ã¤ã³ã¿ã¼ã»ãã |
IMethodBeforeAdvice | ã¡ã½ããå¼ã³åºãã®åãã¤ã³ã¿ã¼ã»ãã |
IAfterReturningAdvice | ã¡ã½ããå¼ã³åºãã®å¾ãã¤ã³ã¿ã¼ã»ãã |
IThrowsAdvice | ä¾å¤ãã¤ã³ã¿ã¼ã»ãã |
ãIMethodInterceptor
ã使ç¨ããç°¡åãªãµã³ãã«ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
public class TraceInterceptor : IMethodInterceptor { public object Invoke(IMethodInvocation invocation) { Console.WriteLine( string.Format( "TraceInterceptor Call: ã¡ã½ããå{0}", invocation.Method.Name ) ); object returnValue = invocation.Proceed(); Console.WriteLine( string.Format( "TraceInterceptor Return: {0}", returnValue ) ); return returnValue; } }
ããã£ãã·ã³ã°ã®ä¾ã§ã¯ã«ã¹ã¿ã å±æ§ã使ç¨ãã¦ã¢ã¹ãã¯ã対象ã®ã¡ã½ããããã¼ã¯ãã¦ãã¾ãããä»ã«ãRegexpMethodPointcutAdvisor
ã¯ã©ã¹ã使ç¨ãã¦ã¡ã½ããåãæå®ããæ¹æ³ãããã¾ãã
<object id="traceAspect" type="Spring.Aop.Support.RegexpMethodPointcutAdvisor, Spring.Aop"> <!-- æ£è¦è¡¨ç¾ã使ç¨ãã¦ã¡ã½ããåãæå®ãã --> <property name="pattern" value="Get*"/> <property name="advice"> <object type="Sample.TraceInterceptor"/> </property> </object>
Webãã¼ã¸ã®ä½æ
ãOrderServiceãDIããWebãã¼ã¸ãä½æãã¾ãã
public class AlbumListPage : Spring.Web.UI.Page { /// <summary>ã¢ã«ãã ä¸è¦§</summary> /// <remarks> /// DataModelå±æ§ã使ç¨ããã¨ããã¹ãããã¯ã®éä¿åããã /// </remarks> [ DataModel ] public IList Albums { get { return _albums; } set { _albums = value; } } /// <summary>注æãµã¼ãã¹</summary> /// <remarks>DIããã»ãã¿ã¼ã¤ã³ã¸ã§ã¯ã·ã§ã³ããã</remarks> public IOrderService OrderService { get { return _orderService; } set { _orderService = value; } } /// <summary>ãã¼ã¿ã¢ãã«ã®åæåãè¡ã</summary> /// <remarks>IsPostBack = false ã®æã«å¼ã°ãã</remarks> /// <param name="e"></param> protected override void OnInitializeDataModel(EventArgs e) { base.OnInitializeDataModel (e); // ãµã¼ãã¹ããã¢ã«ãã ä¸è¦§ãåå¾ãã Albums = OrderService.GetAlbums(); } /// <summary>ã³ã³ããã¼ã«ã®åæåãè¡ã</summary> /// <remarks>æ¯åå¼ã°ãã</remarks> /// <param name="e"></param> protected override void OnInitializeControls(EventArgs e) { base.OnInitializeControls (e); if( !IsPostBack ) { // ãã¼ã¿ã¢ãã«ãRepeaterã«ãã¤ã³ããã Repeater.DataSource = Albums; Repeater.DataBind(); } } /// <summary>è³¼å ¥ãã¿ã³ã¤ãã³ã</summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBuy_Click(object sender, System.EventArgs e) { Session[ "Sale" ] = MakeSale(); // æ§æãã¡ã¤ã«ã§æå®ããã¦ãã // ãdisplayOrderããã¼ã¸ã«é·ç§»ãã SetResult( "displayOrder" ); } }
ããã¼ã¸ãã³ã³ããã§ç®¡çããããã«ã¯ãSpring.Web.UI.Page
ã¯ã©ã¹ãæ´¾çãã¾ãããã®ã¯ã©ã¹ã«ã¯ãDataModel
å±æ§ãªã©ããã¼ã¸ã¯ã©ã¹ã®ä½æãã·ã³ãã«ã«ããæ§ã
ãªæ©è½ãå®è£
ããã¦ãã¾ãã
ããã¼ã¸ã®ã©ã¤ããµã¤ã¯ã«ã®åºæ¬çãªãã¿ã¼ã³ã¯ã以ä¸ã®ããã«ãªãã¾ãã
OnInitializeDataModel
ã¡ã½ããããªã¼ãã¼ã©ã¤ãããç»é¢ã«ä½¿ç¨ãããã¼ã¿ã¢ãã«ãåå¾ããï¼ååæã®ã¿ã³ã¼ã«ãããï¼ã- åå¾ãããã¼ã¿ã¢ãã«ã
DataModel
å±æ§ããã¼ã¯ããã¦ããããããã£ã«è¨å®ããï¼ä»¥å¾ãã¹ãããã¯ãã¦ããã¼ã¿ãä¿æããã¦ããï¼ã OnInitializeControls
ã¡ã½ããããªã¼ãã¼ã©ã¤ããããã¼ã¿ã¢ãã«ãã³ã³ããã¼ã«ã«ãã¤ã³ããããSetResult
ã¡ã½ããã使ç¨ãã¦ãä»ãã¼ã¸ï¼ãªãã¸ã§ã¯ãå®ç¾©ãã¡ã¤ã«ã«è¨å®ããï¼ã«é·ç§»ããã
ããã®ããã«ãè¤éã«ãªããã¡ãªWebãã¼ã¸ã®ã©ã¤ããµã¤ã¯ã«ãã·ã³ãã«ã«ç®¡çã§ããããã«ãªãã¾ããããã«Spring.NETã§ã¯ãASP.NET 2.0ããå®è£ ãããããã¹ã¿ã¼ãã¼ã¸ããå®ç¾ãããã¨ãã§ãã¾ãã
UIé¨ã®ãªãã¸ã§ã¯ãå®ç¾©ãã¡ã¤ã«
<objects> <!-- ãã¹ã¿ã¼ãã¼ã¸ --> <object id="masterTemplate" type="~/Page/Template.aspx"/> <!-- ãã¼ã«ã©ã¤ãºãªãã¸ã§ã¯ã --> <object id="localeResolver" type="Spring.Web.Localization.Resolvers.SessionLocaleResolver, Spring.Web"/> <object id="localizer" type="Spring.Web.Localization.Localizers.ResourceSetLocalizer, Spring.Web"/> <!-- å ¨ãã¼ã¸å ±éã®è¨å® --> <object id="standardPage" abstract="true"> <!-- ãã¹ã¿ã¼ãã¼ã¸ --> <property name="Master" ref="masterTemplate"/> <!-- ãã¼ã«ã©ã¤ãº --> <property name="LocaleResolver" ref="localeResolver"/> <property name="Localizer" ref="localizer"/> <!-- ã¹ã¿ã¤ã«ã·ã¼ãã«ã¼ã --> <property name="CssRoot" value="Css"/> <!-- ã¤ã¡ã¼ã¸ãã¡ã¤ã«ã«ã¼ã --> <property name="ImagesRoot" value="Images"/> <!-- ã¹ã¯ãªãããã¡ã¤ã«ã«ã¼ã --> <property name="ScriptsRoot" value="Scripts"/> </object> <!-- ã¢ã«ãã ä¸è¦§ãã¼ã¸ --> <object type="~/Page/AlbumListPage.aspx" parent="standardPage"> <property name="OrderService" ref="orderService"/> <property name="Results"> <dictionary> <entry key="displayOrder" value="redirect:OrderPage.aspx"/> </dictionary> </property> </object> </objects>
ãOrderServiceã¯ã©ã¹
ãã»ãã¿ã¼ã¤ã³ã¸ã§ã¯ã·ã§ã³ï¼<property>
ã¿ã°ï¼ã§è¨å®ãã¦ãã¾ãã
ãã¾ããSpring.Web.UI.Page
ã¯ã©ã¹ã«ã¯ã以ä¸ã®ã»ãã¿ã¼ããããã£ãç¨æããã¦ãã¾ãã
ããããã£å | å 容 |
Result | SetResult ã¡ã½ããã§ä½¿ç¨ãããªãã¤ã¬ã¯ãå
ã®ãã¼ã¸ã¨ID |
Master | ãã¹ã¿ã¼ãã¼ã¸ã®ãªãã¸ã§ã¯ãID |
CssRoot | ã¹ã¿ã¤ã«ã·ã¼ãã®ã«ã¼ããã¹ |
ImagesRoot | ã¤ã¡ã¼ã¸ãã¡ã¤ã«ã®ã«ã¼ããã¹ |
ScriptsRoot | ã¹ã¯ãªãããã¡ã¤ã«ã®ã«ã¼ããã¹ |
ãMaster
ãCssRoot
ãImagesRoot
ãªã©ã¯å
¨ãã¼ã¸å
±éã®è¨å®ã«ãªããããabstract
/parent
å±æ§ã使ç¨ãã¦ç®¡çãã¦ãã¾ãã
ãã¾ããResults
ããããã£ã«ã¯SetResult
ã¡ã½ããã§é·ç§»ãããã¼ã¸ãè¨å®ãã¾ããããã«ããããã¼ã¸é·ç§»ãã½ã¼ã¹ã³ã¼ãããåãé¤ããã¨ãã§ãã¾ãã
ãã¹ã¿ã¼ãã¼ã¸
ãå ã«è§¦ãã¾ããããSpring.NETã§ã¯ãã¹ã¿ã¼ãã¼ã¸ãä½æãããã¨ãã§ãã¾ãããã®æ©è½ã«ãããå ¨ãã¼ã¸å ±éã®ãã³ãã¬ã¼ããä½æã§ããããã管çãé常ã«ç°¡åã«ãªãã¾ãã
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %> <%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false" Inherits="Spring.Example.Web.Page.Template" %> <HTML> <head> <!-- ãªã½ã¼ã¹ãã¡ã¤ã«ããåå¾ --> <title> <%= GetMessage("default.title") %> </title> <LINK href="<%= CssRoot %>/default.css" type=text/css rel=stylesheet> </head> <body> <form id="Form1" method="post" runat="server"> <div id="logo"> <img src="<%= ImagesRoot %>/title.png"> </div> <BR> <div id="container"> <div id="content"> <!-- ã³ã³ãã³ãã®æ³¨å ¥å ´æ --> <spring:ContentPlaceHolder id="body" runat="server" /> </div> </div> </form> </body> </HTML>
<%@ Page language="c#" Codebehind="AlbumListPage.aspx.cs" AutoEventWireup="false" Inherits="Spring.Example.Web.Page.AlbumListPage" %> <%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %> <HTML> <body> <!-- ã³ã³ãã³ãã®æ³¨å ¥å ãcontentPlaceholderIdã§æå® --> <spring:Content id="body" contentPlaceholderId="body" runat="server"> <asp:Repeater id="Repeater" runat="server"> <!-- çç¥ --> </asp:Repeater> </spring:Content> </body> </HTML>
ããTemplate.aspxãã«ãã<spring:ContentPlaceHolder>
ã¿ã°ã§ãä»ãã¼ã¸ã®ã³ã³ãã³ãã注å
¥ãã¾ãã注å
¥ããã³ã³ãã³ãã¯ã<spring:Content>
ã¿ã°ã§å²ã¿ãcontentPlaceholderId
å±æ§ã§ãContentPlaceHolder
ã®IDãè¨å®ãã¾ãã
ã³ã³ããã®è¨å®
ãæå¾ã«ããWeb.configãã«Springã³ã³ããã®è¨å®ãè¨è¿°ãã¾ãã
<configuration> <configSections> <sectionGroup name="spring"> <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" /> <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /> </sectionGroup> </configSections> <appSettings> <!-- log4netè¨å®ãã¡ã¤ã«ã¸ã®ãã¹ --> <add key="Log4NetConfigFile" value="~/Config/Log4NET.xml"/> </appSettings> <spring> <context type="Spring.Context.Support.WebApplicationContext, Spring.Web"> <!-- åç §ãããªãã¸ã§ã¯ãè¨å®ãã¡ã¤ã«ã¸ã®ãã¹ --> <resource uri="~/Config/Aspects.xml" /> <resource uri="~/Config/Web.xml" /> <resource uri="~/Config/Data.xml" /> <resource uri="~/Config/Service.xml" /> <resource uri="~/Config/Log4net.xml" /> </context> </spring> <system.web> <httpHandlers> <!-- DIããããã«ä½¿ç¨ããSpring.NETã«ã¹ã¿ã ã®HTTPãã³ãã© --> <!-- Webãã¼ã¸ç¨ --> <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" /> <!-- Webãµã¼ãã¹ç¨ --> <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/> </httpHandlers> <!-- çç¥ --> </system.web> </configuration>
ã<resource>
ã¿ã°ã§ããªãã¸ã§ã¯ããå®ç¾©ãã¦ããè¨å®ãã¡ã¤ã«ã¸ã®åç
§ã追å ãã¾ãããã以å¤ã®é¨åã¯ãä¸è¨å
容ãå¤æ´ããå¿
è¦ã¯ããã¾ããã
æå¾ã«
ãSpring.NETã¯ç¾å¨ãçºå±éä¸ã®ãããã¯ãã§ããä»åã¯æ¬¡æãªãªã¼ã¹ã§ã®Webæ©è½ãç´¹ä»ãã¾ããããä»å¾ã®ãã¼ã¸ã§ã³ã§ä»¥ä¸ã®æ©è½ããªãªã¼ã¹ãããäºå®ã§ãã
- Release 1.1 (Q4 2005)
- Web
- Services
- .NET 2.0 Support
- Enterprise Library Integration
- IBatis.NET Integration
- Release 1.2 (Q1 2006)
- Data Accessï¼ADO.NET abstractionï¼
- Smart Client ï¼WinFormsï¼
- Windows Services
- Console Applications
ãSpring.NETã®å¼·ã¿ã¯ãEnterprise LibraryãIBatis.NETãNHibernateãªã©ãä»ãã¬ã¼ã ã¯ã¼ã¯ã¨ã®é£æºããµãã¼ããããããã®æ¥çå¤ã¨ãã¦å©ç¨ã§ãããã¨ãããã¾ãã
ãèå³ãæã£ãæ¹ã¯ããã²Spring.NETã¨DIã試ãã¦ã¿ã¦ãã ããã
åèè³æ
- Spring.NETãã¼ã ï¼è±èªï¼
- Spring.NETãµãã¼ããã©ã¼ã©ã ï¼è±èªï¼
- Spring.NET JP
- CodeZine ãS2Container.NETã®DIã¨AOPãæ´»ç¨ãçç£æ§ã®é«ãã·ã¹ãã ãæ§ç¯ããã éæ¨æ·³å¤« èã2005å¹´10æ
- ï¼ IT ãSpring Frameworkã§ç解ããDIã å±±æ¬å¤§ èã2005å¹´4æ
ã