Computer programs that write or manipulate other programs (Metaprogramming)

Imagine a guy who builds cars. When he building a new car he’s always doing the same thing, more or less. So he builds factory to build cars, and it’s much better.
Now he wants to build new types of cars. Easiest way to do this is, creating new factory for each new type of cars. Now he decides to build factories that build factories that build cars. That’s metaprogramming.

In programming perspective,

Lets assume you wants to write shell script that will echo number one.

# program
echo "1"

Then you wants a shell script that will echo number 2, and another shell script for echo number 3 and so on until 1000. You can write each shell script by manually or you can write shell script which will write a all those 1000 programs as following script (which is a meta program).

# metaprogram
echo '#!/bin/sh' >program
for I in $(seq 1000)
echo "echo $I" >> program
chmod +x program


Usage of the java object ? ask from JVM

If you are a Java developers who come from a C/C++ background have probably at one time wished for a Java equivalent of sizeof(). Java lacks a true sizeof() equivalent utility , but you can ask memory usage of the object from JVM by the Instrumentation framework introduced in Java 5. It can be used to get an estimate of the size of a particular object via its getObjectSize(Object)

General practise to use Instrumentation framework for estimation is following steps.  

  • create a special agent class with a special premain method, generally compiling it against the rest of our code so that it can see the definitions of the classes whose memory usage we’re interested in measuring;
  • the JVM passes a special Instrumentation object to  premain method (in agent class), which can use to query the size of an object;
  • package the compiled agent class into a jar with a special manifest file;
  • run the program, passing in the agent jar to the VM command line arguments.

Above procedure in details.

1. Creating the instrumentation agent class

An instrumentation agent is a class with a special method, with a predefined signature, that the JVM will invoke before the rest of the application for you to set up any instrumentation code. Generally, instrumentation is the act of transforming classes for profiling purposes: for example, we could manipulate the definition of the String class to increment a counter every time a string is created, and thus measure e.g. how many strings per second our application creates. But an interesting additional feature provided by the instrumentation framework is the ability to measure the memory usage of an object.

Agent is simply a class with the following method defined:

public static void premain(String args, Instrumentation inst) {

The JVM will pass to premain method an implementation of the Instrumentation interface, defined in java.lang.instrument. In turn, this interface defines the method getObjectSize(). So for example, if we want to measure the memory usage of an instance of SomeClass, our agent code would look as follows:

import java.lang.instrument.*;
import com.somepackage.SomeClass;

public class MyAgent {
  public static void premain(String args, Instrumentation inst) {
    SomeClass obj = new SomeClass();
    long size = inst.getObjectSize(obj);
    System.out.println("Bytes used by object: " + size);

Note that there’s no interface that agent needs to define: we just need to make sure that we get the method signature correct so that the JVM will find it.

2. Package the agent into a jar

Once we have compiled our agent class, we need to package it into a jar. This step is slightly fiddly, because we also need to create a manifest file. The latter is simple a text file containing a single line that specifies the agent class. For example, you can create a file called manifest.txt with the following line:

Premain-Class: somepackage.MyAgent

Then, to create the jar, we execute the following command (it’s usually worth creating a batch file or shell script with this line in case you need to re-build the agent jar several times):

jar -cmf manifest.txt agent.jar somepackage/MyAgent.class

3. Run the application with the agent

Now, we execute the application as usual, but use the javaagent command line argument to specify that we want to attach our instrumentation agent. For example, assuming the classpath is the current directory and that the application’s main method is in com.mypackage.Main:

java -javaagent:agent.jar -cp .somepackage.Main

Now, before our application is run, our agent’s premain method will be run. And in this case, the size of an instance of SomeClass will be created.

WSO2 Task Server 1.1.0 Released

Trigger Web Tasks Remotely

WSO2 Task Server offers a central server for registering and scheduling tasks. This task provider can be used to execute any web task independently, or for interfacing tasks that have been already defined in other carbon applications.

It offers the convenience of a dedicated task handling service that executes all tasks according to a pre-defined criteria and a specific, periodic sequence. With web tasks, you can easily configure the task criteria as well as the periodic occurrence using the management console of the task server.

Key Features

  • Creating remotely triggered web tasks
  • Interfacing tasks in Carbon servers as a task provider

The full feature list is available at

Known Issues

All known issues have been recorded at ts-1.1.0-outstanding-issues

Reporting Problems

Issues can be reported using the public JIRA available at


WSO2 Task Server developers can be contacted via: 
For Users: 
For Developers: 
For details on subscriptions see 


WSO2 Inc. offers a variety of development and production support programs, ranging from Web-based support up through normal business hours, to premium 24×7 phone support.

For additional support information please refer to

For more information on WSO2 Task Server, visit the WSO2 Oxygen Tank

Secure Sockets Layer (SSL) and SSL Certificates

What Is SSL?

SSL is a security protocol. For establishing an encrypted link between a website (server) and a browser(client), there should be a  standard security technology.   SSL (Secure Sockets Layer)  provide that slandered technology.

Sensitive information such as credit card numbers, social security numbers, and login credentials can be transmit securely with SSL. Normally, data sent between browsers and web servers is sent in plain text—leaving you vulnerable to eavesdropping. If an attacker is able to intercept all data being sent between a browser and a web server they can see and use that information.

SSL protocol state few parameters to be share between server and client for verify the server and encrypt the sessions.  All browsers have the capability to interact with secured web servers using the SSL protocol. However, the browser and the server need what is called an SSL Certificate to be able to establish a secure connection.

What is an SSL Certificate and How Does it Work?

SSL Certificates have a key pair: a public and a private key. Using this two keys it can establish an encrypted connection. The certificate also contains what is called the “subject,” which is the identity of the certificate/website owner.

To get a certificate, you must create a Certificate Signing Request (CSR) on your server. This CSR creates the private key and a CSR data file that you send to the SSL Certificate issuer (called a Certificate Authority or CA). The CA uses the CSR data file to create a public key to match your private key without compromising the key itself. The CA never sees the private key.

Once you receive the SSL Certificate, you install it on your server. You also install a pair of intermediate certificates that establish the credibility of your SSL Certificate by tying it to your CA’s root certificate. The instructions for installing and testing your certificate will be different depending on your server.



1.Browser connects to a web server (website) secured with SSL (https). Browser requests that the server identify itself.

2.Server sends a copy of its SSL Certificate, including the server’s public key.

3.Browser checks the certificate root against a list of trusted CAs and that the certificate is unexpired, unrevoked, and that its common name is valid for the website that it is connecting to. If the browser trusts the certificate, it creates, encrypts, and sends back a symmetric session key using the server’s public key.

4.Server decrypts the symmetric session key using its private key and sends back an acknowledgement encrypted with the session key to start the encrypted session.

5.Server and Browser now encrypt all transmitted data with the session key.


Why Do I Need SSL?

One of the most important components of online business is creating a trusted environment where potential customers feel confident in making purchases. Browsers give visual cues, such as a lock icon or a green bar, to help visitors know when their connection is secured.

In the below image, you can see the green address bar that comes with extended validation (EV) SSL Certificates.