Thursday, 14 November 2013

How to make servlet using OSGi

hello everyone..
Here I'll tell you how to make  Servlet  using Osgi framework.
1. Make new plug-ins project give the name as SimpleServlet.
 Make sure to select Equinox as the target OSGI framework on the first page of the wizard. Also make sure you’ve got an activator (that option is on by default).
 In menifest Eddition -> Dependencies.
import these packages.

* javax.servlet

* javax.servlet.http

* org.osgi.framework

* org.osgi.service.http

* org.osgi.util.tracker

2.make a new class (SimpleServlet)

package simpleservlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SimpleServlet  extends HttpServlet{
    private static final long serialVersionUID = 1L;

      protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
        resp.getWriter().write("Hello world!!");

3.Now make a 2nd  new class for Servlet Service Tracker. (HttpServiceTracker)

package simpleservlet;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
import org.osgi.util.tracker.ServiceTracker;
public class HttpServiceTracker  extends ServiceTracker{
      public HttpServiceTracker(BundleContext context) {
          super(context, HttpService.class.getName(), null);
        // TODO Auto-generated constructor stub

    public Object addingService(ServiceReference reference) {
        HttpService httpService = (HttpService) super.addingService(reference);
        if (httpService == null)
          return null;

        try {
          System.out.println("Registering servlet at /simple");
          httpService.registerServlet("/simple", new SimpleServlet(), null, null);
        } catch (Exception e) {

        return httpService;

      public void removedService(ServiceReference reference, Object service) {
        HttpService httpService = (HttpService) service;

        System.out.println("Unregistering /simple");

        super.removedService(reference, service);


4. Now Come to activator. which is main part of the OSGi.
Edit your Activator like This-
package simpleservlet;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {
    private HttpServiceTracker serviceTracker;
    private static BundleContext context;

    static BundleContext getContext() {
        return context;

     * (non-Javadoc)
     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
    public void start(BundleContext bundleContext) throws Exception {
        Activator.context = bundleContext;
        serviceTracker = new HttpServiceTracker(context);

     * (non-Javadoc)
     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
    public void stop(BundleContext bundleContext) throws Exception {
        Activator.context = null;
         serviceTracker = null;

} configuration..
Make a New Osgi framework run. then go to tab  arguments -> VM arguments write another line

now Apply and run.
5. go to your chrome and type
it will print "Hello world"
 and tutorial for this artical  is available at
Thank you!!

                                                                                                    Anshul Madan
                                                                         CASCADEMIC Solutins Pvt.Ltd

Friday, 1 November 2013


Here I'll tell you about what is Touch Sensing Software and also the difference between Pk40 and MK40( associated with tsi).

There is a library called Touch Sensing Software(TSS) and that is provides by freescale. The TSS solution transforms a typical Freescale microcontroller into a area capacitive touch sensor controller. The touch sensor controller comes with an ability to manage multiple touch pad configurations and mechanical keys while maintaining its standard MCU handle function.

The library provides commonly used touch sense decoding structures for example a keypad, a rotary, a slider, a good analog slider, an analog rotary, and also a matrix. The latest version freescale released is TSS_3_1_0.

To create the project :
1. Firstly copy the binary library through the TSS that is suitable for you.
2. In the example folder there are various example projects for different processors. Copy the project for your processor.
So here i'll tell you about K40 board. It comes with an inbuilt touch interface.
And you possibly can copy KWIKSTIK_DEMO from example.

One thing you need to be carefull, the processor will have different version that is the KWIKSTIK board have PK40X256VLQ100 where P denotes the prototype version there is also a processor called MK40X256VLQ100 where M denotes manufactured version.
There are some difference between the two of these versions.
  1. In PK40 there are 16 electrodes and for each electrode there will be a threshold registers but in MK40 there is only one threshold register for all the electrodes.
  2. The driver software provides by freescale is for PK40 so some of the macros present in driver software will not be present in the header file of MK40. For example, in mcg.c you will get some compilation error so in that case you need to select the default clock value 21 MHz.
  3. The header file generated in codewarrior for PK40 processor is MK40DZ10.h where as for MK40 it is MK40D10.h . 'Z' denotes the initial revision of silicon chip.
So while selecting the processor be carefull. An alphabet can make difference.
                                                                                                             Shabana M
                                                                            CASCADEMIC Solutions Pvt. Ltd.

Tuesday, 29 October 2013

How to start With OSGi

Here I will tell you about OSGi(Open Service Gateway intitative) platform for java. This is beneficial framework for embedded system to function in java. Mostly people function in embedded c, so here i've got also solution for those folks using JNI that i'll explain in this next article regarding OSGi.

Steps to make OSGi with Basic Hello globe programme. Here i'll use Equinox and Apache felix Library for OSGi. comply with these step
Firstly Download Eclipse for your Operating Syatem.

1. Make Your libarary
i) Download the Equinox through http: //download. eclipse. org/equinox/
ii) Go to make workbench for eclipse
iii) GO through  Window--> Preferences--> java-->buid path-->user libraries
iv) Select New and allow User library name "Equinox". Now click on Add external jars, Select every one of the jar files which are inside plugins folder of Equinox and click on OK.
so here you've made your Library.
2. Come up with a simple hello World program.
i) Make new project "plug-in project". Compose project name "helloWorld".
ii) Select target to run being a OSGi framework as Equinox and make certain you have checked for the ACTIVATOR inside next window. then click "Next".
iii) Select HELLO OSGi Bundle and finish it.
and activator under src is present and progarm of Activator is compared to that

package simple;
import org. osgi. platform. BundleActivator;
import org. osgi. platform. BundleContext;

public class Activator implements BundleActivator {
    private HttpServiceTracker serviceTracker;

     * (non-Javadoc)
     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
    public void start(BundleContext context) throws Exception {
        System.out.println("Hello World!!");
    /*private HttpServiceTracker serviceTracker;
     * (non-Javadoc)
     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
    public void stop(BundleContext context) throws Exception {
        System.out.println("Goodbye World!!");


There are Start and Stop Method. When we will give start command with particular bundle then it'll start and if we give stop command then it'll stop that particular bundle.

3) Run
i) Go to run configuration and choose OSGi framework. Select new and allow name "OSGi" and  click on Run.
you will notice in console like that

osgi> ss
"Framework can be launched. "

id    State Bundle
0    ACTIVE org. over shadow. osgi_3. 9. 1. v20130814-1242
1    ACTIVE org. over shadow. equinox. simpleconfigurator_1. 0. 400. v20130327-2119
2    ACTIVE com. ibm. icu_50. 1. 1. v201304230130
3    ACTIVE helloWorld_1. 0. 0. qualifier
Hello World!!

    ss is command showing how many bundle is Active, Resolved.
    now Give the Stop Command "stop 3"
    it will show that adheres to that
Goodbye World!!

So this can be the simple Hello World Programme with OSGi using Equinox.

                                                                                                    Anshul Madan
                                                                            CASCADEMIC Solutions Pvt. Ltd.