<?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: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-3531473547795543952</id><updated>2011-08-24T07:57:23.036-07:00</updated><title type='text'>Programming</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3531473547795543952.post-6586311811564766256</id><published>2010-10-20T07:58:00.000-07:00</published><updated>2010-10-20T08:09:15.633-07:00</updated><title type='text'>Java signal handler implementation</title><content type='html'>Here is a Java signal handler implementation. The signal will be handled even though Thread.sleep is running.

&lt;div style="overflow: auto; line-height: 1em;"&gt;
&lt;pre&gt;&lt;span style="font-size:-1;"&gt;import sun.misc.Signal;
import sun.misc.SignalHandler;

public class Test
{
   public static void main(String[] args)
   {
       SignalHandler signalHandler = new SignalHandler() {
           public void handle(Signal signal) {
               System.err.println("Exiting because of signal: " + signal);
               System.exit(1);
           }
       });
       Signal.handle(new Signal("TERM"), signalHandler);
       Signal.handle(new Signal("INT"), signalHandler);

       try {
           Thread.sleep(50000);
       }
       catch (InterruptedException e) {
           System.err.println("Interrupted");
       }
   }
}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3531473547795543952-6586311811564766256?l=robi-prog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/6586311811564766256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3531473547795543952&amp;postID=6586311811564766256' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/6586311811564766256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/6586311811564766256'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/2010/10/java-signal-handler-implementation.html' title='Java signal handler implementation'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3531473547795543952.post-2315466225240999769</id><published>2010-06-29T14:08:00.000-07:00</published><updated>2011-08-23T12:45:53.838-07:00</updated><title type='text'>Java Comparable and equals() implementation</title><content type='html'>It is strongly recommended (though not required) that the natural ordering of a class (compareTo() method) be consistent with the equals() method (see &lt;a HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html"&gt;java.lang.Comparable&lt;/A&gt;).  The best way to keep them consistent, is to implement the equals() method as a call to the compareTo() method. This will increase the maintainability of the code: if any new fields are added to the class in the future, they will only have to be added to the compareTo() method, the equals() method will not have to be changed.  When calling compareTo() from equals(), we need to be careful, because e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.  &lt;div style="overflow:auto; line-height: 1em;"&gt;&lt;pre&gt;&lt;font size="-1"&gt;public class ComparableExample implements Comparable&amp;lt;ComparableExample&amp;gt;
{
    private int number;
    private boolean bool;
    private String str;
    private Object obj;
    
    @Override
    public boolean equals(Object o)
    {
        if (null == o) { return false; }
        if (this == o) { return true; }
        if ( ! (o instanceof ComparableExample) ) { return false; }

        return 0 == compareTo((ComparableExample)o);
    }

    public int compareTo(ComparableExample that)
    {
        final int BEFORE = -1;
        final int EQUAL  = 0;
        final int AFTER  = 1;

        if (null == that) { throw new NullPointerException(getClass().getSimpleName() + ".compareTo() called with a null parameter"); }
        if (this == that) { return EQUAL; }

        int result = EQUAL;
        if (EQUAL == result) { result = (this.number &lt; that.number ? BEFORE : (this.number &gt; that.number ? AFTER : EQUAL)); }
        if (EQUAL == result) { result = (this.bool ? (that.bool ? EQUAL : AFTER) : (that.bool ? BEFORE : EQUAL)); }
        if (EQUAL == result) { result = (null == this.str ? (null == that.str ? EQUAL : BEFORE) : this.str.compareTo(that.str)); }
        if (EQUAL == result) { result = (null == this.obj ? (null == that.obj ? EQUAL : BEFORE) : this.obj.compareTo(that.obj)); }
        return result;
    }
}&lt;/font&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3531473547795543952-2315466225240999769?l=robi-prog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/2315466225240999769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3531473547795543952&amp;postID=2315466225240999769' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/2315466225240999769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/2315466225240999769'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/2010/06/java-equals-and-compareto-method.html' title='Java Comparable and equals() implementation'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3531473547795543952.post-7075848300368705332</id><published>2009-01-12T16:20:00.001-08:00</published><updated>2009-01-12T16:21:07.185-08:00</updated><title type='text'>Why Singletons Are Controversial</title><content type='html'>I found a good article about why Singletons should not be used:

