Creating a Java interface
You can use Spring Roo's interface
command or an IDE to create a Java interface. In this recipe, we will see how we can create an interface named FlightServiceIntf
.
Getting ready
Start the Roo shell from the C:\roo-cookbook\ch01-recipe
directory, which contains the flight-app
Roo project.
How to do it...
Spring Roo provides the interface
command to create a Java interface, as shown here:
roo> interface --class sample.roo.flightapp.service.FlightServiceIntf Created SRC_MAIN_JAVA\sample\roo\flightapp\service\FlightServiceIntf.java sample.roo.flightapp.service.FlightServiceIntf roo>
How it works...
The following table describes the arguments that the interface
command accepts:
Argument |
Purpose |
---|---|
|
It is a mandatory argument, which specifies the fully-qualified name of the Java interface. |
|
It is an optional argument, which identifies the directory in which to create the interface, default being |
|
It is an optional argument, which instructs Spring Roo to allow reserved words in the name of Java interface. |
There's more...
Using Spring Roo you can't add constants
or declare methods in your Java interface. To add constants or methods, you need to use your IDE. You may have noticed that the rooAnnotations
argument is not available for the interface
command; therefore, you can safely assume that Spring Roo doesn't generate any code corresponding to a Java interface when you make modifications to it.
See also
The Creating a Java class recipe shows how to create a Java class using Spring Roo