Skip to main content

Enterprice Applications සංවර්දනය කිරීම 2 කොටස(MVC).

මෙම ලිපියේ අන්තර්ගතය කලින් ලිපිය හා සබැදේ .කලින් ලිපියෙහි සදහන් කල පරිදි මෘදුකාංග නිර්මාණය සදහා බහුලව භාවිතාවන ක්‍රමවේදයක් පිලිබදව සරලව පැහැදිලි කර දීමට මෙම ලිපිය මගින් බලාපොරොත්තු වෙම්.මෙය සරලව MVC යනුවෙන් හැදින්විය

හැක.තවදුරටත් සරල කලහොත් Model,View,Control යනුවෙන් වෙන්කර දැක්විය හැක.නමුත් මෙය පිලිබදව පැහැදිලි අවබොදයක් ලබාගැනීමට ප්‍රායෝගික පද්දතියක ක්‍රියාකාරිත්වය අනුසාරයෙන් පැහැදිලි කලහොත් එය වඩා සුදුසුයැයි සිතම්.එ සදහා මුලින්ම ප්‍රායෝගික පද්දතියක සිදුවන ක්‍රියාකාරීත්වය පිලිබදව සලකා බලමු.

ඉහත රූපයේ පද්ධතියක ක්‍රියාකාරිත්වය පිළිබඳව ඉතාම සරළ ආකාරයේ පැහැදිලි කිරීමකි.මෙය වැඩි දුර පැහැදිලි කිරිමට අවශ්‍ය නැතැයි සිතමි.
මිළග රූපසටහනේ දැක්වෙන්නේ MVC පිළිබඳ සරළ පැහැදිළි කිරිමකි.මෙය පැහැදිලි කිරිමට කලියෙන් එහි ක්‍රියාකාරිත්වය පිළිබඳව උදාහරනයක් මඟින් තේරුම් ගැනීමට උත්සහ ගනිමු.අපි කවුරුත් භාවිතයට ගන්නා Calculator සලකා බලමු.මෙය තුලත් ක්‍රියාත්මක

වන්නේ MVC Design Patter එකයි.මුලින්ම මෙය තුලට ඇතුලත් කරනු ලබන ගණනය කිරීම් එහි ඇති පාලකය(Contoller) මඟින් උචිත Models (Add / Subtract)වෙත යොමු කරනු ලබනවා.එම Models වලින් එම කාර්ය්‍යය ඉටු වු පසු එහි පිළිතුර යොමු වන්නේ LCD පුවරුව වෙතයි(View).එමඟින් එහි පිළිතුර අපට දර්ශනය කර ගත හැක. මෙම ක්‍රියාවලියේදී,

(Add / Subtract) වැනිදේ Models ------------ M
LCD පුවරුවඑක View ලෙසත් ------------- V
පාලකය Controller එක ලෙසත් ------------- C

ක්‍රියාකරනු ලබයි.
මෙම සරළ උදාහරණය මඟින් ඔබට MCV පිළිබඳව සරළ අවබෝධයක් ලැබෙන්නට ඇතැයි සිතමි.



ඉහත රූපසටහනෙන් දැක්වෙන්නේ MCV මෘදුකාංග පද්ධතියකට යොදා ගත හැකි ආකාරයයි.

* පරිශීලකයකු විසින් යම්කිසි කාර්ය්‍යක් කර ගැනිම සඳහා පද්ධතිය වෙත යොමු කරනු ලබන Request එකකි.මෙම Request එක ලබාගනු ලබන්නේ Control එක මඟිනි.
* සාමන්‍ය ජාවා පරිනණක භාෂාව යොදාගෙන දියුනු කරණු ලබන Web පද්දතියක Controller ලෙස ක්‍රියා කරනුයේ Servlet එකකි.එමඟින් ලබා ගන්නා Request එක එම කාර්ය්‍යට අදාළ Models වෙත එමඟින් යොමු කරනු ලබයි.

