1 package com.atlassian.plugin.impl;
2
3 import java.io.InputStream;
4 import java.net.URL;
5 import java.util.Collection;
6 import java.util.Date;
7 import java.util.List;
8 import java.util.Set;
9
10 import org.apache.commons.lang.Validate;
11
12 import com.atlassian.plugin.AutowireCapablePlugin;
13 import com.atlassian.plugin.ModuleDescriptor;
14 import com.atlassian.plugin.Plugin;
15 import com.atlassian.plugin.PluginInformation;
16 import com.atlassian.plugin.PluginState;
17 import com.atlassian.plugin.Resourced;
18 import com.atlassian.plugin.elements.ResourceDescriptor;
19 import com.atlassian.plugin.elements.ResourceLocation;
20
21
22
23
24
25
26
27
28 public abstract class AbstractDelegatingPlugin implements Plugin, Comparable<Plugin>, AutowireCapablePlugin
29 {
30 private final Plugin delegate;
31
32 public AbstractDelegatingPlugin(final Plugin delegate)
33 {
34 Validate.notNull(delegate);
35 this.delegate = delegate;
36 }
37
38 public int getPluginsVersion()
39 {
40 return delegate.getPluginsVersion();
41 }
42
43 public void setPluginsVersion(final int version)
44 {
45 delegate.setPluginsVersion(version);
46 }
47
48 public String getName()
49 {
50 return delegate.getName();
51 }
52
53 public void setName(final String name)
54 {
55 delegate.setName(name);
56 }
57
58 public String getI18nNameKey()
59 {
60 return delegate.getI18nNameKey();
61 }
62
63 public void setI18nNameKey(final String i18nNameKey)
64 {
65 delegate.setI18nNameKey(i18nNameKey);
66 }
67
68 public String getKey()
69 {
70 return delegate.getKey();
71 }
72
73 public void setKey(final String aPackage)
74 {
75 delegate.setKey(aPackage);
76 }
77
78 public void addModuleDescriptor(final ModuleDescriptor<?> moduleDescriptor)
79 {
80 delegate.addModuleDescriptor(moduleDescriptor);
81 }
82
83 public Collection<ModuleDescriptor<?>> getModuleDescriptors()
84 {
85 return delegate.getModuleDescriptors();
86 }
87
88 public ModuleDescriptor<?> getModuleDescriptor(final String key)
89 {
90 return delegate.getModuleDescriptor(key);
91 }
92
93 public <M> List<ModuleDescriptor<M>> getModuleDescriptorsByModuleClass(final Class<M> moduleClass)
94 {
95 return delegate.getModuleDescriptorsByModuleClass(moduleClass);
96 }
97
98 public boolean isEnabledByDefault()
99 {
100 return delegate.isEnabledByDefault();
101 }
102
103 public void setEnabledByDefault(final boolean enabledByDefault)
104 {
105 delegate.setEnabledByDefault(enabledByDefault);
106 }
107
108 public PluginInformation getPluginInformation()
109 {
110 return delegate.getPluginInformation();
111 }
112
113 public void setPluginInformation(final PluginInformation pluginInformation)
114 {
115 delegate.setPluginInformation(pluginInformation);
116 }
117
118 public void setResources(final Resourced resources)
119 {
120 delegate.setResources(resources);
121 }
122
123 public PluginState getPluginState()
124 {
125 return delegate.getPluginState();
126 }
127
128 public boolean isEnabled()
129 {
130 return delegate.isEnabled();
131 }
132
133 public boolean isSystemPlugin()
134 {
135 return delegate.isSystemPlugin();
136 }
137
138 public boolean containsSystemModule()
139 {
140 return delegate.containsSystemModule();
141 }
142
143 public void setSystemPlugin(final boolean system)
144 {
145 delegate.setSystemPlugin(system);
146 }
147
148 public boolean isBundledPlugin()
149 {
150 return delegate.isBundledPlugin();
151 }
152
153 public Date getDateLoaded()
154 {
155 return delegate.getDateLoaded();
156 }
157
158 public boolean isUninstallable()
159 {
160 return delegate.isUninstallable();
161 }
162
163 public boolean isDeleteable()
164 {
165 return delegate.isDeleteable();
166 }
167
168 public boolean isDynamicallyLoaded()
169 {
170 return delegate.isDynamicallyLoaded();
171 }
172
173 public <T> Class<T> loadClass(final String clazz, final Class<?> callingClass) throws ClassNotFoundException
174 {
175 return delegate.loadClass(clazz, callingClass);
176 }
177
178 public ClassLoader getClassLoader()
179 {
180 return delegate.getClassLoader();
181 }
182
183 public URL getResource(final String path)
184 {
185 return delegate.getResource(path);
186 }
187
188 public InputStream getResourceAsStream(final String name)
189 {
190 return delegate.getResourceAsStream(name);
191 }
192
193 public void setEnabled(final boolean enabled)
194 {
195 delegate.setEnabled(enabled);
196 }
197
198 public void close()
199 {
200 delegate.close();
201 }
202
203 public void install()
204 {
205 delegate.install();
206 }
207
208 public void uninstall()
209 {
210 delegate.uninstall();
211 }
212
213 public void enable()
214 {
215 delegate.enable();
216 }
217
218 public void disable()
219 {
220 delegate.disable();
221 }
222
223 public Set<String> getRequiredPlugins()
224 {
225 return delegate.getRequiredPlugins();
226 }
227
228 public List<ResourceDescriptor> getResourceDescriptors()
229 {
230 return delegate.getResourceDescriptors();
231 }
232
233 public List<ResourceDescriptor> getResourceDescriptors(final String type)
234 {
235 return delegate.getResourceDescriptors(type);
236 }
237
238 public ResourceDescriptor getResourceDescriptor(final String type, final String name)
239 {
240 return delegate.getResourceDescriptor(type, name);
241 }
242
243 public ResourceLocation getResourceLocation(final String type, final String name)
244 {
245 return delegate.getResourceLocation(type, name);
246 }
247
248 public int compareTo(final Plugin o)
249 {
250 return delegate.compareTo(o);
251 }
252
253 public Plugin getDelegate()
254 {
255 return delegate;
256 }
257
258 @Override
259 public String toString()
260 {
261 return delegate.toString();
262 }
263
264
265
266
267
268
269 public <T> T autowire(final Class<T> clazz) throws UnsupportedOperationException
270 {
271 if (delegate instanceof AutowireCapablePlugin)
272 {
273 return ((AutowireCapablePlugin) delegate).autowire(clazz);
274 }
275 else
276 {
277 throw new UnsupportedOperationException("The AutowireCapablePlugin interface is not implemented by the " + "delegate '" + delegate.getClass().getSimpleName() + "'");
278 }
279 }
280
281
282
283
284
285
286 public <T> T autowire(final Class<T> clazz, final AutowireStrategy autowireStrategy) throws UnsupportedOperationException
287 {
288 if (delegate instanceof AutowireCapablePlugin)
289 {
290 return ((AutowireCapablePlugin) delegate).autowire(clazz, autowireStrategy);
291 }
292 else
293 {
294 throw new UnsupportedOperationException("The AutowireCapablePlugin interface is not implemented by the " + "delegate '" + delegate.getClass().getSimpleName() + "'");
295 }
296 }
297
298
299
300
301
302
303 public void autowire(final Object instance) throws UnsupportedOperationException
304 {
305 if (delegate instanceof AutowireCapablePlugin)
306 {
307 ((AutowireCapablePlugin) delegate).autowire(instance);
308 }
309 else
310 {
311 throw new UnsupportedOperationException("The AutowireCapablePlugin interface is not implemented by the " + "delegate '" + delegate.getClass().getSimpleName() + "'");
312 }
313 }
314
315
316
317
318
319
320 public void autowire(final Object instance, final AutowireStrategy autowireStrategy) throws UnsupportedOperationException
321 {
322 if (delegate instanceof AutowireCapablePlugin)
323 {
324 ((AutowireCapablePlugin) delegate).autowire(instance, autowireStrategy);
325 }
326 else
327 {
328 throw new UnsupportedOperationException("The AutowireCapablePlugin interface is not implemented by the " + "delegate '" + delegate.getClass().getSimpleName() + "'");
329 }
330 }
331
332 public Set<String> getPermissions()
333 {
334 return delegate.getPermissions();
335 }
336 }