<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Extending the Eclipse Annotation Properties view
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/bfitzpat">Brian Fitzpatrick</a> in <i>JBoss Tools</i> - <a href="http://community.jboss.org/community/jbosstools/blog/2010/09/13/extending-the-eclipse-annotation-properties-view">View the full blog post</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>While looking into some options on how to make the use of annotations simpler for users, I ran across the Annotation Properties view, which is in Helios in the JAX-WS-&gt;Annotation Properties view category when you're trying to open a view (Window-&gt;Show View-&gt;Other).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you haven't seen this view before (and I know I hadn't), it offers a way to register annotation classes in a common place to allow you to add/remove/edit annotations in a class. By default in the Helios JEE package, it comes with JAXB and JAX-WS annotations already set up. It's a little clunky in spots, but I think it offers some interesting options as far as functionality goes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For example, to create a new JAX-WS annotated class, you can start with your favorite POJO and annotate it pretty quickly:</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7286/Annotation_Properties_View_For_Blog.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7286/450-297/Annotation_Properties_View_For_Blog.jpg </span></a></p><p>The view also offers the ability to filter the available annotations so you're not simply overwhelmed. To get to the Filters dialog, use the View menu and select Filters...</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7287/annotation_properties_view_filters_dialog.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7287/354-464/annotation_properties_view_filters_dialog.jpg </span></a></p><p>This is a little clunky as far as an interface goes. You can only open one instance of the view at a time and can't easily switch between annotation types. But it's a start anyway.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So with this in mind, I asked in the WTP newsgroup about how to go about extending it. Shane Clarke was nice enough to provide some tips...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The two extension points associated with the Annotation Properties view are located in the org.eclipse.jst.ws.annotations.core plug-in. The main two are the the org.eclipse.jst.ws.annotations.core.annotationCategory and org.eclipse.jst.ws.annotations.core.annotationDefinition extension points. Basically you just define a category (which shows up in the Filters dialog) and then define one or more associated annotation classes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The only trick is making sure that the annotations are on the plug-in classpath and then adding the line "Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core" to your MANIFEST.MF.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So as an example, we'll just create a new category:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160; &lt;extension<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point="org.eclipse.jst.ws.annotations.core.annotationCategory"&gt;<br/>&#160;&#160;&#160;&#160;&#160; &lt;category<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; id="org.my.annotation.category"<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; name="My Category Name"&gt;<br/>&#160;&#160;&#160;&#160;&#160; &lt;/category&gt;<br/>&#160;&#160; &lt;/extension&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And then we'll define a new annotation for it:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160; &lt;extension<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point="org.eclipse.jst.ws.annotations.core.annotationDefinition"&gt;<br/>&#160;&#160;&#160;&#160;&#160; &lt;annotation<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; category="org.my.annotation.category"<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="some.annotation.class.MyAnnotation"<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; name="MyAnnotation"&gt;<br/>&#160;&#160;&#160;&#160;&#160; &lt;/annotation&gt;<br/>&#160;&#160; &lt;/extension&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For examples of how they implemented the JAX-WS and JAXB annotations, check out org.eclipse.jst.ws.jaxws.core and org.eclipse.jst.ws.jaxb.core.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Pretty easy. I was able to define annotations for some new functionality in our JBoss ESB product that allows you to annotate a class instead of extending a particular interface or extending an existing class.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7288/annotation_properties_view_esb_blog.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7288/450-297/annotation_properties_view_esb_blog.jpg </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I obviously think that the Annotation Properties view could be used for more than just Web Service class annotations.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But it needs a bit of work... For example, it would be nice if you could create a saved setting like a working set and made more visible - perhaps in the toolbar area at the top of the view. And it would be great if you could create multiple instances and associate a particular view instance with an editor, similar to how the Project Explorer can be linked to the editors and show which file is being worked on.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And I'm not quite sure how to use all of the functionality - like those other two extension points - or some of the settings on the annotationDefinition extension.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>That said, I think it's a great start and it would be awesome to have a consistent way to annotate Java classes. I'm not sure that this is really a WTP-specific view and think it would make more sense in the more general Java tools category, but that's just me.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Big thanks to Shane for the pointers and I'm looking forward to seeing how this functionality improves in future releases!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>--Fitz</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/community/jbosstools/blog/2010/09/13/extending-the-eclipse-annotation-properties-view">going to Community</a></p>

</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>