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