Archive | November 2012

add spring roo addon to support soft delete in entity

  1. svn checkout https://subversion.finalconcept.com.au/final-concept-spring-roo-behaviours/trunk/roo-addon-behaviours ./roo-addon-behaviours
    cd ./roo-addon-behaviours
    mvn install

Roo Commands

  • behaviours soft-delete add –type <JavaType>
  • behaviours soft-delete all

ref: https://redmine.finalconcept.com.au/projects/final-concept-spring-roo-behaviours/wiki/Installation

active record vs DAO in persistence layer

 main argument against using DAO: the fact that it requires a significant amount of repetitive source code to be produced for no immediate advantage over using JDBC or EJB directly. For many developers, this disadvantage is good enough reason to ignore the long-term benefits of using a framework-neutral API, especially where there are strict project deadlines. Without the code generation advantages of FireStorm/DAO, it is not easy to justify to a project manager or project sponsor the time and cost of manually writing DAO design pattern code, regardless of any future benefits they may see.

from: http://www.codefutures.com/products/firestorm/benefits/

Active record claim to be simple, which it encapsulate persistence into its object, and may implement with Rapid development tool like Spring Roo.

How to change repository server in Ubuntu?

Press ALT+F2 and type “software-properties-gtk"

then pick other server prefer at [Download from:] drop down list.

At the end, update repository  by cmd:  “sudo apt-get update”

How to enable JAVA support in Ubuntu browser?

Google Chrome
  • Become the root user by running the su command and then enter the super-user password. Type:
    sudo -s
  • Create a directory called plugins if you do not have it. Type:
    mkdir -p /opt/google/chrome/plugins
  • Go to Google chrome plugins directory before you make the symbolic link. Type:
    cd /opt/google/chrome/plugins
  • Create a symbolic link. Type:
    ln -s /usr/local/java/jre1.7.0/lib/amd64/libnpjp2.so
  • Restart your browser and test Java
Mozilla Firefox
  • Become the root user by running the su command and then enter the super-user password. Type:
    sudo -s
  • Create a directory called plugins if you do not have it. Type:
    mkdir -p /usr/lib/mozilla/plugins
  • Go to Google chrome plugins directory before you make the symbolic link. Type:
    cd /usr/lib/mozilla/plugins
  • Create a symbolic link. Type:
    ln -s /usr/local/java/jre1.7.0/lib/amd64/libnpjp2.so
  • Restart your browser and test Java

ref: http://java.com/en/download/help/enable_browser_ubuntu.xml

How to generate date in Unix/Linux?

# date +"%b %d" -d today
Feb 15
# date +"%b %d" -d "last week"
Feb 08
# date +"%b %d" -d "last month"
Jan 15

How to create menu shortcut in ubuntu?

How to create menu shortcut in ubuntu?

create a file with extension “.desktop” under ~/.local/share/applications  with following details:

 [Desktop Entry]

Encoding=UTF-8
Name=<NAME of shortcut to show on screen>
Comment=<Comment of shortcut>
Version=1.0
Type=Application
Terminal=0
StartupNotify=true
Icon=<path to icon>
Exec=<executable script to start app>
Categories=<Menu category eg, Development;IDE;Java;>

./adb devices no permissions issue

‘./adb devices’ 

is the first command to get connect to android from PC.

Environment: Ubuntu

issue:

List of devices attached
???????????? no permissions

 solution:

Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"

Run the following commands:

sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

Disconnect the USB cable between the phone and the computer.

Reconnect the phone.

Run adb devices to confirm that now it has permission to access the phone. 

  ref: http://stackoverflow.com/questions/9210152/set-up-device-for-development-no-permissions

javax.xml.transform.TransformerException: java.io.FileNotFoundException

Writing xml to file while using java Transformer, having error below:

javax.xml.transform.TransformerException: java.io.FileNotFoundException

Environment: Ubuntu

Reason: Not sure.

I’d tested in both Maven tomcat and Standalone Tomcat 7, only occurred in Standalone Tomcat 7.

Sample code >

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, JRReportStyle.DEFAULT_ENCODING);
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(anOutputFile);
transformer.transform(source, result);

Solution:

Change to use URI – getPath instead of just passing File object into StreamResult.

eg. StreamResult result = new StreamResult(anOutputFile.toURI.getPath());