tag:blogger.com,1999:blog-36281383956379405942024-03-12T18:56:39.092-07:00The F1 NotebookThis blog is supposed to keep track of all the small fixes, good tutorials and cheat-sheets I encounter in my binary life so I won't have to seek them on the web again.Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.comBlogger58125tag:blogger.com,1999:blog-3628138395637940594.post-34320898515996190232011-01-22T15:11:00.001-08:002011-01-22T15:11:58.984-08:00Installing TweetDeck on 64 bit ubuntu How-To guide<div xmlns='http://www.w3.org/1999/xhtml'><a href='http://ubuntuforums.org/showthread.php?t=1524398'>http://ubuntuforums.org/showthread.php?t=1524398</a></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-33824531718919640312011-01-20T06:26:00.001-08:002011-01-20T06:26:56.939-08:00Banshee "seek" function problem solved<div xmlns='http://www.w3.org/1999/xhtml'>Apparently my fav player has been refusing to let me use the 'seek' bar for some time now and I dodged looking for a solution too long now. After 2 minutes of research I found out that all I needed to do was to install the package <i>gstreamer0.10-plugins-ugly</i> and restart Banshee. Funny thing is I don't even remember uninstalling it in the first place (presuming that it was pre-installed).<br/>Anyway.... another bug fix in my F1 Notebook<br/></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-76964319851630953412011-01-15T14:16:00.003-08:002011-01-15T14:16:59.263-08:00Vim commands cheat sheet<div xmlns='http://www.w3.org/1999/xhtml'>full list available <a hrerf='http://www.tuxfiles.org/linuxhelp/vimcheat.html'>here</a></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-84443877194474431042011-01-09T12:26:00.001-08:002011-01-09T12:26:08.631-08:00New features Java EE 6.0<div xmlns='http://www.w3.org/1999/xhtml'>I found a nice article on this topic here: http://www.javabeat.net/articles/99-new-features-in-java-ee-60-1.html<br/></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-64077321981588715882011-01-06T09:23:00.001-08:002011-01-06T09:23:22.529-08:00Linux Subdirectories of Root directory [cheatsheet]<div xmlns='http://www.w3.org/1999/xhtml'><ul><li><b>/bin</b> - <i>Common programs, shared by the system, the system administrator and the users.</i><br/></li><li><b>/boot</b> - <i>The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.</i><br/></li><li><b>/dev</b> - <i>Contains references to all the CPU peripheral hardware, which are represented as files with special properties.</i><br/></li><li><b>/etc</b> - <i>Most important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows</i><br/></li><li><b>/home</b> - <i>Home directories of the common users.<br/></i></li><li><b>/initrd</b> - <i>(on some distributions) Information for booting. Do not remove!</i><br/></li><li><b>/lib</b> - <i>Library files, includes files for all kinds of programs needed by the system and the users.</i><br/></li><li><b>/lost+foun</b>d - <i>Every partition has a lost+found in its upper directory. Files that were saved during failures <br/>are here.</i><br/></li><li><b>/misc</b> - <i>For miscellaneous purposes.</i><br/></li><li><b>/mnt</b> - <i>Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.</i><br/></li><li><b>/ne</b>t - <i>Standard mount point for entire remote file systems</i><br/></li><li><b>/opt</b> - <i>Typically contains extra and third party software</i><br/></li><li><b>/proc</b> - <i>A virtual file system containing information about system resources. More information about the <br/>meaning of the files in proc is obtained by entering the command man proc in a terminal<br/>window. The file proc.txt discusses the virtual file system in detail.</i><br/></li><li><b>/root</b> - <i>The administrative user's home directory. Mind the difference between /, the root directory and<br/>/root, the home directory of the root user.</i><br/></li><li><b>/sbin</b> - <i>Programs for use by the system and the system administrator.</i><br/></li><li><b>/tmp</b> - <i>Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work</i>!<br/></li><li><b>/us</b>r - <i>Programs, libraries, documentation etc. for all user-related programs.</i><br/></li><li><b>/var</b> - <i>Storage for all variable files and temporary files created by users, such as log files, the mail<br/>queue, the print spooler area, space for temporary storage of files downloaded from the Internet,<br/>or to keep an image of a CD before burning it.<br/></i><br/></li></ul></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-78706520626811927172010-12-01T07:56:00.001-08:002010-12-01T07:56:04.310-08:00The Filter Pattern - Selective Iterators<div xmlns='http://www.w3.org/1999/xhtml'><code class=' aptureTMMSelection aptureTMMSelection'><span class='keyword'>The following code is from: http://www.erik-rasmussen.com/blog/2008/01/18/the-filter-pattern-java-conditional-abstraction-with-iterables/ <br/><br/><br/>import</span> java.util.Iterator;<br/><br /><span class='keyword'>import</span> java.util.NoSuchElementException;<br/> <br/><br /><span class='keyword'>public</span> <span class='keyword'>abstract</span> <span class='keyword'>class</span> Filter<T> {<br/><br /> <span class='keyword'>public</span> <span class='keyword'>abstract</span> <span class='keyword'>boolean</span> passes(T object);<br/> <br/><br /> <span class='keyword'>public</span> Iterator<T> filter(Iterator<T> iterator) {<br/><br /> <span class='keyword'>return</span> <span class='keyword'>new</span> FilterIterator(iterator);<br/><br /> }<br/> <br/><br /> <span class='keyword'>public</span> Iterable<T> filter(Iterable<T> iterable) {<br/><br /> <span class='keyword'>return</span> <span class='keyword'>new</span> Iterable<T>() {<br/><br /> <span class='keyword'>public</span> Iterator<T> iterator() {<br/><br /> <span class='keyword'>return</span> filter(iterable.iterator());<br/><br /> }<br/><br /> };<br/><br /> }<br/> <br/><br /> <span class='keyword'>private</span> <span class='keyword'>class</span> FilterIterator <span class='keyword'>implements</span> Iterator<T> {<br/><br /> <span class='keyword'>private</span> Iterator<T> <span class='member'>iterator</span>;<br/><br /> <span class='keyword'>private</span> T <span class='member'>next;</span><br/> <br/><br /> <span class='keyword'>private</span> FilterIterator(Iterator<T> iterator) {<br/><br /> <span class='keyword'>this</span>.iterator = iterator;<br/><br /> toNext();<br/><br /> }<br/> <br/><br /> <span class='keyword'>public</span> <span class='keyword'>boolean</span> hasNext() {<br/><br /> <span class='keyword'>return</span> <span class='member'>next</span> != <span class='keyword'>null</span>;<br/><br /> }<br/> <br/><br /> <span class='keyword'>public</span> T next() {<br/><br /> <span class='keyword'>if</span> (<span class='member'>next</span> == <span class='keyword'>null</span>)<br/><br /> <span class='keyword'>throw</span> <span class='keyword'>new</span> NoSuchElementException();<br/><br /> T returnValue = <span class='member'>next</span>;<br/><br /> toNext();<br/><br /> <span class='keyword'>return</span> returnValue;<br/><br /> }<br/> <br/><br /> <span class='keyword'>public</span> <span class='keyword'>void</span> remove() {<br/><br /> <span class='keyword'>throw</span> <span class='keyword'>new</span> UnsupportedOperationException();<br/><br /> }<br/> <br/><br /> <span class='keyword'>private</span> <span class='keyword'>void</span> toNext() {<br/><br /> <span class='member'>next</span> = <span class='keyword'>null</span>;<br/><br /> <span class='keyword'>while</span> (iterator.hasNext()) {<br/><br /> T item = iterator.next();<br/><br /> <span class='keyword'>if</span> (item != <span class='keyword'>null</span> && passes(item)) {<br/><br /> <span class='member'>next</span> = item;<br/><br /> <span class='keyword'>break</span>;<br/><br /> }<br/><br /> }<br/><br /> }<br/><br /> }<br/><br />}</code></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com1tag:blogger.com,1999:blog-3628138395637940594.post-21812613233066211022010-11-30T13:41:00.001-08:002010-11-30T13:41:38.544-08:00A little insight on Java's 'type erasure' terminology<div xmlns='http://www.w3.org/1999/xhtml'>As everyone knows, generics have been introduced since Java 1.5 to enforce compile-time type-correctness. However, at run-time, all the type safety is removed via a process called 'type erasure'. So all typed Collections will have their type removed from the bytecode at runtime and explicit casts will be introduced when extracting elements from the Collections. For example <i>List<Double> list = new ArrayList<Double>(); </i>will be translated at runtime to <i>List list = new ArrayList(); </i>. As a result of type erasure, type parameters cannot be determined at runtime. This change has been introduced in ordered to ensure pre-Java 5 code (you may call it 'legacy code') inter-operates peacefully with the newly introduced generics.<br/></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-53713587045124422412010-11-15T06:53:00.001-08:002010-11-15T06:53:40.583-08:00[Spring Framework] Constructor vs. Setter injection<div xmlns='http://www.w3.org/1999/xhtml'>Following are a number of paragraphs stripped from<i><b> "Spring in Action, 2nd Edition"</b></i> ,by Craig Walls, published by Manning Publications in 2007, which illustrate in a rather friendly manner the ups and downs when opting for a particular type of mutator: [This goes in my blog as a future reference]<br/><br/><i>"There are certain things that most people can agree upon: the fact that the sky<br/>is blue, that Michael Jordan is the greatest player to touch a basketball, and that<br/>Star Trek V should have never happened. And then there are those things that<br/>should never be discussed in polite company, such as politics, religion, and the<br/>eternal “tastes great/less filling” debates.<br/>Likewise, the choice between constructor injection and setter injection stirs up<br/>as much discourse as the arguments surrounding creamy versus crunchy peanut<br/>butter. Both have their merits and their weaknesses. Which should you choose?<br/><br/><b>Those on the constructor-injection side of the debate will tell you that:</b><br/>• Constructor injection enforces a strong dependency contract. In short, a<br/>bean cannot be instantiated without being given all of its dependencies. It is<br/>perfectly valid and ready to use upon instantiation. Of course, this assumes<br/>that the bean’s constructor has all of the bean’s dependencies in its param-<br/>eter list.<br/><br/>• Because all of the bean’s dependencies are set through its constructor,<br/>there’s no need for superfluous setter methods. This helps keep the lines of<br/>code at a minimum.<br/><br/>• By only allowing properties to be set through the constructor, you are, effec-<br/>tively, making those properties immutable, preventing accidental change in<br/>the course of application flow.<br/><br/><b>However, the setter injection-minded will be quick to respond with:</b><br/>• If a bean has several dependencies, the constructor’s parameter list can be<br/>quite lengthy.<br/><br/>• If there are several ways to construct a valid object, it can be hard to come<br/>up with unique constructors, since constructor signatures vary only by the<br/>number and type of parameters.<br/><br/>• If a constructor takes two or more parameters of the same type, it may be<br/>difficult to determine what each parameter’s purpose is.<br/><br/>• Constructor injection does not lend itself readily to inheritance. A bean’s con-<br/>structor will have to pass parameters to super() in order to set private<br/>properties in the parent object.<br/><br/>Fortunately, Spring doesn’t take sides in this debate and will let you choose the<br/>injection model that suits you best. In fact, you can even mix-and-match construc-<br/>tor and setter injection in the same application... or even in the same bean." </i><br/></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-42015839974181069112010-10-09T04:17:00.000-07:002010-10-09T04:18:31.716-07:00Simple Apache Lucene tutorial courtesy of "Java Code Geeks"http://www.javacodegeeks.com/2010/05/introduction-to-apache-lucene-for-full.htmlDr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-89362780568585218832010-09-16T00:46:00.001-07:002010-09-16T00:46:36.025-07:00Change the GRUB Menu Timeout on Ubuntu<div xmlns='http://www.w3.org/1999/xhtml'><p>When your Ubuntu system boots, you will see the GRUB menu if you hit the Esc key, or if you’ve enabled the menu to <a href='http://www.howtogeek.com/howto/ubuntu/show-the-grub-menu-by-default-on-ubuntu/'>show by default</a>.<br /> The only issue with this is that the default timeout is only 3 seconds.<br /> You may want to increase this amount… or you may even want to decrease <br />it. Either one is simple.</p><br /><p>Open up the /boot/grub/menu.lst file in your favorite text editor. I’m using gedit:</p><br /><blockquote><p>sudo gedit /boot/grub/menu.lst</p><br /></blockquote><br /><p>Now find the section that looks like this:</p><br /><blockquote><p>## timeout sec<br/># Set a timeout, in SEC seconds, before automatically booting the default entry<br/># (normally the first entry defined).<br/>timeout 3</p><br /></blockquote><br /><p>The timeout value is in seconds. Save the file, and when you reboot <br />you will have that many seconds to choose the menu item you want.</p></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-84671861620849016722010-09-16T00:29:00.001-07:002010-09-16T00:29:34.773-07:00show the GRUB menu by default on Ubuntu<div xmlns='http://www.w3.org/1999/xhtml'><p>When Ubuntu boots, you normally briefly see a screen that says “GRUB loading. please wait… Press Esc to enter the menu…”</p><br /><p>If you are hacking around your system and would prefer to always see <br />the GRUB menu (to enter command-line options, for instance), there’s an <br />easy fix.</p><br /><p>Open up the /boot/grub/menu.lst file in your favorite text editor. I’m using gedit:</p><br /><blockquote><p>sudo gedit /boot/grub/menu.lst</p><br /></blockquote><br /><p>Now find the section that looks like this:</p><br /><blockquote><p>## hiddenmenu<br/># Hides the menu by default (press ESC to see the menu)<br/>hiddenmenu</p><br /></blockquote><br /><p>Put a # before hiddenmenu to comment that line out:</p><br /><blockquote><p>## hiddenmenu<br/># Hides the menu by default (press ESC to see the menu)<br/>#hiddenmenu</p><br /></blockquote><br /><p>Save the file, and you should see the menu the next time you reboot.</p><p><br/></p><p>SOURCE: www.howtogeek.com<br/></p></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-4785510023692516652010-09-16T00:05:00.001-07:002010-09-16T00:05:57.976-07:00Adding windows XP to grub menu after intalling this OS AFTER Ubuntu<div xmlns='http://www.w3.org/1999/xhtml'>So your dual booting windows and you want windows to appear in the grub screen at startup. Here's how you do it:<br /><br/><br /><br/>As root: <br /><br/># nano /boot/grub/menu.lst<br /><br/><br /><br/>Add the following lines in wherever you would like the entry to show up:<br /><br/><br /><br/>title MS Windows XP<br /><br/>root (hd0,0) [note below]<br />*<br/>savedefault<br /><br/>makeactive<br /><br/>chainloader +1<br /><br/><br /><br/>*(hd0,0) means /dev/hda1<br /><br/>*(hd0,1) means /dev/hda2</div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-12665517595467973322010-07-07T01:15:00.000-07:002010-07-07T01:20:51.379-07:00SCDJWS 5, web service design patterns notes<div xmlns='http://www.w3.org/1999/xhtml'><h3 align='left' style='' id='sites-page-title-header'><br /><span dir='ltr' id='sites-page-title'>Web Service Design Patterns</span><br /></h3><br /><br /><br /><br /><div dir='ltr'><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>The<br />design patterns related to Web Service help to enhance<br />maintainability of the solution or to minimize QoS impact associated<br />with building applications using web service frameworks. Web Services<br />based interaction might be expensive because of </font><br /></p><br /><ul style='font-family: georgia,serif;'><li><font size='2' style='font-size: 11pt;'>operation<br /> is expensive in term of server-side processing</font></li><li><font size='2' style='font-size: 11pt;'>communication<br /> overhead (amount of data transfer/bandwidth)</font></li><li><font size='2' style='font-size: 11pt;'>encoding/decoding<br /> may be expensive</font></li></ul><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Application<br />designers should look for alternatives in this situation.</font></p><br /><h4 style='font-family: georgia,serif;'><a name='TOC-Asynchronous-Interaction-Pattern'/><font size='3'>Asynchronous Interaction Pattern</font></h4><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Goals<br />of this pattern are:</font></p><br /><ul style='font-family: georgia,serif;'><li><font size='2' style='font-size: 11pt;'>decouple<br /> input and output.</font></li><li><font size='2' style='font-size: 11pt;'>deliver<br /> output from server to client.</font></li><li><font size='2' style='font-size: 11pt;'>Associate<br /> output message with corresponding input message</font></li></ul><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>This<br />can be achieved with various application level designs to achieve the<br />above goals which are Server-side push, Client-side pull. JMS-based<br />and JAX-WS based which are described below.</font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><br /></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'><i><b>Server-side<br />push</b></i></font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Approach<br />1: Client supplies the address of a web service dedicated to<br />process specific response to the request, as part of request and the<br />server contacts the dedicated web service to reply to the query back<br />to the client.</font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Approach<br />2: Client supplies address of a generic web service that can be<br />invoked to supply the result of operation back to client, along with<br />unique token to identify this request, The server later invokes this<br />generic web service to deliver an answer to this client the server<br />uses the same token as part of response message to identify the<br />response to client. WS-Addressing defines a way to create these<br />tokens portably.</font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><br /></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'><i><b>Client-side<br />pull</b></i></font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Client<br />issues a request along with a unique token to server, the server<br />accepts the request, allowing client to continue processing. server<br />process each request to obtain response and stores all responses<br />indexed by tokens supplied by client in each request in a data<br />structure accessible as a new Response web service. Each client<br />queries the new web service for answer to earlier requests using the<br />same token. Enough storage required on server side to store all<br />response, until the client retrieves it. For reliability the storage<br />might need to be persistence. Increases network overhead as client<br />may poll periodically for it's response.</font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><br /></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'><i><b>JMS<br />based</b></i></font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Non-portable<br />web service solution, uses JMS as message transport instead of HTTP.<br />Both Client-side pull and Server-side push can be implemented using<br />JMS. In case of Client-side pull the client uses multiple requests<br />first being a JMS message and the subsequent ones being synchronous<br />and portable.</font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><br /></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'><i><b>JAX-WS<br />based</b></i></font></p><br /><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>JAX-WS<br />introduces Dispatch<T> and Provider<T> interfaces to<br />describe client and server side of the interaction. On client side it<br />introduced the ability to indicate whether the interaction is<br />synchronous or asynchronous, whether it's Client-side pull or<br />Server-side push or one way.</font></p><font size='2'>interface<br /> Dispatch<T>{ // client-side<br/></font> <br /> <font size='2'>T invoke(T<br /> msg);<br/></font> <br /> <font size='2'>Response<T><br /> invokeAsync(T msg);<br/></font> <br /> <font size='2'>Future<?><br /> invokeAsync(T msg, AsyncHandler<T> h);<br/></font> <br /> <font size='2'>void<br /> invikeOneWay(T msg);<br/></font><br /><font size='2'>}<br/></font><br /><font size='2'><br/></font><br /><font size='2'>interface<br /> Provider<T>{ // server-side<br/></font> <br /> <font size='2'>T invoke(T msg,<br /> Map<String, Object> context);<br/></font><font size='2'>}</font><p align='justify' style='margin-bottom: 0in; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Example</font></p><font size='2'>MessagingAPIMessage<br /> request = new MessagingAPIMessage( "sayHello", "Tracy"<br /> );<br/></font><br /><font size='2'>MessagingAPIMessage<br /> response = MessagingAPIMessage) port.invoke( request );<br/></font><br /><font size='2'>System.out.println("Response:<br /> " + response.getResult());<br/></font><br /><font size='2'>AsyncHandler<Object><br /> responseHandler = new AsyncHandler<Object>() {<br/> <br /> </font><font size='2'>public void<br /> handleResponse(Response<Object> resp){<br/> <br /> </font><font size='2'>try {<br/> <br /></font><font size='2'>MessagingAPIMessage<br /> result = (MessagingAPIMessage) response.get();<br/> <br /> </font><font size='2'>System.out.println(<br /> "Response: " + result.getResult() );<br/> <br /> </font><font size='2'>} catch(<br /> Exception e ) { <br /> </font><font size='2'>}<br/> <br /> </font><font size='2'>}<br/></font><font size='2'>};<br/></font><font size='2'>port.invokeAsync(<br /> request, responseHandler );</font><p style='margin-bottom: 0in; font-family: georgia,serif;'><br /></p><br /><font size='2' style='font-size: 11pt; font-family: georgia,serif;'><b>Advantages:<br /> </b>More responsive application, JAX-WS provides transparent<br />implementation</font><font size='2'><br style='font-family: georgia,serif;'/></font><font size='2' style='font-size: 11pt; font-family: georgia,serif;'><b>Disadvantages: </b>Other<br />than JAX-WS requires more complex designs</font><br /><h4 style='font-family: georgia,serif;'><a name='TOC-JMS-Bridge'/><font size='3'>JMS Bridge</font></h4><br /><p style='margin-bottom: 0in; font-weight: normal; font-family: georgia,serif;'><font size='2'>The<br />Characteristics of JMS Bridge pattern are as follow:</font></p><br /><ul style='font-family: georgia,serif;'><li><font size='2'>Keep<br /> different subsystems using their own JMS implementation</font></li><li><font size='2'>Introduce<br /> a client which can relay messages from one JMS implementation to<br /> next</font></li><li><font size='2' style='font-size: 11pt;'>the<br /> JMS clients should be implemented as Web Services</font></li></ul><br /><font size='2' style='font-family: georgia,serif;'><font style='font-size: 11pt;'><b>Advantages</b></font><font style='font-size: 11pt;'>:<br />No need to develop vendor specific to bridge two underlying<br />middle-ware vendor. It's vendor and JMS independent.</font></font><font size='2'><br style='font-family: georgia,serif;'/></font><font size='2' style='font-family: georgia,serif;'><font style='font-size: 11pt;'><b>Disadvantage</b></font><font style='font-size: 11pt;'>:<br /> Overhead XML encoding/transmission and decoding</font></font><br /><h4 style='font-family: georgia,serif;'><a name='TOC-Web-Service-Cache'/><font size='3'>Web Service Cache</font></h4><br /><p style='margin-bottom: 0in; font-weight: normal; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Cache<br />can be introduced at two places which will be transparent to client<br />(as Endpoint Handlers). The overhead is reduced by short-circuiting<br />requests that do not need to be executed.</font></p><br /><font size='2' style='font-family: georgia,serif;'><b>Advantages:<br /></b>Reduce communication and processing overhead</font><font size='2'><br style='font-family: georgia,serif;'/></font><font size='2' style='font-family: georgia,serif;'><font style='font-size: 11pt;'><b>Disadvantage:<br /></b></font><font style='font-size: 11pt;'>Increased memory<br />footprint, application must realize when to invalidate or refresh<br />cache.</font></font><br /><h4 style='font-family: georgia,serif;'><a name='TOC-Web-Service-Broker'/><font size='3'>Web Service Broker</font></h4><br /><p style='margin-bottom: 0in; font-weight: normal; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>Can<br />be used implement some services as Web Service and still address the<br />concerns that web services don't address like transaction<br />propagation. Web Service broker is introduced as a middle-man between<br />the client and the remote service in which the client is interested.<br />Can be implemented as a state-full session bean.</font></p><br /><font size='2' style='font-size: 11pt; font-family: georgia,serif;'><b>Advantage:<br /> </b>Simpler client design</font><font size='2'><br style='font-family: georgia,serif;'/></font><font size='2' style='font-size: 11pt; font-family: georgia,serif;'><b>Disadvantage:<br /> </b>Complex to implement (not guaranteed)</font><br /><h4 style='font-family: georgia,serif;'><a name='TOC-Web-Service-Logger'/><font size='3'>Web Service Logger</font></h4><br /><p style='margin-bottom: 0in; font-weight: normal; font-family: georgia,serif;'><font size='2' style='font-size: 11pt;'>A<br />common approach to introduce logging into the design of an<br />application involves the application of Decorator pattern as follows:</font></p><br /><ul style='font-family: georgia,serif;'><li><br /><font size='2' style='font-size: 11pt;'>An additional object is<br /> introduced as a wrapper around the actual service provider.</font></li><li><font size='2' style='font-size: 11pt;'>The logging functionality is<br /> captured in the wrapper.</font></li></ul><br /></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com1tag:blogger.com,1999:blog-3628138395637940594.post-29327938586136543292010-05-16T01:06:00.001-07:002010-05-16T03:18:20.862-07:00SQLalchemy tweak<div xmlns='http://www.w3.org/1999/xhtml'>If you've been ripping your hair off trying to figure out the "BoundMetaData is not defined" error in SQLAlchemy, the answer is to switch "BoundMetaData" with simply "MetaData", as the first one appears to have been deprecated. The Python code should look like this:<br/><br/><pre lang='python' line='1'>from sqlalchemy import *<br /><br />db = create_engine('sqlite:///MyDb.db')<br />metadata = MetaData(db)<br /><br /><br />Useful SQLAlchemy links:<br />http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html<br />http://www.sqlalchemy.org/docs/05/ormtutorial.html<br /></pre></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-57528472344441919192010-04-14T09:47:00.001-07:002010-04-14T09:47:36.826-07:00basic xml-rpc communication between a python server and c# client<div xmlns='http://www.w3.org/1999/xhtml'><b>Setting up the python server</b><br/><i><br/>import calendar, SimpleXMLRPCServer<br/><br/>#The server object<br/>class Calendar:<br/> def getMonth(self, year, month):<br/> return calendar.month(year, month)<br/><br/> def getYear(self, year):<br/> return calendar.calendar(year)<br/><br/><br/>calendar_object = Calendar()<br/>server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))<br/>server.register_instance(calendar_object)<br/><br/>#Go into the main listener loop<br/>print "Listening on port 8888"<br/>server.serve_forever()</i><br/><br/><br/><b>Setting up the C# client<br/></b><br/><i><b>1. Download the helping DLL's from http://xml-rpc.net/</b></i><br/><i><b>2. Create a proxy interface: </b></i><br/><br/><br/><i>using System;<br/>using CookComputing.XmlRpc;<br/><br/>namespace XMLRPCclient<br/>{<br/> <br/> [XmlRpcUrl("http://127.0.0.1:8888/")] <br/> public interface IClientCalendarProxy : IXmlRpcProxy<br/> {<br/> [XmlRpcMethod("getMonth")]<br/> string getMonth(int p1, int p2);<br/><br/> }<br/>}</i><br/><br/><br/><i><b>3. Init & run your client using the upper defined proxy interface (make sure the URL points to the port of the web service)</b></i> <br/><br/><i>using System;<br/>using CookComputing.XmlRpc;<br/><br/>namespace XMLRPCclient<br/>{<br/><br/> class MainClass<br/> {<br/> public static void Main(string[] args)<br/> {<br/> Console.WriteLine("Hello World!");<br/> <br/> <br/><br/> IClientCalendarProxy proxy = XmlRpcProxyGen.Create<IClientCalendarProxy>();<br/><br/><br/> string ret = proxy.getMonth(2002,8);<br/> Console.WriteLine(ret);<br/><br/> }<br/> }<br/>}<br/><br/><br/><br/></i><b>Useful links:</b><br/><ul><li>Start your exploration of XML-RPC on the <a href='http://www.xmlrpc.com/' linkindex='203'>official home page</a>. The <a href='http://www.xmlrpc.com/spec' linkindex='204'>specification</a> is also a very easy read.</li><li>For reference, use the official Python docs for the XML-RPC <a href='http://www.python.org/doc/current/lib/module-xmlrpclib.html' linkindex='205'>client</a> and <a href='http://www.python.org/doc/current/lib/module-SimpleXMLRPCServer.html' linkindex='206'>server</a> modules.</li><li>Browse <a href='http://xmlrpc.usefulinc.com/' linkindex='208'>Useful Information Company's XML-RPC page</a> for more sample <a href='http://xmlrpc.usefulinc.com/demo/introspect.php' linkindex='209'>XML-RPC services</a>.</li><li>If you plan to do significant work using the protocol, do read and bookmark Eric Kidd's <a href='http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto.html' linkindex='210'>XML-RPC HOWTO</a>.</li><li>Read <a href='http://www.ibm.com/developerworks/library/ws-xpc1/' linkindex='211'>Using XML-RPC for Web services: Getting started with XML-RPC in Perl</a>, by Joe Johnston for an introduction to XML-RPC, and the follow-up <a href='http://www.ibm.com/developerworks/webservices/library/ws-xpc2/' linkindex='212'>XML-RPC Middleware</a>.<br/></li></ul></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com1tag:blogger.com,1999:blog-3628138395637940594.post-74908945848765689102010-03-21T00:42:00.000-07:002010-03-21T00:43:00.340-07:00[windows] deleting winrar temporary data<div xmlns='http://www.w3.org/1999/xhtml'>If you've ever been in the situation where you have to unzip a large archive and you cancel the unzipping process midway, you will find that upon cancellation, the temporary winrar files will not be erased so you will find yourself losing 6,7 Gb of space just like that. To fix this, go to "Run" and type %temp% - this is the temporary folder on your computer, so just go on and delete all the unused stale data (such as winrar temporary files).<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=53bf6c82-19ba-811e-a899-fa8bddc3af18' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-52973689453385900232010-03-19T01:28:00.001-07:002010-03-19T01:28:16.290-07:00Many-To-Many self reference in Java Persistence API<div xmlns='http://www.w3.org/1999/xhtml'> Think of the following scenario: you need a many-to-many relationship between a table and itself... how can you accomplish that with JPA annotations ?<br/> Suppose we have a table Tasks in the database which is mapped to an Entity named Task. A task entry should have a list of parent tasks (prerequisite tasks if you want) and a list of child tasks (tasks which upon the current task's completion would enable them to start). The Task entity class would look a little something like this:<br/><br/>@Entity<br/>@Table (name = "Tasks" , schema = "ProjectManagement" )<br/>public class Task implements Serializable {<br/><br/>// Mandatory @Id PK field<br/><br/>//constructors (including a no-arg constructor)<br/><br/>//fields<br/><br/>// getters and setters<br/><br/><br/>@ManyToMany<br/>@JoinTable ( name = "parent_child_task" , <br/> joinColumns = @JoinColumn ( name = "child_id" , referencedColumnName = "id" ),<br/> inverseJoinColumns = @JoinColumn ( name = "parent_id" , referencedColumnName = "id" ))<br/>private List<Task> prerequisiteTasks = new ArrayList<Task>();<br/><br/>@ManyToMany (mappedBy = "prerequisiteTasks" ) <br/>private List<Task> childTasks = new ArrayList<Task>();<br/><br/>//.... more <br/><br/>}<br/><br/>Hope this makes sense<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=695b4edd-8fe2-8c42-bec7-98144735337e' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com1tag:blogger.com,1999:blog-3628138395637940594.post-78559671453174229582010-03-17T03:44:00.001-07:002010-03-17T03:44:44.145-07:00Operations allowed in EJB 3.0 session beans<div xmlns='http://www.w3.org/1999/xhtml'><ul><li>Operations Allowed in the Methods of a Stateful Session Bean</li></ul><img src='http://lh4.ggpht.com/_jwDQqXObxlk/S6CyH4VIz5I/AAAAAAAAAGA/5K6K7WmwSwA/%5BUNSET%5D.jpg?imgmax=800' style='max-width: 800px;'/><br/><img src='http://lh4.ggpht.com/_jwDQqXObxlk/S6CyPF1DYrI/AAAAAAAAAGE/3uW-SiUDx0Q/%5BUNSET%5D.jpg?imgmax=800' style='max-width: 800px;'/><br/><br/><br/><br/><br/><ul><li>Operations Allowed in the Methods of a Stateless Session Bean</li></ul><img src='http://lh3.ggpht.com/_jwDQqXObxlk/S6CybMCOxvI/AAAAAAAAAGI/9mrCOEk9Dmk/%5BUNSET%5D.jpg?imgmax=800' style='max-width: 800px;'/><br/><br/><img src='http://lh4.ggpht.com/_jwDQqXObxlk/S6CyeEizh2I/AAAAAAAAAGM/TQbIhuTIPRI/%5BUNSET%5D.jpg?imgmax=800' style='max-width: 800px;'/><br/><br/><br/>SOURCE: EJB 3.0 specification<br/><br/><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=20a70918-2096-8c61-8761-d4804b99869d' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-85962000037558992332010-03-16T01:40:00.001-07:002010-03-16T01:40:18.515-07:00Bulk Update and Delete Operations in EJB 3.0 JPQL<div xmlns='http://www.w3.org/1999/xhtml'>Bulk update and delete operations apply to entities of a single entity class (together with its subclasses, if any). Only one entity abstract schema type may be specified in the FROM or UPDATE clause.<br/><br/>The syntax of these operations is as follows:<br/>update_statement ::= update_clause [where_clause]<br/>update_clause ::= UPDATE abstract_schema_name [[AS] identification_variable]<br/> SET update_item {, update_item}*<br/>update_item ::= [identification_variable.]{state_field | single_valued_association_field} =<br/> new_value<br/>new_value ::=<br/> simple_arithmetic_expression |<br/> string_primary |<br/> datetime_primary |<br/> boolean_primary |<br/> enum_primary<br/> simple_entity_expression |<br/> NULL<br/>delete_statement ::= delete_clause [where_clause]<br/>delete_clause ::= DELETE FROM abstract_schema_name [[AS] identification_variable]<br/><br/><ul><li>A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities.</li><li>The new_value specified for an update operation must be compatible in type with the state-field to which it is assigned.</li><li>Bulk update maps directly to a database update operation, bypassing optimistic locking checks. Portable applications must manually update the value of the version column, if desired, and/or manually validate the value of the version column.</li><li>The persistence context is not synchronized with the result of the bulk update or delete.</li></ul><br/><i>Caution should be used when executing bulk update or delete operations because they may result in<br/>inconsistencies between the database and the entities in the active persistence context. In general, bulk update and delete operations should only be performed within a separate transaction or at the beginning of a transaction (before entities have been accessed whose state might be affected by such operations)</i>.<br/><br/>SOURCE: EJB 3.0 Persistence Specification, pages 104-105<br/><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=80a18585-b500-8094-bc0b-e2425e121c1c' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-33611927506309750262010-03-06T00:13:00.001-08:002010-03-06T00:13:43.748-08:00Installing XAMPP on 64 bit Ubuntu<div xmlns='http://www.w3.org/1999/xhtml'>Installing and securing XAMPP:<br/>http://www.codetorment.com/2009/10/20/guide-install-xampp-on-ubuntu/<br/><br/>Basic installing:<br/>http://sadhas.wordpress.com/2009/10/01/install-xampp-in-ubuntu/<br/><br/>Similar topic:<br/>http://azimyasin.wordpress.com/2007/11/13/running-xampp-in-64-bit-machine/<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=dc02a24f-5e03-8b12-9c63-d1d83fd79eae' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-70909837588109010512010-03-05T01:29:00.001-08:002010-03-05T01:30:19.201-08:00How to configure Primary Key Generation in EJB 3 JPA<div xmlns='http://www.w3.org/1999/xhtml'><h2>Introduction</h2> <p>TopLink may create entity identifiers (or primary keys) automatically using any of the following strategies defined by JPA:</p> <ul><li>Sequence objects </li><li>Identity Columns </li><li>Tables </li><li>Provider-assigned strategy </li></ul> Usually, these generation strategies are configured locally to the primary key field or property. <h2><a name='sequence'>Using Sequence Objects</a></h2><a name='sequence'> </a><p><a name='sequence'>When using a database that supports sequence objects (such as Oracle Database), you can configure JPA to use a database sequence object to automatically generate identifiers for your persistent objects. </a></p><a name='sequence'> </a><h3><a name='sequence'>Using A Default Sequence</a></h3><a name='sequence'> </a><p><a name='sequence'>TopLink JPA can produce a default sequence during schema generation. If you use schema generation, then specify that your identifier should be generated and that the <code>SEQUENCE</code> strategy be used to perform the generation. In the following example, the <code>@GeneratedValue</code> annotation indicates that the identifier value should be automatically generated; a strategy of <code>SEQUENCE</code> indicates that a database sequence should be used to generate the identifier. TopLink will create a default sequence object during schema generation. This object will be used by TopLink at run time. </a></p><a name='sequence'> </a><blockquote><a name='sequence'> </a><p class='code'><a name='sequence'> @Entity<br/> public class Inventory implements Serializable {<br/> <br/> @Id<br/> @GeneratedValue(strategy=GenerationType.SEQUENCE)<br/> private long id;</a></p><a name='sequence'> </a></blockquote><a name='sequence'> </a><h3><a name='sequence'>Specifying a Sequence </a></h3><a name='sequence'> </a><p><a name='sequence'>To use a specific named sequence object, whether it is generated by schema generation or already exists in the database, you must define a sequence generator using a <code>@SequenceGenerator</code> annotation. You may choose any unique label as the <code>name</code> for the sequence generator. Reference this name by the <code>generator</code> element in the <code>@GeneratedValue</code> annotation. Also, include the <code>sequenceName</code> element to specify the name of the database sequence object that you are using.</a></p><a name='sequence'> </a><p><a name='sequence'>If the sequence object already exists in the database, then you must specify the <code>allocationSize</code> to match the <code>INCREMENT</code> value of the database sequence object. For example, if you have a sequence object that you defined to <code>INCREMENT BY 5</code>, set the <code>allocationSize</code> to 5 in the sequence generator definition, as the following example shows:</a></p><a name='sequence'> </a><blockquote><a name='sequence'> </a><p class='code'><a name='sequence'> @Entity<br/> public class Inventory implements Serializable {<br/> <br/> @Id<br/> @GeneratedValue(generator="InvSeq")<br/> @SequenceGenerator(name="InvSeq",sequenceName="INV_SEQ", allocationSize=5)<br/> private long id;</a></p><a name='sequence'> </a></blockquote><a name='sequence'> </a><h2><a name='identity'>Using Identity Columns</a></h2><a name='identity'> </a><p><a name='identity'>When using a database that does not support sequences, but does support identity columns (such as SQL Server database), you can configure JPA to use an identity column to generate identifiers.</a></p><a name='identity'> </a><p><a name='identity'>To enable generation of identifiers using identity columns, specify a strategy of <code>IDENTITY</code>. In the following example, the <code>@GeneratedValue</code> annotation indicates that the identifier value should be automatically generated, and the specified strategy of <code>IDENTITY</code> indicates that an identity column should be used to generate the identifier:</a></p><a name='identity'> </a><blockquote><a name='identity'> </a><p class='code'><a name='identity'> @Entity<br/> public class Inventory implements Serializable {<br/> <br/> @Id<br/> @GeneratedValue(strategy=GenerationType.IDENTITY)<br/> private long id;</a></p><a name='identity'> </a></blockquote><a name='identity'> </a><h2><a name='table'>Using a Table</a></h2><a name='table'> </a><p><a name='table'>You can use a table for identifier generation on any database. It is completely portable across databases and will be automatically generated for you when schema generation is enabled. </a></p><a name='table'> </a><h3><a name='table'>Using A Default Table</a></h3><a name='table'> </a><p><a name='table'>During schema generation, TopLink JPA can generate a default table for identifier generation. If you use schema generation, then specify a strategy of <code>TABLE</code> in the <code>@GeneratedValue</code> annotation, as the following example demonstrates. TopLink will create a default table during schema generation. This table will be used by TopLink at run time:</a></p><a name='table'> </a><blockquote><a name='table'> </a><p class='code'><a name='table'> @Entity<br/> public class Inventory implements Serializable {<br/> <br/> @Id<br/> @GeneratedValue(strategy=GenerationType.TABLE)<br/> private long id;</a></p><a name='table'> </a></blockquote><a name='table'> </a><h3><a name='table'>Specifying a Table </a></h3><a name='table'> </a><p><a name='table'>To map to an existing table or cause the table object generated by schema generation to be given a particular name, define a table generator using a <code>@TableGenerator</code> annotation. </a></p><a name='table'> </a><p><a name='table'>The table generator has a name, by which it is referenced in the <code>@GeneratedValue</code> annotation. The generator also lists the name of the specific database table, as well as the names of the key and value columns used to store identifier generators in the table. Each row in the table represents the generator for a particular entity type, with the value in the key column indicating the entity type. The generator for <code>Inventory</code> instances might have a key of <code>INV_GEN</code>, as the following example shows:</a></p><a name='table'> </a><blockquote><a name='table'> </a><p class='code'><a name='table'> @Entity<br/> public class Inventory implements Serializable {<br/> <br/> @Id<br/> @GeneratedValue(generator="InvTab")<br/> @TableGenerator(name="InvTab", table="ID_GEN",<br/> pkColumnName="ID_NAME", valueColumnName="ID_VAL", <br/> pkColumnValue="INV_GEN")<br/> private long id;</a></p><a name='table'> </a></blockquote><a name='table'> </a><p><a name='table'>The table generator defined in the preceding example would be mapped to the following table:</a></p><a name='table'> </a><p><a name='table'> ID_GEN</a></p><a name='table'> </a><blockquote><a name='table'> </a><table width='300' cellspacing='2' cellpadding='2' border='1'> <tbody> <tr> <th width='100'>ID_NAME</th> <th width='200'>ID_VAL</th> </tr> <tr> <td> <div align='center'>INV_GEN</div></td> <td> <div align='center'><last value='' generated=''/></div></td> </tr> </tbody> </table><a name='table'> </a></blockquote><a name='table'> <br/><br/></a><h2><a name='generation'>Using a Default Generation Strategy</a></h2><a name='generation'> </a><p><a name='generation'>By specifying a strategy of <code>AUTO</code> you are indicating your intention to let TopLink pick the strategy to use. Typically, TopLink picks <code>TABLE</code> as the strategy, since it is the most portable strategy available (it does not lock you into a particular database). However, when <code>AUTO</code> is specified, schema generation must be used at least once in order for the default table to be created in the database.</a></p><a name='generation'> </a><p><a name='generation'>The following example demonstrates the use of the <code>AUTO</code> strategy:</a></p><a name='generation'> </a><blockquote><a name='generation'> </a><p class='code'><a name='generation'>@Entity<br/> public class Inventory implements Serializable {<br/><br/> @Id<br/> @GeneratedValue(strategy=GenerationType.AUTO)<br/> private long id;</a></p><a name='generation'> </a></blockquote><a name='generation'> </a><h2><a name='summary'>Summary</a></h2><a name='summary'> The minimum configuration you can use to cause the automatic generation of identifiers is to add a <code>@GeneratedValue</code> annotation to the identifier field or property. If you are using a specific named database sequence or table, you need to define the generator in the metadata with <code>@SequenceGenerator</code> or <code>@TableGenerator</code> annotations. </a><p><a name='summary'>The generation strategy that you choose to generate entity identifiers may depend on the database, on which you application is running: for instance, <code>SEQUENCE</code> and <code>IDENTITY</code> strategies are not supported on all databases.</a></p><a name='summary'><br/>SOURCE: http://www.oracle.com/technology/products/ias/toplink/jpa/howto/id-generation.html <br/></a><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=b0dc4529-c6ab-8561-a840-a0ac93553097' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com1tag:blogger.com,1999:blog-3628138395637940594.post-89042003515197671632010-03-02T08:59:00.001-08:002010-03-02T08:59:14.754-08:00JPA Inheritance mapping strategies<div xmlns='http://www.w3.org/1999/xhtml'>The mapping of class hierarchies is specified through metadata.<br/>There are three basic strategies that are used when mapping a class or class hierarchy to a relational<br/>database:<br/><ul><li>a single table per class hierarchy</li><li>a table per concrete entity class</li><li>a strategy in which fields that are specific to a subclass are mapped to a separate table than the</li><li> fields that are common to the parent class, and a join is performed to instantiate the subclass.</li></ul> An implementation is required to support the single table per class hierarchy inheritance mapping strat-egy and the joined subclass strategy. Support for the table per concrete class inheritance mapping strategy is optional in this release.<br/> Support for the combination of inheritance strategies within a single entity inheritance hierarchy is not required by this specification.<br/><br/><b>2.1.10.1 Single Table per Class Hierarchy Strategy</b><br/> In this strategy, all the classes in a hierarchy are mapped to a single table. The table has a column that serves as a “discriminator column”, that is, a column whose value identifies the specific subclass to which the instance that is represented by the row belongs.<br/> This mapping strategy provides good support for polymorphic relationships between entities and for queries that range over the class hierarchy. It has the drawback, however, that it requires that the columns that correspond to state specific to the subclasses be nullable.<br/><br/><b>2.1.10.2 Table per Concrete Class Strategy</b><br/> In this mapping strategy, each class is mapped to a separate table. All properties of the class, including inherited properties, are mapped to columns of the table for the class.<br/> This strategy has the following drawbacks:<br/> • It provides poor support for polymorphic relationships.<br/> • It typically requires that SQL UNION queries (or a separate SQL query per subclass) be issued for queries that are intended to range over the class hierarchy.<br/><b><br/>2.1.10.3 Joined Subclass Strategy</b><br/> In the joined subclass strategy, the root of the class hierarchy is represented by a single table. Each subclass is represented by a separate table that contains those fields that are specific to the subclass (not inherited from its superclass), as well as the column(s) that represent its primary key. The primary key column(s) of the subclass table serves as a foreign key to the primary key of the superclass table. This strategy provides support for polymorphic relationships between entities.<br/> It has the drawback that it requires that one or more join operations be performed to instantiate instances of a subclass. In deep class hierarchies, this may lead to unacceptable performance. Queries that range over the class hierarchy likewise require joins.<br/><br/><br/>SOURCE: EJB 3.0 JPA Specification<br/><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=d92b2620-ab23-8442-85a0-6cfe0c860c9f' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-64650170152675363732010-02-08T23:14:00.001-08:002010-02-08T23:14:22.259-08:00JBoss security model<div xmlns='http://www.w3.org/1999/xhtml'><img src='http://lh4.ggpht.com/_jwDQqXObxlk/S3ELRelNx1I/AAAAAAAAAF4/3cN4_vH0MU8/%5BUNSET%5D.jpg?imgmax=800' style='max-width: 800px;'/><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=12b331ed-fcb2-832b-b8d1-83c56277237c' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-14692159971067610342010-01-25T10:39:00.001-08:002010-01-25T10:39:20.731-08:00JNDI InitialContext reminder<div xmlns='http://www.w3.org/1999/xhtml'>When building J2EE apps which require JNDI lookup, make sure what type of clients are instantiating the InitialContext object: should it be a container-managed class (i.e. servlet, JSF bean,etc), all you need to do is write: <br/>try {<br/> Context ctx = new InitialContext();<br/> IHelloRemote hello = (IHelloRemote) ctx.lookup("AnotherOne/HelloBean/remote");<br/> hello.sayHello();<br/> } catch (NamingException e) {<br/> e.printStackTrace();<br/> }<br/><br/>But should it be just a regular POJO (btw, you CAN'T use dependency injection in EJB3 POJOs) you have to set some properties which otherwise are set by default by the J2EE app server (at least when I tried it with JBoss it worked just fine):<br/><br/>try{ <br/>Properties properties = new Properties(); <br/> properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); <br/> properties.put("java.naming.provider.url","jnp://localhost:1099"); <br/> properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); <br/> <br/> Context context = new InitialContext(properties);<br/> IHelloRemote hello = (IHelloRemote) ctx.lookup("AnotherOne/HelloBean/remote");<br/> hello.sayHello();<br/> } catch (NamingException e) {<br/> e.printStackTrace();<br/> }<br/><br/><i><br/><br/>Go Spring-Framework yourself...</i><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=35e9e77d-6290-880d-91db-7f2190d35aa9' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0tag:blogger.com,1999:blog-3628138395637940594.post-22675136068903616342010-01-24T10:25:00.001-08:002010-01-24T10:25:01.889-08:00Configuring JMS destinations in Jboss 5<div xmlns='http://www.w3.org/1999/xhtml'>http://javabeanz.wordpress.com/2009/06/05/configuring-jms-in-jboss-5/ <br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=45b99da0-4d8b-8841-abba-cffc6266677a' alt='' class='zemanta-pixie-img'/></div></div>Dr@goshttp://www.blogger.com/profile/02375230288266950250noreply@blogger.com0