Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
backport175
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h3>Introduction</h3> <p><strong>backport175</strong> has been designed to work in highly dynamic environment (such as load-time and runtime weaving for AOP). In environments like this the bytecode on disk is not the "current" one being executed. Since the bytecode has been transformed during the execution of the application. What this means is that annotations can have been added or removed. </p> <p>We therefore need two things:</p> <ol> <li>a way for the vendor/user to define a bytecode provider since the current one is not available on disk</li> <li>an API for refreshing/updating the annotation reader, so we know that the annotations we have reflects the annotation in the latest bytecode</li> </ol> <p>All these operation should be fully thread-safe, if not, then we have a bug. </p> <h3>Defining the bytecode provider</h3> <p>This is done by implementing the <code>org.codehaus.backport175.reader.bytecode.spi.BytecodeProvider</code> interface. This interface is a strategy with one single method you need to implement:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> public interface BytecodeProvider { /** * Returns the bytecode for a specific class. * * @param className the fully qualified name of the class * @param loader the class loader that has loaded the class * @return the bytecode */ byte[] getBytecode(String className, ClassLoader loader); } </pre></td></tr></table> <h3>Registering the bytecode provider</h3> <p>The bytecode provider implementation class is registered in the <code>org.codehaus.backport175.reader.bytecode.AnnotationReader</code> class by invoking:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> AnnotationReader.setDefaultBytecodeProvider(new BytecodeProviderImpl()); </pre></td></tr></table> <p>If no bytecode provider is registered then a default one that uses <code>getResourceAsStream()</code>, e.g. reads in the bytecode from disk, is used.</p> <p>It is also possible to set a bytecode provider on a per class basis, which can be usefull in some circumstances.<br /> Refer to the API documentation for more details.</p> <h3>Refreshing the annotation reader</h3> <p>When a change to the bytecode has been made it is needed to refresh the annotation reader, so that it can pull the new bytecode from the <code>BytecodeProvider</code>, parse it and update the reader with the new information about the annotations.</p> <p>This is done by invoking one of the <code>refresh(..)</code> methods in the <code>org.codehaus.backport175.reader.bytecode.AnnotationReader</code> class:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> // refreshes one single class AnnotationReader.refresh(POJO.class); // refreshes all classes (that has been accessed through the Annotations interface so far) AnnotationReader.refreshAll(); </pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced