Skip to main content

Posts

Showing posts from October, 2013

StartExplorer Eclipse Plug-in

http://basti1302.github.io/startexplorer/

In resource views like the Navigator or Package Explorer you can select files and folders. StartExplorer offers the following options here:
Show in file managerStart shell hereOpen files with default applicationCopy resource path to clipboardCustom Commands All options work with a single selected resource as well as with multiple resources. If multiple resources are selected and an option only works for files (or only for folders) all resources of the wrong type are ignored and the command is executed for the resources it is applicable for. Show in file manager: (Works for files and folders) Starts a file manager (depending on your system, this might be the Windows Explorer, Finder on Mac OS, Nautilus on Gnome, Konqueror on KDE, Thunar on Xfce or PCMan File Manager on LXDE) for the selected resource. If it is a folder, the file manager is opened for this folder. If it is a file, the file manager is opened for the parent folder of this file. On so…

Reloading class using spring-loaded Jar

As a  java developer using eclipse, every time, when we made the change on the class, annotation or the xml files, eclipse will pop up a message let us decide ‘continue, restart  tomcat and more’. I am kind of appreciate its kindness. However,  most of the time, I have to select ‘restart’. So, I just wish eclipse  or tomcat can help to reload class files and don’t bother me that option.
Before, I found jRebel which is perfect for my wishing. It is just hard to push management team pay for that  $365 per license annually. http://zeroturnaround.com/software/jrebel/
So, I need to cater myself and the one I can afford which is $0 a year, and it’s using Apache License.
How to config? #1  download jar  from https://github.com/spring-projects/spring-loaded
#2 in your eclipse, adding below arguments in the VM arguments. You need to amend the path to the jar file in your machine.
-Djavaagent:C:/Dev/lib/springloaded-1.1.2.20130430.jar –noverify
#3 Ready to go

Configure the transaction in Springframework 2 style

<!--  base Interceptor with most of configuration for transaction            -->
  <bean id="abstractTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true" abstract="true">
    <property name="transactionManager"><ref bean="slapdTransactionManager"/></property>
    <property name="optimize"><value>true</value></property>
    <property name="transactionAttributes">
      <props>
        <prop key="persist*">PROPAGATION_REQUIRED, -Exception</prop>
        <prop key="find*">readOnly</prop>
        <prop key="get*">readOnly</prop>
        <prop key="*">PROPAGATION_REQUIRED, -Exception</prop>
      </props>
    </property>
  </bean>

  <bean id="realBean" class=&q…

Annotation Inheritance in Java

Annotation Inheritance
It is important to understand the rules relating to inheritance of annotations, as these have a bearing on join point matching based on the presence or absence of annotations. 

By default annotations are not inherited. Given the following program 

@MyAnnotation
class Super {
@Oneway public void foo() {}
}

class Sub extends Super {
public void foo() {}
}

Then Sub does not have the MyAnnotation annotation, and Sub.foo() is not an @Oneway method, despite the fact that it overrides Super.foo() which is. 

If an annotation type has the meta-annotation @Inherited then an annotation of that type on a class will cause the annotation to be inherited by sub-classes. So, in the example above, if the MyAnnotation type had the @Inherited attribute, then Sub would have the MyAnnotation annotation. 

@Inherited annotations are not inherited when used to annotate anything other than a type. A type that implements one or more interfaces never inherits any annotations from the interfaces it im…

Oracle's DECODE function

Oracle's decode function can be used to create arbitrary ORDER BY clauses. This is useful if you are providing lists with the most frequently picked value at the top - e.g. a list of countries which starts with 'United States' and then turns into a conventional alphabetical listing. Your SELECT statement will have two things in the ORDER BY clause - first it sorts by a DECODE that turns your favoured value into '1' and all other values into '2' and then it sorts the rest of the list conventionally. The alternatives to using DECODE are to hard code the entire list (bad!) or add a numeric column to the underlying table that defines the sort order, which is a lot more work than a DECODE in an ORDER BY.SQL> r1 select country_name2 from iso_countries3* order by decode(country_name,'UNITED STATES',1,2) , country_nameCOUNTRY_NAME--------------------------------------------------UNITED STATESAFGHANISTANALBANIAALGERIAAMERICAN SAMOAANDORRAANGOLAANGUILL…