/Users/andrea/_magisterarbeit/korpus/clean/testkorpus/32/file19.html NN ----------------------------------------- : Advanced NP Search NP Search NP Help NN Search NP for IN . SENT Log VV In IN My PP$ Account NP Shopping NP CartNewPopularSite NP Help VV Home NP Articles NNS Object VVP Technologies NP Patterns NNS C NP Design NP Patterns NNS . SENT The DT Proxy JJ Pattern NN C NP Design NP Patterns NNS . SENT The DT Proxy JJ PatternBy NP James NP W NP . SENT Cooper NP . SENT Sample NN Chapter NN is VBZ provided VVN courtesy NN of IN Addison NP Wesley NP Professional NP . SENT Date NN . SENT Dec NP 27 CD , , 2002 CD . SENT SaveDiscussPrintE NP mailArticle NN InformationContentsSample NP CodeComparison NP with IN Related NP PatternsArticle NP DescriptionThe NP Proxy NN pattern NN is VBZ used VVN when WRB you PP need VVP to TO represent VV an DT object NN that WDT is VBZ complex JJ or CC time NN consuming NN to TO create VV with IN a DT simpler JJR one NN . SENT If IN creating VVG an DT object NN is VBZ expensive JJ in IN time NN or CC computer NN resources NNS , , Proxy NN allows VVZ you PP to TO postpone VV this DT creation NN until IN you PP need VVP the DT actual JJ object NN . SENT From IN the DT Book NP C NP Design NP Patterns NNS . SENT A DT Tutorial JJ 49 CD . SENT 49 CD Save NP 10 CD The DT Proxy NN pattern NN is VBZ used VVN when WRB you PP need VVP to TO represent VV an DT object NN that WDT is VBZ complex JJ or CC time NN consuming NN to TO create VV with IN a DT simpler JJR one NN . SENT If IN creating VVG an DT object NN is VBZ expensive JJ in IN time NN or CC computer NN resources NNS , , Proxy NN allows VVZ you PP to TO postpone VV this DT creation NN until IN you PP need VVP the DT actual JJ object NN . SENT A DT Proxy NN usually RB has VHZ the DT same JJ methods NNS as IN the DT object NN it PP represents VVZ , , and CC once RB the DT object NN is VBZ loaded VVN , , it PP passes VVZ on IN the DT method NN calls VVZ from IN the DT Proxy NN to TO the DT actual JJ object NN . SENT There EX are VBP several JJ cases NNS where WRB a DT Proxy NN can MD be VB useful JJ . SENT An DT object NN , , such JJ as IN a DT large JJ image NN , , takes VVZ a DT long JJ time NN to TO load VV . SENT The DT results NNS of IN a DT computation NN take VV a DT long JJ time NN to TO complete VV , , and CC you PP need VVP to TO display VV intermediate JJ results NNS while IN the DT computation NN continues VVZ . SENT The DT object NN is VBZ on IN a DT remote JJ machine NN , , and CC loading VVG it PP over IN the DT network NN may MD be VB slow JJ , , especially RB during IN peak NN network NN load NN periods NNS . SENT The DT object NN has VHZ limited VVN access NN rights NNS , , and CC the DT proxy NN can MD validate VV the DT access NN permissions NNS for IN that DT user NN . SENT Proxies NNS can MD also RB be VB used VVN to TO distinguish VV between IN requesting VVG an DT instance NN of IN an DT object NN and CC the DT actual JJ need NN to TO access VV it PP . SENT For IN example NN , , program NN initialization NN may MD set VV up RP a DT number NN of IN objects NNS that WDT may MD not RB all RB be VB used VVN right RB away RB . SENT In IN that DT case NN , , the DT proxy NN can MD load VV the DT real JJ object NN only RB when WRB it PP is VBZ needed VVN . SENT Let VV s PP consider VV the DT case NN of IN a DT large JJ image NN that IN a DT program NN must MD load VV and CC display VV . SENT When WRB the DT program NN starts VVZ , , there EX must MD be VB some DT indication NN that IN an DT image NN is VBZ to TO be VB displayed VVN so RB that IN the DT screen NN lays VVZ out RP correctly RB , , but CC the DT actual JJ image NN display NN can MD be VB postponed VVN until IN the DT image NN is VBZ completely RB loaded VVN . SENT This DT is VBZ particularly RB important JJ in IN programs NNS such JJ as IN word NN processors NNS and CC Web NP browsers NNS that WDT lay VVP out RP text NN around IN the DT images NNS even RB before IN the DT images NNS are VBP available JJ . SENT An DT image NN proxy NN can MD note VV the DT image NN and CC begin VV loading VVG it PP in IN the DT background NN while IN drawing VVG a DT simple JJ rectangle NN or CC other JJ symbol NN to TO represent VV the DT image NN s PP extent NN on IN the DT screen NN before IN it PP appears VVZ . SENT The DT proxy NN can MD even RB delay VV loading VVG the DT image NN at IN all DT until IN it PP receives VVZ a DT paint NN request NN and CC only RB then RB begin VV the DT process NN . SENT Sample NP Code NP In IN this DT example NN , , we PP create VVP a DT simple JJ program NN to TO display VV an DT image NN on IN an DT Image NN control NN when WRB it PP is VBZ loaded VVN . SENT Rather RB than IN loading VVG the DT image NN directly RB , , we PP use VVP a DT class NN we PP call VVP ImageProxy NP to TO defer VV loading NN and CC draw VV a DT rectangle NN until IN loading NN is VBZ completed VVN . SENT private JJ void JJ init NN imgProxy NN new JJ ImageProxy NN . SENT public JJ Form NP 1 CD InitializeComponent NN . SENT init NN . SENT private JJ void NN button NN 1 CD Click NP object NN sender NN , , EventArgs NP e NN Pic NP . SENT Image NN imgProxy NN . SENT getImage NN . SENT Note NN that IN we PP create VVP the DT instance NN of IN the DT ImageProxy NN just RB as IN we PP would MD have VH for IN an DT Image NN . SENT The DT ImageProxy NP class NN sets VVZ up RP the DT image NN loading NN and CC creates VVZ an DT Imager NP object NN to TO follow VV the DT loading NN process NN . SENT It PP returns VVZ a DT class NN that WDT implements VVZ the DT Imager NP interface NN . SENT public JJ interface NN Imager NP Image NN getImage NN . SENT In IN this DT simple JJ case NN , , the DT ImageProxy NP class NN just RB delays VVZ five CD seconds NNS and CC then RB switches VVZ from IN the DT preliminary JJ image NN to TO the DT final JJ image NN . SENT It PP does VVZ this DT using VVG an DT instance NN of IN the DT Timer NN class NN . SENT Timers NNS are VBP handled VVN using VVG a DT TimerCallback NP class NN that WDT defines VVZ the DT method NN to TO be VB called VVN when WRB the DT timer NN ticks VVZ . SENT This DT is VBZ very RB similar JJ to TO the DT way NN we PP add VVP other JJ event NN handlers NNS . SENT And CC this DT callback NN method NN , , timerCall NN , , sets VVZ the DT done VVN flag NN and CC turns VVZ off RP the DT timer NN . SENT public JJ class NN ImageProxy NP private JJ bool NN done VVN . SENT private JJ Timer NN timer NN . SENT public JJ ImageProxy NN create VV a DT timer NN thread NN and CC start VV it PP timer NN new JJ Timer NN new JJ TimerCallback NP timerCall NN , , this RB , , 5000 CD , , 0 CD . SENT called VVN when WRB timer NN completes VVZ private JJ void NN timerCall NN object NN obj NN done VVN true JJ . SENT timer NN . SENT Dispose VV . SENT public JJ Image NN getImage NN Imager NP img NN . SENT if IN done VVN img NN new JJ FinalImage NN . SENT else RB img NN new JJ QuickImage NP . SENT return NN img NN . SENT getImage NN . SENT We PP implement VV the DT Imager NP interface NN in IN two CD tiny JJ classes NNS we PP called VVD QuickImage NP and CC FinalImage NP . SENT One PP gets VVZ a DT small JJ gif NN image NN and CC the DT other JJ a DT larger JJR and CC presumably RB slower JJR jpeg NN image NN . SENT In IN C NP , , Image NN is VBZ an DT abstract JJ class NN , , and CC the DT Bitmap NP , , Cursor NN , , Icon NN , , and CC Metafile NP classes NNS are VBP derived VVN from IN it PP . SENT So IN the DT actual JJ class NN we PP will MD return VV is VBZ derived VVN from IN Image NN . SENT The DT QuickImage NP class NN returns VVZ a DT Bitmap NN from IN a DT gif NN file NN , , and CC the DT final JJ image NN a DT jpeg NN file NN . SENT public JJ class NN QuickImage NN . SENT Imager NP public JJ QuickImage NP public JJ Image NN getImage NN return NN new JJ Bitmap NP Box NP . SENT gif NN . SENT public JJ class NN FinalImage NN . SENT Imager NP public JJ FinalImage NP public JJ Image NN getImage NN return NN new JJ Bitmap NP flowrtree NN . SENT jpg NN . SENT When WRB you PP go VVP to TO fetch VV an DT image NN , , you PP initially RB get VVP the DT quick JJ image NN , , and CC after IN five CD seconds NNS , , if IN you PP call VVP the DT method NN again RB , , you PP get VVP the DT final JJ image NN . SENT The DT program NN s VVZ two CD states NNS are VBP illustrated VVN in IN Figure NP 20 CD 1 CD . SENT Figure NN 20 CD 1 CD . SENT The DT proxy JJ image NN display NN on IN the DT top NN is VBZ shown VVN until IN the DT image NN loads NNS as RB shown VVN on IN the DT bottom NN . SENT Proxies NNS in IN C NP You PP see VVP more RBR proxylike JJ behavior NN in IN C NP than IN in IN other JJ languages NNS because IN it PP is VBZ crafted VVN for IN network NN and CC Internet NN use NN . SENT For IN example NN , , the DT ADO NN . SENT NETdatabase NP connection NN classes NNS are VBP all RB effectively RB proxies NNS . SENT Copy VV on IN Write VV You PP can MD also RB use VV proxies NNS to TO keep VV copies NNS of IN large JJ objects NNS that WDT may MD or CC may MD not RB change VV . SENT If IN you PP create VVP a DT second JJ instance NN of IN an DT expensive JJ object NN , , a DT Proxy NN can MD decide VV there EX is VBZ no DT reason NN to TO make VV a DT copy NN yet RB . SENT It PP simply RB uses VVZ the DT original JJ object NN . SENT Then RB if IN the DT program NN makes VVZ a DT change NN in IN the DT new JJ copy NN , , the DT Proxy NN can MD copy VV the DT original JJ object NN and CC make VV the DT change NN in IN the DT new JJ instance NN . SENT This DT can MD be VB a DT great JJ time NN and CC space NN saver NN when WRB objects NNS do VVP not RB always RB change VV after IN they PP are VBP instantiated VVN . SENT 2 LS . SENT Comparison NN with IN Related JJ Patterns NNS Next IN SectionMost JJ Active JJ CommentsGOFPosted JJ Aug NN 25 CD , , 2004 CD 09 CD . SENT 12 CD PM NP by IN knuckleswanny NP 0 CD RepliesMake NP a DT New NP CommentYou NP must MD login NN in IN order NN to TO post VV a DT comment NN . SENT You PP May MD Also RB LikeBuilding NP Plugins NP with IN C NP Part NP 4 CD . SENT Logging VVG and CC DeploymentBy NP Nathan NP GoodSep NP 17 CD , , 2004 CD C NP Design NP Patterns NNS . SENT AdapterBy NP Steven NP John NP MetskerOct NP 8 CD , , 2004 CD Understanding NN and CC Using VVG Windows NNS API NP Calls VVZ for IN Excel NP ProgrammingBy NP Rob NP Bovey NP , , Stephen NP Bullen NP , , John NP GreenFeb NP 11 CD , , 2005 CD See NP All NP Related NP ArticlesSearch NP Related NP Safari NN BooksSearch NP electronic JJ versions NNS of IN over IN 1500 CD technical JJ books NNS . SENT PromotionsBuy NP One NP Get VVP One CD Half NN PriceExpires NNS . SENT NeverRFID JJ . SENT Applications NNS , , Security NP , , and CC PrivacyExpires NP . SENT NeverSee NP All NP PromotionsMost NP Popular NP ArticlesFramework NP Patterns NNS . SENT Exception NN Handling NN , , Logging VVG , , and CC TracingBy NP Christian NP ThilmanyJan NP 30 CD , , 2004 CD C NP Design NP Patterns NNS . SENT The DT Fa NN ade NP PatternBy NP James NP W NP . SENT CooperDec NP 20 CD , , 2002 CD C NP Design NP Patterns NNS . SENT AdapterBy NP Steven NP John NP MetskerOct NP 8 CD , , 2004 CD About IN Legal NP Notice NP Privacy NN Policy NP Press NP Jobs NP Write VV For IN Us NP Contact NP Us NP Advertise VVP Site NN MapPTG NP Network NP . SENT Adobe NP PressCisco NP PressBrady NP GamesExam NP Cram NP 2 CD Fair NP Shake NP PressInformITPeachpit NP PressPearson NP Corporate NP StorePearson NP Government NP StorePHPTRQueSamsWharton NP School NP Publishing NP 2005 CD Pearson NP Education NP , , Addison NP Wesley NP Professional NP . SENT All DT rights NNS reserved VVD . SENT 75 CD Arlington NP Street NP , , Suite NP 300 CD , , Boston NP , , MA NN 02116 CD