{"id":1560,"date":"2016-09-07T14:11:52","date_gmt":"2016-09-07T14:11:52","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=1560"},"modified":"2019-02-25T05:21:05","modified_gmt":"2019-02-25T05:21:05","slug":"how-spring-works-internally","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/how-spring-works-internally\/","title":{"rendered":"How Spring works internally"},"content":{"rendered":"<ol>\n<li>The Way aspect function calls are made are through proxy classes internally <\/li>\n<li>Internally the Spring framework creates proxy classed and calls to the code generated as per the xml are run in proxy class methods before the actual class are called<\/li>\n<li>In the below example in <strong>DrawingApp.java<\/strong> I try to create a object for the class circle by invoking factoryService getBean Method<\/li>\n<li>This method returns a Object of class ShapeServiceProxy with the custom methods for xml code added <\/li>\n<\/ol>\n<p><strong>ShapeService.java<\/strong> <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.mugil.shapes;\r\n\r\npublic class ShapeService {\r\n\tprivate Circle objCircle;\r\n\tprivate Triangle objTriangle;\r\n\t\t\r\n\tpublic Circle getObjCircle() {\r\n\t\treturn objCircle;\r\n\t}\r\n\tpublic void setObjCircle(Circle objCircle) {\r\n\t\tthis.objCircle = objCircle;\r\n\t}\r\n\tpublic Triangle getObjTriangle() {\r\n\t\treturn objTriangle;\r\n\t}\r\n\tpublic void setObjTriangle(Triangle objTriangle) {\r\n\t\tthis.objTriangle = objTriangle;\r\n\t}\t\r\n}\r\n<\/pre>\n<p><strong>ShapeServiceProxy.java<\/strong> <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.mugil.shapes;\r\n\r\npublic class ShapeServiceProxy extends ShapeService {\r\n\t\r\n\tpublic Circle getObjCircle() {\r\n\t\tnew LoggingAspect().getLogMessage();\r\n\t\treturn super.getObjCircle();\r\n\t}\r\n}\r\n\r\n<\/pre>\n<p><strong>DrawingApp.java<\/strong> <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.mugil.shapes;\r\n\r\npublic class DrawingApp\r\n {\r\n\tpublic static void main(String&#x5B;] args) \r\n        {\r\n\t\tFactoryService objFactSer = new FactoryService();\r\n\t\tShapeService objSS = (ShapeService)objFactSer.getBean(&quot;ShapeService&quot;);\r\n\t\tobjSS.getObjCircle();\r\n\t}\r\n}\r\n\r\n<\/pre>\n<p><strong>FactoryService.java<\/strong> <\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.mugil.shapes;\r\n\r\npublic class FactoryService {\r\n\t\r\n\tpublic Object getBean(String className)\r\n\t{\r\n\t\tif(className.equals(&quot;Circle&quot;))\r\n\t\t\treturn new Circle();\r\n\t\telse if(className.equals(&quot;Triangle&quot;))\r\n\t\t\treturn new Triangle();\r\n\t\telse if(className.equals(&quot;DrawingApp&quot;))\r\n\t\t\treturn new DrawingApp();\r\n\t\telse if(className.equals(&quot;ShapeService&quot;))\r\n\t\t\treturn new ShapeServiceProxy();\r\n\t\t\t\r\n\t\treturn null;\r\n\t}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Way aspect function calls are made are through proxy classes internally Internally the Spring framework creates proxy classed and calls to the code generated as per the xml are run in proxy class methods before the actual class are called In the below example in DrawingApp.java I try to create a object for the&hellip; <a href=\"https:\/\/codethataint.com\/blog\/how-spring-works-internally\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[192],"tags":[253],"class_list":["post-1560","post","type-post","status-publish","format-standard","hentry","category-interview","tag-interview"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=1560"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1560\/revisions"}],"predecessor-version":[{"id":1561,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1560\/revisions\/1561"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=1560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=1560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=1560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}