当前位置: 首页>>代码示例>>Java>>正文


Java JobDataMap.getString方法代码示例

本文整理汇总了Java中org.quartz.JobDataMap.getString方法的典型用法代码示例。如果您正苦于以下问题:Java JobDataMap.getString方法的具体用法?Java JobDataMap.getString怎么用?Java JobDataMap.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.JobDataMap的用法示例。


在下文中一共展示了JobDataMap.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void execute(JobExecutionContext context)
    throws JobExecutionException {

    JobDataMap data = context.getMergedJobDataMap();
    
    String command = data.getString(PROP_COMMAND);

    String parameters = data.getString(PROP_PARAMETERS);

    if (parameters == null) {
        parameters = "";
    }

    boolean wait = true;
    if(data.containsKey(PROP_WAIT_FOR_PROCESS)) {
        wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS);
    }
    boolean consumeStreams = false;
    if(data.containsKey(PROP_CONSUME_STREAMS)) {
        consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS);
    }
        
    Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams);
    context.setResult(exitCode);
    
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:27,代码来源:NativeJob.java

示例2: jobToBeExecuted

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void jobToBeExecuted(final JobExecutionContext context) {
	final JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
	String targetObject = jobDataMap.getString("targetObject");
	String targetMethod = jobDataMap.getString("targetMethod");
	if (logger.isInfoEnabled()) {
		logger.info("定时任务开始执行:{}.{}", targetObject, targetMethod);
	}
	// 保存日志
	TaskFireLog log = new TaskFireLog();
	log.setStartTime(context.getFireTime());
	log.setGroupName(targetObject);
	log.setTaskName(targetMethod);
	log.setStatus(JOBSTATE.INIT_STATS);
	log.setServerHost(NativeUtil.getHostName());
	log.setServerDuid(NativeUtil.getDUID());
	schedulerService.updateLog(log);
	jobDataMap.put(JOB_LOG, log);
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:19,代码来源:JobListener.java

示例3: executeInternal

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	JobKey key = jobExecutionContext.getJobDetail().getKey();
	System.out.println("Cron Job started with key :" + key.getName() + ", Group :"+key.getGroup() + " , Thread Name :"+Thread.currentThread().getName() + " ,Time now :"+new Date());
	
	System.out.println("======================================");
	System.out.println("Accessing annotation example: "+jobService.getAllJobs());
	List<Map<String, Object>> list = jobService.getAllJobs();
	System.out.println("Job list :"+list);
	System.out.println("======================================");
	
	//*********** For retrieving stored key-value pairs ***********/
	JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();
	String myValue = dataMap.getString("myKey");
	System.out.println("Value:" + myValue);

	System.out.println("Thread: "+ Thread.currentThread().getName() +" stopped.");
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:19,代码来源:CronJob.java

示例4: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
	long start = System.currentTimeMillis();
	JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
	String taskType = jobDataMap.getString("taskType");
	String targetObject = jobDataMap.getString("targetObject");
	String targetMethod = jobDataMap.getString("targetMethod");
	logger.info("定时任务开始执行: [{}.{}]", targetObject, targetMethod);
	try {
		ApplicationContext applicationContext = (ApplicationContext) context.getScheduler().getContext()
				.get("applicationContext");
		if (TaskType.local.equals(taskType)) {
			Object refer = applicationContext.getBean(targetObject);
			refer.getClass().getDeclaredMethod(targetMethod).invoke(refer);
		} else if (TaskType.dubbo.equals(taskType)) {
			String system = jobDataMap.getString("targetSystem");
			BaseProvider provider = (BaseProvider) DubboUtil.refer(applicationContext, system);
			provider.execute(new Parameter(targetObject, targetMethod));
		}
		double time = (System.currentTimeMillis() - start) / 1000.0;
		logger.info("定时任务[{}.{}]用时:{}s", targetObject, targetMethod, time);
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:25,代码来源:BaseJob.java

示例5: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
		long start = System.currentTimeMillis();
		JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
		String taskType = jobDataMap.getString("taskType");
		String targetObject = jobDataMap.getString("targetObject");
		String targetMethod = jobDataMap.getString("targetMethod");
		logger.info("定时任务开始执行: [{}.{}]", targetObject, targetMethod);
		try {
			ApplicationContext applicationContext = (ApplicationContext) context.getScheduler().getContext()
					.get("applicationContext");
			if (TaskType.local.equals(taskType)) {
				Object object = applicationContext.getBean(targetObject);
				MethodAccess methodAccess = MethodAccess.get(object.getClass());
				 methodAccess.invoke(object, targetMethod);
			} else if (TaskType.dubbo.equals(taskType)) {
//				Object object = DubboUtil.refer(applicationContext, targetObject);
//				MethodAccess methodAccess = MethodAccess.get(object.getClass());
//				 methodAccess.invoke(object, targetMethod);
			}
			double time = (System.currentTimeMillis() - start) / 1000.0;
			logger.info("定时任务[{}.{}]用时:{}s", targetObject, targetMethod, time);
		} catch (Exception e) {
			throw new JobExecutionException(e);
		}
	}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:26,代码来源:BaseJob.java

示例6: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
    long start = System.currentTimeMillis();
    JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
    String taskType = jobDataMap.getString("taskType");
    String targetObject = jobDataMap.getString("targetObject");
    String targetMethod = jobDataMap.getString("targetMethod");
    String key = targetMethod + "." + targetObject;
    try {
        logger.info("定时任务[{}.{}]开始", targetObject, targetMethod);
        if (CacheUtil.getCache().lock(key)) {
            try {
                ApplicationContext applicationContext = (ApplicationContext)context.getScheduler().getContext()
                    .get("applicationContext");
                if (TaskType.local.equals(taskType)) {
                    Object refer = applicationContext.getBean(targetObject);
                    refer.getClass().getDeclaredMethod(targetMethod).invoke(refer);
                } else if (TaskType.dubbo.equals(taskType)) {
                    BaseProvider provider = (BaseProvider)applicationContext
                        .getBean(jobDataMap.getString("targetSystem"));
                    provider.execute(new Parameter(targetObject, targetMethod));
                }
                Double time = (System.currentTimeMillis() - start) / 1000.0;
                logger.info("定时任务[{}.{}]用时:{}s", targetObject, targetMethod, time.toString());
            } finally {
                unLock(key);
            }
        }
    } catch (Exception e) {
        throw new JobExecutionException(e);
    }
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:32,代码来源:BaseJob.java

示例7: jobWasExecuted

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public void jobWasExecuted(final JobExecutionContext context, JobExecutionException exp) {
	Timestamp end = new Timestamp(System.currentTimeMillis());
	final JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
	String targetObject = jobDataMap.getString("targetObject");
	String targetMethod = jobDataMap.getString("targetMethod");
	if (logger.isInfoEnabled()) {
		logger.info("定时任务执行结束:{}.{}", targetObject, targetMethod);
	}
	// 更新任务执行状态
	final TaskFireLog log = (TaskFireLog) jobDataMap.get(JOB_LOG);
	if (log != null) {
		log.setEndTime(end);
		if (exp != null) {
			logger.error("定时任务失败: [" + targetObject + "." + targetMethod + "]", exp);
			String contactEmail = jobDataMap.getString("contactEmail");
			if (StringUtils.isNotBlank(contactEmail)) {
				String topic = String.format("调度[%s.%s]发生异常", targetMethod, targetMethod);
				sendEmail(new Email(contactEmail, topic, exp.getMessage()));
			}
			log.setStatus(JOBSTATE.ERROR_STATS);
			log.setFireInfo(exp.getMessage());
		} else {
			if (log.getStatus().equals(JOBSTATE.INIT_STATS)) {
				log.setStatus(JOBSTATE.SUCCESS_STATS);
			}
		}
	}
	executorService.submit(new Runnable() {
		public void run() {
			if (log != null) {
				try {
					schedulerService.updateLog(log);
				} catch (Exception e) {
					logger.error("Update TaskRunLog cause error. The log object is : " + JSON.toJSONString(log), e);
				}
			}
		}
	});
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:40,代码来源:JobListener.java

示例8: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
    String pluginName = jobDataMap.getString("pluginName");
    try {
        JMXPlugin jmxPlugin = (JMXPlugin) jobDataMap.get("pluginObject");
        String jmxServerName = jobDataMap.getString("jmxServerName");

        List<JMXMetricsValueInfo> jmxMetricsValueInfos = JMXManager.getJmxMetricValue(jmxServerName,jmxPlugin);

        //设置agentSignName
        for (JMXMetricsValueInfo jmxMetricsValueInfo : jmxMetricsValueInfos) {
            if (AgentConfiguration.INSTANCE.isDockerRuntime()){
                //容器环境直接取 JavaExecCommandInfo.appName
                jmxMetricsValueInfo.getJmxConnectionInfo().setName(jmxMetricsValueInfo.getJmxConnectionInfo().getConnectionServerName());
            }else {
                String agentSignName = jmxPlugin.agentSignName(jmxMetricsValueInfo,
                        jmxMetricsValueInfo.getJmxConnectionInfo().getPid());
                if ("{jmxServerName}".equals(agentSignName)) {
                    //设置变量
                    jmxMetricsValueInfo.getJmxConnectionInfo().setName(jmxServerName);
                }else{
                    jmxMetricsValueInfo.getJmxConnectionInfo().setName(agentSignName);
                }
            }
        }

        MetricsCommon jmxMetricsValue = new JMXMetricsValue(jmxPlugin,jmxMetricsValueInfos);
        ReportMetrics.push(jmxMetricsValue.getReportObjects());
    } catch (Exception e) {
        log.error("插件 {} 运行异常",pluginName,e);
    }
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:34,代码来源:JMXPluginJob.java

示例9: getInitialContext

import org.quartz.JobDataMap; //导入方法依赖的package包/类
private InitialContext getInitialContext(JobDataMap jobDataMap)
    throws NamingException {
    Hashtable params = new Hashtable(2);
    
    String initialContextFactory =
        jobDataMap.getString(INITIAL_CONTEXT_FACTORY);
    if (initialContextFactory != null) {
        params.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
    }
    
    String providerUrl = jobDataMap.getString(PROVIDER_URL);
    if (providerUrl != null) {
        params.put(Context.PROVIDER_URL, providerUrl);
    }

    String principal = jobDataMap.getString(PRINCIPAL);
    if ( principal != null ) {
        params.put( Context.SECURITY_PRINCIPAL, principal );
    }

    String credentials = jobDataMap.getString(CREDENTIALS);
    if ( credentials != null ) {
        params.put( Context.SECURITY_CREDENTIALS, credentials );
    }

    return (params.size() == 0) ? new InitialContext() : new InitialContext(params);
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:28,代码来源:EJBInvokerJob.java

示例10: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    long timestamp = System.currentTimeMillis() / 1000;
    JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
    String pluginName = jobDataMap.getString("pluginName");
    try {
        DetectPlugin detectPlugin = (DetectPlugin) jobDataMap.get("pluginObject");
        MetricsCommon metricsValue = new DetectMetricsValue(detectPlugin,timestamp);
        //可能会涉及到外网的连接,采用异步方式
        ExecuteThreadUtil.execute(new JobThread(metricsValue,"detect job thread"));
    } catch (Exception e) {
        log.error("插件 {} 运行异常",pluginName,e);
    }
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:15,代码来源:DetectPluginJob.java

示例11: executeInternal

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	JobKey key = jobExecutionContext.getJobDetail().getKey();
	System.out.println("Simple Job started with key :" + key.getName() + ", Group :"+key.getGroup() + " , Thread Name :"+Thread.currentThread().getName());
	
	System.out.println("======================================");
	System.out.println("Accessing annotation example: "+jobService.getAllJobs());
	List<Map<String, Object>> list = jobService.getAllJobs();
	System.out.println("Job list :"+list);
	System.out.println("======================================");
	
	//*********** For retrieving stored key-value pairs ***********/
	JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();
	String myValue = dataMap.getString("myKey");
	System.out.println("Value:" + myValue);

	//*********** For retrieving stored object, It will try to deserialize the bytes Object. ***********/
	/*
	SchedulerContext schedulerContext = null;
       try {
           schedulerContext = jobExecutionContext.getScheduler().getContext();
       } catch (SchedulerException e1) {
           e1.printStackTrace();
       }
       YourClass yourClassObject = (YourClass) schedulerContext.get("storedObjectKey");
	 */

	while(toStopFlag){
		try {
			System.out.println("Test Job Running... Thread Name :"+Thread.currentThread().getName());
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	System.out.println("Thread: "+ Thread.currentThread().getName() +" stopped.");
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:38,代码来源:SimpleJob.java

示例12: getInitialContext

import org.quartz.JobDataMap; //导入方法依赖的package包/类
public static InitialContext getInitialContext(final JobDataMap jobDataMap) throws NamingException
{
    
    Hashtable params = new Hashtable(2);
    
    String initialContextFactory =
        jobDataMap.getString(INITIAL_CONTEXT_FACTORY);

    if (initialContextFactory != null) {
        params.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
    }
    
    String providerUrl = jobDataMap.getString(PROVIDER_URL);
    if (providerUrl != null) {
        params.put(Context.PROVIDER_URL, providerUrl);
    }

    String principal = jobDataMap.getString(PRINCIPAL);
    if ( principal != null ) {
        params.put( Context.SECURITY_PRINCIPAL, principal );
    }

    String credentials = jobDataMap.getString(CREDENTIALS);
    if ( credentials != null ) {
        params.put( Context.SECURITY_CREDENTIALS, credentials );
    }

    if (params.size() == 0) {
        return new InitialContext();
    } else {
        return new InitialContext(params);
    }
    
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:35,代码来源:JmsHelper.java

示例13: execute

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap jobDataMap = context.getMergedJobDataMap();
    String botId = jobDataMap.getString("bot");
    String channelId = jobDataMap.getString("channel");
    String content = jobDataMap.getString("content");

    if (botId != null && channelId != null && content != null) {
        Optional<IDiscordClient> client = clientRegistry.getClients().entrySet().stream()
            .filter(entry -> botId.equals(entry.getKey().getId())
                || botId.equals(entry.getKey().getName())
                || (entry.getValue().isReady() && botId.equals(entry.getValue().getOurUser().getStringID())))
            .map(Map.Entry::getValue)
            .findAny();
        if (client.isPresent()) {
            IChannel channel = client.get().getChannelByID(snowflake(channelId));
            if (channel != null) {
                sendMessage(channel, content);
            } else {
                throw new JobExecutionException("Channel " + channelId + " is not known by the bot");
            }
        } else {
            throw new JobExecutionException("No bot exists with identifier: " + botId);
        }
    } else {
        throw new JobExecutionException("Job requires bot, channel and content parameters");
    }
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:29,代码来源:DiscordMessenger.java

示例14: executeRemind

import org.quartz.JobDataMap; //导入方法依赖的package包/类
private void executeRemind(JobDataMap map) {
	String taskId=map.getString("taskId");
	String messageSenders=map.getString("messageSenders");
	String principal=map.getString("principal");
	String messageTemplateId=map.getString("messageTemplateId");
	TaskReminderMessageSender sender=ContextHolder.getBean(TaskReminderMessageSender.BEAN_ID);
	sender.sendReminderMessage(taskId, principal, messageTemplateId, messageSenders.split(","));
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:9,代码来源:TaskReminderJob.java

示例15: sendEmail

import org.quartz.JobDataMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void sendEmail(JobDataMap map) {
	String subject 	   = map.getString("subject");
	String messageBody = map.getString("messageBody");
	List<String> to    = (List<String>) map.get("to");
	List<String> cc	   = (List<String>) map.get("cc");
	List<String> bcc   = (List<String>) map.get("bcc");
	
	MimeMessage message = mailSender.createMimeMessage();

	try {
		MimeMessageHelper helper = new MimeMessageHelper(message, false);
		for(String receipient : to) {
			helper.setFrom("[email protected]", "Julius from Dynamic Quartz");
			helper.setTo(receipient);
			helper.setSubject(subject);
			helper.setText(messageBody);
			if(!isEmpty(cc))
				helper.setCc(cc.stream().toArray(String[]::new));
			if(!isEmpty(bcc))
				helper.setBcc(bcc.stream().toArray(String[]::new));
			mailSender.send(message);
		}
	} catch (MessagingException | UnsupportedEncodingException e) {
		log.error("An error occurred: {}", e.getLocalizedMessage());
	}
}
 
开发者ID:juliuskrah,项目名称:quartz-manager,代码行数:28,代码来源:EmailJob.java


注:本文中的org.quartz.JobDataMap.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。