&lt;A HREF="http://code.google.com/p/google-singleton-detector/wiki/WhySingletonsAreControversial"&gt;Why Singletons Are Controversial&lt;/A&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3531473547795543952-7075848300368705332?l=robi-prog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/7075848300368705332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3531473547795543952&amp;postID=7075848300368705332' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/7075848300368705332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/7075848300368705332'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/2009/01/why-singletons-are-controversial.html' title='Why Singletons Are Controversial'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3531473547795543952.post-3670308679881451367</id><published>2008-06-27T09:26:00.000-07:00</published><updated>2010-06-30T06:46:41.336-07:00</updated><title type='text'>jBoss deployment error message</title><content type='html'>When you deploy, jBoss automatically checks the structural integrity and Specification compliance of the JAR file. If this check fails, the JAR has &lt;i&gt;not&lt;/i&gt; been deployed. The error messages are relatively helpful; for example:
&lt;div style="overflow:auto; line-height: 1em;"&gt;
&lt;pre&gt;&lt;font size="-1"&gt;Bean   : SomeEJB
Method : public abstract returnType methodName(parameters)
         throws RemoteException,...
Section: 7.10.5
Warning: The methods defined in the remote interface must
         have a matching method in the bean's class with
         the same name and same number and types of
         arguments.
&lt;/font&gt;&lt;/pre&gt;&lt;/div&gt;
   Not only has jBoss detected a violation of the EJB Specification, it has indicated which section of the Specification to look at (7.10.5 in this case). If you see messages like this, you need to correct the code.

However, jBoss doesn't say what is the exact difference between the remote interface (usually called SomeService.java) and the bean definition (usually called SomeBean.java). Check all of the following: the method name, the type of its parameters, the list of exceptions it throws and its scope. Here is how it should be usually:
&lt;br/&gt;
&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" target="_blank" href="http://4.bp.blogspot.com/_Ff06eLn4Kqc/SGUeYFjoJdI/AAAAAAAAANs/ucinciKzzqE/s1600-h/jBoss.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_Ff06eLn4Kqc/SGUeYFjoJdI/AAAAAAAAANs/ucinciKzzqE/s400/jBoss.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5216609142535890386" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3531473547795543952-3670308679881451367?l=robi-prog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/3670308679881451367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3531473547795543952&amp;postID=3670308679881451367' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/3670308679881451367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/3670308679881451367'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/2008/06/jboss-deployment-error-message.html' title='jBoss deployment error message'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Ff06eLn4Kqc/SGUeYFjoJdI/AAAAAAAAANs/ucinciKzzqE/s72-c/jBoss.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3531473547795543952.post-3345630745976698060</id><published>2008-01-03T10:36:00.000-08:00</published><updated>2010-06-30T06:47:12.048-07:00</updated><title type='text'>C++ operator&lt; implementation</title><content type='html'>&lt;div style="overflow:auto; line-height: 1em;"&gt;
&lt;pre&gt;&lt;font size="-1"&gt;class Foo
{
  int         a;
  float       b;
  std::string c;

  /* ... */

  bool operator&lt;(const Foo&amp;amp; foo) const
  {
     if (a != foo.a) return a &amp;lt; foo.a;
     if (b != foo.b) return b &amp;lt; foo.b;
     if (c != foo.c) return c &amp;lt; foo.c;
     return false;
  }
}&lt;/font&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3531473547795543952-3345630745976698060?l=robi-prog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robi-prog.blogspot.com/feeds/3345630745976698060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3531473547795543952&amp;postID=3345630745976698060' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/3345630745976698060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3531473547795543952/posts/default/3345630745976698060'/><link rel='alternate' type='text/html' href='http://robi-prog.blogspot.com/2008/01/c-operator-implementation.html' title='C++ operator&lt; implementation'/><author><name>Robi</name><uri>http://www.blogger.com/profile/16435838865749316772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_Ff06eLn4Kqc/R30pPQokBNI/AAAAAAAAAFU/Uw9sNeJkFBM/S220/Igazolvany3.jpg'/></author><thr:total>0</thr:total></entry></feed>
