~hudson-ubuntu/+junk/sezpoz

« back to all changes in this revision

Viewing changes to www/index.html

  • Committer: James Page
  • Date: 2010-11-24 13:57:41 UTC
  • Revision ID: james.page@canonical.com-20101124135741-8ntgqh7ltywqy3x2
Initial release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<title>SezPoz</title>
 
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
5
</head>
 
6
 
 
7
<h1>Introduction</h1>
 
8
<p>
 
9
SezPoz is a lightweight and simple-to-learn library that lets you perform modular service lookups.
 
10
It provides some of the same capabilities as (for example) <code>java.util.ServiceLoader</code>,
 
11
Eclipse extension points, and NetBeans <code>Lookup</code> and XML layers.
 
12
However, SezPoz has some special advantages:
 
13
</p>
 
14
<ol>
 
15
  <li>
 
16
      <p>
 
17
      The service registrations are made just using type-checked Java annotations.
 
18
      There are no configuration files to edit, and your Java IDE can show you registrations since they are simply usages of an annotation.
 
19
      On JDK 6, no special build or packaging steps are required (just javac); on JDK 5, you just need to run APT (with default arguments),
 
20
      instead of or in addition to javac for any sources which may contain indexable items.
 
21
      Looking up services just requires that you have a <code>ClassLoader</code> which can "see" all of the "modules" (as with <code>ServiceLoader</code>).
 
22
      </p>
 
23
  </li>
 
24
  <li>
 
25
      <p>
 
26
      You can register individual objects (values of static fields or methods) instead of whole classes.
 
27
      </p>
 
28
  </li>
 
29
  <li>
 
30
      <p>
 
31
      You can associate static metadata with each implementation, using regular annotation values.
 
32
      The caller can choose to inspect the metadata without loading the actual implementation object (as with Eclipse extension points).
 
33
      </p>
 
34
  </li>
 
35
</ol>
 
36
<p>
 
