5598 |
30 Mar 11 |
nicklas |
1 |
/** |
5598 |
30 Mar 11 |
nicklas |
$Id$ |
5598 |
30 Mar 11 |
nicklas |
3 |
|
5598 |
30 Mar 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5598 |
30 Mar 11 |
nicklas |
5 |
|
5598 |
30 Mar 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5598 |
30 Mar 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5598 |
30 Mar 11 |
nicklas |
8 |
|
5598 |
30 Mar 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5598 |
30 Mar 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5598 |
30 Mar 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5598 |
30 Mar 11 |
nicklas |
of the License, or (at your option) any later version. |
5598 |
30 Mar 11 |
nicklas |
13 |
|
5598 |
30 Mar 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5598 |
30 Mar 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5598 |
30 Mar 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5598 |
30 Mar 11 |
nicklas |
GNU General Public License for more details. |
5598 |
30 Mar 11 |
nicklas |
18 |
|
5598 |
30 Mar 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5598 |
30 Mar 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5598 |
30 Mar 11 |
nicklas |
21 |
*/ |
5598 |
30 Mar 11 |
nicklas |
22 |
package net.sf.basedb.util.extensions.manager; |
5598 |
30 Mar 11 |
nicklas |
23 |
|
5602 |
07 Apr 11 |
nicklas |
24 |
import net.sf.basedb.util.extensions.manager.ExtensionsFile.WriteableExtensionsFile; |
5602 |
07 Apr 11 |
nicklas |
25 |
|
5598 |
30 Mar 11 |
nicklas |
26 |
/** |
5598 |
30 Mar 11 |
nicklas |
Interface that is used to request a callback for each extensions file |
5598 |
30 Mar 11 |
nicklas |
managed by an extensions manager. Implementations are more or less free |
5598 |
30 Mar 11 |
nicklas |
to do whatever they want with the file. Typically, they will scan the |
5598 |
30 Mar 11 |
nicklas |
XML metadata or the contents of a JAR file and do something with it. |
5598 |
30 Mar 11 |
nicklas |
<p> |
5598 |
30 Mar 11 |
nicklas |
32 |
|
5598 |
30 Mar 11 |
nicklas |
A processer implementation is used by calling {@link |
5598 |
30 Mar 11 |
nicklas |
ExtensionsManager#processFiles(ExtensionsFileProcessor)}. |
5598 |
30 Mar 11 |
nicklas |
<p> |
5598 |
30 Mar 11 |
nicklas |
36 |
|
5598 |
30 Mar 11 |
nicklas |
The manager will first call {@link #begin(ExtensionsManager, int)} and |
5823 |
24 Oct 11 |
nicklas |
then {@link #processFile(ExtensionsManager, ExtensionsFile.WriteableExtensionsFile)} for each |
5598 |
30 Mar 11 |
nicklas |
file that has been confirmed to contain a valid extension definitions |
5598 |
30 Mar 11 |
nicklas |
file. If all files could be processed without problems the manager |
5598 |
30 Mar 11 |
nicklas |
finishes by calling {@link #done(ExtensionsManager)}. If the processor |
5598 |
30 Mar 11 |
nicklas |
throws an exception the processing is immediately aborted and |
5598 |
30 Mar 11 |
nicklas |
{@link #done(ExtensionsManager, Throwable)} is called instead. |
5598 |
30 Mar 11 |
nicklas |
44 |
|
5598 |
30 Mar 11 |
nicklas |
@author Nicklas |
5598 |
30 Mar 11 |
nicklas |
@since 3.0 |
5598 |
30 Mar 11 |
nicklas |
@base.modified $Date$ |
5598 |
30 Mar 11 |
nicklas |
48 |
*/ |
5598 |
30 Mar 11 |
nicklas |
49 |
public interface ExtensionsFileProcessor |
5598 |
30 Mar 11 |
nicklas |
50 |
{ |
5598 |
30 Mar 11 |
nicklas |
51 |
|
5598 |
30 Mar 11 |
nicklas |
52 |
/** |
5598 |
30 Mar 11 |
nicklas |
Called by the extensions manager before the processing starts. |
5598 |
30 Mar 11 |
nicklas |
54 |
|
5598 |
30 Mar 11 |
nicklas |
@param manager The manager that is executing the action |
5598 |
30 Mar 11 |
nicklas |
@param numFiles The number of extension files that is going to be processed this time |
5598 |
30 Mar 11 |
nicklas |
57 |
*/ |
5598 |
30 Mar 11 |
nicklas |
58 |
public void begin(ExtensionsManager manager, int numFiles); |
5598 |
30 Mar 11 |
nicklas |
59 |
|
5598 |
30 Mar 11 |
nicklas |
60 |
/** |
5598 |
30 Mar 11 |
nicklas |
Called by the extensions manager for each extensions file that it |
5598 |
30 Mar 11 |
nicklas |
manages. The order of the files is generally not predicatable and |
5598 |
30 Mar 11 |
nicklas |
may change from one invokation to the next. |
5598 |
30 Mar 11 |
nicklas |
<p> |
5598 |
30 Mar 11 |
nicklas |
65 |
|
5598 |
30 Mar 11 |
nicklas |
If the processor throws an exception the manager will abort |
5598 |
30 Mar 11 |
nicklas |
processing and call {@link #done(ExtensionsManager, Throwable)}. |
5602 |
07 Apr 11 |
nicklas |
Error that are related to a specific file should be catched |
5602 |
07 Apr 11 |
nicklas |
by the processor and registered by calling ....... |
5598 |
30 Mar 11 |
nicklas |
<p> |
5598 |
30 Mar 11 |
nicklas |
71 |
|
5598 |
30 Mar 11 |
nicklas |
If all files was processed without exceptions the manager |
5598 |
30 Mar 11 |
nicklas |
will call {@link #done(ExtensionsManager)}. |
5602 |
07 Apr 11 |
nicklas |
74 |
|
5602 |
07 Apr 11 |
nicklas |
<p> |
5602 |
07 Apr 11 |
nicklas |
Note that the file is read-only to begin with. If the processor |
5602 |
07 Apr 11 |
nicklas |
wants to call any write-operation the file must be opened by |
5602 |
07 Apr 11 |
nicklas |
calling {@link WriteableExtensionsFile#open()}. It is recommended |
5602 |
07 Apr 11 |
nicklas |
that the processor calls {@link WriteableExtensionsFile#close()} |
5602 |
07 Apr 11 |
nicklas |
once it is done writing. |
5598 |
30 Mar 11 |
nicklas |
81 |
|
5598 |
30 Mar 11 |
nicklas |
@param manager The manager that is executing the action |
5598 |
30 Mar 11 |
nicklas |
@param file The file to be processed |
5598 |
30 Mar 11 |
nicklas |
84 |
*/ |
5602 |
07 Apr 11 |
nicklas |
85 |
public void processFile(ExtensionsManager manager, WriteableExtensionsFile file); |
5598 |
30 Mar 11 |
nicklas |
86 |
|
5598 |
30 Mar 11 |
nicklas |
87 |
/** |
5598 |
30 Mar 11 |
nicklas |
Called by the extensions manager after a successful completion of the |
5598 |
30 Mar 11 |
nicklas |
processing. |
5598 |
30 Mar 11 |
nicklas |
@param manager The manager that is executing the action |
5598 |
30 Mar 11 |
nicklas |
91 |
*/ |
5598 |
30 Mar 11 |
nicklas |
92 |
public void done(ExtensionsManager manager); |
5598 |
30 Mar 11 |
nicklas |
93 |
|
5598 |
30 Mar 11 |
nicklas |
94 |
/** |
5598 |
30 Mar 11 |
nicklas |
Called by the extensions manager if an exception was thrown |
5598 |
30 Mar 11 |
nicklas |
by the processor. |
5598 |
30 Mar 11 |
nicklas |
@param manager The manager that is executing the action |
5598 |
30 Mar 11 |
nicklas |
@param t The exception |
5598 |
30 Mar 11 |
nicklas |
99 |
*/ |
5598 |
30 Mar 11 |
nicklas |
100 |
public void done(ExtensionsManager manager, Throwable t); |
5598 |
30 Mar 11 |
nicklas |
101 |
|
5598 |
30 Mar 11 |
nicklas |
102 |
} |