14 Sample Application and Code Examples

This chapter describes WebLogic Server code examples and sample applications that offer several approaches to learning about and working with WebLogic Server. These examples and sample applications are available through performing a custom installation and selecting to install the Server Examples.

This chapter includes the following sections:

WebLogic Server optionally installs API code examples in WL_HOME\samples\server\examples\src\examples, where WL_HOME is the top-level directory of your WebLogic Server installation, and makes them available from the Start menu. On Linux and other platforms the Examples Server can be started from the WL_HOME/samples/domains/wl_server directory.

The default administration username and password for the Examples domain is weblogic/welcome1.

Note:

If you change the password for the user weblogic, WebLogic Server may fail to boot. For more information and workarounds, see "Limitation Regarding User weblogic" in Managing Server Startup and Shutdown for Oracle WebLogic Server.

Java EE 6 Examples

Oracle WebLogic Server fully supports the Java Platform, Enterprise Edition (Java EE) 6 specification. The Java EE 6 examples demonstrate how to implement Java EE 6 APIs and Oracle WebLogic Server-specific features. The examples are grouped in the following categories:

  • Bean Validation: Use bean validation with JPA entities, JPA from Java SE, and JSF managed beans.

  • Context and Dependency Injection (CDI): Introduces CDI with type-safe dependency injection, interceptors, and producers.

  • Data Source: Use the @DataSourceDefinition annotation.

  • EJB 3.1: Use asynchronous methods, a calendar-based timer, simplified programming model and packaging in a WAR file, portable global JNDI names, and singleton session beans.

  • Java API for RESTful Web Services (JAX-RS) 1.1: Build RESTful Web services with JAX-RS.

  • Java EE Connector Architecture 1.6: Use the Java EE Connector Architecture to connect two applications together using a stock trading application.

  • JPA 2.0: Use the JPA Criteria Query API and the @ElementCollection mapping type.

  • JSF 2.0: Incorporate Ajax in Web applications, create bookmarkable Web applications, and use Facelets and templating.

  • Servlet 3.0: Use annotations for servlets, filters, and listeners, handle file uploads with multipart files, and use asynchronous servlet and request handling, programmatic security, and servlet Web fragments.

Additional API Examples

These examples demonstrate how to implement additional Java EE APIs and Oracle WebLogic Server-specific features. The examples are grouped in the following categories:

  • Database Connectivity: Use DataSources, MultiDataSources, and Rowsets.

  • EJB: Create stateless, stateful, entity, and message-driven EJBs, and more.

  • Internationalization: Internationalize an application using simple message catalogs.

  • Messaging: Use JMS topics, queues, and message-driven beans.

  • Resource Adapter: Use an entity EJB to interact with a Java EE Connector Architecture resource adapter.

  • Security: Use the Java Authentication and Authorization Service, SAML, and outbound and two-way SSL.

  • Transactions: Use JTA to perform distributed transactions using the two phase commit protocol across two XA resources.

  • Web Application: Create simple servlets and JSPs, use the HTTP Publish-Subscribe server, and more.

  • Web Services: Create a variety of Web Services using JWS annotations.

  • XML: Use the STAX API and XMLBeans

  • Cluster: Cluster an EJB and use HTTP session state replication.

  • WebLogic Scripting Tool: Use the WebLogic Scripting Tool (WLST) to configure and manage a running WebLogic Administration Server.

  • Split Development: Use the WebLogic split development directory structure to build, package, and deploy Enterprise Applications.

  • Service Component Architecture: Use WebLogic SCA, a lightweight Spring 2.5 (or higher) container, in a shopping cart application that demonstrates many of its key features.

  • Spring: Use Spring-simplified configuration in a Spring-based Web application.

Avitek Medical Records

Avitek Medical Records (or "MedRec") is a comprehensive educational sample application that demonstrates WebLogic Server and Java EE features, as well as best practices. If you select to install the Server Examples, Avitek Medical Records is available from the Start menu on Windows machines. On Linux and other platforms it can be started from the WL_HOME/samples/domains/medrec directory, where WL_HOME is the top-level installation directory for WebLogic Server.

The sample application, MedRec (Spring) demonstrates Spring 3.0.x application development practices.

The default administration username and password for the Medical Records domain is weblogic/welcome1.

Derby Open-Source Database

Derby is an open source relational database management system based on Java, JDBC, and SQL standards. It is bundled with WebLogic Server for use by the sample applications and code examples as a demonstration database. For more information about Derby, see http://db.apache.org/derby.