37
(Why the name? SezPoz "says" the "position" of your services. It is also a
 
38
"<a href="http://slovnik.seznam.cz/search.py?wd=seznam&amp;lg=cz_en">seznam</a>
 
39
<a href="http://slovnik.seznam.cz/search.py?wd=pozn%C3%A1mka&amp;lg=cz_en">poznámek</a>".)
 
40
</p>
 
41
 
 
42
<h1>Sources and Binaries</h1>
 
43
<p>
 
44
Sources are in the form of Maven projects. To build:
 
45
</p>
 
46
<pre>
 
47
mvn install
 
48
</pre>
 
49
<p>
 
50
To try the demo application:
 
51
</p>
 
52
<pre>
 
53
mvn -f demo/app/pom.xml exec:exec
 
54
</pre>
 
55
<p>
 
56
Binaries, sources, and Javadoc can all be downloaded from the
 
57
<a href="http://download.java.net/maven/2/net/java/sezpoz/sezpoz/">Maven repository</a>.
 
58
</p>
 
59
<p>
 
60
For usage from Maven applications, add the java.net repository
 
61
(<a href="https://maven2-repository.dev.java.net/">details</a>)
 
62
and use the artifact <code>net.java.sezpoz:sezpoz</code>, for example:
 
63
</p>
 
64
<pre>
 
65
&lt;repositories>
 
66
  &lt;repository>
 
67
    &lt;id>maven2-repository.dev.java.net&lt;/id>
 
68
    &lt;name>Java.net Repository for Maven&lt;/name>
 
69
    &lt;url>http://download.java.net/maven/2/&lt;/url>
 
70
  &lt;/repository>
 
71
&lt;/repositories>
 
72
&lt;dependencies>
 
73
  &lt;dependency>
 
74
    &lt;groupId>net.java.sezpoz&lt;/groupId>
 
75
    &lt;artifactId>sezpoz&lt;/artifactId>
 
76
    &lt;version>1.7&lt;/version>
 
77
  &lt;/dependency>
 
78
&lt;/dependencies>
 
79
</pre>
 
80
 
 
81
<h1>Usage Summary</h1>
 
82
<p>
 
83
See Javadoc for details on particular classes, or just look at
 
84
<a href="http://download.java.net/maven/2/net/java/sezpoz/demo/">demo sources</a>.
 
85
<p>
 
86
 
 
87
Support for declaring, creating, and inspecting indices of annotated Java elements.
 
88
 <p>
 
89
 For example, to permit registration of simple menu items, while
 
90
 making it possible to prepare a menu without loading any of them
 
91
 until they are actually selected:
 
92
 <pre>
 
93
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 
94
 @Retention(RetentionPolicy.SOURCE)
 
95
 @Indexable(type=ActionListener.class)
 
96
 public @interface MenuItem {
 
97
     String menuName();
 
98
     String itemName();
 
99
     String iconPath() default "";
 
100
 }
 
101
 </pre>
 
102
 A concrete registration might look like:
 
103
 <pre>
 
104
 @MenuItem(menuName="File", itemName="Print", iconPath=".../print.png")
 
105
 public class PrintAction extends AbstractAction {
 
106
     public void actionPerformed(ActionEvent e) {...}
 
107
 }
 
108
 </pre>
 
109
 Alternatively:
 
110
 <pre>
 
111
 public class Actions {
 
112
     @MenuItem(menuName="File", itemName="Print")
 
113
     public static Action print() {...}
 
114
 }
 
115
 </pre>
 
116
 or even:
 
117
 <pre>
 
118
 public class Actions {
 
119
     @MenuItem(menuName="File", itemName="Print")
 
120
     public static final Action PRINT = ...;
 
121
 }
 
122
 </pre>
 
123
 To create the index on JDK 6, just compile your sources normally with javac.
 
124
 If using JDK 5, simply run apt instead of/in addition to javac.
 
125
 (The processor is in the same JAR as this API and should be autodetected.)
 
126
 <p>
 
127
 Usage is then simple:
 
128
 <pre>
 
129
 for (final IndexItem&lt;MenuItem,ActionListener&gt; item :
 
130
         Index.load(MenuItem.class, ActionListener.class)) {
 
131
     JMenu menu = new JMenu(item.annotation().menuName());
 
132
     JMenuItem menuitem = new JMenuItem(item.annotation().itemName());
 
133
     String icon = item.annotation().iconPath();
 
134
     if (!icon.equals("")) {
 
135
          menuitem.setIcon(new ImageIcon(icon));
 
136
     }
 
137
     menuitem.addActionListener(new ActionListener() {
 
138
         public void actionPerformed(ActionEvent e) {
 
139
             try {
 
140
                 item.instance().actionPerformed(e);
 
141
             } catch (InstantiationException x) {
 
142
                 x.printStackTrace();
 
143
             }
 
144
         }
 
145
     });
 
146
 }
 
147
 </pre>
 
148
 
 
149
<h1>Notes</h1>
 
150
<p>
 
151
Known limitations:
 
152
</p>
 
153
<ol>
 
154
<li><p>When using JDK 5 and apt, incremental compilation can result in an index file being generated with only some
 
155
of the desired entries, if other source files are omitted e.g. by Ant.
 
156
</p><p>
 
157
This scenario works better using JDK 6's javac: if you compile just some sources which are marked with an indexable annotation,
 
158
these entries will be appended to any existing registrations from previous runs of the compiler.
 
159
(You should run a clean build if you <em>delete</em> annotations from sources.)
 
160
</p></li>
 
161
<li><p>The Java language spec currently prohibits recursive annotation definitions,
 
162
although as of this writing javac does not.
 
163
See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6264216">bug #6264216</a>.</p></li>
 
164
</ol>
 
165
 
 
166
<p>
 
167
Eclipse-specific notes: make sure annotation processing is enabled at least for any
 
168
projects registering objects using annotations. Make sure the SezPoz library is
 
169
in the factory path for annotation processors. You also need to check the box
 
170
<b>Run this container's processor in batch mode</b> from the <b>Advanced</b>
 
171
button in <b>Java Compiler > Annotation Processing > Factory Path</b>.
 
172
There does not appear to be any way for Eclipse to discover processors
 
173
in the regular classpath as JSR 269 suggests, and there does not appear to be
 
174
any way to make these settings apply automatically to all projects.
 
175
Eclipse users are recommended to use javac (e.g. via Maven) to build.
 
176
<a href="http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_apt_getting_started.htm">Eclipse Help Page</a>
 
177
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=280542">Eclipse bug #280542</a>
 
178
</p>
 
179
 
 
180
</body>
 
181
</html>
 
182
<!-- perhaps mention: http://wiki.glassfish.java.net/Wiki.jsp?page=DependencyMechanism -->
 
183
<!-- similar to Eclipse: http://jpf.sourceforge.net/ -->
 
184
<!-- can mention that Hudson now uses it -->
 
185
<!-- investigate interoperability with Peaberry -->