...
Most of the work has already been done for us: we just have to make a contribution to the MetaWorker service, which is already plugged into the component class transformation pipeline. MetaWorker spots the annotations we define and uses a second object, a MetaDataExtractor we provide, to convert the annotation into a meta-data value.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Contribute(MetaWorker.class) public static void mapAnnotationsToMetaDataValue( MappedConfiguration<Class, MetaDataExtractor> configuration) { configuration .add(ForbidFraming.class, new FixedExtractor<ForbidFraming>( FnordSymbols.FORBID_FRAMING)); } |
...
We contribute into the pipeline; the order is important: since the filter will need to write JavaScript, it must be added after the built-in filter that provides the JavaScriptSupport environmental object.
Code Block | lang | java|||
---|---|---|---|---|
| ||||
@Contribute(MarkupRenderer.class) public static void addFilter( OrderedConfiguration<MarkupRendererFilter> configuration) { configuration.addInstance("ForbidFraming", ForbidFramingFilter.class, "after:JavascriptSupport"); } |
...
This code makes one assumption: that the fnord application's Layout component added fnord.js to every page. That's necessary for the JavaScript that's added:
Code Block | lang | javascript|||
---|---|---|---|---|
| ||||
Fnord = { popOutOfFrame : function() { if (top != self) top.location.replace(location); } } |
...