<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5316823764132757458</id><updated>2026-02-04T01:40:01.903-08:00</updated><category term="ADF"/><category term="PrimeFaces"/><category term="VORow"/><category term="View"/><category term="View Object"/><category term="View Row"/><category term="bordspellen"/><category term="eclipse startup ObjectNotFoundException"/><category term="editor"/><category term="gezelschapsspellen"/><category term="ikwileenspel.be"/><category term="inplace"/><category term="kaartspellen"/><category term="seam 3"/><category term="startup annotation"/><category term="validation"/><category term="validationException"/><category term="weld"/><title type='text'>Fortega IT Solutions</title><subtitle type='html'>This is the blog of bla</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.fortega.be/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5316823764132757458.post-7045008050278470955</id><published>2014-03-20T05:43:00.003-07:00</published><updated>2014-03-20T05:52:14.751-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ADF"/><category scheme="http://www.blogger.com/atom/ns#" term="validation"/><category scheme="http://www.blogger.com/atom/ns#" term="validationException"/><category scheme="http://www.blogger.com/atom/ns#" term="View"/><category scheme="http://www.blogger.com/atom/ns#" term="View Object"/><category scheme="http://www.blogger.com/atom/ns#" term="View Row"/><category scheme="http://www.blogger.com/atom/ns#" term="VORow"/><title type='text'>ADF - Throwing a validation exception from a view row object</title><content type='html'>In ADF, you can easily add method validators on Entity level. However, sometimes this is not enough. If your validation logic is complex (for instance: if you need all other rows to validate against, for some kind of special uniqueness constraint), this is not enough.&lt;br /&gt;
&lt;br /&gt;
You can throw a general exception from the setter of your attribute in the view object, but that is not enough, because this will look different (no &#39;red&#39; field, and a different style of exception on the screen).&lt;br /&gt;
&lt;br /&gt;
To solve this, you will need to throw an &#39;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;AttrValException&lt;/span&gt;&#39;, as shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;General method in the view row base class.&lt;/span&gt;&lt;br /&gt;
&lt;br/&gt;
&lt;div style=&quot;border:1px solid gray; margin-top:5px; padding:5px;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;Final static String RESOURCE_BUNDLE_NAME = &quot;my_resource_bundle&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;protected void throwValidationException(String message, String attrName) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; PropertiesBundleDef resBundle = new PropertiesBundleDef(this.getViewDef());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; resBundle.setPropertiesFile(RESOURCEBUNDLE_NAME);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; throw new AttrValException(MetaObjectBase.TYP_VIEW_OBJECT, resBundle, message, getViewObject().getFullName(), attrName);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;
Setter of view row object:&lt;br /&gt;
&lt;br/&gt;
&lt;div style=&quot;border:1px solid gray; margin-top:5px; padding:5px;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;public void setMyCode(String value){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; if(/* your validation logic */){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;throwValidationException(&quot;myCodeValidationErrorMsgKey&quot;, &quot;MyCode&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; setAttributeInternal(MY_CODE, value);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.fortega.be/feeds/7045008050278470955/comments/default' title='Reacties posten'/><link rel='replies' type='text/html' href='http://blog.fortega.be/2014/03/adf-throwing-validation-exception-from.html#comment-form' title='0 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/7045008050278470955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/7045008050278470955'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/2014/03/adf-throwing-validation-exception-from.html' title='ADF - Throwing a validation exception from a view row object'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316823764132757458.post-3584758298842179522</id><published>2013-01-03T06:00:00.000-08:00</published><updated>2013-01-03T06:01:06.952-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bordspellen"/><category scheme="http://www.blogger.com/atom/ns#" term="gezelschapsspellen"/><category scheme="http://www.blogger.com/atom/ns#" term="ikwileenspel.be"/><category scheme="http://www.blogger.com/atom/ns#" term="kaartspellen"/><title type='text'>ikwileenspel.be</title><content type='html'>De beste gezelschapsspellen voor de beste prijs: &lt;a href=&quot;http://www.ikwileenspel.be/&quot;&gt;www.ikwileenspel.be&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Vanaf nu verkopen we dus bord- en kaartspellen. Neem maar eens een kijkje op onze website :-)</content><link rel='replies' type='application/atom+xml' href='http://blog.fortega.be/feeds/3584758298842179522/comments/default' title='Reacties posten'/><link rel='replies' type='text/html' href='http://blog.fortega.be/2013/01/ikwileenspelbe.html#comment-form' title='0 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/3584758298842179522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/3584758298842179522'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/2013/01/ikwileenspelbe.html' title='ikwileenspel.be'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316823764132757458.post-5429250117448811313</id><published>2011-06-27T06:33:00.000-07:00</published><updated>2011-06-27T06:33:31.167-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse startup ObjectNotFoundException"/><title type='text'>Eclipse startup - eclipse.core.internal.dtree.ObjectNotFoundException</title><content type='html'>After killing the eclipse process and restarting my pc, Eclipse was not able to startup anymore.&lt;br /&gt;
&lt;br /&gt;
In my log file (workspace_dir\.metadata\.log), I saw following exception:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/code&gt;org.eclipse.core.internal.dtree.ObjectNotFoundException: Tree element &#39;mypckg/myClass.class&#39; not found.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.AbstractDataTree.handleNotFound(AbstractDataTree.java:257)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DeltaDataTree.getData(DeltaDataTree.java:585)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:50)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:47)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:47)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:47)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:47)&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;After some research I tried to delete the workspace_dir\.metadata\.plugins\org.eclipse.core.resources\.snap file, which solved the problem. Don&#39;t ask me why. You can tell me why if you know :-)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.fortega.be/feeds/5429250117448811313/comments/default' title='Reacties posten'/><link rel='replies' type='text/html' href='http://blog.fortega.be/2011/06/eclipse-startup-eclipsecoreinternaldtre.html#comment-form' title='2 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/5429250117448811313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/5429250117448811313'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/2011/06/eclipse-startup-eclipsecoreinternaldtre.html' title='Eclipse startup - eclipse.core.internal.dtree.ObjectNotFoundException'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316823764132757458.post-5633417479532590305</id><published>2011-05-09T12:32:00.000-07:00</published><updated>2011-05-09T12:40:40.817-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="editor"/><category scheme="http://www.blogger.com/atom/ns#" term="inplace"/><category scheme="http://www.blogger.com/atom/ns#" term="PrimeFaces"/><title type='text'>PrimeFaces inplace wrapped around editor</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot;&gt;In Primefaces, there is a &amp;lt;p:inplace&amp;gt; component, which is a nice component to use for inline editing,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;and a &amp;lt;p:editor&amp;gt;, which is an input component with rich text formatting capabilities.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;But the two didn&#39;t really match. If one uses a &amp;lt;p:inplace&amp;gt; wrapped around a &amp;lt;p:editor&amp;gt;, the editor does not work as it is supposed to. The problem is that the editor is not designed to work in a container which is initially hidden. And that&#39;s just the behavior you depend on when you want to use an inplace component.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;However, with this little trick, you can use an inplace component wrapped around an editor. The editor has a &#39;lazy&#39; property. If you set this to true, you can initialize the editor at the moment it is shown:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &amp;lt;h:form id=&quot;formWithInplace&quot;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p:inplace id=&quot;inplaceid&quot;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p:editor value=&quot;#{editorBean.value}&quot; saveListener=&quot;#{editorBean.save}&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;lazy=&quot;true&quot; widgetVar=&quot;editorWidget&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/p:inplace&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;code&gt;&amp;nbsp; &amp;lt;/h:form&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;So now we have an inplace wrapped around a lazy editor. The only thing we have to do now, is initialize the editor when the inplace is clicked (and the editor is shown). As the inplace does not have an &#39;onclick&#39; parameter, we will use jQuery and the id of the inplace component:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; jQuery(PrimeFaces.escapeClientId(&#39;formWithInplace:inplaceid&#39;)).click(&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(){&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; editorWidget.init();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia,serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.fortega.be/feeds/5633417479532590305/comments/default' title='Reacties posten'/><link rel='replies' type='text/html' href='http://blog.fortega.be/2011/05/primefaces-inplace-editor.html#comment-form' title='0 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/5633417479532590305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/5633417479532590305'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/2011/05/primefaces-inplace-editor.html' title='PrimeFaces inplace wrapped around editor'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316823764132757458.post-290487175907439008</id><published>2011-04-15T11:24:00.001-07:00</published><updated>2011-05-09T03:34:26.137-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="seam 3"/><category scheme="http://www.blogger.com/atom/ns#" term="startup annotation"/><category scheme="http://www.blogger.com/atom/ns#" term="weld"/><title type='text'>Seam 3 / Weld alternative for @Startup annotation</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot;&gt;In Seam 2, if you wanted a seam component to be initialized when the application was started up, you could use the @Startup annotation.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;In Seam 3 (or better: weld), this annotation is not supported. If you want a bean to be started up when the application starts up, you could write a method which observes an event:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;public class BeanToBeInitializedAtStartup {&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;    p&lt;/span&gt;ublic void onStartup(@Observes @Initialized WebApplication webApplication){&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;//do nothing, bean will be initialized when application is started&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;However, this means you will need such a method for every bean, which is a lot more of overhead than the simple @Startup annotation.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;A solution for this is to use a simple helper class, which initializes all beans which implement some interface you define yourself:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;First, you will need an interface. This interface does not require any methods.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;public interface Startup { &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Next, all of the beans you want to be initialized should implement this interface&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;public class BeanToBeInitializedAtStartup implements Startup { }&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;That looks a lot better! Now of course you need some helper class, which initializes all beans which implement the Startup annotation:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #555555;&quot;&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;public class BeanStartupHelper {&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void onStartup(@Observes @Initialized WebApplication webApplication,&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BeanManager beanManager) {&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;          &lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;for(Bean bean : beanManager.getBeans(Startup.class)){&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; CreationalContext context = beanManager.createCreationalContext(bean);&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; beanManager.getReference(bean, Startup.class, context);&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;times new roman&#39;; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;}&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;The BeanStartupHelper is actually also a bean, and as you can see, this bean contains a method which observes the initialization of the webapplication. A reference to the BeanManager object is injected as a parameter of this method. We use the BeanManager object to create the beans we need, which are all beans which implement the Startup annotation.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Result&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;There is a clear separation between the beans themselves and the implementation of the startup method. The only thing needed for your beans is the fact that they need to implement a Startup interface. You only need one method which observes the initialization of your application, in which all &#39;startup&#39; beans will be initialized!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia,serif; font-size: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.fortega.be/feeds/290487175907439008/comments/default' title='Reacties posten'/><link rel='replies' type='text/html' href='http://blog.fortega.be/2011/04/seam-3-weld-alternative-for-startup.html#comment-form' title='5 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/290487175907439008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316823764132757458/posts/default/290487175907439008'/><link rel='alternate' type='text/html' href='http://blog.fortega.be/2011/04/seam-3-weld-alternative-for-startup.html' title='Seam 3 / Weld alternative for @Startup annotation'/><author><name>Bart Lamberigts</name><uri>http://www.blogger.com/profile/05705541002076545077</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry></feed>