Clarity

  • 1.  Need help, How to create a job by using JAVA.

    Posted Oct 05, 2010 06:06 AM
    Hi,

    We have some requirements to convert the data to .CSV file by using java job. if anyone done, to creating a job based on java, just share me a sample java code which have developed. it would be appriciated for your great help.

    Thanks
    Senthil


  • 2.  RE: Need help, How to create a job by using JAVA.

    Posted Oct 05, 2010 09:17 PM
    This can easily be accomplished with a GEL script. Just include this line:
    <file:writeFile fileName="${filename}" delimiter=",">
     
    More interestingly, could you give the reason why the requirement specifically calls for a JAVA job??


  • 3.  RE: Need help, How to create a job by using JAVA.

    Posted Nov 04, 2013 01:57 AM

    Hi,

     This is the sample code for custom job using java.

     

    myBackgroundJob .java
    -----------------------------------

    package com.myserver.jobs.background;
    import com.niku.union.interfaces.JobSchedulerContext;
    import com.niku.union.interfaces.SchedulerListener;

    public class myBackgroundJob implements SchedulerListener {

        public myBackgroundJob() {
        }


        public void scheduledEventFired(JobSchedulerContext jobContext_)
                throws Exception {
            
            if (jobContext_ == null) {
                throw new Exception("Invalid JobContext");
            }
            try {
                testJob(jobContext_);
                
                
            } catch (Exception e) {
                throw new Exception("Cannot doSomeWork()::" + e);
            }
        }
        
        
        
        private void  testJob(JobSchedulerContext context) throws Exception
        {
            String firstname=context.getSecurityIdentifier().getFirstName();
            context.getJob().logMessage("JOB ID"+context.getJob().getId());
            context.getJob().logWarning("Session ID"+context.getSecurityIdentifier().getSessionId());
            
        }


    }
     

    jar the above java class (include your requirement in testJob() method )and deploy it in clarity/lib folder. create job of type Java and give Executable name as fully qualified

    path "com.myserver.jobs.background.myBackgroundJob". restart the bg once.

    Now Java Job ready to run.