Thursday 26 January 2012

Spring Integration 2.1

Spring Integration 2.1 has been released. The main new features of 2.1 include: RabbitMQ/AMQP, GemFire, Redis, and MongoDB, JSR-223 Scripting, Stored Procedure, and Spring Payload Enricher. Also included is FTP and SFTP Outbound Gateways and Migrating from Spring Integration 2.0.
Here is Spring Integration Homepage: http://www.springsource.org/spring-integration
Maven configuration for Spring Integration: http://www.springsource.org/node/2962

Tuesday 17 January 2012

AtomicInteger

AtomicLong, AtomicInteger, AtomicBoolean - these are java classes from package java.util.concurrent.atomic that can be used when atomic access to an object is needed.

Guava library

Some useful classes and methods from Guava library:
  • Charset.UTF_8, Charsets.UTF_16, ... - helpers for creating Charset class
  • Defaults.defaultValue(Class) - default value of given class
  • ImmutableSet, ImmutableList, ImmutableMap - builders for collections types f.e. List list = ImmutableList.of("1","2");
  • Joiner - for concatenating Strings
  • Strings.emptyToNull, Strings.nullToEmpty - String converters
  • Objects.equal(val1,val2) - returns if objects are equal
  • Objects.hashCode(...) - generates hashCode from list of objects
  • Objects.toStringHelper - utility for creating toString methods
  • Preconditions - methods for checking conditions on objects, if not meet then an Exception is thrown
  • Files - utility for file operations. copy (coping files), equals (files content is equal), getCheckSum (file check sum), getFileExtension, move (moving file in the file system), newReader (creates reader object on the file), newWriter (creates writer object on the file), readLines (returns list of strings), toBytesArray (array of bytes for file), toString (whole file as string), touch (touch on file in filesystem)
  • Closeables.closeQuietly - close stream without throwing IOException
  • Flushables.flushQuietly - flush without throwing IOException
  • BiMapsm - bidirectional map
  • MultiMaps, MultiLists - many implementations of multimaps multilists
  • Hashing, HashFunction - utilities for creating hash functions, usage of md5 calculation
  • IntMath, LogMath, DoubleMath, BigIntegerMath - operations tested for overflow, using hardware details for efficiency
  • CacheBuilder - for easy creating caches that expire after given time, amount, with other parameters
  • Cache.stats - for getting statistics of the cache object

More details on Guava library home page: http://code.google.com/p/guava-libraries/

Sunday 15 January 2012

Changing CXF WebService address

In the Apache CXF we do not have a constructor to create web service with local wsdl file or address to the web service which would override the default one. But we can do it on the constructed object. Here is an example:
WebServicesSoap port = service.getWebServicesSoap();
BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webServiceAddress); 

Changing Eclipse project into a Java Project

In the .project file add java nature and builders:
<projectDescription>
    <buildSpec>
        <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
                <arguments>
                </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>
and in the .classpath file add Java libs reference:
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>

Sunday 8 January 2012

Commons-collections library

Here are some useful features from commons-collections library:
  • CollectionUtils, MapUtils- for intersection, counting, iteration on collections and maps
  • BidiMap - supports bidirectional maps
(Version 3.2.1) More info on: http://commons.apache.org/collections/userguide.html

Common-lang library

Some useful classes and methods from the library commons-lang:
  • StringUtils - methods to manipulate on Strings
  • StringEscapeUtils - methods to escape and unescape Java, JavaScript, HTML, XML and SQL
  • WordUtils - methods to manipulate on Strings on level of words
  • CharEncoding.isSupported - method checking if encoding is supported by System
  • SystemUtils - methods checking java version used, java home, java IO temporary directory, user directory
  • SerializationUtils - methods for object serialization and desarialization
  • ObjectUtils - null-safe implementation of methods comparing objects
  • ClassUtils - helper methods on classes definition
(Version: 3.1) More info on: http://commons.apache.org/lang/userguide.html

How to define an annotation in java?


Just like creating a java interface, create f.e. a file ExampleAnnotation.java with the following code:

@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface ExampleAnnotation
{
// Property Definition here.
}

You have to add the following annotations in the definition:
  • Target - define where annotation can be added (methods, class, fields, properties, constructor, local variable, package, annotation type)
  •  Retention - where annotation will be available (only in source, in class definition, also in runtime)

Tuesday 3 January 2012

Shortcuts for Copy & Paste in Cygwin

After installing Cygwin on Windows system we don't have easy shortcuts for Copy & Paste. In Windows's console window, open the properties dialog. The options contain "Quick edit mode". It must be set. Save the properties. Now selecting with the left-mouse you also copy, and with the middle-mouse you paste.

Sunday 1 January 2012

New release of Astah

There is a new version of Astah, software for building UML 6.5.1
Download is available from: http://www.astah.net/download#professional

We can use also an Astah's plug-in for Atlassian Confluence: https://plugins.atlassian.com/plugin/details/815022