- 浏览: 184809 次
-
最新评论
-
adamed:
zhangwenzhuo 写道为什么this.get()会返回 ...
jQuery源码历代记5 -
zhangwenzhuo:
为什么this.get()会返回本身的呢?
jQuery源码历代记5 -
narutolby:
支持下~,哈哈~
jQuery历代记1 -
cpszy:
mark下
jQuery历代记1 -
gleams:
支持你
jQuery历代记1
请您先登录,才能继续操作
In the example in Listing 10.2, the helloWorld() method that was invoked on the EJB didn't defined any parameters. The EJBInvokedJob class enables you to pass arguments to an EJB method by specifying them using the EJB_ARGS_KEY and EJB_ARG_TYPES_KEY parameters shown in Table 10.1.
<o:p> </o:p>
列表10.2中定义的供EJB调用的helloWord()方法并没有定义任何参数。EJBInvokedJob类允许你想EJB方法中传递参数。方法是使用表10.1中的EJB_ARGS_KEY 和 EJB_ARG_TYPES_KEY。
<o:p> </o:p>
Listing 10.3 shows another simple example that passes an argument to a different version of helloWorld() EJB running on the Apache Geronimo J2EE server.
<o:p> </o:p>
列表 10.3 显示了另一个简单的示例,将参数传递给其他版本的运行在Apache Geronimo J2EE 服务器上的EJB helloWorld() 。
<o:p> </o:p>
Listing 10.3 is very similar to Listing 10.2, except that it includes the parameters EJB_ARGS_KEY and EJB_ARG_TYPES_KEY. Also, because it's running against the Geronimo J2EE application server, it needed to add the arguments for PRINCIPAL and CREDENTIALS.
<o:p> </o:p>
列表10.3与10.2非常类似除了10.3中包含参数EJB_ARGS_KEY 和 EJB_ARG_TYPES_KEY。当然由于运行在Geronimo J2EE服务器上,它需要添加额外的参数(PRINCIPAL 和 CREDENTIALS)。
<o:p> </o:p>
Listing 10.3. A Simple Example Using the EJBInvokerJob<o:p></o:p>
列表10.3 一个简单的使用EJBInvokerJob的例子<o:p></o:p>
- package org.cavaness.quartzbook.chapter10;
- import java.util.Date;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.quartz.JobDetail;
- import org.quartz.Scheduler;
- import org.quartz.SchedulerException;
- import org.quartz.Trigger;
- import org.quartz.TriggerUtils;
- import org.quartz.impl.StdSchedulerFactory;
- import org.quartz.jobs.ee.ejb.EJBInvokerJob;
- public class Listing_10_3 {
- static Log logger = LogFactory.getLog(Listing_10_3.class);
- public static void main(String[] args) {
- Listing_10_3 example = new Listing_10_3();
- try {
- // Create a Scheduler and schedule the Job
- Scheduler scheduler = example.createScheduler();
- example.scheduleJob(scheduler);
- // Start the Scheduler running
- scheduler.start();
- logger.info("Scheduler started at " + new Date());
- } catch (SchedulerException ex) {
- logger.error(ex);
- }
- }
- // Schedule the EJBInvokerJob
- private void scheduleJob(Scheduler scheduler)
- throws SchedulerException {
- // Create a JobDetail for the Job
- JobDetail jobDetail = new JobDetail("HelloWorldJob",
- Scheduler.DEFAULT_GROUP,
- org.quartz.jobs.ee.ejb.EJBInvokerJob.class);
- // Load all of the necessary EJB parameters
- loadJobDataMap(jobDetail);
- // Create a trigger that fires every 10 seconds, forever
- Trigger trigger = TriggerUtils.makeSecondlyTrigger(10);
- trigger.setName("helloWorldTrigger");
- // Start the trigger firing from now
- trigger.setStartTime(new Date());
- // Associate the trigger with the job in the scheduler
- scheduler.scheduleJob(jobDetail, trigger);
- }
- /*
- * Configure the EJB parameters in the JobDataMap
- * 在JobDataMap中配置EJB参数
- */
- public JobDetail loadJobDataMap(JobDetail jobDetail) {
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.EJB_JNDI_NAME_KEY, "ejb/Test");
- jobDetail.getJobDataMap().put(EJBInvokerJob.EJB_METHOD_KEY,
- "helloWorld");
- Object[] args = new Object[1];
- args[0] = " from Quartz";
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.EJB_ARGS_KEY, args);
- Class[] argTypes = new Class[1];
- argTypes[0] = java.lang.String.class;
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.EJB_ARG_TYPES_KEY, argTypes);
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.PROVIDER_URL, "127.0.0.1:4201");
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.INITIAL_CONTEXT_FACTORY,
- "org.openejb.client.RemoteInitialContextFactory");
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.PRINCIPAL, "system");
- jobDetail.getJobDataMap().put(
- EJBInvokerJob.CREDENTIALS, "manager");
- return jobDetail;
- }
- /*
- * return an instance of the Scheduler from the factory
- */
- public Scheduler createScheduler() throws SchedulerException {
- return StdSchedulerFactory.getDefaultScheduler();
- }
- }
EJBInvokerJob Parameters and Serialization<o:p></o:p> EJBInvokerJob参数与串行化<o:p></o:p> Because of the typical serialization problems that are associated with Java and distributed applications, you should stick to passing Strings and primitives to your EJB methods. If you need to pass more complex types, your code must serialize the objects between client and server properly. For more in-depth information on Java serialization, check out Sun's Serialization specification at http://java.sun.com/j2se/1.5.0/docs/guide/serialization. <o:p> </o:p> 由于典型的串行化问题都与JAVA分布式应用有关,所以你最好只传递字符串和基本类型到EJB方法中。如果你需要传递复杂类型你需要在客户端和服务器代码中恰当的串行化对象。更加深入的关于JAVA串行化的资料点击Sun的串行化规范:http://java.sun.com/j2se/1.5.0/docs/guide/serialization。 <o:p> </o:p> |
<o:p> </o:p>
Because Quartz needs to get a reference to the home and remote interfaces for the EJB, you need to deploy some J2EE client JARs with your external Quartz application. The JARs you need to add depend on which J2EE container you're using. If you're using WebLogic, for example, you'll probably just put the weblogic.jar with the Quartz application. For Geronimo, several are involved. Check with the server documentation to be sure.
<o:p> </o:p>
应为Quartz需要为EJB获取本地与远程的接口,你必须将一些J2EE客户端jar包导入到外部Quartz应用中。添加的Jar包依赖于你使用的J2EE容器。例如,如果你使用WebLogic你需要将weblogic.jar导入到Quartz应用中。如果使用Geronimo导入其他几个被调用的包。你需要查看服务器支持文档。
<o:p> </o:p>
Running Quartz Within the J2EE Application Server<o:p></o:p>
在J2EE应用服务器中部署Quartz<o:p></o:p>
Running Quartz as a J2EE client is a little more involved than running Quartz as an external J2SE application. This is mostly because deploying applications within the container is somewhat more complicated. In addition, the J2EE specification puts some constraints on components within the container. One of the biggest guidelines that the specification gives involves who and what can create Java threads. Because it's the container's responsibility to manage all resources, it can't allow just anything or anyone to create threads. If it did, it would have a harder time managing the environment and keeping things stable. Quartz creates its own worker threads, so you need to follow some steps to make sure things work properly.
<o:p> </o:p>
与作为外部J2SE应用相比将Quartz作为一个J2EE客户端比较复杂。这是因为在容器中部署应用就比较复杂。另外J2EE规范对容器内的组件加以约束。影响最大的准则是规范规定了谁或者什么可以创建JAVA线程。因为容器通过创建线程管理资源。所以不允许任何人或物私自创建线程。如果这样做了容器将不能管理环境也不能保持容器中事务的稳定。Quartz创建自己的工作线程。这样你就必须按下面的步骤配置以保证Quartz正常运行。
<o:p> </o:p>
Assume that a stateless session bean such as the one from Listing 10.1 is already deployed in the container. The easiest way to deploy Quartz within the container is to build a WAR file that contains all the necessary files and then use the admin tools, or Eclipse, to deploy the Web application within the container.
<o:p> </o:p>
加入要向容器中部署一个列表10.1那样的无状态会话bean。最简单的方法是将Quartz建立一个包含所有必要文件的war文件使用管理员工具或Eclipse将Web应用部署到容器中。
<o:p> </o:p>
The Web application directory structure is just like that of any other Web application. You need to add the following files to it:
<o:p> </o:p>
Web应用文件夹与其他Web应用相同。你需要相其中添加下面的文件。
<o:p> </o:p>
- web.xml (put in WEB-INF)
- quartz.properties (put in WEB-INF/classes)
- quartz_jobs.xml (put in WEB-INF/classes)
- Quartz binary (put in WEB-INF/lib)
- Third-party libraries (put in WEB-INF/lib)
Because you are building a Web application, you need to add the requisite web.xml deployment descriptor. Listing 10.4 shows the web.xml for our client application that will be installed within the container.
<o:p> </o:p>
因为你要建立Web应用。你必须添加Web.xml文件。列表10.4显示了将要部署到容器中的客户端应用的web.xml。
<o:p> </o:p>
Listing 10.4. The web.xml for the Quartz J2EE Client Application<o:p></o:p>
列表10.4 Quartz J2EE客户端应用的web.xml<o:p></o:p>
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app>
- <servlet>
- <servlet-name>QuartzServlet</servlet-name>
- <servlet-class>
- org.quartz.ee.servlet.QuartzInitializerServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>QuartzServlet</servlet-name>
- <url-pattern>/servlet/QuartzServlet</url-pattern>
- </servlet-mapping>
- </web-app>
The Quartz framework includes a Java servlet called QuartzInitializerServlet that, when invoked, initializes the Quartz Scheduler and loads job information. In Listing 10.4, we've set the <load-on-startup> parameter to have a value of 1 so the servlet will be loaded and initialized when the container is started. By using the servlet to start the Quartz Scheduler, we avoid the issues of thread permission because the container will allow servlets to create user threads.
<o:p> </o:p>
Quartz 包含一个Java Servlet(QuartzInitializerServlet)当它被用来初始化Quartz 的Scheduler并加载job信息。在列表10.4中我们设置<load-on-startup>参数为1,当容器初始化时这个servlet就会被加载并初始化。通过使用servlet启动Quartz Scheduler我们避免了线程权限问题,因为容器允许servlet创建用户权限。<o:p></o:p>
<o:p> </o:p>
QuartzInitializerListener Added to Quartz<o:p></o:p> 将QuartzInitializerListener添加到Quartz中<o:p></o:p> Recently, a new class called QuartzInitializerListener was added to Quartz that implements the javax.servlet.ServletContextListener interface. This class can be used as an alternative to the QuartzInitializerServlet mentioned earlier. 最近一个新类QuartzInitializerListener被添加到Quartz中改类实现javax.servlet.ServletContextListener接口,QuartzInitializerListener可以作为刚刚提到的QuartzInitializerServlet替代方案。 |
<o:p> </o:p>
Next, you need to put the standard quartz.properties file into the WEB-INF/classes directory of the Web application. There's nothing special about this version of the properties file; it's essentially what we did in past chapters. However, here we use the JobInitializationPlugin (this was shown in Chapter 8, "Using Quartz Plug-Ins," and is designed to load job information from an XML file). By default, the plug-in looks for a file called quartz_jobs.xml and loads the jobs found in the file. As Chapter 8 described, using this particular plug-in keeps you from having to write job-loading code and be forced to recompile when changes occur. The quartz_jobs.xml file for this example is shown in Listing 10.5.
<o:p> </o:p>
下一步你需要将quartz.properties文件添加到WEB-INF/classes文件夹中。Properties文件没有版本限制与我们在前面章节讲解的配置文件没有区别。然而,这里我们使用了JobInitializationPlugin(在第8章 使用Quartz插件 做详细讲解),它被设计用来从XML文件中加载Job信息。默认情况下,插件寻找quartz_jobs.xml文件并从中加载job信息。正如第8章描述的那样,这个特殊的插件使你不必编写job加载代码,也就不用在job发生改变时重新编译代码。这个例子的quartz_jobs.xml如列表10.5。
<o:p> </o:p>
Listing 10.5. The quartz_jobs.xml Used Within the J2EE Client<o:p></o:p>
列表10.5 在J2EE客户端使用的quartz_jobs.xml<o:p></o:p>
- <?xml version='1.0' encoding='utf-8'?>
- <quartz>
- <job>
- <job-detail>
- <name>HelloWorldJob</name>
- <group>DEFAULT</group>
- <job-class>org.quartz.jobs.ee.ejb.EJBInvokerJob</job-class>
- <volatility>false</volatility>
- <durability>false</durability>
- <recover>false</recover>
- <job-data-map allows-transient-data="true">
- <entry>
- <key>ejb</key>
- <value>ejb/Test</value>
- </entry>
- <entry>
- <key>java.naming.factory.initial</key>
- <value>org.openejb.client.RemoteInitialContextFactory</value>
- </entry>
- <entry>
- <key>java.naming.provider.url</key>
- <value>127.0.0.1:4201</value>
- </entry>
- <entry>
- <key>method</key>
- &nb
发表评论
-
JQuery CookBook翻译连载7(第四章)
2010-06-29 18:45 1038今天超级爆发,整理出来第四章中文版翻译。 -
JQuery CookBook翻译连载6(第三章)
2010-06-29 11:31 1020放出jQuery CookBook翻译的第三章。 最近找工作 ... -
JQuery CookBook 翻译连载6(第2章发布)
2010-06-01 14:15 957jQuery Cookbook第1、2章合订版。 不知 ... -
JQuery CookBook 翻译连载5(第1章发布)
2010-05-16 16:55 935jQuery cookBook 第一章翻译打包发布。 ... -
JQuery CookBook翻译连载1
2010-05-14 11:46 8251.1 在HTML页面中添加j ... -
JQuery CookBook翻译连载2
2010-05-14 11:45 8131.2 在页面DOM加载结束后、整个页面加载结束前执行jQue ... -
JQuery CookBook翻译连载3
2010-05-14 11:34 7171.3 使用选择器及jQuery函 ... -
JQuery CookBook翻译连载4
2010-05-14 11:09 6931.4 在特定的上下文 中查找元素 问 ... -
Quartz Job Scheduling Framework第11章翻译初稿
2007-10-27 15:21 1073内容在附件中 -
Quartz Job Scheduling Framework第7章翻译初稿
2007-10-27 15:18 1147内容在附件中 -
Quartz Job Scheduling Framework第5章翻译初稿
2007-10-27 15:18 982在附件中 -
Quartz Job Scheduling Framework第2章翻译初稿
2007-10-27 15:17 1159在附件中 -
Quartz Job Scheduling Framework第8章翻译初稿 续
2007-09-27 19:46 2192You can have as many properti ... -
Quartz Job Scheduling Framework第8章翻译初稿
2007-09-27 19:42 2638Chapter 8. Using Quartz Plug- ... -
Quartz Job Scheduling Framework翻译初稿奉上
2007-09-26 21:55 1614由于时间与水平限制。这本经典书籍翻译的可能并不尽如人意,在此先 ... -
Quartz Job Scheduling Framework第10章翻译初稿
2007-09-26 21:40 2636Chapter 10. Using Quartz with J ...
相关推荐
Quartz Job Scheduling Framework是一个强大的、开放源代码的作业调度框架,它使应用程序能够在指定的时间执行任务,无需人工干预。这个框架广泛应用于Java应用程序中,用于实现定时任务和工作流管理。在第11章中,...
在阅读《Quartz Job Scheduling Framework》第5章时,你会了解到如何创建和配置Cron Triggers,如何结合SimpleTrigger和CalendarIntervalTrigger实现不同类型的定时任务,以及如何优化Quartz的配置以适应大规模的...
Quartz Job Scheduling Framework第2章翻译初稿 博文链接:https://adamed.iteye.com/blog/135880
Quartz Job Scheduling Framework是一个强大的、开源的作业调度框架,用于在Java应用程序中安排任务执行。这个框架允许开发者创建和管理作业,以及定义作业的触发时间。第7章的主题聚焦于实现Quartz监听器,这是一个...
少儿编程scratch项目源代码文件案例素材-纸人伙计.zip
scratch少儿编程逻辑思维游戏源码-忍者罗伊 V5.zip
scratch少儿编程逻辑思维游戏源码-跑和枪.zip
前端开发_基于jQuery和EasyUI框架_企业级Web应用UI组件库与后台管理系统模板_提供GPL开源版本和商业授权版本的双重授权模式_适用于快速构建响应式管理后台和复杂数据可
少儿编程scratch项目源代码文件案例素材-纸格通关 云变量.zip
微信机器人开发_Wechaty框架_百度云主机部署_自然语言处理_消息自动化处理_多媒体文件管理_聊天记录持久化_表情包导出_语音视频自动保存_文件管理系统集成_跨平台数据同步_个
少儿编程scratch项目源代码文件案例素材-钻机机器人.zip
少儿编程scratch项目源代码文件案例素材-作战基地.zip
云计算_微服务分布式架构SpringCloudSpringBootDubboVuejs_互联网云快速开发框架敏捷开发系统代码生成工作流CMS图表统计地图统计_免费开源JAVA企业
scratch少儿编程逻辑思维游戏源码-日落塔.zip
Tobapuww_GPT-Recovery-Files_12888_1745866661386
少儿编程scratch项目源代码文件案例素材-战斗竞技场.zip
scratch少儿编程逻辑思维游戏源码-球球大作战.zip
聚合支付系统/官方个人免签系统/三方支付系统稳定安全高并发 附教程 系统采用FastAdmin框架独立全新开发,安全稳定,系统支持代理、商户、码商等业务逻辑。 针对最近一些JD,TB等业务定制,子账号业务逻辑API 非常详细,方便内置对接! IP白名单 业务逻辑 支持IP白名单,黑名单,全局白名单,全局黑名单,保障系统的安全。 接口验签名 采用支付宝RSA加密接口方式,防止篡改数据,导致对账困难,资金大量损失,无故少钱 对接灵活 全部对接参数灵活操作 风控完善 轮询、交易金额、随机金额、最大金额、最小金额等 测试环境: Nginx+PHP7.0+MySQL5.6 网站运行目录:/public 伪静态设置为:thinkphp规则 数据库信息修改路径:/application/database.php
校园社交服务_微信小程序云开发_公告资讯失物招领二手交易兼职招聘表白墙_为高校师生提供一站式校园生活服务平台包含校园动态通知课程表查询失物发布与认领二手物品交易平台兼职信息发布与求
yinghuayu2377_myFTPDemo_32152_1745866651913