SpringSource has published release candidate 2 of the upcoming 3.0 release of their Spring Framework. New Feature is the compliance with JSR-330 (“Dependency Injection for Java”). The JSR was developed together by Google (for their Guice Framework and SpringSource (for their Spring Framework) and is finally approved since 14.10.2009.
A little example shows how to develop services with interfaces and implementations without dependencies to Spring Framework or Google Guice:
The Maven pom.xml
4.0.0de.schaeftlein.devjsr330-samplejarjsr330-sample0.0.1-SNAPSHOTSample App with Spring 3.0 RC 2 and JSR3303.0.0.RC2org.springframeworkspring-core${springVersion}org.springframeworkspring-beans${springVersion}org.springframeworkspring-context${springVersion}org.springframeworkspring-asm${springVersion}org.springframeworkspring-expression${springVersion}junitjunit4.7testjavax.injectjavax.inject1jsr330-samplesrc/main/java${basedir}/src/test/javasrc/main/resources**/.svn**/.svn/****/_svn_svn**/_svn/**src/test/resources**/.svn**/.svn/****/_svn_svn**/_svn/**org.apache.maven.pluginsmaven-compiler-plugin1.61.6org.apache.maven.pluginsmaven-eclipse-plugintruetrue_svn.svnorg.apache.maven.pluginsmaven-jar-plugintrueorg.apache.maven.pluginsmaven-source-pluginattach-sourcesverifyjar
package de.schaeftlein.dev.spring;
public interface SecureUtil
{
void compareEncryption(String input);
}
a implementation for our service
package de.schaeftlein.dev.spring;
import javax.inject.Inject;
import javax.inject.Named;
@Named("SecureUtil")
public class SecureUtilImpl implements SecureUtil
{
@Inject // automatically set by DI framework
@Named("secure") // get the namend bean
private Encryption secureEncryption;
@Inject // automatically set by DI framework
@Named("URLEncoderEncyrption") // get the bean by its classname
private Encryption unsecureEncryption;
public void compareEncryption(String input){
String encodedSecure = secureEncryption.encode(input);
System.out.println("Secure encoded: "+encodedSecure);
String encodeUnsecure = unsecureEncryption.encode(input);
System.out.println("Unsecure encoded: "+encodeUnsecure);
System.out.println("Secure decoded: "+secureEncryption.decode(encodedSecure));
System.out.println("Unsecure decoded: "+unsecureEncryption.decode(encodeUnsecure));
}
}
finally a main class for testing
package de.schaeftlein.dev.spring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Main
{
/**
* main method
*/
public static void main(String[] args)
{
ApplicationContext ctx = new AnnotationConfigApplicationContext(Main.class.getPackage().getName()); // new way to get Application context without applicationContext.xml available
SecureUtil util = ctx.getBean("SecureUtil", SecureUtil.class); // get bean with new generics method
util.compareEncryption("an sample input string 1234567890");
}
}
output of our Main class
19.11.2009 18:56:03 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@c1b531: startup date [Thu Nov 19 18:56:03 CET 2009]; root of context hierarchy
19.11.2009 18:56:03 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
19.11.2009 18:56:03 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a83b8a: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,secure,SecureUtil,URLEncoderEncyrption]; root of factory hierarchy
Secure encoded: QDQvd4uK14YNUQ4uoqhqsZEMDDxUqJAMyisvZr2wsA2GyMC5tSEIiw==
Unsecure encoded: an+sample+input+string+1234567890
Secure decoded: an sample input string 1234567890
Unsecure decoded: an sample input string 1234567890
A beta version of Chrome OS is available as VMX/VMDK image for vmware or virtualbox and live cd. Chrome OS is a OpenSuSe based operating system around the Google Chrome browser.
Steps to test VM image of chrome os beta
Download VMDK image
Extract tar.gz File to standard folder of vmware
Start vmware server
Choose from “Virtual machine” menu “add Virtual machine to inventory”
Choose VMX file inside extracted image of chrome os
Upgrade Virtual machine to newest “hardware” by choosing link on right side from the vm summary page
Remove Network Connection from VM and Add new one with “Add Hardware” and type “Network Adapter” with “Nat” mode
Boot VM and cornfirm warning about IDE geometry and scsi controller
Click on “Make Goggle chrome default browser” and confirm dialog
Click on computer button (down left side) and click under status on network connection
Enter root password: root
confirm warning about network manager with ok
Choose under “Global Options” network setup method “traditional method with ifup”
Go to “Overview” tab and click on “edit” button below
click on “next” button
go back to “global options” and change back to “user controlled with networkmanager”
Reboot machine by clicking on computer and shutdown with type reboot
After reboot you can surf with google chrome without any problem
Windows 7 Home Premium has no XP Mode Feature like in Pro or Ultimate Edition to run an Windows XP virtual machine seamless. Home Premium can be upgraded by Anytime Upgrade within Windows to Professional or Ultimate (90$* or 140$*). You need at least Professional Version for XP Mode. So i looked for alternatives. Under Windows XP was VMWare server 2.x my first choice without seamless mode. Seamless Mode made VM windows be available in host OS as “normal” windows without the rest of the VM OS. One Alternative is VMWare Workstation 7 with seamless mode (176€*). Paralells has currently an beta version available with Coherence (seamless) feature. Virtualbox as open source alternative has seamless mode too. You need only to install the guest additions of virtualbox, reboot after installation and call from menu “seamless mode”.
So i give Virtualbox a try and installed the current 3.0.10 version under Windows 7. VirtualBox can work with VMware VMDK Hard disks out of the box.
Steps to convert from VMware to Virtualbox:
Start VMware image under VMware
Uninstall VMware Tools inside VM
Shutdown VM
Open DOS command shell in VM folder
set path variable to include VMWare server folder: set path=;%PATH%
convert splitted VM hard disk to single file: vmware-vdiskmanager -r source_multiples.vmdk -t 2 single_file.vmdk (use ” to surround file name if file name contains spaces)
copy new single_file.vmdk and single_file-flat.vmdk to \harddisks on host os with virtualbox
Start VirtualBox under host OS
Open in file menu “Virtual media manager”
Go to “Hard Disks” tab
Click on Add Button and choose single_file.vmdk
Close dialog with OK button
Click on “New” button to create a new VM
Click on “Next” button
Enter name for new VM and choose operation system including version (in my example Win_vista” as name, “Microsoft Windows” as OS and “Windows Vista” as version)
Set memory to a suitable value (on my machine i prefer 512MB for good enough performance)
On the next page choose “Use existing hard disk” and select from Drop down the old VMware hard disk image
Click on Finish
Open Settings of new VM to correct problems with different hard ware in VMware and VirtualBox
Go to System => Motherboard and “enable IO APIC”
a had an scsci lsi logic controller under VMware: Go to “Hard Disks” and “Enable Additional Controller” including selection of “SCSI (Lsilogic)”s
Start new VM
Install Virtualbox guest additions from vm window menu under “Devices”
reboot vm
Start for example a IE windows inside vm and call from “Machine” menu “seamless mode”
Currently that doesn’t seems to work with windows vista. Another VM in virtualbox with windows XP Professional works as expected in seamless mode.
Keep in mind that such a migration with Windows Vista as guest os needs another activation because of changed multiple hardware components.
Another possibility is to install the unofficial Virtual PC 6.1 for windows 7 from the knowledge base (32bit / 64bit). As described here you see in the windows 7 start menu the entries of the installed programs under the xp vm to start them directly in seamless mode. Comparing to the windows 7 XP mode their is the requirement for a separate windows xp license for a windows home or starter host os. Windows 7 professional or ultimate include such a license for a virtual windows xp on the same machine. Virtual PC needs a Virtualization hardware support like intel VT-X or AMD-V. The installation of Virtual PC fails if the processor and mainboard don’t fit to this requirement.
Startmenu entry of Virtual PC
Start installed Apps inside XP VM from Windows 7
Seamless started XP VM Application under Windows 7
*Price are only snapshots from the manufacturer websites without any guarantee and only provided to compare the possibilities.
Upgrading ant was in the past no big deal. Just download the binary archive, extract it and adopt the ANT_HOME environment variable. ANT_HOME is set to the extracted folder and PATH contains a entry %ANT_HOME%\bin. So PATH does not need to change during an ant update. I’m recently updated from ANT 1.6.5 to 1.7.1. and was a bit suprised by the output of ant -version. It still shows 1.6.5 as version. I checked the environment variables but everything was fine. The problem is that ANT batch files look in different folders according to the manual. Prior to the ANT_HOME\lib folder will be the files in USER_HOME\.ant\lib be added to the classpath. This user home folder was on my machine still filled up with the jars from the 1.6.5 release. After deleting the contents show ant now the correct version. I understand the purpose of having additional libs available for own used tasks but the result behavior was annoying.
Either Vodafone and T-Mobile use hidden picture compressions and remove alt text inside web pages when you surf with a UMTS stick. The traffic goes through a transparent proxy with that “feature”. Pictures inside browsers have less quality. Most annoying for me is that if you browse on geocaching.com for Geocaches on a map. You see normally the name of the cache if your mouse goes over the cache icon on the map. With a mobile internet connection you see a hint that “Shift-R improves quality of that picture and SHIFT-A improves the quality of all picture on that page”. A solution for this is a firefox plugin called: “Modify Headers“. Go to the extras menu and open “Modify Headers” entry. Enter a new rule and in the first field (Name) “Cache-Control” and in the second field “no-cache” (Value). Save the rule and enable them. Restart the browser. Now reopen with firefox a page with pictures. Quality as with normal internet connections and no more annoying hints to improve quality. In geocaching.com maps will now the name of the cache presented as expected.