<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohamed Elhamra on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Elhamra on Medium]]></description>
        <link>https://medium.com/@mohamed.elhamra?source=rss-77e00b07cbfb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Gb4WMhSmEgsavj604PJwcQ.png</url>
            <title>Stories by Mohamed Elhamra on Medium</title>
            <link>https://medium.com/@mohamed.elhamra?source=rss-77e00b07cbfb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:55:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamed.elhamra/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hibernate framework basics and architecture]]></title>
            <link>https://medium.com/@mohamed.elhamra/hibernate-framework-basics-and-architecture-fe2bea5911ae?source=rss-77e00b07cbfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe2bea5911ae</guid>
            <category><![CDATA[orm]]></category>
            <category><![CDATA[hibernate-jpa]]></category>
            <category><![CDATA[jpa]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[hibernate]]></category>
            <dc:creator><![CDATA[Mohamed Elhamra]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 17:32:48 GMT</pubDate>
            <atom:updated>2020-06-30T17:32:48.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H62ng5hMWk-UHNZQ.PNG" /></figure><h3>Introduction</h3><p>Hello everyone!! 😃😃<br>In this blog, I will talk about one of the most popular ORM frameworks in the Java ecosystem, which is Hibernate, but I will mainly focus on the architecture of this framework, the core components, and their functionalities.<br>So let’s get started.</p><blockquote><em>💡 ORM or object-relational mapping is the programming technique to map application domain model objects to the relational database tables.</em></blockquote><h3>What is JPA?</h3><p>Before talking about Hibernate, we need first to understand the <strong>JPA</strong>.<br><strong>JPA</strong> or <strong>Java Persistence API</strong> is a standard for mapping Java objects to relational databases, which means that each object is represented as a table in the database, in other words, the Java objects can outlive outside the Java application and the <strong>JPA</strong> specification lets you define which objects should be persisted, and how those objects should be persisted in your Java applications, as well as via the <strong>JPA</strong> the developer can map, store, update, and retrieve data from relational databases to Java objects and vice versa.</p><blockquote><em>💡 </em><strong><em>JPA</em></strong><em> specifications are defined with annotations in </em><em>javax.presistence package.</em></blockquote><p>Whereas we have some problems here because the <strong>JPA</strong> is just a specification, meaning there is no implementation. You can annotate your classes as much as you would like with <strong>JPA annotations</strong>, however, without implementation, nothing will happen.<br>We can think that <strong>JPA</strong> is an interface but in order to work with it, we need an implementation.</p><h3>JPA implementations (Hibernate)</h3><p>As you can see, in the section above we found out a problem which is the implementation of <strong>JPA</strong>, but don’t worry <strong>JPA</strong> has many implementations such as <strong>EclipseLink</strong>, <strong>Apache OpenJPA,</strong> and <strong>Hibernate framework</strong> which is the most popular.</p><p>So, from everything we’ve seen, we can define <strong>Hibernate</strong> as <strong>Java-based ORM tool</strong> that provides a framework for mapping application domain objects to the relational database tables and vice versa, moreover by Hibernate we can manipulate data from relational databases to Java objects without working with the <strong>SQL</strong> because Hibernate contains predefined methods for creating, updating, deleting, inserting objects from and to database tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SprabX-h9EWLSs4T.PNG" /></figure><h3>Hibernate architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*DhSa4jTRAk2HZ4am.PNG" /></figure><p>As you can see in the picture <strong>Hibernate</strong> holds several components. In this section, I will try to clarify each component and its role:</p><p><strong>Configuration object:</strong> org.hibernate.cfg.Configuration is a predefined class which holds configuration properties of <strong>Hibernate</strong>, it’s created first when creating the Hibernate application, it has two components:</p><ul><li>Database connection which provides the configuration for the connection.</li><li>The class mapping setup which creates the connection between the java class and the database.</li></ul><p><strong>SessionFactory object:</strong> It is instantiated by the Configuration Object, it’s a factory of Session and client of ConnectionProvider. It holds second-level cache (optional) of data.<br>The org.hibernate.SessionFactory interface provides factory methods to create objects of Session.</p><blockquote><em>👉 Note: We can have one </em><em>SessionFactory per database, so if we want to work with multiple databases, we need multiple </em><em>SessionFactory and for each SessionFactory a configuration file.</em></blockquote><p><strong>Session object:</strong> It is considered as an interface between the data stored in the database and the application. It is a short-lived object that wraps the <strong>JDBC connection</strong> also it’s a factory of Transaction, Query, and Criteria as well as the org.hibernate.Session interface provides methods to insert, update, and delete the objects. It holds the first-level cache (mandatory) of data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7IxnDaxXCcKOD9Z5.PNG" /></figure><p><strong>Transaction:</strong> The org.hibernate.Transaction interface provides methods for transaction management and handles the transaction works in the Hibernate framework.</p><p><strong>Query object:</strong> The org.hibernate.query.Query interface used to manipulate the persistent objects (creation, retrieving data …) using SQL or HQL.</p><blockquote><em>👉Note: HQL or Hibernate query language is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties.</em></blockquote><p><strong>Criteria object:</strong> org.hibernate.Criteria interface is also used to manipulate the persistent object but by executing the object-oriented criteria queries, meaning that this interface provides predefined methods to add criteria to a query.</p><h3>Hibernate benefits</h3><ul><li>Hibernate eliminates all the boiler-plate code that comes with JDBC.</li><li>Hibernate cache helps us in getting more performance.</li><li>Hibernate provides a powerful query language (HQL).</li><li>Easy integration of Hibernate.</li><li>Hibernate support lazy initialization using proxy objects.</li></ul><h3>Conclusion</h3><p>I know that there is a lot of to say and understand in Hibernate framework but I tried in this blog to give you just the most important points of this framework, I will try in the future blogs to focus more on details(implementations).<br>I hope you understand all the points that we have touched on, if you find this blog interesting don’t hesitate to share it with your friends. 😃😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe2bea5911ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring MVC architecture]]></title>
            <link>https://medium.com/@mohamed.elhamra/spring-mvc-architecture-89e598bb98be?source=rss-77e00b07cbfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/89e598bb98be</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-mvc]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[mvc-frameworks]]></category>
            <dc:creator><![CDATA[Mohamed Elhamra]]></dc:creator>
            <pubDate>Wed, 24 Jun 2020 13:08:19 GMT</pubDate>
            <atom:updated>2020-06-24T13:08:19.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gPQpG7bu6OLZd9xtJ57Fw.png" /></figure><h3>Introduction</h3><p>Hello everyone, in this article I will discuss the Spring web MVC, the components of this framework, their roles, the architecture as well as the request execution flow in Spring MVC application. So please enjoy reading!</p><h3>Spring MVC components</h3><p>The <strong>Spring Web MVC</strong> framework provides Model-View-Controller (MVC) architecture and a lot of ready components that can be used to develop Web applications. In this section, we will focus mainly on the components:</p><h3>1-Front controller</h3><p>The front controller is responsible to perform pre-processing and post-processing of incoming requests.<br>For example:</p><ul><li><strong>pre-processing request:</strong> capturing form data incoming from the client.</li><li><strong>post-processing request:</strong> returning data to the client.</li></ul><p>In Spring Web MVC based application we will use the DispatcherServlet as a front controller which is a pre-defined servlet provided by the Spring MVC module.</p><blockquote><em>💡Java Servlet are programs that act as a middle layer between a request coming from a Web browser or HTTP client, and applications on the HTTP server.</em></blockquote><h3>2.Handler mapper</h3><p>The handler mapper is a pre-defined class available in Spring MVC which is responsible to identify the request handler (controller) and return details to the DispatcherServlet.</p><h3>3.Controller</h3><p>A controller is a class which is responsible to handle the request, there are some pre-defined controllers available in the Spring MVC like below:</p><ul><li>org.springframework.web.servlet.mvc.SimpleFormController</li><li>org.springframework.web.servlet.mvc.AbstractFormController</li><li>org.springframework.web.servlet.mvc.multiaction.MultiActionController etc…</li></ul><p>Also, we can define our costume controllers using the @Controller annotation.</p><h3>4.Model and View</h3><p>Once the request processing is completed the controller will return the org.springframework.web.servlet.ModelAndView object to the DispatcherServlet.</p><p>The <strong>model</strong> holds data retrieved from the data source.<br>The <strong>view</strong> represents a logical view name.</p><h3>5.View resolvers</h3><p>In Spring MVC we have multiple view resolver classes that implement the interface org.springframework.web.servlet.ViewResolver :</p><ul><li>org.springframework.web.servlet.view.InternalResourceViewResolver</li><li>org.springframework.web.servlet.view.UrlBasedViewResolver etc…</li></ul><p>These view resolvers are responsible to identify view files (location and extension).</p><h3>6.View component</h3><p>Responsible to render model data on view files.</p><blockquote><em>💡 All the above-mentioned components (i.e. HandlerMapping, Controller, and ViewResolver) are parts of WebApplicationContext, which is an extension of the ApplicationContext with some extra features necessary for web applications.</em></blockquote><h3>Request execution flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/0*wLgCWiwX-t6eARC2.png" /></figure><p>The Spring Web MVC framework is designed around the DispatcherServlet.</p><p>🔍 What happens behind the scene when an HTTP request is sent to the server:</p><ol><li>Incoming Http request will be received by the Dispatcher servlet, which will send request URL to the HandlerMapper.</li><li>HandlerMapper will identify the appropriate request handler (controller) which is responsible to handle the request. After, the HandlerMapper will send handler request details to DispatcherServlet.</li><li>DispatcherServlet will call the respective Controller class method.</li><li>Controller method will process the request and will send ModelAndView object (Model→Data, View → Logical file name)to DispatcherServlet .</li><li>DispatcherServlet will send the view name to the ViewResolver.</li><li>ViewResolver will identify the view location &amp; extension and sends data to DispatcherServlet.</li><li>DispatcherServlet will give the model and view details to the view component.</li><li>View component will render the appropriate view which holds the data model.</li><li>DispatcherServlet will send back the response to the browser.</li></ol><h3>Summary</h3><p>That was all for this blog, I tried to clarify all the components of the <strong>Spring Web MVC</strong> and their roles as well as the request execution flow, I hope you enjoy it.<br>Don’t hesitate to share this blog whit your friends!!! 😄 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89e598bb98be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring dependency injection]]></title>
            <link>https://medium.com/@mohamed.elhamra/spring-dependency-injection-d4676390d314?source=rss-77e00b07cbfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4676390d314</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring]]></category>
            <dc:creator><![CDATA[Mohamed Elhamra]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 14:09:52 GMT</pubDate>
            <atom:updated>2020-06-16T14:09:52.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6ZIsPBUtpfgqvzn80Gsxg.png" /></figure><h3>What is DI?</h3><p>Hello audience, today I am going to discuss the spring dependency injection which is a design pattern used to implement the IoC in the <a href="https://www.mohamed-elhamra.me/posts/ioc-container-in-spring-framework/"><strong>Spring container</strong></a>.</p><p>Before talking about the implementation of this mechanism, I need first to define the dependency injection:</p><blockquote><em>In software engineering, </em><strong><em>dependency injection</em></strong><em> is a technique in which an object receives other objects that it depends on. These other objects are called dependencies.</em></blockquote><p>That’s the <a href="https://en.wikipedia.org/wiki/Dependency_injection"><strong>Wikipedia definition</strong></a>, I know that’s not enough to understand, but I will give you an example to illustrate more this mechanism.</p><p>Suppose we have two classes, Computer and AsusHardDisk, and the class Computer uses some functionality of the AsusHardDisk class, so we need to create an object of AsusHardDisk inside the Computer to make calls to these functionalities, now we can say that class Computer has a dependency on class AsusHardDisk.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6c0770be9aa07dd7020b1f5479eafb9/href">https://medium.com/media/b6c0770be9aa07dd7020b1f5479eafb9/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c77ac5eb714ce8630252e04199f2924/href">https://medium.com/media/7c77ac5eb714ce8630252e04199f2924/href</a></iframe><p>Imagine if the class Computer no longer needs the class AsusHardDisk and wants to use HpHardDisk.</p><p>Now, we are facing a problem because we will need to recreate the class Computer with the new hard disk.</p><p>But when using the <strong>dependency injection</strong> you no longer need to instantiate the dependencies inside your classes, instead, the <strong>DI</strong> does all the work for you.<br><strong>DI</strong> is considered as a middleman between a class that needs another, especially <strong>DI</strong> makes our class Computer independent from creating the HardDisk class.</p><p>In general, the <strong>IoC container</strong> lets you inject required objects in the runtime instead of the compile-time by the <strong>dependency injection</strong>, in order to make java classes independent of each other (loosely coupling) and frees them from object creation and maintenance.</p><p>Basically, in Spring there are two types of DI:</p><ul><li>Setter dependency injection.</li><li>Constructor dependency injection.</li></ul><h3>Types of Spring dependency injection</h3><h4>1. Setter dependency injection</h4><p>The dependencies will be injected with the help of the setters.<br><strong>Example:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e059d960c87f15f5cca6b8a1a3e5244a/href">https://medium.com/media/e059d960c87f15f5cca6b8a1a3e5244a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/882972c7c2eea9ffdfa6558668df4664/href">https://medium.com/media/882972c7c2eea9ffdfa6558668df4664/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0b5f434602e9dd605a5220be77252d1/href">https://medium.com/media/c0b5f434602e9dd605a5220be77252d1/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87ee9aec9516d34cf7782fc1a1884012/href">https://medium.com/media/87ee9aec9516d34cf7782fc1a1884012/href</a></iframe><p>If we compare the class Computer used in the first section and the one used in this section we can conclude that:</p><ul><li>The class Computer is no longer responsible for the instantiation of the dependencies.</li><li>The dependencies are created by the <strong>IoC container</strong> using <strong>DI</strong>.</li></ul><h4>2. Constructor dependency injection</h4><p>In this, the DI will be injected with the help of constructors.</p><p><strong>Example:</strong> Let us take the same example as of setter dependency injection but we will change just the configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcae1bd96e984dd637c04a503a545548/href">https://medium.com/media/dcae1bd96e984dd637c04a503a545548/href</a></iframe><blockquote><strong><em>Note:</em></strong><em> All the codes above are available via this link : </em><a href="https://github.com/mohamed-elhamra/DI-demo.git"><strong><em>DI Demo</em></strong></a></blockquote><p><strong>Process Flow:</strong> The process flow of bean instantiation and injection of dependencies is given in the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*7SICo9aWK04PMhgs.PNG" /></figure><h3>Summary</h3><p>As you can see, DI has many benefits such as:</p><ul><li>Helping in Unit testing.</li><li>Boilerplate code is reduced, as initializing of dependencies is done by the injector component.</li><li>Extending the application becomes easier.</li><li>It helps to enable loose coupling, which is important in application programming.</li></ul><p>That was all for this blog, I hope you enjoy it and you understood all the points that we have touched on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4676390d314" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IoC container in spring framework]]></title>
            <link>https://medium.com/@mohamed.elhamra/ioc-container-in-spring-framework-fd2d8b1e2ac6?source=rss-77e00b07cbfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd2d8b1e2ac6</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[ioc-container]]></category>
            <dc:creator><![CDATA[Mohamed Elhamra]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 17:45:24 GMT</pubDate>
            <atom:updated>2020-06-07T17:46:30.095Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I2QsO-Y9n_XsoV5ch_NYWA.png" /></figure><h3>Introduction</h3><p>Today we will talk about one of the most popular frameworks in the world which is Spring, but we will focus mainly on the IoC container of this framework. In the Spring framework, the IoC container is considered as the heart of the whole framework because it’s responsible for the creation of the object, wiring the object together, configuring these objects, and handling the entire life cycle of these objects from their creation until they are completely destroyed.<br>So in the next sections, we will clarify more how the container does all those works.</p><h3>Inversion of control (IoC)</h3><p>After diving into other principles or notion we need first to understand what the IoC stands for.<br>IoC or inversion of control is a principle in software engineering by which the control of the object is transferred from the programmer into the framework especially a container, in our case the IoC container.</p><p>To understand this more, we will illustrate this principle by this example:<br>Imagine you are a programmer, and you want to write a code to solve a problem, after diving into coding you make calls to a library to work with. However, by IoC, the flow is inverted because the inversion of control enables the framework to take control of the flow of a program and make calls to your code.</p><p>Some advantages of IoC:</p><ul><li>Greater modularity of the program</li><li>Easy testing of code</li></ul><p>Spring framework implements the inversion of control through different mechanisms such as:</p><ul><li>DI (dependency injection)</li><li>Service locator pattern</li><li>Strategy design pattern</li><li>Factory pattern</li></ul><blockquote><em>I will talk about these mechanisms in future blogs</em></blockquote><h3>How does the IoC container work?</h3><p>The Spring container doesn’t know how to instantiate our object alone so to make that we need to specify a configuration metadata to our container, this configuration can be specified through the XML file, Java code, Java annotations, then the spring container uses our POJO class as well as the configuration, and he can create the beans.</p><blockquote><strong><em>Bean</em></strong><em>: an object that is instantiated and managed by the Spring IoC container</em></blockquote><p>Below, the diagram that illustrates how the container works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/0*jKdQnAb9si4NINnL.PNG" /></figure><h3>Configuration of the IoC container</h3><p>Configuration metadata represent how you, as an application developer, tell the Spring container to instantiate, configure, assemble the objects in your application.</p><p>This configuration metadata is nothing but bean definition, as we mentioned above, the metadata can be represented as:</p><ul><li><strong>XML file</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/874d74469c455293377ac79077de456c/href">https://medium.com/media/874d74469c455293377ac79077de456c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/801bf35a27e255955a519303ead0d0f0/href">https://medium.com/media/801bf35a27e255955a519303ead0d0f0/href</a></iframe><p>In the example above, we tell the Spring container to create a Bean of the class HelloWorld and instantiate the field “message” with the value “Hello World”</p><ul><li><strong>JAVA code</strong></li></ul><p>Same things we will do but now with the java-based configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e08332752c45406df298a4b319e4aad/href">https://medium.com/media/0e08332752c45406df298a4b319e4aad/href</a></iframe><ul><li><strong>JAVA annotations</strong></li></ul><p>Starting from Spring 2.5 it became possible to configure our class using annotations. So instead of using the XML to describe the configuration, you can move the bean configuration to the class itself by using annotations(@Component, @Autowired…)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24e08f4eade73457bd4f7b3fed986649/href">https://medium.com/media/24e08f4eade73457bd4f7b3fed986649/href</a></iframe><h3>Type of containers in the spring framework</h3><p>There are two types of containers present in the Spring Framework.</p><h4>1. Spring BeanFactory Container:</h4><p>It is the simplest container present in the Spring framework which provides the basic support for DI (Dependency Injection). We use the following interface to work with this container.<br>org.springframework.beans.factory.BeanFactory</p><p>We will illustrate the implementation of this interface using the example above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a37ede0c6b1791f44bc8f5689ec9d637/href">https://medium.com/media/a37ede0c6b1791f44bc8f5689ec9d637/href</a></iframe><h4>2. Spring ApplicationContext Container:</h4><p>This is another container present in the spring container which adds extra enterprise-specific functionality. These functionalities include the capability to resolve textual messages from a properties file and publishing application events to the attentive event listeners. We use the following interface to work with this container.<br>org.springframework.context.ApplicationContext</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9433f098b6e683d9ab781ad488427db/href">https://medium.com/media/b9433f098b6e683d9ab781ad488427db/href</a></iframe><p>if we will run these two programs, the result will be the same for both implementations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*EKWyHMlsnkp_NG4-.PNG" /></figure><h4>4. BeanFactory vs ApplicationContext Container:</h4><p>The ApplicationContext container is the superset of the BeanFactory container. It means that all functionality of the BeanFactory container is present in the ApplicationContext container. Therefore, ApplicationContext container is often preferred over BeanFactory container. BeanFactory is often used to build lightweight applications such as mobile devices, applet-based applications, etc. where data volume as well as speed is important. Below are the most commonly used ApplicationContext implementations.</p><p>• FileSystemXmlApplicationContext – Here, we have to provide the full path of the XML bean configuration file to the constructor in order to load the metadata of the beans from an XML file.<br>• ClassPathXmlApplicationContext – Here, we need to set CLASSPATH of the bean configuration XML file in order to load the metadata of the beans from an XML file.<br>• WebXmlApplicationContext – Here, the container loads the XML file within a web application which has metadata of all beans.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*bOyrU6uOldtdUSdk.jpg" /></figure><h3>Conclusion</h3><p>That was all for this blog, I hope you enjoy it and you understood all the points that we have touched on, if you have questions don’t hesitate to ask me.<br>if you want to test the examples above, below, you will find my Github code link:<br><a href="https://github.com/mohamed-elhamra/IoC-container-in-Spring.git"><strong>IoC container Spring demo</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd2d8b1e2ac6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>