Source Code Cross Referenced for ScheduledJobLoader.java in  » Web-Framework » TURBINE » org » apache » turbine » modules » 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 » Web Framework » TURBINE » org.apache.turbine.modules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.modules;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.List;
023:
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:
027:        import org.apache.turbine.Turbine;
028:        import org.apache.turbine.TurbineConstants;
029:        import org.apache.turbine.services.assemblerbroker.AssemblerBrokerService;
030:        import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
031:        import org.apache.turbine.services.schedule.JobEntry;
032:        import org.apache.turbine.util.ObjectUtils;
033:        import org.apache.turbine.util.RunData;
034:
035:        /**
036:         * ScheduledJobs loader class.
037:         *
038:         * @author <a href="mailto:mbryson@mindspring.com">Dave Bryson</a>
039:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
040:         * @version $Id: ScheduledJobLoader.java 534527 2007-05-02 16:10:59Z tv $
041:         */
042:        public class ScheduledJobLoader extends GenericLoader {
043:            /** Serial Version UID */
044:            private static final long serialVersionUID = 7207944483452185019L;
045:
046:            /** Logging */
047:            private static Log log = LogFactory
048:                    .getLog(ScheduledJobLoader.class);
049:
050:            /** The single instance of this class. */
051:            private static ScheduledJobLoader instance = new ScheduledJobLoader(
052:                    Turbine.getConfiguration().getInt(
053:                            TurbineConstants.SCHEDULED_JOB_CACHE_SIZE_KEY,
054:                            TurbineConstants.SCHEDULED_JOB_CACHE_SIZE_DEFAULT));
055:
056:            /** The Assembler Broker Service */
057:            private static AssemblerBrokerService ab = TurbineAssemblerBroker
058:                    .getService();
059:
060:            /**
061:             * These ctor's are private to force clients to use getInstance()
062:             * to access this class.
063:             */
064:            private ScheduledJobLoader() {
065:                super ();
066:            }
067:
068:            /**
069:             * These ctor's are private to force clients to use getInstance()
070:             * to access this class.
071:             */
072:            private ScheduledJobLoader(int i) {
073:                super (i);
074:            }
075:
076:            /**
077:             * Adds an instance of an object into the hashtable.
078:             *
079:             * @param name Name of object.
080:             * @param job Job to be associated with name.
081:             */
082:            private void addInstance(String name, ScheduledJob job) {
083:                if (cache()) {
084:                    this .put(name, (ScheduledJob) job);
085:                }
086:            }
087:
088:            /**
089:             * Attempts to load and execute the external ScheduledJob.
090:             *
091:             * @param job The JobEntry.
092:             * @param name Name of object that will execute the job.
093:             * @exception Exception a generic exception.
094:             */
095:            public void exec(JobEntry job, String name) throws Exception {
096:                // Execute job
097:                getInstance(name).run(job);
098:            }
099:
100:            /**
101:             * Attempts to load and execute the external ScheduledJob.
102:             *
103:             * HELP! - THIS IS UGLY!
104:             *
105:             * I want the cache stuff from GenericLoader, BUT, I don't think
106:             * the scheduler needs the Rundata object.  The scheduler runs
107:             * independently of an HTTP request.  This should not extend
108:             * GenericLoader!  Thoughts??
109:             *
110:             * @param data Turbine information.
111:             * @param name Name of object that will execute the job.
112:             * @exception Exception a generic exception.
113:             */
114:            public void exec(RunData data, String name) throws Exception {
115:                throw new Exception(
116:                        "RunData objects not accepted for Scheduled jobs");
117:            }
118:
119:            /**
120:             * Pulls out an instance of the object by name.  Name is just the
121:             * single name of the object.
122:             *
123:             * @param name Name of object instance.
124:             * @return An ScheduledJob with the specified name, or null.
125:             * @exception Exception a generic exception.
126:             */
127:            public ScheduledJob getInstance(String name) throws Exception {
128:                ScheduledJob job = null;
129:
130:                // Check if the screen is already in the cache
131:                if (cache() && this .containsKey(name)) {
132:                    job = (ScheduledJob) this .get(name);
133:                    log.debug("Found Job " + name + " in the cache!");
134:                } else {
135:                    log.debug("Loading Job " + name
136:                            + " from the Assembler Broker");
137:
138:                    try {
139:                        if (ab != null) {
140:                            // Attempt to load the job
141:                            job = (ScheduledJob) ab.getAssembler(
142:                                    AssemblerBrokerService.SCHEDULEDJOB_TYPE,
143:                                    name);
144:                        }
145:                    } catch (ClassCastException cce) {
146:                        // This can alternatively let this exception be thrown
147:                        // So that the ClassCastException is shown in the
148:                        // browser window.  Like this it shows "Screen not Found"
149:                        job = null;
150:                    }
151:
152:                    if (job == null) {
153:                        // If we did not find a screen we should try and give
154:                        // the user a reason for that...
155:                        // FIX ME: The AssemblerFactories should each add it's
156:                        // own string here...
157:                        List packages = Turbine.getConfiguration().getList(
158:                                TurbineConstants.MODULE_PACKAGES);
159:
160:                        ObjectUtils.addOnce(packages, GenericLoader
161:                                .getBasePackage());
162:
163:                        throw new ClassNotFoundException(
164:                                "\n\n\tRequested ScheduledJob not found: "
165:                                        + name
166:                                        + "\n\tTurbine looked in the following "
167:                                        + "modules.packages path: \n\t"
168:                                        + packages.toString() + "\n");
169:                    } else if (cache()) {
170:                        // The new instance is added to the cache
171:                        addInstance(name, job);
172:                    }
173:                }
174:                return job;
175:            }
176:
177:            /**
178:             * The method through which this class is accessed.
179:             *
180:             * @return The single instance of this class.
181:             */
182:            public static ScheduledJobLoader getInstance() {
183:                return instance;
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.