Junos Space Developer
Reply
Contributor
Ar2r
Posts: 42
Registered: ‎11-29-2011
0

Setting Job data

 

Hi,

 

Is it possible to set JobData inside schedulable method instead of  in annotation?

 

@Schedulable
@JobData(
		name = "trololo",
		iconFileName = "hello_space-new_180x180-normal.png"
	)
public JobInfoTO trololo(ApiContext apiCtx, ScheduleContext  scheduleCtx) {
	InternalScheduleContext iSctx = (InternalScheduleContext) scheduleCtx;
	int jobInstanceId = iSctx.getJobInstanceId();
	
	// something like this	
	iSctx.setJobInstanceName("New Name");
	
	// also, setJobInstanceId method doesn't work
	iSctx.setJobInstanceId(jobInstanceId);
jobMgr.setJobInstanceResult(jobInstanceId, "Success", JobStatus.SUCCESS, null); return null; }

 Also, it's impossible to set job id by setJobInstanceId method. Job id is generated automatically.

 

Where is Job icon file located? In Eclipse docs said that  in <your_app>/web/preload, but there are four folders in project: AppName, AppNameEJB, AppNameWebSvc, AppNameWeb. Witch one should contain ./web/preload folder?

 

Thank you.

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Setting Job data

Hi,

 

    I will check and get back on this.

 

 

Regards,

 

Vimala.

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Setting Job data

Hi,

 

   We are still looking at the code to verify whether we can set the JobData inside the schduler.  I will respond to your query by tommorrow EOD.

 

 

 

Thanks,

 

vimala.

Contributor
Ar2r
Posts: 42
Registered: ‎11-29-2011
0

Re: Setting Job data

Thank you.

 

One more question:

 

I couldn't found any docs about it. JobManager instance has method to shedule job: scheduleJob(JobTO arg0, ScheduleTO arg1). What is the first argument? how can I get?

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Setting Job data

Hi,

 

We don't normally call this jobMgr.scheduleJob directly.  The recommended way is to restify the job interface, and then use REST API's to schedule the job.  But here is how you would call it, directly:

 

 

public static void testJobManager() throws Exception {

            InitialContext ctx = new InitialContext();

            JobManager jobMgr = (JobManager)ctx.lookup("cems/cmp.JobManagerEJB/remote");

            String serviceJndiName =   "ChangeRequestManagerBeanEJB";

            String op = "commitChangeList";

            int dataId = 1;

 

            byte[] data = null;

            try {

              

               Object[] params = { dataId };

               //TODO Should call InfoSender.serialize() instead. However, see note below

               data = serialize(params, 1,2);

            }

            catch (Exception e) {}

 

            JobTO jto = new JobTO(serviceJndiName, data, op);

            ScheduleTO sto = new ScheduleTO();

 

            jobMgr.scheduleJob(jto, sto);

        }

 

You need to create this folder and Space will preload it for you:


 /inventoryManagerWeb/web/images/preload/devicefamily/M320.png
./inventoryManagerWeb/web/images/preload/devicefamily/ex8208.png
./inventoryManagerWeb/web/images/preload/devicefamily/ex6200.png
./inventoryManagerWeb/web/images/preload/devicefamily/StateLsys.png
./inventoryManagerWeb/web/images/preload/devicefamily/ex3200-48c-48poe.png
./inventoryManagerWeb/web/images/preload/devicefamily/NS5200.png
./inventoryManagerWeb/web/images/preload/devicefamily/ISG.png
./inventoryManagerWeb/web/images/preload/devicefamily/srx220.png
./inventoryManagerWeb/web/images/preload/devicefamily/mx5.png
./inventoryManagerWeb/web/images/preload/devicefamily/ex4200-24.png
./inventoryManagerWeb/web/images/preload/devicefamily/StateOrangeConnecting.png
./inventoryManagerWeb/web/images/preload/devicefamily/srx3400.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Clone_Device_Disabled_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Connection_Profile_Add_Enabled_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Configlet_Download_Enabled_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Delete_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Connection_Profile_Add_Disabled_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/View_Configlet_Enabled_24x24.png
./inventoryManagerWeb/web/images/preload/rapidDeployment/Delete_Disabled24x24.png

 Then you can just refer to the image as srx3400.png, for example.  Without any path.  There is no documentation which details the arguments for all the methods. 

 

I hope this clears.

 

 

Thanks,

 

Vimala.

 

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.