|
Welcome to the Enterprise Java Technologies Tech Tips for December 20, 2007. Here you'll get tips on using enterprise Java technologies and APIs, such as those in Java Platform, Enterprise Edition (Java EE).
You can now read the Enterprise Java Technologies Tech Tips online as a web log.
This issue includes a Tech Tips Quiz..
Any use of this code and/or information below is subject to the license terms.
Over the years, the Enterprise Java Technologies Tech Tips have
covered a wide variety of enterprise Java technology topics.
Here's a short quiz that tests your knowledge of some topics
covered in recent Tech Tips. You can find the answers at the end
of the quiz.
- What is
@UriTemplate?
- The location of a template used for constructing a URI.
- A JAX-RS annotation that identifies the URI path for a RESTful web service resource.
- A JAXB annotation that serializes a RESTful web service URI parameter.
- None of the above.
- What type of security store is used for a GlassFish v2
application server whose domain is configured with the
enterprise profile?
- JKS
- NSS
- SLS
- The following tag appears in a JSP page for an application:
<jsfExt:scripts/>
What does the tag do?
- Includes the
jsfExt script into the application.
- Includes the JavaServer Faces tag library into the application.
- Includes the script.aculo.us JavaScript library into the application.
- Includes the Dynamic Faces JavaScript library into the application.
- True or false, when a Java Persistence implementation runs in
J2SE mode, an application is responsible for creating it's
own entity managers?
- True
- False
- You want to create a simple web service to manage inventory.
You create a class that can be used to model any inventory
object that you want to expose through your web service, as
follows:
public abstract class Item implements Serializable {
private long id;
private String brand;
private String name;
private double price;
...
}
Then you define classes for specific inventory objects such
as the following:
public class Glove extends Item {
private String size;
}
You then define the web service interface:
@WebService()
public class Inventory {
...
public List<Item> getItems() {...}
public boolean addItem(Item item) {...}
...
}
If you deploy the web service and then look at the generated
WSDL and schema, would you see a definition for specific
inventory items such as Glove?
- Yes
- No
Answers
- What is
@UriTemplate?
- A JAX-RS annotation that identifies the URI path for
a RESTful web service resource. The annotation identifies the
URI path for which a resource class or class method
associated with a RESTful web service will serve requests.
For more information about RESTful web services and JAX-RS,
see the November 16, 2007 Tech Tip Implementing RESTful Web
Services in Java.
- What type of security store is used for a GlassFish v2
application server whose domain is configured with the
enterprise profile?
- NSS. A GlassFish v2 profile presets configuration
parameters for a particular type of use. The three profiles
are developer, cluster, and enterprise. One of the
configuration parameters is Security Store, which identifies
how security and trust-related artifacts such as certificates
and keys are stored. For the enterprise profile, the Security
Store value is set to NSS, which stands for Network Security
Services. For more information about security-related
settings in GlassFish v2 profiles, see the November 30, 2007
Tech Tip Enabling the GlassFish v2 Application Server as an
SSL Server.
- The following tag appears in a JSP page for an application:
<jsfExt:scripts/>
What does the tag do?
- Includes the Dynamic Faces JavaScript library into the
application.
<jsfExt:scripts/> is the standard tag to include
for Dynamic Faces applications. You can see an example of
a Dynamic Faces application in the October, 2007 Tech Tip
Client-Side Polling With Dynamic Faces.
- True or false, when a Java Persistence implementation runs in
J2SE mode, an application is responsible for creating it's
own entity managers?
-
True. You can use Java Persistence implementations that
are compliant with the EJB 3.0 specification (JSR-220) in
either of two modes: Java EE (formerly called "in-container")
and J2SE (formerly called "out-of-container"). In Java EE
mode, an
EntityManager instance can be obtained through
injection or through JNDI lookup. The lifecycle of an entity
manager instance obtained in this way is managed by the
container. In J2SE mode, the application is responsible for
managing the lifecycle of its entity managers. An
EntityManagerFactory can be used to create the entity
manager. For more information about the two modes of running
a Java Persistence implementation, as well as insights into
optimizing the performance of a Java Persistence
implementation, see the May 26, 2007 Tech Tip How to Get the
Best Performance Out of a Java Persistence Implementation.
- You want to create a simple web service to manage inventory.
You create a class that can be used to model any inventory
object that you want to expose through your web service, as
follows:
public abstract class Item implements Serializable {
private long id;
private String brand;
private String name;
private double price;
...
}
Then you define classes for specific inventory objects such
as the following:
public class Glove extends Item {
private String size;
}
You then define the web service interface:
@WebService()
public class Inventory {
...
public List<Item> getItems() {...}
public boolean addItem(Item item) {...}
...
}
If you deploy the web service and then look at the generated
WSDL and schema, would you see a definition for specific
inventory items such as Glove?
- No. If you deployed this web service and then looked at
the generated WSDL and schema, you would notice that only
the
Item type is defined -- there would be no mention of
Glove or any other specific item that extends the abstract
Item class. This is because when JAX-WS introspects the
Inventory class there is no mention of classes for the
specific items. To remedy that you can use the @XmlSeeAlso
annotation and list the other classes that you want to
expose through the Inventory web service. For more
information about the @XmlSeeAlso annotation and how it can
be used to enable support for type substitution, see the
September 2007 Tech Tip Using Type Substitution With Web
Services.
Developers Assistance
Need programming advice on Java EE? Try Developer Expert Assistance
|