Friday, 27 September 2013

Android 4.4 KitKat New UI.

All of now know what Google has named the next version of its Android system, its KitKat. But what has been a secret so far is about the features that will come with this chocolaty android version. Screenshots of the Android 4.4 aka KitKat has surfaced online which shows the dialer screen and a new messaging interface.



New messaging application altogether rather than just being a new UI of the existing setup. The  Screenshot shows the controls of app on the top right corner and the color scheme is similar to that of What’s App. The secondscreen shot on the other hand shows a clean layout of the dialer which flaunts a blue color.

The Android 4.4 KitKat may arrive with next Nexus Smartphone which apparently will be called as Nexus 5 in the month of October.

Thursday, 26 September 2013

Scheduled Tasks With Cron(QUARTZ).

To configure regularly scheduled tasks that operate at defined times or regular
 intervals. 
These tasks are commonly known as cron jobs. Quartz is a open source job scheduling framework,
 that let you scheduler a task to run on a predefine date and time.

When a Quartz application is first launched,the main thread starts the Scheduler.
The QuartzScheduler is created and creates an instance of the  
 org.quartz.core.QuartzSchedulerThread class.The QuartzScheduler Thread contains the processing
 loop for determining when the next job should be triggered.As the name implies,the 
QuartzSchedulerThread is a Java thread.It runs as a nondaemon thread with a normal priority. 
 
When first Tomcat server is on  "Initializing Scheduling PlugIn" will be printed then 
when we schdule the task it will be executed on that particular time.
 
InitializeServlet.java 
package com.cron;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class InitializeServlet extends HttpServlet {

 public void init() throws ServletException {
        try {
        System.out.println("Initializing Scheduling PlugIn");
       CronScheluder objPlugin = new CronScheluder();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
CronScheluder.java
package com.cron; import org.quartz.CronTrigger; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerFactory; import org.quartz.impl.StdSchedulerFactory; public class CronScheluder { public CronScheluder() throws Exception { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sche = sf.getScheduler(); sche.start(); 
    // MyJob class will be executed at given interval. 
    JobDetail jDetail = new JobDetail("Scheduling", "NJob", MyJob.class);
    //"0 0 12 * * ?" Fire at 12pm (noon) every day
    //"0/2 * * * * ?" Fire at every 2 seconds every day
   CronTrigger crTrigger = new CronTrigger("cronTrigger","NJob","0 0 12 * * ?");
    sche.scheduleJob(jDetail, crTrigger);
  }
}
 
MyJob.java:
 
package com.cron;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

public class MyJob extends BaseHibernateDAO implements Job {

    public void execute(JobExecutionContext context)
     throws JobExecutionException {

        System.out.println("Cron executing "); 

    }
}
 
If we want to run Quartz parallel to the main thread 
 
CronScheluder.java 
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

public class CronScheluder extends Thread{

public void run(){
 try{
 SchedulerFactory sf = new StdSchedulerFactory();
 Scheduler sche = sf.getScheduler();
 sche.start();
 JobDetail jDetail = new JobDetail("Newsletter", "NJob", MyJob.class);
 //"0 0 12 * * ?" Fire at 12pm (noon) every day
 //"0/2 * * * * ?" Fire at every 2 seconds every day
 CronTrigger crTrigger = 
        new CronTrigger("cronTrigger", "NJob", "0 0 12 * * ?");
 sche.scheduleJob(jDetail, crTrigger);
 // sche.shutdown();
}catch (Exception e) {

  e.printStackTrace();
             }
}
}
InitializeServlet.java 
 
  try {
        System.out.println("Initializing Scheduling PlugIn");
        CronScheluder objPlugin = new CronScheluder();
        if(!objPlugin.isAlive()){
   objPlugin.start();
        }
      }

Monday, 23 September 2013

How to call a Web Service For Cross Domain in FLEX




Step1: 
Set The Paths For the Java and Blazeds.
                 CATALINA_HOME: C:\blazeds-turnkey-4.0.0.14931\tomcat.
             Java Paths: 
                 Java_Home: C:\Program Files\Java\jdk1.7.0_03;
                 path: C:\Program Files\Java\jdk1.7.0_03\bin; 

Step2:
In  C:\blazeds-turnkey-4.0.0.14931\tomcat\Webapps  create a folder with a some name
And then go to samples folder copy WEB_INF folder in that folder and paste that WEB_INF folder in
Folder which you created.

Step3:
 WEB-INF must contain
classes,flex,jsp,lib,src folders and web.xml file.

Step4:
Create A project in  Flash Builder by selecting the Blazeds server with
                Root Folder:       C:\blazeds-turnkey-4.0.0.14931\tomcat\webapps\folder Name   
                Root URL:          http://localhost:8400/Webconfigfile\ folder Name  
                Context Root:    \ folder Name

Step5:
In Flex Application Declaration block
<s:WebService  id="WBSample"
                             destination="ws-catalog"
                             useProxy="true"
                             result="WBSample_resultHandler(event)"
                             fault="WBSample_faultHandler(event)"
 load="WBSample.CelsiusToFahrenheit(12)" />


Step6:
 In the folder which you Created open WEB_INF folder --> flex folder --> proxy-config file with notepad.
                In that set the destination tag like this below

<destination id="ws-catalog" 
 <properties>
<wsdl>http://www.w3schools.com/webservices/tempconvert.asmx?wsdl</wsdl>
 <soap>*</soap>
</properties>
 <adapter ref="soap-proxy"/>
 </destination>


  In that destination id and destination  attribute in Webservice tag should be same.  

                               Without server directly from flex:
 Step1:
In Flex Application Declaration block 
     <s:WebService id="wsSaveEmployee" 
wsdl="http://www.w3schools.com/webservices/tempconvert.asmx?wsdl
          showBusyCursor="true">
          <s:operation name="CelsiusToFahrenheit"
                   resultFormat="object"
                   result="saveChangePwdresult(event)" 
fault="saveChangePwdfault(event)"/> </s:WebService>
 Step2:
 CelsiusToFahrenheit is the method name in WebService.           
              wsSaveEmployee.CelsiusToFahrenheit.send(24);