Professional Java Tools for Extreme Programming [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Java Tools for Extreme Programming [Electronic resources] - نسخه متنی

Richard Hightower, Warner Onstineet al.

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید











Webdoclet Tags

Let's take a moment and discuss the tags we've used in our servlet example shown in the previous listing. The first tag in our example is @web.servlet. This tag is designed to create the class-level <servlet> element within the deployment descriptor. For our servlet, we've defined the name, display-name, and load-on-startup attribute of the tag:

@web.servlet name="SimpleServlet" 
display-name="Simple Servlet"
1oad-on-startup=" Y'

The result of the tag once processed by XDoclet will be:

<servlet>
<servlet-name>SimpleServlet</servlet-name>
<display-name>Simple Servlet</display-name>
<servlet-class>example.SimpleServlet</servlet-class>
<load-on-startup>1</load-on-start up>
</servlet>

The attributes available for the @web.servlet tag are shown in the following table.




























Attribute


Description


Required


Name


Servlet name


T


display-name


Servlet display name


F


Icon


Servlet icon


F


Description


Servlet description


F


load-on-startup


The load order of this servlet – number where 1 is first


F


run-as


The role to run this servlet as


F


The next two webdoclet tags in our example use the @web-servlet-init-param to create the init-param tags within the deployment descriptor:

@web-servlet-init-param name="table" value="production" 
@web-servlet-init-param name="account" value="accounts"

The result of these tags will be:

<servlet> 
<servlet-name>
...
<init-param>
<param-name>table</param-name>
<param-value>production</param-value>
</init-param>
<init-param>
<param-name>table</param-name>
<param-value>production</param-value>
</init-param>
</servlet>

The attributes available for the @web.servlet-init-param tag are shown in the following table.






















Attribute


Description


Required


Name


Parameter value


T


Value


Parameter value


F


Icon


Servlet icon


F


Description


Servlet description


F


After creating the necessary parameters for the servlet, we can define any J2EE resources needed by the servlet. In our example servlet, we will be accessing a database to pull rows that will be displayed to the user based on the init-params:

@web.resource-ref description="database connection" 
name=' jdbc/dbconnection"
type="javax.sgl.DataSource"
auth="Container"

The result of this webdoclet tag will be:

<resource-ref>
<description>JDBC Connection</description>
<res-ref-name>jdbc/dbconnection</res-ref-name>
<res-type>javax.sg1.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

The attributes available for the @web.resource-ref tag are shown in the following table.




























Attribute


Description


Required


Name


Resource name


T


Type


Resource type


T


Auth


Resource authentication: Application or Container


T


Description


Resource description


F


Scope


Resource scope: Shareable Unshareable


F


Jndi-name


Resource Jndi-name


F


Finally, we can apply the necessary pattern-matching mappings necessary for launching the servlet. This is accomplished using the @web.servlet-mapping tag:

@web.servlet-mapping url-pattern="/Example/*" 
@web.servlet-mapping url-pattern="/SimpleServlet"

These two tags will define the following mappings in our deployment descriptor:

<servlet-mapping>
<servlet-name>SimpleServlet</servlet-name>
<url-pattern >/Example/* </url-pattern >
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleServlet</servlet-name>
<url-pattern>SimpleServlet</url-pattem>
</servlet-mapping>

The attribute available in the @web.servlet-mapping tag is shown in the following table.













Attribute


Description


Required


url-pattern


Pattern to match


T


/ 228