|
1
|
- Attribute Oriented Programming
|
|
2
|
- What is xDoclet
- How to Use
|
|
3
|
- Attribute Oriented Programming
- Allows you to add meta-data to your attributes
- Uses JavaDoc extensions to define how your methods are going to be used
- Does code generation for a variety of platforms ( EJB, Servlets,
descriptor files, etc )
- Extensible
- http://xdoclet.sourceforge.net
|
|
4
|
- You don’t need to handle building/maintaining descriptor files
- The developer only has to work with one Java source file instead of many
- Reduction of development time because of the first 2 points
|
|
5
|
- How to use in your code
- Generation via Ant
|
|
6
|
|
|
7
|
|
|
8
|
- <!-- Session Beans -->
- <session >
-
<description><![CDATA[Stateless Contact Server example
bean]]></description>
-
<ejb-name>ContactServer</ejb-name>
-
<home>com.wickidcool.contacts.server.ContactServerHome</home>
-
<remote>com.wickidcool.contacts.server.ContactServer</remote>
-
<local-home>com.wickidcool.contacts.server.ContactServerLocalHome</local-home>
-
<local>com.wickidcool.contacts.server.ContactServerLocal</local>
-
<ejb-class>com.wickidcool.contacts.server.ContactServerSession</ejb-class>
-
<session-type>Stateless</session-type>
-
<transaction-type>Container</transaction-type>
- </session>
|
|
9
|
- /**
- * Create a new contact.
- *
- * @ejb.interface-method
view-type="remote"
- */
- public ContactVO createInstance() throws RemoteException {
- // Some Code in here
- }
|
|
10
|
- ContactServerHome
- ContactServer
- ContactServerLocalHome
- ContactServerLocal
- ContactServerSession
- Subclasses your EJB class
|
|
11
|
- *
- * @ejb.ejb-ref ejb-name="User"
- *
ref-name="ejb/UserLocal"
- *
view-type="local"
- *
- * @ejb.ejb-ref ejb-name="Contact"
- *
ref-name="ejb/ContactLocal"
- *
view-type="local"
|
|
12
|
- <ejb-local-ref >
-
<ejb-ref-name>ejb/UserLocal</ejb-ref-name>
-
<ejb-ref-type>Entity</ejb-ref-type>
-
<local-home>com.wickidcool.contacts.server.UserLocalHome</local-home>
-
<local>com.wickidcool.contacts.server.UserLocal</local>
-
<ejb-link>User</ejb-link>
- </ejb-local-ref>
- <ejb-local-ref >
-
<ejb-ref-name>ejb/ContactLocal</ejb-ref-name>
-
<ejb-ref-type>Entity</ejb-ref-type>
-
<local-home>com.wickidcool.contacts.server.ContactLocalHome</local-home>
-
<local>com.wickidcool.contacts.server.ContactLocal</local>
-
<ejb-link>Contact</ejb-link>
- </ejb-local-ref>
|
|
13
|
- /**
- * Servlet for handling deletion
of contact.
- *
- *
@web.servlet
- * display-name="Delete Contact
Servlet"
- * name="deleteContact"
- *
- * @web.servlet-mapping
- *
url-pattern="/deleteContact/*"
- *
- * @author alwick
- */
|
|
14
|
- Done Using Ant
- Uses xDoclet properties and libraries
- Define classpath
- Define the tasks (init)
- Execute ejbdoclet against your code to generate Home/Remote interfaces
and the deployment descriptor
- Execute webdoclet to build web descriptor file
- Compile the generated code with your source code
- Refresh Eclipse project
|
|
15
|
- Go to http://xdoclet.sf.net
- Download latest version (1.0.2b3)
- Unzip into c:\java\xdoclet directory
|
|
16
|
- Go through Source Code . You can download the code from here.
- View the Ant Script and analyze the target/tasks
- Execute Ant build script
- View output
- Generated Source code
- Util class
- Local and Remote framework
- EJB descriptor files
- Web descriptor file
|