Category Archives: apache isis
Simulating Enums in Naked Objects
One thing that Naked Objects 4.0 doesn’t yet support is Java 5-style enums. We think we know what we need to do to support it (I guess that will be 4.1), but for now let me offer you a way to get the same general effect.
Let’s make this concrete by considering (hackneyed example, I know) a library. Suppose that this library can loan out both Books and CDs, and that we wanted to have a StockType to enumerate these different types of stock.
First, let’s start with an Enumerated interface:
Read the rest of this entry
Domain Driven Design using Naked Objects – book now in print!
In case you missed the announcement from the pragprog newsletter, the book is now in print.
Just in time for the holidays!
Putting a Custom UI on Naked Objects: Part 4, Business Rules
In the previous post in this series we saw how the Naked Objects metamodel uses Facets to allow arbitrary metadata to be associated to the classes, properties, collections or actions. We’ve already explored the well-defined facets that are used to capture presentation semantics and to enable interactions, but we still need to see how facets enable business rules to be captured.
As I’ve previously blogged about, Naked Objects allows three different types of business rules to be implemented. In the metamodel API there is a corresponding interface for each of these rule types, implemented by Facets:
| Business rule | Description | API | Facet implementation examples |
|---|---|---|---|
| Visibility | can this user see the class member? | HidingInteractionAdvisor | @Hidden annotation, hideXxx() supporting methods |
| Usability | if so, can this user use (edit, modify or invoke) the class member? | DisablingInteractionAdvisor | @Disabled annotation, disableXxx() supporting methods |
| Validity | if so, can this user use (edit, modify or invoke) the class member? | ValidatingInteractionAdvisor | @RegEx annotation, validateXxx() supporting methods |
For example, the following Read the rest of this entry
Putting a Custom UI on Naked Objects: Part 3, The MetaModel API
In part one of this series we saw how to bootstrap Naked Objects, and in part two we saw how we can interact directly with domain objects as pojos (with Naked Objects taking care of persistence and transaction management). But we can also interact with domain objects through their NakedObject wrapper/adapter. Although more indirect, it is also more powerful. So let’s see how.
Recall that NakedObject does three things main things: it wraps the pojo (getObject()), it provides access to the metamodel through the corresponding NakedObjectSpecification (getSpecification()), and it provides access to the object’s Oid (getOid()).
If NakedObject is analogous to java.lang.Object, then NakedObjectSpecification is analogous to java.lang.Class, describing the class members (properties, collections and actions) of each NakedObject. It provides:
Read the rest of this entry
Putting a Custom UI on Naked Objects: Part 2, Interacting with Pojos
In the previous post we saw how to bootstrap Naked Objects, and open a PersistenceSession. In this post let’s see how to actually get hold of and interact with a domain object.
First thing we usually do is to get hold of the registered services (as per nakedobjects.services key in nakedobjects.properties configuration file). These will typically be repositories allowing us to locate existing domain objects, like Customers or Orders. For example, in the claims example app, we have an EmployeeRepository example:
Read the rest of this entry
Putting a Custom UI on Naked Objects: Part 1, Bootstrapping
One of the objectives for Naked Objects v4.0 was to make the framework more modular. So although (as the screencasts here show) it can still be used as a full-stack framework, it’s also possible to use it just for domain and persistence services. You can then graft on your own user interface as required.
What do I mean by “domain and persistence” services? Well:
- Naked Objects will automatically instantiate any domain services (including repositories and factories), and will inject these into your domain objects.
- It also makes it easy to switch from an in-memory object store while initially prototyping to a full RDBMS (or other) implementation later on.
- It’ll give you authentication/authorization, either in-built or integrating to your enterprise’s existing mechanisms.
- If you are writing client/server code (say, a JavaFX GUI), then it’ll take care of all the remoting for you, marshalling and unmarshalling your domain objects across the wire.
Moreover:
Read the rest of this entry
Overriding Annotations with a DSL
In the previous post I discussed the usage of annotations in domain models, and characterized them as either capturing domain semantics intrinsic to the domain, or semantics pertaining to adjacent layers (eg persistence, or presentation).
I also mentioned though that if you really dislike annotations, it’s quite possible to redefine the Naked Objects programming model so it picks up the information from elsewhere, such as a tiny DSL. So let’s see how.
Read the rest of this entry
Annotations vs XML
For me, the best innovation on the Java platform (and .NET too) in recent years has the introduction of annotations/attributes. But not everyone thinks so, even now.
Here’s a comment made to me in an offlist exchange from the DDD yahoo group:
“One thing I can tell you is that I despise attributes / annotations. I think it is because it very tightly couples one to whatever is providing those attributes.”
So, since I’m a fan of annotations, I think I should defend them. I think it’s worth identifying two categories:
Read the rest of this entry
TSSJS Europe 2009 Slides Online
Just had an enjoyable few days at the TSS Java Symposium conference in Prague. Never been to Prague before – like everyone told me, a very beautiful city.
At the conference itself also met some very interesting people and there were some interesting sessions – I intend to blog more fully about it in the next few days.
In the meantime, if you’re interested in seeing my presentation, it’s been uploaded (along with all the others) . Seemed to be well enough received and I was happy with the size of audience (my elevator pitch is improving!). There was rather too much content for an hour, though… it definitely lived up to the session title of being “a whistlestop tour”.
Naked Objects Programming: Bounded Classes
In this screencast we’re going to continue looking at domain object properties, building on the first post in this series.
We’ve already seen how Naked objects allows us to write supporting validateXxx() and choicesXxx() methods which we can use to limit the set of values that can be taken for a property, (eg “visa”, “mastercard” or “amex”). But suppose there were two different classes that both had the same rules? That would suggest there’s a concept missing from our ubiquitous language (eg PaymentMethodType). What the values then represent are the bounded set of instances of that type (just like an enum).
So in this screencast Read the rest of this entry
Naked Objects Programming: Property Business Rules
In the first post in this series, we saw how to add a new property to a domain object and specify some choices.
One of the aims of Naked Objects is to ensure that our domain objects are behaviourally-complete: that they encapsulate a coherent set of responsibilities. Not anaemic domain models, but OO like your mother taught you.
So in this screencast Read the rest of this entry
Naked Objects Programming: Properties and Choices
Naked Objects excels as a rapid prototyping environment. However, many rapid prototyping environments focus on user interface details, and gloss over the underlying domain concepts that sit underneath. With Naked Objects though (because the UI is generated automatically from the domain model), when we do rapid development prototyping we are prototyping the domain model itself.
This post is the first in a series of screencasts showing how to code using the Naked Objects programming model. In it we build upon the example claims application and show how to add a property to a domain object, and provide a list of choices (a drop-down list) for that property.
Read the rest of this entry
Naked Objects at TSSJS Europe
In a few weeks time theserverside will be running their Java Symposium conference in Prague.
I’m pleased to say I’ll be doing a session there, providing a whistlestop tour to the various features available in Naked Objects 4.0. If you can make it, why not drop in and introduce yourself.
Naked Objects example 'claims' app and other resources
As I blogged about in previously, Naked Objects is available from the Maven central repository. But to get you started there’s also a download available from the project website on Sourceforge which provides some example applications and other resources.
In this screencast I show you how to import and then run one of these example applications in Eclipse, and I go through the other resources available.
Read the rest of this entry
Using Project Lombok with Naked Objects
Project Lombok is a recent project that exploits with Java 1.6′s APT (Annotation Processing Tool) API to generate boilerplate code from annotations. In this screencast I show how Lombok can be easily used to remove the boilerplate getters and setters from a pojo domain object.
Read the rest of this entry
Session on Scimpi
One of the alternate viewers I discuss in the last chapter of the book is Scimpi. This is a web framework designed by Robert Matthews (project architect for Naked Objects itself), and which is implemented as a viewer for Naked Objects.
Like the original HTML viewer, Scimpi is still an OOUI: each of its pages correspond to a domain object. However, unlike the HTML viewer Scimpi is designed from the outset to be customisable. Whereas with the HTML viewer there’s no way to influence the page shown, Scimpi on the other hand searches for the best page to render the object by. Only if no page exists is a default view used. That means that different objects can be displayed in different ways.
Another difference is that the HTML viewer “owns” the entire page and always renders all the visible properties of the object. Scimpi in contrast uses (something akin to) taglibs, so the developer has much more control as to what is shown.
Putting the above two together, it also allows for Scimpi to provide composite views, such as an order / orderline.
I’m going to be giving a short 30 min talk on Scimpi at the Devoxx conference in November, so if you were planning on going then you might want to take a look.
Using the Naked Objects 4.0 Maven Archetype
The first in a series of screencasts on using Naked Objects and its sister projects. This one shows how to get started using the Maven archetype that comes with Naked Objects 4.0. For a larger view, click play and then press the button in the bottom right.
Read the rest of this entry
Exploring Domains and Collaborating with Domain Experts
Exploration and experimentation are essential in DDD. Rather than stopping the moment we get one useful model, we should look for alternatives that might reveal a deeper insight.
But we need to ensure that the exploration involves our domain experts; we are after all co-explorers. A heavy-duty requirements document will certainly drive the domain experts away, but even whiteboarding ideas using any kind of technical notation can be a turn-off, and lacks concrete feedback.
A couple of months ago skillsmatter.com ran a small 1-day conference devoted to domain driven design. Alongside Eric Evans, Gojko Adzic and other DDD alumni, I also gave a talk, and chose to discuss how Naked Objects can be use to build working prototypes that engage the users, “animating the domain model” and bringing it to life.
The Skillsmatter folk recorded podcasts of the entire proceedings, so if you’re interested then take a look at my talk and some of the others.
Hexagonal Architecture for Naked Objects
I’m currently busily working through the detailed and helpful (I have to say that, but it’s true!) comments that my technical reviewers have given me on the book. One thing that several reviewers mentioned was the lack of some sort of overall architecture to help understand what Naked Objects actually is.
In an earlier draft I had put together some words and a diagram on Naked Objects as an implementation of Alistair Cockburn’s Hexagonal Architecture, but had subsequently removed them. Based on this feedback I’ve spruced them up and added them back in. The diagram also acts as a roadmap to the book itself (the overlays are the chapter numbers):
Restful Objects Resources
Restful Objects is a sister project to Naked Objects that provides an out-of-the-box RESTful web service interface to your domain model.
Its application library (applib) defines a set of resources, annotated using JSR-311 APIs. They are:




