<br />
<b>Warning</b>:  Declaration of PageLinesBanners::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/banners/section.php</b> on line <b>205</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesFeatures::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/features/section.php</b> on line <b>254</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesFeatures::section_head($clone_id) should be compatible with PageLinesSection::section_head() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/features/section.php</b> on line <b>61</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesHighlight::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/highlight/section.php</b> on line <b>94</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesCarousel::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/carousel/section.php</b> on line <b>168</b><br />
<br />
<b>Warning</b>:  Declaration of PLheroUnit::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/hero/section.php</b> on line <b>140</b><br />
<br />
<b>Warning</b>:  Declaration of PLNavBar::section_template($clone_id, $location = '') should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/navbar/section.php</b> on line <b>199</b><br />
<br />
<b>Warning</b>:  Declaration of PLMasthead::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/masthead/section.php</b> on line <b>178</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesQuickSlider::section_template($clone_id) should be compatible with PageLinesSection::section_template() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/quickslider/section.php</b> on line <b>59</b><br />
<br />
<b>Warning</b>:  Declaration of PageLinesQuickSlider::section_head($clone_id) should be compatible with PageLinesSection::section_head() in <b>/home/c0nannet/public_html/blog/wp-content/themes/pagelines/sections/quickslider/section.php</b> on line <b>29</b><br />
{"id":90,"date":"2012-10-20T12:42:06","date_gmt":"2012-10-20T12:42:06","guid":{"rendered":"http:\/\/c0nan.net\/blog\/?p=90"},"modified":"2012-10-29T13:13:08","modified_gmt":"2012-10-29T13:13:08","slug":"loading-classes-on-the-fly","status":"publish","type":"post","link":"https:\/\/c0nan.net\/blog\/loading-classes-on-the-fly\/","title":{"rendered":"Loading classes on the fly"},"content":{"rendered":"<p>Lets try and put this in perspective. for some or other reason, you or your has this dire need to hot swop classes in your Java EE solution, maybe because of some trivial reason, or maybe because you are a freaking genius and have this magic trick up your sleeve, either way you have to get it done.<\/p>\n<p>Lets start with a simple example:<\/p>\n<p>First, we get the foundation in place.<br \/>\nN.B The jar file needs to be included in the classpath<\/p>\n<p>MyPlugandPlayEngin.java<\/p>\n<pre>public interface MyPnPInterface{\r\n   \/\/ This interface only makes life easier when defining the scope and functionality of the dynamic class\r\n   String doStuff(Properties properties);\r\n}\r\n\r\npublic class MyPlugandPlayEngin{\r\n\r\n   public static main(String[] args){\r\n\r\n      \/\/If you want you can use a custom classloader here, else just use the default, supplied by the VM\r\n\r\n      URLClassLoader classLoader = null;\r\n      if (this.driverFilePaths != null){\r\n         classLoader = new URLClassLoader();\r\n      }\r\n\r\n      MyPnPInterface pnp = null;\r\n\r\n      try {\r\n         if (classLoader != null){\r\n            \/\/ Class.forName will return a Class object, so you can then just return instance and cast to the interface\r\n            pnp = (MyPnPInterface ) Class.forName(args[0], true, classLoader).newInstance();\r\n            DriverManager.registerDriver(driver);\r\n            classLoader.loadClass(this.className);\r\n         }else{\r\n            \/\/ Default classloader\r\n            Class clazz = Class.forName(args[0]);\r\n            pnp = (MyPnPInterface ) clazz.newInstance();\r\n         }\r\n\r\n         Properties properties = new Properties();\r\n         properties.setProperty(\"property1\", args[1]);\r\n\r\n         pnp.doStuff(properties);\r\n\r\n      }catch Exception e(){\r\n         e.printStacktrace;\r\n      }\r\n   }\r\n}<\/pre>\n<p>MyPnPClass.java<\/p>\n<pre>public class MyPnPClass implements MyPnPInterface{\r\n   String doStuff(Properties props);\r\n}<\/pre>\n<p>\nNow when you are working with many times you will need to dynamically generate<br \/>\nan instance of the generic type, there is a more simpler way to get this instance.<br \/>\n<\/p>\n<pre>public class myClass&lt;A as MyPnPInterface&gt;{\r\n\r\n   private Class&lt;a&gt; getAClass(){ \r\n   \/\/When you are working with generics, those generics as part of the class as an array of arguments Class\r\n      clazz = ((Class&lt;a&gt;)((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]);\r\n      return clazz; \r\n   } \r\n\r\n   private A getA(){ \r\n      return getAClass.newInstance(); \r\n   } \r\n}\r\n<\/pre>\n<p>How AWESOME is that? Now you can just instantiate the class with the generic<\/p>\n<pre>\r\n\r\npublic MyClass&lt;MyPnPInterface&gt; myClazz = new MyClass&lt;MyPnPClass&gt;();\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Lets try and put this in perspective. for some or other reason, you or your has this dire need to hot swop classes in your Java EE solution, maybe because of some trivial reason, or maybe because you are a freaking genius and have this magic trick up your sleeve, either way you have to [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/posts\/90"}],"collection":[{"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":23,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":150,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions\/150"}],"wp:attachment":[{"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c0nan.net\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}