Beginning Spring. Höller Jürgen
Чтение книги онлайн.

Читать онлайн книгу Beginning Spring - Höller Jürgen страница 9

Название: Beginning Spring

Автор: Höller Jürgen

Издательство: Автор

Жанр: Зарубежная образовательная литература

Серия:

isbn: 9781118893111

isbn:

СКАЧАТЬ are obtained by calling other bean definition methods, and those obtained dependencies are injected into the bean. Java-based configuration metadata was introduced with Spring 3.0.

      In a big project, it's a good idea to divide configuration metadata into several different files so that it can be managed easily and can be managed by different developers at the same time. This division usually reflects the layers of the application. You create a separate bean definition file or class for each layer in the application, and you also create some additional bean definition files or classes for other container-specific configuration tasks as well. Therefore, for a typical web application project that's developed using Spring, it is very common to see bean definition files or classes similar to these:

      • Beans that operate in the web/presentation layer of the application are defined in the beans-web.xml file or ConfigurationForWeb class.

      • Beans that operate in the service/business layer of the application are defined in the beans-service.xml file or the ConfigurationForService class.

      • Beans that operate in the data access layer of the application are defined in the beans-dao.xml file or the ConfigurationForDao class.

      • Beans that are necessary for several container-specific features to be activated are defined in the beans-config.xml file or the ConigurationForConfig class.

      • Beans that are used for security requirements of the application are defined in the beans-security.xml file or the ConfigurationForSecurity class.

      Your application doesn't have to have this exact collection of files. The number and granularity of configuration metadata files varies according to the architecture and specific requirements of the target application. However, the files in this list are a good starting point, and you can always add new ones and divide existing ones according to your needs.

      Configuring and Using the Container

      The Spring Container is also a Java object, which is created in the application at some specific point and then allowed to manage the rest of the application. You can instantiate the Spring Container in basically two different ways. In standalone applications, you use the programmatic approach. In web applications, on the other hand, the declarative approach is preferable with the help of some configuration within the web.xml file.

The following Try It Out shows how the Spring Container can be created and used in a standalone environment using Java-based configuration. We try to employ a simple form of layered architecture by defining beans corresponding to each layer illustrated in the Figure 2.2:

FIGURE 2.2

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

iVBORw0KGgoAAAANSUhEUgAABAEAAAHMCAYAAACkzbHVAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAE2uSURBVHhe7d0LdqsqFADQjiazcTgZTybUOeWCnwQQ0DTpbVr3Xsv3bqMiHEjKQdt+XAEAAIBDsAgAAAAAB2ERAAAAAA7CIgAAAAAchEUAAAAAOAiLAAAAAHAQFgEAAADgICwCAAAAwEFYBAAAAICDsAgAAAAAB2ERAAAAAA7CIgAAAAAchEUAAAAAOAiLAAAAAHAQFgEAAADgICwCAAAAwEFYBAAAAICDsAgAAAAAB2ERAAAAAA7CIgAAAAAchEUAAAAAOAiLAAAAAHAQFgEAAADgICwCAAAAwEFY
СКАЧАТЬ