DayTrader 7 was designed to exercise as many Java EE 7 specifications as possible within a coherent, real-world trading workload. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/WASdev/sample.daytrader7/llms.txt
Use this file to discover all available pages before exploring further.
server.xml featureManager block lists exactly 13 Liberty features that correspond to these specifications — every feature is actively used by either the core trading flow or by the Web Primitives micro-benchmark suite. This makes DayTrader 7 a valuable tool both for measuring aggregate application-server performance and for isolating per-specification bottlenecks.
Feature Reference
1. EJB 3.2 — ejb-3.2
Enterprise JavaBeans is the backbone of DayTrader 7’s business tier. Three EJB component types are used together.
TradeSLSBBean is a @Stateless session bean annotated with container-managed transactions. Every business method uses @TransactionAttribute(REQUIRED) by default, ensuring that a buy or sell and its associated JPA writes commit atomically. The publishQuotePriceChange method uses @TransactionAttribute(REQUIRES_NEW) to commit the JMS publish in a separate transaction.
DTBroker3MDB and DTStreamer3MDB are @MessageDriven beans. DTBroker3MDB consumes the TradeBrokerQueue (point-to-point) to complete async orders; DTStreamer3MDB subscribes to the TradeStreamerTopic (pub/sub) to relay stock price events.
MarketSummarySingleton is an @Singleton EJB that uses @Schedule to refresh the market summary every 20 seconds and @Lock(LockType.READ) / @Lock(LockType.WRITE) to protect concurrent access to the cached MarketSummaryDataBean.
PingEJBLocal, PingEJBIFace, PingEJBLocalDecorator in web/prims/ isolate EJB invocation overhead.
2. JPA 2.1 — jpa-2.1
The daytrader persistence unit (JTA-managed, bound to jdbc/TradeDataSource) contains five entity classes. TradeSLSBBean uses a container-injected EntityManager for all persistence operations.
entityManager.find()for every account, quote, and holding lookup.entityManager.persist()for new orders, holdings, and accounts.entityManager.merge()for profile and quote updates.entityManager.remove()for completed sell-order holdings and long-run order cleanup.@NamedQuery/@NamedNativeQuery—quoteejb.allQuotes(JPQL),quoteejb.quoteForUpdate(nativeSELECT ... FOR UPDATE), and multipleorderejb.*named queries.- Criteria API —
getHoldings()andgetClosedOrders()inTradeSLSBBeanbuild queries withCriteriaBuilderandCriteriaQuery<T>. - Schema
optLockcolumn — every table has anoptLockinteger column in the DDL, but it is not mapped to a@Versionfield in the entity classes. Concurrent buy/sell operations on the same quote are instead serialized via theSELECT ... FOR UPDATEnative query (quoteejb.quoteForUpdate).
<shared-cache-mode>NONE</shared-cache-mode>) so every read exercises the full JDBC path.
3. Servlet 3.1 — servlet-3.1
Servlets provide the HTML-based trading interface and the automated benchmark scenario driver.
| Servlet | Purpose |
|---|---|
TradeAppServlet | Main user interface: login, buy, sell, portfolio, quotes |
TradeScenarioServlet | Automated benchmark scenario loop; drives random buy/sell/getQuote operations |
TradeConfigServlet | Runtime configuration panel (runtime mode, market summary interval, etc.) |
PingServlet, PingServlet2DB, PingServlet2Jsp, PingServlet2Servlet, PingServlet30Async, PingServlet31Async, PingServlet31AsyncRead, PingUpgradeServlet, and others isolate individual Servlet 3.x features including async context, non-blocking I/O reads (ReadListener), and HTTP Upgrade.
4. JSF 2.2 — jsf-2.2
The JSF front-end provides a complete browser-based UI for authenticated trading. Managed beans use CDI scopes and are injected with TradeAction via producer methods.
| Bean | Scope | Responsibility |
|---|---|---|
TradeAppJSF | @SessionScoped | Login, logout, registration, buy, sell navigation |
PortfolioJSF | @SessionScoped | Portfolio and holdings display |
OrderDataJSF | @SessionScoped | Order history and status |
QuoteJSF | @SessionScoped | Quote lookup and display |
AccountDataJSF | @SessionScoped | Account balance and profile editing |
MarketSummaryJSF | @SessionScoped | Market summary panel |
TradeConfigJSF | @ApplicationScoped | Configuration panel backed by TradeConfig |
PingCDIJSFBean tests JSF + CDI integration.
5. CDI 1.2 — cdi-1.2
CDI wires the JSF and WebSocket tiers together and bridges JMS messaging to the WebSocket endpoint without tight coupling.
Producer methods eliminate JNDI lookups from JSF beans:
DTStreamer3MDB to MarketSummaryWebSocket without any direct dependency. The MDB fires an event; the WebSocket endpoint observes it:
JSFLoginFilter is a @WebFilter(urlPatterns = "*.faces") servlet filter that protects JSF pages from unauthenticated access by checking the HTTP session before forwarding requests.
Primitives: PingCDIBean, PingServletCDI, PingServletCDIBeanManagerViaCDICurrent, PingServletCDIBeanManagerViaJNDI.
6. JMS 2.0 / MDB 3.2 — mdb-3.2
Asynchronous order processing is the primary use of JMS. TradeSLSBBean uses the JMS 2.0 simplified API (JMSContext) to send messages to both destinations.
Point-to-point (queue) — async order completion:
wasJmsServer-1.0) provides TradeBrokerQueue and TradeTopicSpace without an external broker.
Primitives: PingServlet2MDBQueue, PingServlet2MDBTopic in web/prims/ejb3/.
7. WebSocket 1.1 — websocket-1.1
MarketSummaryWebSocket is a @ServerEndpoint that maintains a static CopyOnWriteArrayList<Session> of all connected browser clients. It starts a ManagedScheduledExecutorService-based scheduler when the first client connects, and cancels it when the last client disconnects.
DTStreamer3MDB, the scheduler wakes up and pushes JSON-encoded stock price changes to every open session using session.getBasicRemote().sendText(json).
Primitives: PingWebSocketTextSync, PingWebSocketTextAsync, PingWebSocketBinary, PingWebSocketJson benchmark raw WebSocket throughput for text, async text, binary, and JSON payloads.
8. Concurrency Utilities 1.0 — concurrent-1.0
Two managed concurrency objects are injected by the container.
ManagedThreadFactory in TradeSLSBBean enables the ASYNCH_MANAGEDTHREAD order processing mode, where order completion runs in a container-aware managed thread instead of a JMS queue:
ManagedScheduledExecutorService in MarketSummaryWebSocket drives the periodic push scheduler for WebSocket clients:
PingManagedExecutor (exercises ManagedExecutorService via async servlet) and PingManagedThread (exercises ManagedThreadFactory directly).
9. JSONP 1.0 — jsonp-1.0
JSON-P is used to serialize market summary and stock price change data for WebSocket delivery. MarketSummaryWebSocket uses Json.createObjectBuilder() to merge two JSON objects before broadcasting:
RecentStockChangeList utility also uses the JSON-P API to build the per-symbol change list sent as a JsonObject string over the WebSocket.
Primitive: PingJSONP — a servlet that uses JsonGenerator (streaming write) and JsonParser (streaming read) to benchmark raw JSON-P throughput.
10. Bean Validation 1.1 — beanValidation-1.1
Bean Validation constraints are declared on the JPA entities and validated by the JSF tier at form submission time.
AccountDataBean—@NotNullonloginCountandlogoutCount.HoldingDataBean—@NotNullonquantity.OrderDataBean—@NotNullonquantity.QuoteDataBean—@NotNullonvolumeandchange1.AccountProfileDataBean—@NotNullonuserID.
LoginValidator JSF validator (@FacesValidator("loginValidator")) validates that the login username matches the expected format (uid:\d+) using a regular expression check.
11. Embedded JMS Messaging — wasJmsServer-1.0 / wasJmsClient-2.0
The Liberty wasJmsServer-1.0 feature embeds a full JMS messaging engine directly in the server process, eliminating the need for an external broker. wasJmsClient-2.0 provides the client-side connection factories and destination resources used by TradeSLSBBean.
The messaging engine configuration in server.xml defines:
NonPersistent delivery to maximize throughput (messages are not journalled to disk), which is appropriate for a benchmark workload.
12. Local Connector — localConnector-1.0
The Liberty localConnector-1.0 feature enables local JMX-based management and admin connectivity. It is required for Liberty administration tooling and for certain management operations used by the DayTrader configuration and reset servlets when running within a Liberty server.
Web Primitives Coverage
The
daytrader-ee7-web module contains a dedicated package of isolated micro-benchmark servlets at com.ibm.websphere.samples.daytrader.web.prims. Each servlet exercises a single Java EE feature in isolation, making it straightforward to attribute a performance change to a specific specification without the noise of the full trading workload.| Category | Key Primitives |
|---|---|
| Servlet baseline | PingServlet, PingServletWriter, PingServletSetContentLength |
| Async Servlet | PingServlet30Async, PingServlet31Async, PingServlet31AsyncRead |
| JDBC | PingJDBCRead, PingJDBCRead2JSP, PingJDBCWrite, PingServlet2DB |
| EJB | PingEJBLocal, PingEJBIFace, PingEJBLocalDecorator |
| CDI | PingCDIBean, PingServletCDI, PingCDIJSFBean |
| JMS / MDB | PingServlet2MDBQueue, PingServlet2MDBTopic |
| WebSocket | PingWebSocketTextSync, PingWebSocketTextAsync, PingWebSocketBinary, PingWebSocketJson |
| JSON-P | PingJSONP |
| Concurrency | PingManagedExecutor, PingManagedThread |
| JSP | PingServlet2Jsp, PingServlet2Include |
| Session | PingSession1, PingSession2, PingSession3, PingSession3Object |
| HTTP Upgrade | PingUpgradeServlet |