Friday Nov 14, 2008
Friday Nov 14, 2008
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.
a. True
b. False
a. Persistence.nonrepeat()
b. EntityManager.lock()
c. LockMode.set()
d. None of the above
a. A framework for enabling interoperable web services.
b. A lightweight, scripting-friendly, web application environment that runs on the Java platform.
c. A container for JavaScript widgets.
d. An debugger for the NetBeans IDE that provides advanced analysis features.
e. An MBean generator.
a. Username Authentication with Symmetric Keys
b. SAML Authorization over SSL
c. STS Issued Endorsing Token
d. All of the above
e. None of the above
@XmlRootElement
public class StatusInfoBean {
public String status = "Idle"
public int tonerRemaining = 25;
}
If the application uses Jersey 1.0 to transform the status data into the mapped type of JSON notation, what will the JSON-formatted data look like?
a.{"StatusInfoBean":{"status":"Idle","tonerRemaining":"25"}}{"status":"Idle", "tonerRemaining":"25"}{"StatusInfoBean":{"status":{"$":"Idle"},"tonerRemaining":{"$":"25"}}}{"status":{StatusInfoBean":[{"status":"Idle","tonerRemaining":"25"}]
Answers
a. True
b. False
a. True. This feature in JSF 2.0 allows you to turn any collection of page markup into a JSF user interface (UI)
component -- with attached validators, converters, action listeners, and value change listeners -- for use
by page authors. Unlike composite components created with other approaches such as Facelets, composite
components in JSF 2.0 technology support all the features of a real UIComponent.
To learn more about composite UI components in JSF 2.0, see the August 29, 2008 Tech Tip
True
Abstraction: Composite UI Components in JSF 2.0 -- Part 1 and the September 15, 2008 Tech Tip
True Abstraction: Composite UI Components in JSF 2.0 -- Part 2.
a. Persistence.nonrepeat()
b. EntityManager.lock()
c. LockMode.set()
d. None of the above
b. EntityManager.lock(). Stale data means data that is no longer current. Guarding against
using stale data for computation in the Java Persistence API (JPA) on a versioned entity means preventing
situations such as the following:
| Transaction T1 | Transaction T2 |
|---|---|
tx1.begin();
d1 = findDepartment(dId);
//d1's original name is "Engrg"
d1.setName("MarketEngrg");
tx1.commit();
|
tx2.begin();
e1 = findEmp(eId);
d1 = e1.getDepartment();
if(d1's name is "Engrg")
e1.raiseByTenPercent();
tx2.commit();
|
In this situation, transaction T2 checks employee e1's version in the database,
but does not check employee d1's version because it doesn't see d1
as "dirty". Transaction T2 doesn't make the d1 check even though it uses
d1's version in its computation. As a result, employee e1 gets an undeserved raise.
One way to prevent this situation is to use the lock() method of the EntityManager class.
This method sets the lock mode, READ or WRITE, for an entity object contained in the persistence context.
If the lock mode is READ, the entity manager protects against dirty reads or non-repeatable reads.
If the lock mode is WRITE, it forces an update to the entity's version column.
Another approach is to use pessimistic locking. In pessimistic locking, all transactions occur in a completely isolated fashion, that is, as if all transactions in the system had executed serially, one after the other. A read transaction locks the row representing the data in the underlying datasource. A write transaction can commit only after the read commits. During the read transaction, the value of the data being locked does not change.
For more information about preventing the use of stale data in JPA, see the July 2, 2008 Tech Tip, Preventing Non-Repeatable Reads in JPA Using EclipseLink.
a. A framework for enabling interoperable web services.
b. A lightweight, scripting-friendly, web application environment that runs on the Java platform.
c. A container for JavaScript widgets.
d. An debugger for the NetBeans IDE that provides advanced analysis features.
e. An MBean generator.
b. A lightweight, scripting-friendly, web application environment that runs on the Java platform. Using Phobos, you can take advantage of the benefits offered by scripting languages and leverage the power of the Java platform. Being scripting-friendly, Phobos provides a programming environment that fosters rapid application development. The primary language supported by Phobos is JavaScript, which Phobos supports using the Mozilla Rhino scripting engine. To learn more about Phobos and see an example of its use with jMaki, see the August 12, 2008 Tech Tip Building An Ajax-Enabled Web Application Using Phobos and jMaki.
a. Username Authentication with Symmetric Keys
b. SAML Authorization over SSL
c. STS Issued Endorsing Token
d. All of the above
e. None of the above
d. All of the above. The NetBeans IDE offers an easy way to enable security using the Metro web services stack of technologies. One of the ways it does this is by providing a set of security profiles that specify the mechanism to be used in securing conversations. The NetBeans IDE offers a variety of security profiles to choose from, three of which are Username Authentication with Symmetric Keys, SAML Authorization over SSL, and STS Issued Endorsing Token. Four of the security profiles offered by the NetBeans IDE (STS Issued Token, STS Issued Token with Service Certificate, STS Issued Endorsing Token, and STS Issued Supporting Token) secure web services with Security Token Service (STS)-issued tokens. This enables secure conversations with Metro-based web services in accordance with the WS-Trust security specification. For more information about security profiles and support for WS-Trust in Metro, see the October 14, 2008 Tech Tip, Using WS-Trust Support in Metro to Secure Web Services.
@XmlRootElement
public class StatusInfoBean {
public String status = "Idle"
public int tonerRemaining = 25;
}
If the application uses Jersey 1.0 to transform the status data into the mapped type of JSON notation, what will the JSON-formatted data look like?
a.{"StatusInfoBean":{"status":"Idle","tonerRemaining":"25"}}{"status":"Idle", "tonerRemaining":"25"}{"StatusInfoBean":{"status":{"$":"Idle"},"tonerRemaining":{"$":"25"}}}{"status":{StatusInfoBean":[{"status":"Idle","tonerRemaining":"25"}]
b.{"status":"Idle", "tonerRemaining":"25"}.
Jersey 1.0 is an open-source, production-ready reference implementation
of JAX-RS, the Java API for RESTful Web Services (JSR-311).
Jersey makes it easy to create RESTful web services in Java. JSON (JavaScript Object Notation) is a lightweight data-interchange
format that is based on the object notation of the JavaScript language. Because of it's simple text format, JSON provides
a good alternative to other data interchange formats such as XML and is particularly attractive as a data interchange format
for RESTful web services.
Jersey 1.0 can generate three types of JSON notation from JAXB beans: mapped format, Jettison format,
and BadgerFish format. You specify the type of format in a JAXB context resolver using the JSONJAXBContext.JSON_NOTATION
parameter. For example, JSONJAXBContext.JSONNotation.MAPPED specifies the mapped format, which is also the default
format. Answer b represents the printer status data in mapped format. Answer a represents the printer status data in
Jettison format. And answer c represents the printer status data in BadgerFish format. Answer d does not correspond to any format
supported by Jersey 1.0. For more information about support for JSON in Jersey 1.0, see the October 27, 2008
Tech Tip, Configuring JSON for RESTful
Web Services in Jersey 1.0.
Nice
Posted by 125.18.2.25 on November 19, 2008 at 01:55 AM PST #
thank myou
Posted by ali hamedi on November 19, 2008 at 02:26 AM PST #
Thanks a lot.Got some thing to learn from...
Posted by Sanjeev Kulkarni on November 20, 2008 at 03:41 AM PST #
Should have a quiz like this every month.
Posted by rahil on November 26, 2008 at 08:13 AM PST #
You might want to check developers.sun.com. They post new quiz questions frequently.
Posted by Edward Ort on November 26, 2008 at 10:34 AM PST #