* Model එක මඟින් ඊට අදාළ කාර්ය්‍යන් සිදුකරනු ලබයි.සමාන්‍යයෙන් පද්ධතියෙ Logic කොටස සිදුකරනු ලබන්නේ Model කොටස මඟිනි.එම කාර්ය්‍ය සඳහා Database එකක සහය අවශ්‍ය නම් ඒ සඳහා සහය ගනු ලබන්නේද Model මඟිනි.Model කොටසවැඩිදියුනු කිරීම සදහා අපට Spring,EJB වැනි තාක්ෂණයක් යොදාගත හැක.

* Model ය තුල ඊට අදාළ Logic කොටස ක්‍රියාත්මක වීමෙන් පසු එමඟින් ලබාගන්නා දත්ත මීළගට අවශ්‍ය වන්නේ පරිශිලකයාට දර්ශණය කීරිමයි.මේ සඳහා View කොටස උපයෝගි වෙයි.එම නිසා මීළගට View සඳහා දත්ත යොමු කෙරේ.

* View කොටස වැඩිදිවුනු කිරීම සදහාද අපට Jsp,Struts වැනි තාක්ෂණයක් යොදාගත හැක.එමඟින් අවසාන ප්‍රතිඵ්ය පරිශීලකයාට දර්ශණය වීමට සලස්වයි.


මෙම සරළ සිද්ධාන්තය බොහෝ විට මෘදුකාංග සංවර්ධනයේදි Design Patter එකක් ලෙස යොදා ගැනේ.නමුත් සමහර අවස්ථා වල MVC යොදා ගන්නවායි සිතා සිටියත් එය හරි හැටි යොදා නොගැනිමේ අවස්ථාද දුබල නොවේ.අපගේ මීළග ලිපියෙන් අපි මෙහි යෙදීම් පිළිබඳව ඉදිරිපත් කිරිමට බලාපොරොත්තු වෙමු.

Comments

Achini said…
a valuable post.has clearly explained.thankz alot...keep it up.

Popular posts from this blog

How to enable proxy service security in ESB 4.9.0?

Security is  one of the major concern when we developing API base integrations or application developments. WSO2 supports WS Security , WS-Policy and WS-Security Policy specifications. These specifications define a behavior model for web services. Proxy service security requirements are different from each others. WSO2 ESB providing pre-define commonly used twenty security scenarios to choose based on the security requirements. This functionality is provided by the security management feature which is bundled by default in service management feature in ESB. This configuration can be done via the web console until ESB 4.8.1 release, but this has been removed from the ESB 4.9.0. Even though this feature isn't provided by the ESB web console itself same functionality can be achieved by the new WSO2 Dev Studio . WSO2 always motivate to use dev studio to prepare required artifacts to the ESB rather than the web console. Better way to explain this scenario is by example. Following...

How to preserving HTTP headers in WSO2 ESB 4.9.0 ?

Preserving HTTP headers are important when executing backend services via applications/middleware. This is because most of the time certain important headers are removed or modified by the applications/middleware which run the communication. The previous version of our WSO2 ESB, version 4.8.1, only supported “ server ” and “ user agent ” header fields to preserve with, but with the new ESB 4.9.0, we’ve introduced a new new property ( http.headers.preserve ) for the passthru ( repository/conf/ passthru-http.properties ) and Nhttp( repository/conf/ nhttp.properties ) transporters to preserve more HTTP headers. Passthru transporter – support header fields               Location Keep-Alive Content-Length Content-Type Date Server User-Agent Host Nhttp transport – support headers Server User-Agent Date You can specify header fields which should be preserved in a comma-separated list, as shown below. http.headers.p...

How SSL Tunneling working in the WSO2 ESB

This blog post assumes that the user who reads has some basic understanding of SSL tunneling and the basic message flow of the ESB. If you are not familiar with the concepts of the SSL tunneling you can refer my previous blog post about the SSL tunneling and you can get detail idea about the message flow from this article . I will give brief introduction about the targetHandler for understand concepts easily. As you may already know TargetHandler(TH) is responsible for handling requests and responses for the backend side. It is maintaining status (REQUEST_READY, RESPONSE_READY .. ,etc) based on the events which fired by the IOReactor and executing relevant methods. As the example if a response which is coming from the backend side hits to the ESB, IOReactor fire the responseRecived method in the targetHandler side. Followings are the basic methods contain in the target handler and their responsibilities. Connect: -  This is executed when new outgoing connection needed. ...