Sat, 31 Mar 2018 19:35:04 +0200
module synchronization with database
6 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2017 Mike Becker. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | * | |
28 | */ | |
29 | package de.uapcore.lightpit; | |
30 | ||
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
31 | import java.sql.Connection; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
32 | import java.sql.PreparedStatement; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
33 | import java.sql.ResultSet; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
34 | import java.sql.SQLException; |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
35 | import java.util.ArrayList; |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
36 | import java.util.Collections; |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
37 | import java.util.HashMap; |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
38 | import java.util.List; |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
39 | import java.util.Map; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
40 | import java.util.Map.Entry; |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
41 | import java.util.Optional; |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
42 | import java.util.concurrent.CopyOnWriteArrayList; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
43 | import java.util.concurrent.atomic.AtomicBoolean; |
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
44 | import javax.servlet.Registration; |
6 | 45 | import javax.servlet.ServletContext; |
46 | import javax.servlet.ServletContextEvent; | |
47 | import javax.servlet.ServletContextListener; | |
48 | import javax.servlet.annotation.WebListener; | |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
49 | import org.slf4j.Logger; |
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
50 | import org.slf4j.LoggerFactory; |
6 | 51 | |
52 | /** | |
53 | * Scans registered servlets for LightPIT modules. | |
54 | */ | |
55 | @WebListener | |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
56 | public final class ModuleManager implements ServletContextListener { |
6 | 57 | |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
58 | private static final Logger LOG = LoggerFactory.getLogger(ModuleManager.class); |
6 | 59 | |
60 | /** | |
61 | * The attribute name in the servlet context under which an instance of this class can be found. | |
62 | */ | |
63 | public static final String SC_ATTR_NAME = ModuleManager.class.getName(); | |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
64 | private ServletContext sc; |
6 | 65 | |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
66 | /** |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
67 | * This flag is true, when synchronization is needed. |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
68 | */ |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
69 | private AtomicBoolean dirty = new AtomicBoolean(true); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
70 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
71 | private final CopyOnWriteArrayList<Menu> mainMenu = new CopyOnWriteArrayList<>(); |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
72 | private final List<Menu> immutableMainMenu = Collections.unmodifiableList(mainMenu); |
6 | 73 | |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
74 | /** |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
75 | * Maps class names to module information. |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
76 | */ |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
77 | private final Map<String, LightPITModule> registeredModules = new HashMap<>(); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
78 | |
6 | 79 | @Override |
80 | public void contextInitialized(ServletContextEvent sce) { | |
81 | sc = sce.getServletContext(); | |
82 | reloadAll(); | |
83 | sc.setAttribute(SC_ATTR_NAME, this); | |
84 | LOG.info("Module manager injected into ServletContext."); | |
85 | } | |
86 | ||
87 | @Override | |
88 | public void contextDestroyed(ServletContextEvent sce) { | |
89 | unloadAll(); | |
90 | } | |
91 | ||
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
92 | private Optional<LightPITModule> getModuleInfo(Registration reg) { |
6 | 93 | try { |
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
94 | final Class scclass = Class.forName(reg.getClassName()); |
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
95 | |
9
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
96 | final boolean lpservlet = AbstractLightPITServlet.class.isAssignableFrom(scclass); |
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
97 | final boolean lpmodule = scclass.isAnnotationPresent(LightPITModule.class); |
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
98 | |
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
99 | if (lpservlet && !lpmodule) { |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
100 | LOG.warn( |
9
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
101 | "{} is a LightPIT Servlet but is missing the module annotation.", |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
102 | reg.getClassName() |
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
103 | ); |
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
104 | } else if (!lpservlet && lpmodule) { |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
105 | LOG.warn( |
9
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
106 | "{} is annotated as a LightPIT Module but does not extend {}.", |
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
107 | reg.getClassName(), |
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
108 | AbstractLightPITServlet.class.getSimpleName() |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
109 | ); |
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
110 | } |
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
111 | |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
112 | if (lpservlet && lpmodule) { |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
113 | final Class<? extends AbstractLightPITServlet> clazz = scclass; |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
114 | final LightPITModule moduleInfo = clazz.getAnnotation(LightPITModule.class); |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
115 | return Optional.of(moduleInfo); |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
116 | } else { |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
117 | return Optional.empty(); |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
118 | } |
6 | 119 | } catch (ClassNotFoundException ex) { |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
120 | LOG.error( |
9
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
121 | "Servlet registration refers to class {} which cannot be found by the class loader (Reason: {})", |
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
122 | reg.getClassName(), |
20a9b2bc9063
makes LightPITServlet abstract
Mike Becker <universe@uap-core.de>
parents:
8
diff
changeset
|
123 | ex.getMessage() |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
124 | ); |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
125 | return Optional.empty(); |
6 | 126 | } |
127 | } | |
128 | ||
7
598670d5b0b8
core functionality should also use the modules system, changed the code structure accordingly
Mike Becker <universe@uap-core.de>
parents:
6
diff
changeset
|
129 | private void handleServletRegistration(String name, Registration reg) { |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
130 | final Optional<LightPITModule> moduleInfo = getModuleInfo(reg); |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
131 | if (moduleInfo.isPresent()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
132 | registeredModules.put(reg.getClassName(), moduleInfo.get()); |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
133 | LOG.info("Module detected: {}", name); |
6 | 134 | } else { |
8
2dfdb79b5344
adds slf4j to project as netbeans library (make sure to have it configured in your environment)
Mike Becker <universe@uap-core.de>
parents:
7
diff
changeset
|
135 | LOG.debug("Servlet {} is no module, skipping.", name); |
6 | 136 | } |
137 | } | |
138 | ||
139 | /** | |
140 | * Scans for modules and reloads them all. | |
141 | */ | |
142 | public void reloadAll() { | |
143 | sc.getServletRegistrations().forEach(this::handleServletRegistration); | |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
144 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
145 | // TODO: implement dependency resolver |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
146 | |
6 | 147 | LOG.info("Modules loaded."); |
148 | } | |
149 | ||
150 | /** | |
20
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
151 | * Synchronizes module information with the database. |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
152 | * |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
153 | * @param db interface to the database |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
154 | */ |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
155 | public void syncWithDatabase(DatabaseFacade db) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
156 | if (dirty.compareAndSet(true, false)) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
157 | if (db.getDataSource().isPresent()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
158 | try (Connection conn = db.getDataSource().get().getConnection()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
159 | PreparedStatement |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
160 | check = conn.prepareStatement("SELECT visible FROM lpitcore_module WHERE classname = ?"), |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
161 | insert = conn.prepareStatement("INSERT INTO lpitcore_module (classname, visible) VALUES (?, ?)"); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
162 | insert.setBoolean(2, true); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
163 | // update/delete not required, we do this in the module management UI |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
164 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
165 | final List<Menu> updatedMenu = new ArrayList<>(); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
166 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
167 | for (Entry<String, LightPITModule> mod : registeredModules.entrySet()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
168 | if (mod.getValue().systemModule()) continue; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
169 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
170 | check.setString(1, mod.getKey()); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
171 | try (ResultSet r = check.executeQuery()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
172 | final boolean addToMenu; |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
173 | if (r.next()) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
174 | addToMenu = r.getBoolean(1); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
175 | } else { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
176 | insert.setString(1, mod.getKey()); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
177 | insert.executeUpdate(); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
178 | addToMenu = !mod.getValue().menuKey().isEmpty(); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
179 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
180 | if (addToMenu) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
181 | updatedMenu.add(new Menu( |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
182 | mod.getKey(), |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
183 | new ResourceKey(mod.getValue().bundleBaseName(), mod.getValue().menuKey()), |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
184 | mod.getValue().modulePath() |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
185 | )); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
186 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
187 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
188 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
189 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
190 | mainMenu.removeIf((e) -> !updatedMenu.contains(e)); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
191 | mainMenu.addAllAbsent(updatedMenu); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
192 | } catch (SQLException ex) { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
193 | LOG.error("Unexpected SQL Exception", ex); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
194 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
195 | } else { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
196 | LOG.warn("No datasource present. Cannot sync module information with database."); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
197 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
198 | } else { |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
199 | LOG.debug("Module information clean - no synchronization required."); |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
200 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
201 | } |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
202 | |
bd1a76c91d5b
module synchronization with database
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
203 | /** |
6 | 204 | * Unloads all found modules. |
205 | */ | |
206 | public void unloadAll() { | |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
207 | mainMenu.clear(); |
6 | 208 | LOG.info("All modules unloaded."); |
209 | } | |
10
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
210 | |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
211 | /** |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
212 | * Returns the main menu. |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
213 | * @return a list of menus belonging to the main menu |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
214 | */ |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
215 | public List<Menu> getMainMenu() { |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
216 | return immutableMainMenu; |
89e3e6e28b69
implements automatic menu generation from module information
Mike Becker <universe@uap-core.de>
parents:
9
diff
changeset
|
217 | } |
6 | 218 | } |