Knowledge

Intercepting filter pattern

Source đź“ť

26:
which creates pluggable filters to process common services in a standard manner without requiring changes to core request processing code. The filters intercept incoming requests and outgoing responses, allowing preprocessing and post-processing, and these filters can be added or removed
27:
unobtrusively without changing existing code. This pattern applies reusable processing transparently before and after the actual request execution by the front and page controllers.
43:
This manages filter processing and creates the filter chain with the appropriate filters, in the correct order, and initiates processing.
927: 1452: 1560: 1477: 86:
Reduced performance can be a concern, as unnecessarily long chains of interceptors and filters may hurt performance.
20: 59:
These are the individual filters that are mapped to a target and their processing is coordinated by filter chain.
1425: 1250: 1049: 82:
Increased flexibility: Generic common components can be applied and removed declaratively, improving flexibility.
1143: 1273: 1233: 920: 1243: 1238: 1518: 863: 1133: 1341: 1336: 1163: 1381: 1346: 1313: 963: 913: 1283: 1255: 1193: 1178: 1158: 1094: 936: 812: 23: 1260: 1188: 1138: 973: 1539: 1442: 1288: 1268: 1213: 1351: 1308: 1303: 1293: 1203: 8: 1391: 1376: 1371: 1228: 1113: 1059: 822: 817: 79:
Improved reusability: Common code is centralized in pluggable components enhancing reuse.
51:
A Filter Chain is a specific series of filters, composed so as to form a logical chain.
1513: 1492: 1401: 1298: 1148: 1041: 993: 955: 1183: 1026: 1016: 1011: 983: 978: 807: 1482: 1223: 1168: 1089: 1079: 1069: 1064: 802: 94:
Sample code implementation for filters with custom filter strategy is given below.
1472: 1418: 1396: 1173: 1128: 1099: 1074: 1054: 1001: 968: 944: 35:
Filter manager, filter chain, filters and target are components of the pattern.
1457: 1318: 1021: 1006: 1554: 1278: 1123: 1084: 1031: 1534: 1497: 1386: 1361: 1153: 905: 1487: 1462: 1447: 1366: 1198: 1467: 666://Then dispatch to next resource, which is probably 519://Then dispatch to next resource, which is probably 97:Code for implementing a filter - debugging filter: 253:Code for implementing a filter - core processor: 1552: 753:// pass request & response through various 67:This is the resource requested by the client. 921: 935: 858: 856: 854: 852: 850: 848: 846: 844: 842: 840: 838: 928: 914: 864:"Core J2EE Patterns - Intercepting Filter" 213://Do some filter processing here, such as 889: 887: 885: 835: 1553: 882: 75:Following benefits can be considered: 909: 893: 898:. New York: Apress. pp. 98–106. 13: 14: 1572: 38: 216:// displaying request parameters 1426:Enterprise Integration Patterns 70: 46: 89: 1: 828: 409:Code for handling requests: 30: 7: 1519:Portland Pattern Repository 896:Pro Java EE Spring Patterns 796: 10: 1577: 54: 1527: 1506: 1435: 1410: 1327: 1212: 1112: 1040: 992: 954: 943: 556:Code for filter manager: 396://Do core processing here 62: 1561:Software design patterns 1144:Event-based asynchronous 937:Software design patterns 705: 558: 411: 255: 99: 1050:Chain of responsibility 813:Template method pattern 703:Code for filter chain: 1189:Scheduled-task pattern 1139:Double-checked locking 669:// the View to display 522:// the View to display 1540:Architectural pattern 1443:Christopher Alexander 1352:Dependency injection 1309:Inversion of control 1304:Data transfer object 1204:Thread-local storage 627:AuthenticationFilter 480:AuthenticationFilter 1357:Intercepting filter 823:Pipeline (software) 818:Interceptor pattern 17:Intercepting Filter 1514:The Hillside Group 1299:Data access object 1149:Guarded suspension 1134:Binding properties 894:Kayal, D. (2008). 1548: 1547: 1342:Business delegate 1274:Publish–subscribe 1108: 1107: 808:Decorator pattern 1568: 1347:Composite entity 1224:Front controller 964:Abstract factory 952: 951: 930: 923: 916: 907: 906: 900: 899: 891: 880: 879: 877: 875: 860: 803:Front controller 790: 787: 784: 781: 778: 775: 772: 769: 766: 763: 760: 757: 754: 751: 748: 745: 742: 739: 736: 733: 730: 727: 724: 723:// apply filters 721: 720:// filter chain 718: 715: 712: 709: 697: 694: 691: 688: 685: 682: 679: 676: 673: 670: 667: 664: 661: 658: 655: 652: 649: 646: 643: 640: 637: 634: 631: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 600:ServletException 598: 595: 592: 589: 586: 583: 580: 577: 574: 571: 568: 565: 562: 550: 547: 544: 541: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 453:ServletException 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 403: 400: 397: 394: 391: 390:ServletException 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 271: 268: 265: 262: 259: 247: 244: 241: 238: 235: 232: 229: 226: 223: 220: 217: 214: 211: 208: 207:ServletException 205: 202: 199: 196: 193: 190: 187: 184: 181: 178: 175: 172: 169: 166: 163: 160: 157: 154: 151: 148: 145: 142: 139: 136: 133: 130: 127: 124: 121: 118: 115: 112: 109: 106: 103: 1576: 1575: 1571: 1570: 1569: 1567: 1566: 1565: 1551: 1550: 1549: 1544: 1523: 1502: 1493:Douglas Schmidt 1473:Ward Cunningham 1431: 1419:Design Patterns 1406: 1397:Method chaining 1329: 1323: 1284:Service locator 1215: 1208: 1179:Read–write lock 1115: 1104: 1095:Template method 1036: 988: 946: 939: 934: 904: 903: 892: 883: 873: 871: 862: 861: 836: 831: 799: 792: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 719: 716: 713: 710: 707: 699: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 626: 623: 620: 618:DebuggingFilter 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 582:ServletResponse 581: 578: 575: 572: 569: 566: 563: 560: 552: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 471:DebuggingFilter 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 435:ServletResponse 434: 431: 428: 425: 422: 419: 416: 413: 405: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 372:ServletResponse 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 341: 338: 335: 332: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 249: 248: 245: 242: 239: 236: 233: 230: 227: 224: 221: 218: 215: 212: 209: 206: 203: 200: 197: 194: 191: 189:ServletResponse 188: 185: 182: 179: 176: 173: 170: 167: 164: 161: 158: 155: 152: 149: 146: 143: 140: 137: 135:DebuggingFilter 134: 131: 128: 125: 122: 119: 116: 113: 110: 108:DebuggingFilter 107: 104: 101: 92: 73: 65: 57: 49: 41: 33: 12: 11: 5: 1574: 1564: 1563: 1546: 1545: 1543: 1542: 1537: 1531: 1529: 1525: 1524: 1522: 1521: 1516: 1510: 1508: 1504: 1503: 1501: 1500: 1495: 1490: 1485: 1480: 1475: 1470: 1465: 1460: 1458:John Vlissides 1455: 1450: 1445: 1439: 1437: 1433: 1432: 1430: 1429: 1422: 1414: 1412: 1408: 1407: 1405: 1404: 1399: 1394: 1389: 1384: 1379: 1374: 1369: 1364: 1359: 1354: 1349: 1344: 1339: 1333: 1331: 1325: 1324: 1322: 1321: 1316: 1311: 1306: 1301: 1296: 1291: 1286: 1281: 1276: 1271: 1266: 1258: 1253: 1248: 1247: 1246: 1241: 1231: 1226: 1220: 1218: 1210: 1209: 1207: 1206: 1201: 1196: 1191: 1186: 1181: 1176: 1171: 1166: 1161: 1156: 1151: 1146: 1141: 1136: 1131: 1126: 1120: 1118: 1110: 1109: 1106: 1105: 1103: 1102: 1097: 1092: 1087: 1082: 1077: 1072: 1067: 1062: 1057: 1052: 1046: 1044: 1038: 1037: 1035: 1034: 1029: 1024: 1019: 1014: 1009: 1004: 998: 996: 990: 989: 987: 986: 981: 976: 974:Factory method 971: 966: 960: 958: 949: 941: 940: 933: 932: 925: 918: 910: 902: 901: 881: 833: 832: 830: 827: 826: 825: 820: 815: 810: 805: 798: 795: 706: 573:ServletRequest 567:processRequest 559: 426:ServletRequest 420:processRequest 412: 363:ServletRequest 256: 180:ServletRequest 100: 91: 88: 84: 83: 80: 72: 69: 64: 61: 56: 53: 48: 45: 40: 39:Filter manager 37: 32: 29: 9: 6: 4: 3: 2: 1573: 1562: 1559: 1558: 1556: 1541: 1538: 1536: 1533: 1532: 1530: 1526: 1520: 1517: 1515: 1512: 1511: 1509: 1505: 1499: 1496: 1494: 1491: 1489: 1486: 1484: 1483:Robert Martin 1481: 1479: 1478:Martin Fowler 1476: 1474: 1471: 1469: 1466: 1464: 1461: 1459: 1456: 1454: 1453:Ralph Johnson 1451: 1449: 1446: 1444: 1441: 1440: 1438: 1434: 1428: 1427: 1423: 1421: 1420: 1416: 1415: 1413: 1409: 1403: 1400: 1398: 1395: 1393: 1390: 1388: 1385: 1383: 1380: 1378: 1375: 1373: 1370: 1368: 1365: 1363: 1360: 1358: 1355: 1353: 1350: 1348: 1345: 1343: 1340: 1338: 1335: 1334: 1332: 1326: 1320: 1317: 1315: 1312: 1310: 1307: 1305: 1302: 1300: 1297: 1295: 1292: 1290: 1289:Active record 1287: 1285: 1282: 1280: 1279:Naked objects 1277: 1275: 1272: 1270: 1269:Specification 1267: 1265: 1263: 1259: 1257: 1254: 1252: 1249: 1245: 1242: 1240: 1237: 1236: 1235: 1232: 1230: 1227: 1225: 1222: 1221: 1219: 1217: 1214:Architectural 1211: 1205: 1202: 1200: 1197: 1195: 1192: 1190: 1187: 1185: 1182: 1180: 1177: 1175: 1172: 1170: 1167: 1165: 1162: 1160: 1157: 1155: 1152: 1150: 1147: 1145: 1142: 1140: 1137: 1135: 1132: 1130: 1127: 1125: 1124:Active object 1122: 1121: 1119: 1117: 1111: 1101: 1098: 1096: 1093: 1091: 1088: 1086: 1083: 1081: 1078: 1076: 1073: 1071: 1068: 1066: 1063: 1061: 1058: 1056: 1053: 1051: 1048: 1047: 1045: 1043: 1039: 1033: 1030: 1028: 1025: 1023: 1020: 1018: 1015: 1013: 1010: 1008: 1005: 1003: 1000: 999: 997: 995: 991: 985: 982: 980: 977: 975: 972: 970: 967: 965: 962: 961: 959: 957: 953: 950: 948: 942: 938: 931: 926: 924: 919: 917: 912: 911: 908: 897: 890: 888: 886: 869: 865: 859: 857: 855: 853: 851: 849: 847: 845: 843: 841: 839: 834: 824: 821: 819: 816: 814: 811: 809: 806: 804: 801: 800: 794: 704: 701: 636:CoreProcessor 557: 554: 489:CoreProcessor 410: 407: 318:CoreProcessor 291:CoreProcessor 264:CoreProcessor 254: 251: 98: 95: 87: 81: 78: 77: 76: 68: 60: 52: 44: 36: 28: 25: 22: 18: 1535:Anti-pattern 1498:Linda Rising 1424: 1417: 1362:Lazy loading 1356: 1294:Identity map 1261: 945:Gang of Four 895: 872:. Retrieved 867: 793: 702: 700: 555: 553: 408: 406: 252: 250: 96: 93: 85: 74: 71:Consequences 66: 58: 50: 47:Filter chain 42: 34: 16: 15: 1507:Communities 1488:Jim Coplien 1463:Grady Booch 1448:Erich Gamma 1392:Type tunnel 1377:Object pool 1372:Null object 1367:Mock object 1229:Interceptor 1199:Thread pool 1114:Concurrency 1060:Interpreter 714:FilterChain 594:IOException 447:IOException 384:IOException 201:IOException 90:Sample code 1402:Delegation 1337:Blackboard 1042:Behavioral 994:Structural 956:Creational 874:6 February 829:References 756:// filters 672:dispatcher 642:processors 609:processors 525:dispatcher 495:processors 462:processors 267:implements 111:implements 1468:Kent Beck 1194:Semaphore 1184:Scheduler 1027:Flyweight 1017:Decorator 1012:Composite 984:Singleton 979:Prototype 606:Processor 459:Processor 324:Processor 279:Processor 270:Processor 141:Processor 123:Processor 114:Processor 31:Structure 1555:Category 1528:See also 1330:patterns 1216:patterns 1169:Proactor 1116:patterns 1090:Strategy 1080:Observer 1070:Mediator 1065:Iterator 947:patterns 870:. Oracle 797:See also 777:response 678:dispatch 531:dispatch 342:myTarget 327:myTarget 159:myTarget 144:myTarget 1382:Servant 1314:Model 2 1174:Reactor 1164:Monitor 1129:Balking 1100:Visitor 1075:Memento 1055:Command 1002:Adapter 969:Builder 771:request 765:execute 744:filters 648:execute 501:execute 357:execute 276:private 225:execute 174:execute 120:private 55:Filters 24:pattern 1436:People 1319:Broker 1022:Facade 1007:Bridge 868:Oracle 759:filter 738:filter 735:Filter 708:public 591:throws 561:public 444:throws 414:public 381:throws 351:public 336:target 315:public 288:public 282:target 258:public 219:target 198:throws 168:public 153:target 132:public 126:target 102:public 63:Target 21:JavaEE 1411:Books 1328:Other 1264:-tier 1085:State 1032:Proxy 732:final 711:class 639:())); 492:())); 261:class 105:class 19:is a 1387:Twin 1244:MVVM 1159:Lock 1154:Join 876:2016 564:void 417:void 354:void 306:null 300:this 171:void 1256:ECS 1251:ADR 1239:MVP 1234:MVC 726:for 690:res 684:req 660:res 654:req 633:new 624:new 615:new 585:res 576:req 543:res 537:req 513:res 507:req 486:new 477:new 468:new 438:res 429:req 375:res 366:req 237:res 231:req 192:res 183:req 1557:: 884:^ 866:. 837:^ 780:); 693:); 663:); 546:); 516:); 309:); 294:() 240:); 1262:n 929:e 922:t 915:v 878:. 789:} 786:} 783:} 774:, 768:( 762:. 750:{ 747:) 741:: 729:( 717:{ 696:} 687:, 681:( 675:. 657:, 651:( 645:. 630:( 621:( 612:= 603:{ 597:, 588:) 579:, 570:( 549:} 540:, 534:( 528:. 510:, 504:( 498:. 483:( 474:( 465:= 456:{ 450:, 441:) 432:, 423:( 402:} 399:} 393:{ 387:, 378:) 369:, 360:( 348:} 345:; 339:= 333:{ 330:) 321:( 312:} 303:( 297:{ 285:; 273:{ 246:} 243:} 234:, 228:( 222:. 210:{ 204:, 195:) 186:, 177:( 165:} 162:; 156:= 150:{ 147:) 138:( 129:; 117:{

Index

JavaEE
pattern
Front controller
Decorator pattern
Template method pattern
Interceptor pattern
Pipeline (software)











"Core J2EE Patterns - Intercepting Filter"



v
t
e
Software design patterns
Gang of Four
patterns

Creational
Abstract factory
Builder

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