开发者

What is 'Facet' in JavaEE?

开发者 https://www.devze.com 2022-12-12 21:58 出处:网络
I wonder not only what is Facet b开发者_如何学JAVAut also what is Facet \'in physical level\' (as I understand it\'s not a separate jar, but what?)?

I wonder not only what is Facet b开发者_如何学JAVAut also what is Facet 'in physical level' (as I understand it's not a separate jar, but what?)?

I also wonder how can it affect my application after deploying. I'll explain on real example:

I had 2 facets (which were created by IDE): Spring Facet and Web Facet (for jsf). I deployed it to Tomcat and my application worked fine.

Then I added (by means of IDE) one more facet - JPA Facet. I redeployed application and.. it still worked fine :)

So, I'm just curious what is that and why do we need it?


This is not Java EE related. This is IDE related. The term is at its own not programming related.

From http://www.thefreedictionary.com/facet

fac·et (fst) n.

  1. One of the flat polished surfaces cut on a gemstone or occurring naturally on a crystal.
  2. Anatomy A small, smooth, flat surface, as on a bone or tooth.
  3. Biology One of the lenslike visual units of a compound eye, as of an insect.
  4. One of numerous aspects, as of a subject. See Synonyms at phase.

It's 4.

In this specific case it's just an aspect which is to be used in the project, so that the IDE can intercept on it with regard to generators, wizards, auto-include libraries and so on. If you add for example the JPA facet, then you will get more options to do the IDE-magic with JPA.


As BalusC said, this is not Java EE related but IDE related. This allows to add "characteristics" to a project in a flexible way.

From the IntelliJ IDEA Q&A for Eclipse Users (because you mentioned IDEA):

Q: Facets — what they are for?

A: To streamline the project configuration.

Facets encapsulate the support for a variety of frameworks, technologies and languages. For example, to enable Spring in your project, you only have to add the corresponding facet. All libraries are downloaded and configured, you get the full range of coding assistance, refactorings, etc. Moreover, the code model is also recognized, so you are completely free from worrying about any configuration issues.

In most cases, you can add more than one facet of the same type to your project. For example, you can have multiple Web facets for deploying the application to different servers, or several EJB facets, each for its own EJB version. (See also Project Configuration.)

And yes, Eclipse uses "Facets" too:

What is 'Facet' in JavaEE?

AFAIK, NetBeans doesn't (see Q: How do I configure a web framework for my project?).


As explained in Eclipse & Intellij documentation, Facets define characteristics and requirements (certain configuration, specific for a particular framework/technology).

When you add a facet to a project, that project is configured to perform a certain task, fulfill certain requirements, or have certain characteristics.

In Brief You Have to Follow Some structure to Implement some framework/technology. IDEs have options to implement it for you to make your life easier.

To elaborate it in details I am giving some thorough details directly from Eclipse Documentations. This is Eclipse specific.

While creating a project you will get the option to implement facet for your project. For example, the EAR facet sets up a project to function as an enterprise application by adding a deployment descriptor and setting up the project's classpath.

To add another facet to a project that already exists, complete the following steps:

  1. In the Project Explorer view of the Java™ EE perspective, right-click the project and then select Properties.
  2. Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.
  3. Click Modify Project and select the check boxes next to the facets you want the project to have.

Note: Only the facets that are valid for the project are listed

Some facets may not work together. Thus, you can also choose a preset combination of facets from the Presets list.

  1. Choose a version number for the facet by clicking the current version number and selecting the version number you want from the drop-down list.
  2. Optional: To remove a facet, clear its check box. Not all facets can be removed.
  3. Optional: If you want to limit the project so it will be compatible with one or more runtimes, click on the Runtimes tab and select the runtimes that you want the project to be compatible with. For more information on runtimes, see Specifying target servers for J2EE projects.
  4. Click Finish to exit the Modify Faceted Project dialog and then click OK.

Facets also have version numbers in Eclipse. You can change the version numbers of facets as long as you stay within the requirements for the facets. To change the version of a facet in your project, complete the following steps:

  1. In the Project Explorer view of the Java EE perspective, right-click the project and then select Properties.
  2. Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.
  3. Click Modify Project and click the facet you want to change.
  4. Select the version of the facet from the drop-down box next to the facet's name.
  5. Click Finish to close the Modify Faceted Project window and then click OK.

You can do more things with the facets. I have given the examples for your better understanding. For details, please go through the documentation of your favorite IDE.


Facets is a web application framework that leverages a simple MVC architecture for the server side and a feature-packed Javascript component model for the client. The two pieces are designed to be seemlessly integrated for very dynamic AJAX-style apps

0

精彩评论

暂无评论...
验证码 换一张
取 消