|  Sample Applications, Code Examples, and Test Domain

Getting Started  | Samples |  Fast Track |  Documentation |  Oracle Technology Network

Controls: Start the Administration Console  Shut Down Server  

Java EE 6 Code Examples

Using Bean Validation with JPA Entities

This example demonstrates the use of bean validation with JPA to define constraints on a User entity object. The constraints @NotNull, @Pattern, @Min and @Email are used to ensure that the data being persisted meets the specified requirements. The validation constraints are automatically checked when the object is persisted and any validation errors are propagated back through to the JSF tier, to be displayed to the user as an error.

Run the example  |   Instructions


Using Bean Validation with JSF Managed Beans

This example demonstrates the integration of bean validation with JSF through the use of validation constraints on JSF Managed Beans. A simple calculator style application is used, in which JSF Managed Beans are used for gathering the input data and storing the calculation result. Standard validation constraints such as @NotNull and @Pattern are placed in the Managed Bean fields to ensure the validity of the input data. Additionally, an example of a custom validation constraint, @NonZero, is used to ensure the value provided is non zero.

Run the example  |   Instructions


Contexts and Dependency Injection (CDI)

This example introduces Contexts and Dependency Injection (CDI) for the Java EE Platform. CDI is one of several new features in Java EE 6 that help connect the Web tier and the business tier of the Java EE platform.

Run the example  |   Instructions


Using a Calendar-Based Timer

This example demonstrates the calendar-based scheduling capabilities that are supported in the EJB 3.1 specification. This scheduling functionality takes the form of CRON-styled schedule definitions that can be placed on EJB methods, in order to have the methods automatically invoked according to the defined schedule.

Run the example  |   Instructions


Simplified Programming Model and Packaging in a WAR File

This example demonstrates the simplified programming and packaging model changes supported in the EJB 3.1 specification. In this example, a @Stateless annotation is provided on a plain old Java class that exposes it as an EJB session bean. This is then injected into a @WebServlet class using an @EJB annotation to demonstrate it being used an EJB module. The EJB session bean and servlet classes are packaged and deployed together in a WAR file, demonstrating the simpler packaging and deployment changes available in Java EE 6.

Run the example  |   Instructions


Using the JPA Criteria Query

This example demonstrates the new Criteria Query API that was added to JPA 2.0. The Criteria Query API provides another way to issue queries for JPA @Entity objects in addition to JPQL that was provided in the past. By using Java APIs that are provided, such as CriteriaBuilder, CriteriaQuery and Predicate, it is possible to construct dynamic, type-safe queries that can be executed at runtime.

Run the example  |   Instructions


Incorporating AJAX in Web Applications

This example demonstrates the basic use of some of the Ajax features provided in JSF 2.0. The example uses a <f:ajax> component nested in <h:commandButton> to send an Ajax request that is used to refresh a displayed timestamp in the current page. An Ajax component nested in a JSF command link tag <h:commandLink> is used to send Ajax requests. Clicking the Refresh button invokes the AjaxBean.showTime method, which services the Ajax request and ultimately updates the <h:outputText> component with the output.

Run the example  |   Instructions


Using Facelets and Templating

This example demonstrates the use of Facelets in JSF 2.0. It shows the use of the powerful page templating facility and the custom component model that Facelets provides to enable reusability of common page layouts and content. JSF templates enable a reusable page layout to be defined using a set of <ui:insert> components. The actual JSF pages that provide the content of the application use a defined template through the <ui:composition> component, then insert the desired content into the respective sections of the template using <ui:define> components.

Run the example  |   Instructions


Using Annotations for Servlets, Filters, and Listeners

This example demonstrates using the servlet 3.0 feature that allows developers to define Web application components solely from annotations, such as @WebServlet, @WebListener, and @WebFilter, no longer requiring definition and mapping entries within the web.xml descriptor.

Run the example  |   Instructions


Asynchronous Servlet and Request Handling

This example demonstrates asynchronous processing in servlet 3.0, in which a servlet is marked as being capable of handling asynchronous requests @WebServlet(urlPatterns = "/run",asyncSupported = true) and an asynchronous context is started from the incoming request using its startAsync method, allowing the response to be returned immediately to the browser. This allows long running operations to be handled more efficiently without consuming resources while waiting for the work to complete.

Run the example  |   Instructions


Servlet Web Fragment

This example demonstrates the pluggable nature of servlet 3.0, in which modular, self-contained extensions can be easily added to Web applications. The modular extension provides its own configuration using a deployment descriptor element called <web-fragment>, which gets merged automatically with the containing Web application at deployment time.

Run the example  |   Instructions


Singleton Session Bean

This example demonstrates the use of the EJB 3.1 Singleton session bean, which provides a formal programming construct that guarantees a session bean will be instantiated once per application. In this example, a @Singleton @Stateless session bean provides a central counter service. The Counter EJB is called from a Java client to demonstrate it being used, with the count being consistently incremented by 1 as the client is invoked multiple times.

Instructions for running the EJB 3.1 Singleton Session Bean sample application


Building RESTFul Web Services with JAX-RS

The Java API for RESTful Web Services (JAX-RS) provides support for creating Web services according to Representational State Transfer (REST) architectural style. JAX-RS uses annotations to simplify the development of RESTful Web services. This example defines a RESTful Web service using JAX-RS within a stateless session EJB. It uses annotations to define resources and the actions that can be performed on those resources.

Instructions for running the JAX-RS sample application

 

 

Sample Applications and Code Examples

Test Domain

Use the WebLogic Server Examples domain to try out your own applications! By default, this directory is located in ORACLE_HOME/user_projects/domains/wl_server, where ORACLE_HOME represents the directory you specified as the Oracle Home when you installed WebLogic Server; for example, C:\Oracle\Middleware\Oracle_Home.

You can use the WebLogic Server instance you are running right now to try out your JSPs, servlet or other Java Platform, Enterprise Edition (Java EE) Applications. See the Fast Track Deployment and Administrator Guide.

WebLogic Server API Examples

The API examples demonstrate Java EE and WebLogic Server features. Each example comes with source code, instructions for building and running the examples, and ant scripts to automate the build process.

Managed Coherence Servers Examples

Three examples are included that demonstrate building and deploying a domain with managed Coherence servers: one shows a single-server domain; a second shows a domain with a Coherence cluster; and a third shows rolling restart of storage-enabled members of managed Coherence servers.

Avitek Medical Records Sample Application

The Avitek Medical Records application is an educational tool for all levels of Java EE developers. It showcases the use of each Java EE component, and illustrates best practice design patterns for component interaction and client development. MedRec also illustrates best practices for developing and deploying applications with WebLogic Server. Complete source code and documentation is available for this application.

To launch the Medical Records Application, first shut down the current WebLogic Server instance using the Shut Down Server button in the top right corner of this page. Then run the startWebLogic script from the MedRec domain root directory. By default, this directory is located in ORACLE_HOME/user_projects/domains/medrec.

Oracle WebLogic Server How Tos, Demos, News, and Community


  Copyright © 1996,2013, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
  Other names may be trademarks of their respective owners.