Thursday, 16 February 2012


Tool for testing WebServices: soapUI. You can use it as a separate application (which is a paid version) or for free as an Eclipse plugin.
More info on eclipse version is here:

Saturday, 11 February 2012

Invoke webservice in java

To invoke WebService in java without any WS library, just using HttpURLConnection you can act like here:
   URL url = new URL(address);
   HttpURLConnection rc = (HttpURLConnection) url.openConnection();
   rc.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
   int len = soapEnvelope.length();
   rc.setRequestProperty("Content-Length", Integer.toString(len));
   rc.setRequestProperty("SOAPAction", soapAction);
   OutputStreamWriter out = new OutputStreamWriter(
   out.write(soapEnvelope, 0, len);
   InputStreamReader read = new InputStreamReader(rc.getInputStream());
   StringBuilder returns = new StringBuilder();
   int ch =;
   while (ch != -1) {
    returns.append((char) ch);
    ch =;


To easily run many Threads in java ExecutorService can be used. It is an abstraction for creating a pool of threads for running tasks. Tasks can return results in Future object. We can create Thread pools using methods of class Executors. There are plenty of options: amount of Threads to use, rise of ones,...
More details can be found on:

An example of using these construction is here:
import java.util.Date;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorServiceExample {

 final int size = 20000000;

 private long[] arr = new long[size];

 class Task implements Callable {

  private int index, range;

  public Task(int index, int range) {
   this.index = index;
   this.range = range;

  public Boolean call() throws Exception {
   boolean ret = false;

   for (int i = index; i < index + range; i++) {


   return ret;


 public ExecutorServiceExample() {
  Random random = new Random(new Date().getTime());
  for (int i = 0; i < size; i++) {
   arr[i] = random.nextLong();

 public static void main(String[] args) {

  ExecutorServiceExample ese = new ExecutorServiceExample();


 private boolean check(int i, long val) {
  if (arr[i] * val * val == val * val * val) {
   System.out.println("Found:" + i);
   return true;
  return false;

 private void findConcur(long val) {
  int range = 100;
  long start = new Date().getTime();
  ExecutorService service = Executors.newFixedThreadPool(100);

  for (int i = 0; i < size / range; i++) {
   service.submit(new Task(i * range, range));
  System.out.println("Seq in " + (new Date().getTime() - start));

 private void findSeq(long val) {
  long start = new Date().getTime();
  for (int i = 0; i < size; i++) {
   check(i, val);
  System.out.println("Seq in " + (new Date().getTime() - start));

To run this example you will probably need to add parameter to increase heap size (f.e. -Xmx1300m)

Thursday, 9 February 2012

Exposing variables by JMX in Spring Applications

If you wish to expose variable by JMX in the Spring application you have to:
  1. Add in the spring context the tag:
  2. On the managed class add annotation @ManagedResource
  3. On this method you want to be exposed add annotation
    • For getters and setters - @ManagedAttribute
    • For all type of operations - @ManagedOperation


Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants). Multitenancy is contrasted with a multi-instance architecture where separate software instances (or hardware systems) are set up for different client organizations. With a multitenant architecture, a software application is designed to virtually partition its data and configuration, and each client organization works with a customized virtual application instance.

Sunday, 5 February 2012

Adding Google Reader subscribe button

If you want to add in the webpage the button to subscribe RSS by Google Reader, then use this page: There you can put the url to your RSS in one field and generate the HTML code needed to be inserted into the web page content. That's all!

How to escape HTML?

To escape HTML for usage in blogs, web pages, ... you can use:

Saturday, 4 February 2012

How to highlight code syntax in the blogger? Use SyntaxHighlighter!

I decided to use a library for highlighting code syntax. I have found SyntaxHighlighter. To install it you have to add some script in the html code. For my case I wanted to use it for java and xml code.
Here is what I have added (you can use hosted files or files from your server):
<script src='' type='text/javascript'/>
<script src='' type='text/javascript'/>
<script src='' type='text/javascript'/>

<link href='' rel='stylesheet' type='text/css'/>
<link href=' ' rel='stylesheet' type='text/css'/>
<script type='text/javascript'>
Then you just need to put your code inside pre tag:
<pre class="brush: java">
  int add(int a, int b) {
     return a + b;
And you will get:
  int add(int a, int b) {
     return a + b;
More info on the SyntaxHighlighter home page:
More on installation is described on:
List of languages whose syntax are implemented are here:

Thursday, 2 February 2012

Lucidchart diagrams

If you are in need to create a diagram and you have no tool for it, try Your browser is enough. You can draw Flowcharts, UML Diagrams, Mid Maps, Organisation Diagrams and others.