петък, 25 юли 2008 г.

Interface injection


...

Spring doesn't offer support for interface injection as Fowler described it, but Spring does provide a couple types of "autowire" capabilities. Autowire is a means of automagically invoking setters on a target object by looking for source objects in the entire Spring context. If the target object has a setter that takes a single parameter, the type of that parameter is located in the Spring context. If Spring knows of any bean that matches the setter's type, it will invoke the setter.

As an example, if a JavaBean in Spring is set to "autowire=byType" and has a method signature of void setProperties(Properties props), Spring will look for a bean in its context that is of type Properties. If it finds one, it will pass it to the target bean's setter method. If it finds more than one source object of type Properties it will throw an exception.

Spring also has another type of autowire that uses the name of the setter property and looks for a source object with the same name. If found, the source object is passed to the target object's setter method...

As noted above, Spring's support of Interface Injection is an all or nothing approach and cannot be controlled very well. Autowire by type is a very magical type of IoC that proves too loose in many large applications, primarily because there isn't an efficient way to tell Spring which methods should be autowired and which ones are strictly off-limits....

The framework enables "autowiring" by default. To change the wiring mode, modify the spring.autowire property.

The autowire property can be set to several options: name, type, auto, constructor.


http://opensource.atlassian.com/confluence/spring/display/DISC/Adding+Interface+Injection+to+Spring
http://cwiki.apache.org/WW/spring.html

четвъртък, 24 юли 2008 г.

Maven properties (build.properties) -Properties Reference



The properties files in Maven are processed in the following order:

  1. Built-in properties are processed
  2. ${basedir}/project.properties (basedir is replaced by the directory where the project.xml file in use resides)
  3. ${basedir}/build.properties
  4. ${user.home}/build.properties
  5. System properties
* build.properties stores the path of local repository too

The built-in properties are specified in the plugin.properties file of a plugin, or in defaults.properties within Maven itself.

Both the project.properties and build.properties files in the project directory are also inherited along with the related project.xml file.

The last definition takes precedence, so ${user.home}/build.properties will override anything specified in a project, and properties given on the command line using -D will override everything.

Note: there are no per-user defaults, as there has not been a property shown where this concept makes sense. Currently, there are also no site-wide defaults, however this is planned for future versions of Maven.

http://maven.zones.apache.org/~continuum/staging-sites/m1-core/maven-1.x/reference/properties.html

вторник, 22 юли 2008 г.

Protocol Buffers - Google's Data Interchange Format



Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages – Java, C++, C#, Python and Perl.

It is used everyone inside Google.
The initial version Proto1 was developed in Google starting in early 2001.
Proto2 is a complete rewrite, though it keeps most of the design and uses many of the implementation ideas from Proto1. Some features have been added, some removed. Most importantly, though, the code is cleaned up and does not have any dependencies on Google libraries that have not yet been open-sourced...

...
Do we write hand-coded parsing and serialization routines for each data structure? Well, we used to. Needless to say, that didn't last long. When you have tens of thousands of different structures in your code base that need their own serialization formats, you simply cannot write them all by hand.

Instead, we developed Protocol Buffers. Protocol Buffers allow you to define simple data structures in a special definition language, then compile them to produce classes to represent those structures in the language of your choice. These classes come complete with heavily-optimized code to parse and serialize your message in an extremely compact format. Best of all, the classes are easy to use: each field has simple "get" and "set" methods, and once you're ready, serializing the whole thing to – or parsing it from – a byte array or an I/O stream just takes a single method call...
...
And, yes, it is very fast – at least an order of magnitude faster than XML.


Links:
http://google-opensource.blogspot.com/2008/07/protocol-buffers-googles-data.html
http://www.infoq.com/news/2008/07/google-protocol-buffers
http://code.google.com/apis/protocolbuffers/

Effective Java programming v2

Today I have been decided to put in my blog examples and recipes from the book - Effective Java programming, v2

петък, 18 юли 2008 г.

Hot water freezes faster than cold water

Hot water freezes faster than cold water!

This is one of the most unintuitive natural observation, which to date has no known reasonable, nor scientific accepted explanation.

http://math.ucr.edu/home/baez/physics/General/hot_water.html

http://www.apnoia.org/ivantic/fizika/faq/hot_water.html

четвъртък, 10 юли 2008 г.

JUnit 4



http://www.vogella.de/articles/JUnit/article.html
http://wsgi.net/~espeak/junit_tutorial.html

Installing and test if junit works:
* set CLASSPATH drive:\junit-4.4;drive:\junit-4.4.jar (see if is set echo "CLASSPATH")
* drive:\>java -classpath %CLASSPATH% org.junit.runner.JUnitCore org.junit.tests.AllTe
sts

събота, 5 юли 2008 г.

Продажба / покупка на злато

http://www.fibank.bg/inside.php?language=1&parent=59
http://jwswealth.info/722A9356-A868-4C2A-B694-485E1CC6733B/B634E71A-76CA-41EC-97BE-9CB1BCEB3C6E/982597AF-E998-453E-BE2A-1D065B9FCDA0.html
http://www.novini.net/2008/02/blog-post_26.html

Май е по добре да купуваш злато от колкото да харчиш в казино?
Вие как мислете?