X
  • Sun
    December 20, 2007

Tech Tips Quiz

Guest Author

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.


  1. What is @UriTemplate?

     

    1. The location of a template used for constructing a URI.
    2. A JAX-RS annotation that identifies the URI path for a RESTful web service resource.
    3. A JAXB annotation that serializes a RESTful web service URI parameter.
    4. None of the above.


     

  2. What type of security store is used for a GlassFish v2
    application server whose domain is configured with the
    enterprise profile?

     

    1. JKS
    2. NSS
    3. SLS


     

  3. The following tag appears in a JSP page for an application:

     

       <jsfExt:scripts/> 

     

    What does the tag do?

     

    1. Includes the jsfExt script into the application.
    2. Includes the JavaServer Faces tag library into the application.
    3. Includes the script.aculo.us JavaScript library into the application.
    4. Includes the Dynamic Faces JavaScript library into the application.


     

  4. True or false, when a Java Persistence implementation runs in
    J2SE mode, an application is responsible for creating it's
    own entity managers?


    1. True
    2. False


     

  5. 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?




    1. Yes
    2. No



Answers

  1. What is @UriTemplate?



    1. 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
      .




  2. What type of security store is used for a GlassFish v2
    application server whose domain is configured with the
    enterprise profile?


    1. 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
      .



  3. The following tag appears in a JSP page for an application:


         <jsfExt:scripts/> 


    What does the tag do?

     


    1. 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.


  4. True or false, when a Java Persistence implementation runs in
    J2SE mode, an application is responsible for creating it's
    own entity managers?



    1. 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
      .

  5. 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?



  1. 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
    .


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.