Source Code Cross Referenced for TaskManager.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » task » 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.task 
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: TaskManager.java 473861 2006-11-12 03:51:14Z gregor $  */
020:
021:        package org.apache.lenya.cms.task;
022:
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.util.HashMap;
026:        import java.util.Map;
027:
028:        import org.apache.avalon.framework.configuration.Configurable;
029:        import org.apache.avalon.framework.configuration.Configuration;
030:        import org.apache.avalon.framework.configuration.ConfigurationException;
031:        import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
032:        import org.apache.avalon.framework.service.ServiceManager;
033:        import org.apache.log4j.Logger;
034:        import org.xml.sax.SAXException;
035:
036:        /**
037:         * The task manager
038:         * @deprecated Use the usecase framework instead.
039:         */
040:        public class TaskManager implements  Configurable {
041:            private static Logger log = Logger.getLogger(TaskManager.class);
042:            /**
043:             * <code>TASK_ELEMENT</code> The task element
044:             */
045:            public static final String TASK_ELEMENT = "task";
046:            /**
047:             * <code>TASK_ID_ATTRIBUTE</code> The task id attribute
048:             */
049:            public static final String TASK_ID_ATTRIBUTE = "id";
050:            /**
051:             * <code>CONFIGURATION_FILE</code> The path to the configuration file
052:             */
053:            public static final String CONFIGURATION_FILE = File.separator
054:                    + "config" + File.separator + "tasks" + File.separator
055:                    + "tasks.xconf";
056:
057:            /**
058:             * <code>EMTPY_TASK</code> Constant for an empty task
059:             */
060:            public static final String EMTPY_TASK = "empty";
061:            /**
062:             * <code>ANT_TASK</code> Constant for an ant task
063:             */
064:            public static final String ANT_TASK = "ant";
065:
066:            // maps task-ids to tasks
067:            private Map tasks = new HashMap();
068:
069:            private ServiceManager manager;
070:
071:            /**
072:             * Creates a new TaskManager object.
073:             * @param manager The service manager to use.
074:             */
075:            public TaskManager(ServiceManager manager) {
076:                this .manager = manager;
077:            }
078:
079:            /**
080:             * Creates a new instance of TaskManager
081:             * @param publicationPath path to publication
082:             * @param manager The service manager to use.
083:             * @throws ConfigurationException if the configuration failed.
084:             * @throws SAXException when parsing the config file failed.
085:             * @throws IOException when an I/O error occured.
086:             */
087:            public TaskManager(String publicationPath, ServiceManager manager)
088:                    throws ConfigurationException, SAXException, IOException {
089:                this (manager);
090:
091:                String configurationFilePath = publicationPath
092:                        + CONFIGURATION_FILE;
093:                log.debug("Loading tasks: " + configurationFilePath);
094:
095:                File configurationFile = new File(configurationFilePath);
096:
097:                if (configurationFile.isFile()) {
098:                    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
099:                    Configuration configuration = builder
100:                            .buildFromFile(configurationFile);
101:                    configure(configuration);
102:
103:                } else {
104:                    log.info("Task configuration not loaded - file ["
105:                            + configurationFile.getAbsolutePath()
106:                            + "] does not exist.");
107:                }
108:
109:                Task empty = new EmptyTask();
110:                empty.service(this .manager);
111:                this .tasks.put(EMTPY_TASK, empty);
112:
113:                Task ant = new AntTask();
114:                ant.service(this .manager);
115:                this .tasks.put(ANT_TASK, ant);
116:            }
117:
118:            /**
119:             * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
120:             */
121:            public void configure(Configuration configuration)
122:                    throws ConfigurationException {
123:                log.debug("Creating tasks:");
124:
125:                // create task list
126:                Configuration[] taskConfigurations = configuration
127:                        .getChildren(TASK_ELEMENT);
128:
129:                // set task IDs
130:                for (int i = 0; i < taskConfigurations.length; i++) {
131:                    String taskId = taskConfigurations[i]
132:                            .getAttribute(TASK_ID_ATTRIBUTE);
133:                    log.debug("Creating task '" + taskId + "'");
134:
135:                    Task task = TaskFactory.getInstance().createTask(
136:                            taskConfigurations[i]);
137:                    task.service(this .manager);
138:                    this .tasks.put(taskId, task);
139:                }
140:            }
141:
142:            /**
143:             * Return all task ids
144:             * @return The task ids
145:             */
146:            public String[] getTaskIds() {
147:                return (String[]) this .tasks.keySet().toArray(
148:                        new String[this .tasks.size()]);
149:            }
150:
151:            /**
152:             * Get the task with a given task-id
153:             * @param taskId the task-id of the requested task
154:             * @return the task
155:             * @throws ExecutionException if there is no task with the given task-id.
156:             */
157:            public Task getTask(String taskId) throws ExecutionException {
158:                if (!this .tasks.containsKey(taskId)) {
159:                    throw new ExecutionException("Task with ID '" + taskId
160:                            + "' not found!");
161:                }
162:
163:                return (Task) this.tasks.get(taskId);
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.