Skip to main content

juneau-petstore

The juneau-petstore family is the canonical Apache Juneau showcase application. It packages a small, complete sample petstore (pets, orders, users) and deploys it under two runtimes, Jetty/Microservice and Spring Boot, using the exact same REST surface. Its centrepiece is an admin console built entirely on the Juneau console framework: fourteen pages that exercise datatables, charts, staged edits, async jobs, themes and the four rendering flavors. This section tours that console, page by page.

In-tree, no external repo. The petstore lives directly in the Juneau reactor under juneau-petstore/.

Module layout​

juneau-petstore/                         (top-level aggregator, packaging=pom)
├── juneau-petstore-core/ Shared, deployment-agnostic surface (REST API, console, tests)
├── juneau-petstore-jetty/ Jetty/Microservice deployment
└── juneau-petstore-springboot/ Spring Boot deployment

Each module ships as a plain jar (no OSGi-bundle wrapping for the sample). The library Juneau modules they depend on are still OSGi bundles, so OSGi consumers lose nothing.

What is mounted where​

The core-hosted surface is identical across both deployments by construction (it is shared code, not parallel copies):

URLResourceWhat it is
/petstore/*PetStoreResourceThe petstore REST API: GET/POST/PUT/DELETE over pets, orders and users, backed by an in-memory PetStore service seeded from classpath JSON.
/console/*PetstoreConsoleResourceThe admin console. Each page is a child resource (StoreRest, PetsRest, OrdersRest, UsersRest, OpsRest, DevRest, AboutRest) that extends PetstoreConsolePage.
/juneau-console/*ConsoleAssetsRestThe console shell scripts and stylesheets, served by ConsoleChromeMixin.
/petstore-uiPetstoreUiResourceA no-build React app that talks to /petstore; the console embeds it as the React rendering flavor.

The deployment-specific surface is intentionally non-parity:

SurfaceJetty deploymentSpring Boot deployment
Microservice adminConfigResource, LogsResource, ShutdownResource (from juneau-microservice-examples), behind their own AdminBoundary CSRF filter(omitted; Spring Boot has its own actuator)
Spring @Autowired injection demo(n/a; no Spring container)HelloResource + HelloMessageProvider (/hello/*)

The core's PetstoreConsoleResource and PetStoreResource extend BasicRestServlet (servlet API only, nothing Spring or Microservice specific). Each deployment's RootResources mounts them as @Rest(children={...}); the Jetty one extends BasicRestServletGroup, the Spring Boot one extends BasicSpringRestServletGroup so children resolve as Spring beans. Switching runtimes is a matter of swapping the router base class and the bootstrap.

Running the petstore​

See start-petstore-jetty.py and start-petstore-springboot.py for the launch scripts.

python3 scripts/start-petstore-jetty.py          # http://localhost:10000
python3 scripts/start-petstore-springboot.py # http://localhost:5000

Jetty runs on port 10000 and Spring Boot on 5000; see Ports used in these docs.

Then open /console (it redirects to /console/store), or /petstore/pets for the raw JSON API.

The console tour​

The petstore console store page: header, navigation, welcome card and the recent orders table

The console is one chrome (header, navigation tree, footer, theme) wrapped around cards. The pages below are numbered P1 through P14 in the order of the navigation tree. Each tour page is described the same way: what it shows, the FreeMarker template, the Java builder twin that produces the same page contract, the tests that pin it, and the framework pages it demonstrates.

PageRouteTour page
Chrome and navigation/console/*Console Tour
P1 Store/console/storeStore
P2 Pets/console/petsPets
P3 Sold pets/console/pets/soldSold Pets
P4 Pet detail/console/pets/{id}/{tab}Pet Detail
P5 Orders/console/ordersOrders
P6 Jobs/console/ops/jobsJobs
P7 Audit/console/ops/auditAudit
P8 Custom cards/console/dev/cardsCustom Cards
P9 Themes/console/dev/themesThemes
P10 Pending changes/console/pets/changesPending Changes
P11 Users/console/usersUsers
P12 Rendering flavors/console/dev/flavors/{html,freemarker,mustache,react}Rendering Flavors
P13 Secure/console/dev/secureSecure
P14 About/console/aboutAbout
Developer pages (charts, data, dashboard)/console/dev/{charts,data,dashboard}Developer Pages
Porting the patterns to your own admin UIn/aPorting to the Console

Where the tests live​

The console tests are in juneau-petstore/juneau-petstore-core/src/test/java/org/apache/juneau/petstore/console/. Each resource has a *Rest_Test, PetstorePages_ContractTest pins the page contract of the main pages, and the browser subpackage holds the browser tests. Every tour page names the tests that cover it.

Where to look in the source​

  • org.apache.juneau.petstore.rest.PetStoreResource: the CRUD API.
  • org.apache.juneau.petstore.service.PetStore: the in-memory store.
  • org.apache.juneau.petstore.console.PetstoreConsoleResource and PetstoreConsolePage: the console host and the base class every page extends.
  • org.apache.juneau.petstore.console.pages: the builder twins (PetsPageBuilders, OpsPageBuilders, ...).
  • org.apache.juneau.petstore.jetty.App / RootResources: the Jetty deployment.
  • org.apache.juneau.petstore.springboot.App / RootResources: the Spring Boot deployment.

See also​

See also​

The four rendering flavors are covered on Rendering Flavors and the bearer-token demo on Secure. For how the petstore changed from earlier releases, see the v10.0 Migration Guide.