JBoss.org Community Documentation
The most popular of the projects we deal with are the J2EE ones, such as Dynamic Web Project, EJB Project, or EAR project. Web projects of JBoss Tools are Struts, JSF and Seam projects. All of them are called faceted projects. Thus, in this chapter we are going to tell you about facets the main benefit of which to provide proper structuring and packaging for any type of project.
The idea behind faceted projects is that each project can accept units of functionality, or facets, which can be added or removed by the user. Most often, these facets either add to the project's classpath, enable a builder, or watch the project in some other fashion. Generally, every project concerned has at least one facet when it's created. As an example, a Web project has a WebDoclet facet, or an EJB Project has an EJB Module facet as prerequisites.
WTP projects have undergone some criticism as being over-engineered or too restrictive in their design. WTP projects are set up in a tree-relationship to each other, where one project can be a child of another. For example, an EAR project may have a Web Project child, an EJB project child, or other types.
However, the benefit of this is that the structure of your projects is then known, and packaging it up *should* be trivial. Apparently, if your project is non-standard, or you feel too confined by such rigid structural requirements, you can still choose to package your project using the Archives plugin.
There are two ways to add facets to a project. The first way is to include facets into already existing project. For that you should bring up the context menu for selected project and click Properties. At this point, choose Project Facets from the left. It will represent a list of the facets for your project and give opportunity to modify it by clicking on Modify Project... button.
The other way is adding necessary facets while organizing a new project. To demonstrate it let's create a new Dynamic Web Project selecting as usual File > New > Other... and then Web > Dynamic Web Project.
Click Next and you will see Dynamic Web Project page.
The first page of most WTP projects allows you to target a specific runtime, representing a server's library location. It will also provide you the ability to add this project to an EAR project, and select a pre-selected default set of facets, called a configuration, rather than manually select each facet you might want.
Selecting the runtime, again, allows the project to install the proper classpaths to the project so it knows what code to compile against.
The second page of the wizard allows you to enable or disable specific facets, as described above. Some facets may require others, and some may conflict with others, but on the whole this page allows you to add any number of facets that don't conflict with each other. It means that the list doesn't show those facets that couldn't be in the same project. To view the information on limitations and requirements for the chosen facet right-click on the facet and press Show Constraints.
Notice that here it is also possible to change the version of any facet. If the chosen version isn't compatible with any other facet version, you'll be prompted about this in the combo box underneath.
Further pages in the wizard are specific to either the project type, or the facets selected.