Interceptor pattern: Difference between revisions

Content deleted Content added
Yobot (talk | contribs)
m WP:CHECKWIKI error fixes + general fixes, References after punctuation per WP:REFPUNC and WP:PAIC using AWB (7510)
Citation bot (talk | contribs)
Alter: title. | Use this bot. Report bugs. | Suggested by Whoop whoop pull up | #UCB_webform 25/134
 
(15 intermediate revisions by 12 users not shown)
Line 1:
[[File:Interceptor.VSD Example.png|thumb|upright=1.6|Example of an interceptor]]
In the field of [[software development]], an '''interceptor pattern''' is a software [[software design pattern]] that is used when software systems or [[software framework|framework]]s want to offer a way to change, or augment, their usual processing cycle. For example, a (simplified) typical processing sequence for a web-server is to receive a URI from the browser, map it to a file on disk, open the file and send its contents to the browser. Any of these steps could be replaced or changed, i.e.g. by replacing the way URIs are mapped to filenames, or by inserting a new step which processes the files contents.
 
Key aspects of the pattern are that the change is ''transparent'' and used ''automatically''. In essence, the rest of the systemssystem does not have to know something has been added or changed and can keep working as before. To facilitate this, a ''predefined interface'' for extension has to be implemented, some kind of ''dispatching'' mechanism is required where interceptors are registered (this may be dynamic, at runtime, or static, e.g. through configuration files) and ''context objects'' are provided, which allow access to the frameworksframework's internal state.<ref name="POSA2">[{{Cite web |url=http://www.cs.wustl.edu/~schmidt/POSA/POSA2/ |title=Schmidt, Stal, Rohnert & Buschmann: "Pattern-Oriented Software Architecture Vol.2: Patterns for Concurrent and Networked Objects", pp. 109--140, April 2001] |access-date=2009-11-24 |archive-url=https://web.archive.org/web/20171223032440/http://www.cs.wustl.edu/~schmidt/POSA/POSA2/ |archive-date=2017-12-23 |url-status=dead }}</ref>
 
== Uses &and Contextcontext ==
Typical users of this pattern are web-servers<ref name="tomcat">[http://tomcat.apache.org/tomcat-6.0-doc/config/cluster-interceptor.html Apache Software Foundation: Tomcat 6.0 Channel Interceptor Reference, accessed 2009-Nov-24]</ref> (as mentioned above), object-<ref name="CORBA-PI">[http://www.omg.org/spec/CORBA/3.1/ OMG, "CORBA v3.1, Part I: Interfaces", Chapter 16 "Portable Interceptors", January 2008]</ref> and [[message-oriented middleware]]<ref name="MOM">[{{Cite web |url=http://www.edwardcurry.org/web_publications/curry_DEBS_04.pdf |title=E. Curry, D. Chambers, and G. Lyons, “Extending"Extending Message-Oriented Middleware using Interception”Interception", presented at Third International Workshop on Distributed Event-Based Systems (DEBS '04), ICSE '04, Edinburgh, Scotland, UK, 2004.] |access-date=2009-11-24 |archive-date=2011-07-26 |archive-url=https://web.archive.org/web/20110726015301/http://www.edwardcurry.org/web_publications/curry_DEBS_04.pdf |url-status=dead }}</ref>
 
An example of implementation of this pattern is the ''javax.servlet.Filter'' interface, which is part of [[Java Platform, Enterprise Edition]].
Typical users of this pattern are web-servers<ref name="tomcat">[http://tomcat.apache.org/tomcat-6.0-doc/config/cluster-interceptor.html Apache Software Foundation: Tomcat 6.0 Channel Interceptor Reference, accessed 2009-Nov-24]</ref> (as mentioned above), object-<ref name="CORBA-PI">[http://www.omg.org/spec/CORBA/3.1/ OMG, "CORBA v3.1, Part I: Interfaces", Chapter 16 "Portable Interceptors", January 2008]</ref> and message-oriented middleware<ref name="MOM">[http://www.edwardcurry.org/web_publications/curry_DEBS_04.pdf E. Curry, D. Chambers, and G. Lyons, “Extending Message-Oriented Middleware using Interception”, presented at Third International Workshop on Distributed Event-Based Systems (DEBS '04), ICSE '04, Edinburgh, Scotland, UK, 2004.]</ref>
 
[[Aspect-oriented programming|Aspect-Oriented Programming]] (AOP)]] can also be used in some situations to provide the capability of an interceptor, although AOP doesn't use the elements typically defined {{Clarify|date=May 2012}} for the interceptor pattern.
An example of implementation of this pattern is the ''javax.servlet.Filter'' interface, which is part of [[Java Platform, Enterprise Edition]].
 
[[Aspect-oriented programming|Aspect-Oriented Programming (AOP)]] can also be used in some situations to provide the capability of an interceptor, although AOP doesn't use the elements typically defined for the interceptor pattern.
 
== References ==
{{reflist}}
 
{{Design Patterns Patterns}}
 
{{DEFAULTSORT:Interceptor Pattern}}
[[Category:Architectural pattern (computer science)]]
[[Category:Concurrent computing]]
[[Category:Software design patterns]]
[[Category:Concurrent computing]]
 
[[de:Interceptor (Entwurfsmuster)]]