Source Code Cross Referenced for ServletJob.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » scheduler » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.lenya.cms.scheduler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        /* $Id: ServletJob.java 473861 2006-11-12 03:51:14Z gregor $  */
020:
021:        package org.apache.lenya.cms.scheduler;
022:
023:        import javax.servlet.http.HttpServletRequest;
024:
025:        import org.apache.lenya.util.NamespaceMap;
026:        import org.apache.lenya.xml.NamespaceHelper;
027:        import org.apache.log4j.Logger;
028:        import org.quartz.Job;
029:        import org.quartz.JobDataMap;
030:        import org.quartz.JobDetail;
031:        import org.quartz.SchedulerException;
032:        import org.w3c.dom.DOMException;
033:        import org.w3c.dom.Element;
034:
035:        /**
036:         * Scheduling job that uses an HttpServletRequest to obtain its Job data.
037:         */
038:        public abstract class ServletJob implements  Job {
039:
040:            private static Logger log = Logger.getLogger(ServletJob.class);
041:
042:            /**
043:             * <code>ELEMENT_JOB</code> The job element
044:             */
045:            public static final String ELEMENT_JOB = "job";
046:            /**
047:             * <code>ATTRIBUTE_ID</code> The id attribute
048:             */
049:            public static final String ATTRIBUTE_ID = "id";
050:            /**
051:             * <code>ATTRIBUTE_CLASS</code> The class attribute
052:             */
053:            public static final String ATTRIBUTE_CLASS = "class";
054:            /**
055:             * <code>ATTRIBUTE_DOCUMENT_URL</code> The document url attribute
056:             */
057:            public static final String ATTRIBUTE_DOCUMENT_URL = "url";
058:            /**
059:             * <code>ATTRIBUTE_SERVLET_CONTEXT</code> The servlet context attribute
060:             */
061:            public static final String ATTRIBUTE_SERVLET_CONTEXT = "servletcontext";
062:            /**
063:             * <code>PARAMETER_DOCUMENT_URL</code> The document URL parameter
064:             */
065:            public static final String PARAMETER_DOCUMENT_URL = "document-url";
066:
067:            /**
068:             * Creates the job data from an HTTP request.
069:             * @param request The request.
070:             * @return A job data map.
071:             * @throws SchedulerException when something went wrong.
072:             */
073:            public JobDataMap createJobData(HttpServletRequest request)
074:                    throws SchedulerException {
075:                JobDataMap map = new JobDataMap();
076:                String key = NamespaceMap.getFullName(LoadQuartzServlet.PREFIX,
077:                        PARAMETER_DOCUMENT_URL);
078:                String documentUrl = request.getParameter(key);
079:                if (documentUrl == null) {
080:                    throw new SchedulerException(
081:                            "Document URL must not be null!");
082:                }
083:                map.put(key, documentUrl);
084:                return map;
085:            }
086:
087:            /**
088:             * Loads the job data from an XML element.
089:             * @param element An XML element.
090:             * @param jobGroup The job group the job belongs to.
091:             * @param servletContextPath The servlet context path.
092:             * @return A job detail object.
093:             * @throws SchedulerException when something went wrong.
094:             */
095:            public JobDetail load(Element element, String jobGroup,
096:                    String servletContextPath) throws SchedulerException {
097:                String jobId = element.getAttribute(ATTRIBUTE_ID);
098:                JobDetail jobDetail = new JobDetail(jobId, jobGroup, getClass());
099:                return jobDetail;
100:
101:            }
102:
103:            /**
104:             * Saves the job data to an XML element.
105:             * @param helper The namespace helper of the document the element shall belong to.
106:             * @param jobDetail The job detail to save.
107:             * @return An XML element.
108:             * @throws SchedulerException when something went wrong.
109:             */
110:            public Element save(NamespaceHelper helper, JobDetail jobDetail)
111:                    throws SchedulerException {
112:                log.debug("Saving job");
113:
114:                try {
115:                    Element jobElement = helper.createElement(ELEMENT_JOB);
116:                    jobElement.setAttribute(ATTRIBUTE_ID, jobDetail.getName());
117:                    jobElement.setAttribute(ATTRIBUTE_CLASS, getClass()
118:                            .getName());
119:
120:                    String documentUrl = getDocumentUrl(jobDetail);
121:                    jobElement
122:                            .setAttribute(ATTRIBUTE_DOCUMENT_URL, documentUrl);
123:
124:                    return jobElement;
125:                } catch (final DOMException e) {
126:                    log.error("" + e.toString());
127:                    throw new SchedulerException(e);
128:                }
129:            }
130:
131:            /**
132:             * Returns the document URL of a certain job.
133:             * @param jobDetail The job detail.
134:             * @return A string.
135:             */
136:            public String getDocumentUrl(JobDetail jobDetail) {
137:                JobDataMap map = jobDetail.getJobDataMap();
138:                NamespaceMap wrapper = new NamespaceMap(map,
139:                        LoadQuartzServlet.PREFIX);
140:                String documentUrl = (String) wrapper
141:                        .get(PARAMETER_DOCUMENT_URL);
142:                return documentUrl;
143:            }
144:
145:            /**
146:             * Sets the document URL of a job.
147:             * @param jobDetail The job detail.
148:             * @param url The URL.
149:             */
150:            public void setDocumentUrl(JobDetail jobDetail, String url) {
151:                JobDataMap map = jobDetail.getJobDataMap();
152:                NamespaceMap wrapper = new NamespaceMap(map,
153:                        LoadQuartzServlet.PREFIX);
154:                wrapper.put(PARAMETER_DOCUMENT_URL, url);
155:                jobDetail.setJobDataMap(map);
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.