{"id":1895,"date":"2023-07-11T09:05:38","date_gmt":"2023-07-11T09:05:38","guid":{"rendered":"https:\/\/blog.amt.in\/?p=1895"},"modified":"2023-07-11T09:05:38","modified_gmt":"2023-07-11T09:05:38","slug":"insights-on-spring-framework","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2023\/07\/11\/insights-on-spring-framework\/","title":{"rendered":"Insights on Spring Framework"},"content":{"rendered":"<p>The\u00c2\u00a0Spring Framework\u00c2\u00a0is an\u00c2\u00a0application framework\u00c2\u00a0and\u00c2\u00a0inversion of control\u00c2\u00a0container\u00c2\u00a0for the\u00c2\u00a0Java platform. The framework&#8217;s core features can be used by any Java application, but there are extensions for building web applications on top of the\u00c2\u00a0Java EE\u00c2\u00a0(Enterprise Edition) platform. Although the framework does not impose any specific\u00c2\u00a0programming model, it has become popular in the Java community as an addition to the\u00c2\u00a0Enterprise JavaBeans\u00c2\u00a0(EJB) model. The Spring Framework is\u00c2\u00a0open source.<\/p>\n<p>The Spring Framework includes several modules that provide a range of services:<\/p>\n<ul>\n<li>Spring Core Container: this is the base module of Spring and provides spring containers (Bean Factory and Application Context).<\/li>\n<li>Aspect-oriented programming: enables implementing\u00c2\u00a0cross-cutting concerns.<\/li>\n<li>Authentication\u00c2\u00a0and\u00c2\u00a0authorization: configurable security processes that support a range of standards, protocols, tools and practices via the\u00c2\u00a0Spring Security\u00c2\u00a0sub-project (formerly Acegi Security System for Spring).<\/li>\n<li>Convention over configuration: a rapid application development solution for Spring-based enterprise applications is offered in the\u00c2\u00a0Spring Roo\u00c2\u00a0module<\/li>\n<li>Data access: working with\u00c2\u00a0relational database management systems\u00c2\u00a0on the Java platform using\u00c2\u00a0Java Database Connectivity\u00c2\u00a0(JDBC) and\u00c2\u00a0object-relational mapping\u00c2\u00a0tools and with\u00c2\u00a0NoSQL\u00c2\u00a0databases<\/li>\n<li>Inversion of control\u00c2\u00a0container: configuration of application components and lifecycle management of Java objects, done mainly via\u00c2\u00a0dependency injection<\/li>\n<li>Messaging: configurative registration of message listener objects for transparent message-consumption from\u00c2\u00a0message queues\u00c2\u00a0via\u00c2\u00a0Java Message Service\u00c2\u00a0(JMS), improvement of message sending over standard JMS APIs<\/li>\n<li>Model\u00e2\u20ac\u201cview\u00e2\u20ac\u201ccontroller: an\u00c2\u00a0HTTP- and\u00c2\u00a0servlet-based framework providing hooks for extension and customization for web applications and\u00c2\u00a0RESTful\u00c2\u00a0(representational state transfer) Web services.<\/li>\n<li>Remote access framework: configurative\u00c2\u00a0remote procedure call\u00c2\u00a0(RPC)-style\u00c2\u00a0marshalling\u00c2\u00a0of Java objects over networks supporting\u00c2\u00a0Java remote method invocation\u00c2\u00a0(RMI),\u00c2\u00a0CORBA\u00c2\u00a0(Common Object Request Broker Architecture) and\u00c2\u00a0HTTP-based protocols including\u00c2\u00a0Web services\u00c2\u00a0(SOAP (Simple Object Access Protocol))<\/li>\n<li>Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects<\/li>\n<li>Remote management: configurative exposure and management of Java objects for local or remote configuration via\u00c2\u00a0Java Management Extensions\u00c2\u00a0(JMX)<\/li>\n<li>Testing: support classes for writing unit tests and integration tests<\/li>\n<\/ul>\n<h3><span id=\"Inversion_of_control_container_(dependency_injection)\" class=\"mw-headline\">Inversion of control container (dependency injection)<\/span><\/h3>\n<p>Central to the Spring Framework is its\u00c2\u00a0inversion of control\u00c2\u00a0(IoC) container, which provides a consistent means of configuring and managing Java objects using\u00c2\u00a0reflection. The container is responsible for managing\u00c2\u00a0object lifecycles\u00c2\u00a0of specific objects: creating these objects, calling their initialization methods, and configuring these objects by wiring them together.<\/p>\n<p>Objects created by the container are also called managed objects or\u00c2\u00a0beans. The container can be configured by loading\u00c2\u00a0XML\u00c2\u00a0(Extensible Markup Language) files or detecting specific\u00c2\u00a0Java annotations\u00c2\u00a0on configuration classes. These data sources contain the bean definitions that provide the information required to create the beans.<\/p>\n<p>Objects can be obtained by means of either dependency lookup or dependency injection.\u00c2\u00a0Dependency lookup is a pattern where a caller asks the container object for an object with a specific name or of a specific type. Dependency injection is a pattern where the container passes objects by name to other objects, via either\u00c2\u00a0constructors,\u00c2\u00a0properties, or\u00c2\u00a0factory methods.<\/p>\n<p>In many cases one need not use the container when using other parts of the Spring Framework, although using it will likely make an application easier to configure and customize. The Spring container provides a consistent mechanism to configure applications and integrates with almost all Java environments, from small-scale applications to large enterprise applications.<\/p>\n<p>The container can be turned into a partially compliant\u00c2\u00a0EJB (Enterprise JavaBeans) 3.0\u00c2\u00a0container by means of the Pitchfork project. Some\u00c2\u00a0criticize the Spring Framework for not complying with standards.\u00c2\u00a0However, SpringSource doesn&#8217;t see EJB 3 compliance as a major goal, and claims that the Spring Framework and the container allow for more powerful programming models.\u00c2\u00a0The programmer does not directly create an object, but describe how they should be created, by defining it in the Spring configuration file. Similarly services and components are not called directly; instead a Spring configuration file defines which services and components must be called. This IoC is intended to increase the ease of maintenance and testing.<\/p>\n<h3><span id=\"Aspect-oriented_programming_framework\" class=\"mw-headline\">Aspect-oriented programming framework<\/span><\/h3>\n<p>The Spring Framework has its own\u00c2\u00a0Aspect-oriented programming\u00c2\u00a0(AOP) framework that modularizes cross-cutting concerns in\u00c2\u00a0aspects. The motivation for creating a separate AOP framework comes from the belief that it should be possible to provide basic AOP features without too much complexity in either design, implementation, or configuration. The Spring AOP framework also takes full advantage of the Spring container.<\/p>\n<p>The Spring AOP framework is\u00c2\u00a0proxy pattern-based, and is configured at\u00c2\u00a0run time. This removes the need for a compilation step or load-time weaving. On the other hand, interception only allows for public method-execution on existing objects at a\u00c2\u00a0join point.<\/p>\n<p>Compared to the\u00c2\u00a0AspectJ\u00c2\u00a0framework, Spring AOP is less powerful, but also less complicated. Spring 1.2 includes support to configure AspectJ aspects in the container. Spring 2.0 added more integration with AspectJ; for example, the\u00c2\u00a0pointcut\u00c2\u00a0language is reused and can be mixed with Spring AOP-based aspects. Further, Spring 2.0 added a Spring Aspects library that uses AspectJ to offer common Spring features such as declarative transaction management and dependency injection via AspectJ compile-time or load-time weaving.\u00c2\u00a0Spring Source\u00c2\u00a0also uses AspectJ AOP in other Spring projects such as Spring Roo and Spring Insight, with Spring Security also offering an AspectJ-based aspect library.<\/p>\n<p>Spring AOP has been designed to make it able to work with cross-cutting concerns inside the Spring Framework. Any object which is created and configured by the container can be enriched using Spring AOP.<\/p>\n<p>The Spring Framework uses Spring AOP internally for transaction management, security, remote access, and\u00c2\u00a0JMX.<\/p>\n<h3><span id=\"Data_access_framework\" class=\"mw-headline\">Data access framework<\/span><\/h3>\n<p>Spring&#8217;s data access framework addresses common difficulties developers face when working with databases in applications. Support is provided for all popular data access frameworks in Java: JDBC,\u00c2\u00a0iBatis\/MyBatis,\u00c2\u00a0Hibernate,\u00c2\u00a0Java Data Objects\u00c2\u00a0(JDO),\u00c2\u00a0Java Persistence API\u00c2\u00a0(JPA),\u00c2\u00a0Oracle TopLink,\u00c2\u00a0Apache OJB, and\u00c2\u00a0Apache Cayenne, among others.<\/p>\n<p>For all of these supported frameworks, Spring provides these features<\/p>\n<ul>\n<li>Resource management &#8211; automatically acquiring and releasing database resources<\/li>\n<li>Exception handling &#8211; translating data access related exception to a Spring data access hierarchy<\/li>\n<li>Transaction participation &#8211; transparent participation in ongoing transactions<\/li>\n<li>Resource unwrapping &#8211; retrieving database objects from connection pool wrappers<\/li>\n<li>Abstraction for\u00c2\u00a0binary large object\u00c2\u00a0(BLOB) and\u00c2\u00a0character large object\u00c2\u00a0(CLOB) handling<\/li>\n<\/ul>\n<p>All these features become available when using\u00c2\u00a0template classes\u00c2\u00a0provided by Spring for each supported framework. Critics have said these template classes are intrusive and offer no advantage over using (for example) the Hibernate API directly.\u00c2\u00a0In response, the Spring developers have made it possible to use the Hibernate and JPA APIs directly. This however requires transparent transaction management, as application code no longer assumes the responsibility to obtain and close database resources, and does not support exception translation.<\/p>\n<p>Together with Spring&#8217;s transaction management, its data access framework offers a flexible abstraction for working with data access frameworks. The Spring Framework doesn&#8217;t offer a common data access API; instead, the full power of the supported APIs is kept intact. The Spring Framework is the only framework available in Java that offers managed data access environments outside of an application server or container.<\/p>\n<p>The above is a brief about Spring Framework. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The\u00c2\u00a0Spring Framework\u00c2\u00a0is an\u00c2\u00a0application framework\u00c2\u00a0and\u00c2\u00a0inversion of<\/p>\n","protected":false},"author":1,"featured_media":1897,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[711,380,7,143],"tags":[713,381,18,145],"class_list":["post-1895","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-spring-framework","category-techtrends","category-web-applications","tag-java","tag-spring-framework","tag-technology","tag-web-applications"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=1895"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1895\/revisions"}],"predecessor-version":[{"id":1896,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/1895\/revisions\/1896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/1897"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=1895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=1895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=1895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}