1330 |
01 Apr 11 |
nicklas |
1 |
/** |
1330 |
01 Apr 11 |
nicklas |
$Id$ |
1330 |
01 Apr 11 |
nicklas |
3 |
|
1330 |
01 Apr 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
1330 |
01 Apr 11 |
nicklas |
5 |
|
1330 |
01 Apr 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
1330 |
01 Apr 11 |
nicklas |
Available at http://base.thep.lu.se/ |
1330 |
01 Apr 11 |
nicklas |
8 |
|
1330 |
01 Apr 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
1330 |
01 Apr 11 |
nicklas |
modify it under the terms of the GNU General Public License |
1330 |
01 Apr 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
1330 |
01 Apr 11 |
nicklas |
of the License, or (at your option) any later version. |
1330 |
01 Apr 11 |
nicklas |
13 |
|
1330 |
01 Apr 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
1330 |
01 Apr 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1330 |
01 Apr 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1330 |
01 Apr 11 |
nicklas |
GNU General Public License for more details. |
1330 |
01 Apr 11 |
nicklas |
18 |
|
1330 |
01 Apr 11 |
nicklas |
You should have received a copy of the GNU General Public License |
1330 |
01 Apr 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1330 |
01 Apr 11 |
nicklas |
21 |
*/ |
1330 |
01 Apr 11 |
nicklas |
22 |
package net.sf.basedb.hdfs; |
1330 |
01 Apr 11 |
nicklas |
23 |
|
1330 |
01 Apr 11 |
nicklas |
24 |
import net.sf.basedb.core.plugin.About; |
1330 |
01 Apr 11 |
nicklas |
25 |
import net.sf.basedb.util.extensions.ActionFactory; |
1330 |
01 Apr 11 |
nicklas |
26 |
import net.sf.basedb.util.extensions.Extension; |
1330 |
01 Apr 11 |
nicklas |
27 |
import net.sf.basedb.util.extensions.ExtensionsUtil; |
1330 |
01 Apr 11 |
nicklas |
28 |
import net.sf.basedb.util.extensions.InvokationContext; |
1330 |
01 Apr 11 |
nicklas |
29 |
import net.sf.basedb.util.uri.ConnectionManagerFactory; |
1330 |
01 Apr 11 |
nicklas |
30 |
|
1330 |
01 Apr 11 |
nicklas |
31 |
/** |
1330 |
01 Apr 11 |
nicklas |
Action factory for http connection manager factory. This factory |
1330 |
01 Apr 11 |
nicklas |
will create a singleton instance of {@link HttpConnectionManagerFactory} |
1330 |
01 Apr 11 |
nicklas |
upon the first use. This instance will be used for all further |
1330 |
01 Apr 11 |
nicklas |
uses of this extension. |
1330 |
01 Apr 11 |
nicklas |
36 |
|
1330 |
01 Apr 11 |
nicklas |
@author Nicklas |
1330 |
01 Apr 11 |
nicklas |
@since 1.0 |
1330 |
01 Apr 11 |
nicklas |
39 |
*/ |
1330 |
01 Apr 11 |
nicklas |
40 |
public class HdfsConnectionManagerActionFactory |
1330 |
01 Apr 11 |
nicklas |
41 |
implements ActionFactory<ConnectionManagerFactory> |
1330 |
01 Apr 11 |
nicklas |
42 |
{ |
1330 |
01 Apr 11 |
nicklas |
43 |
|
1330 |
01 Apr 11 |
nicklas |
44 |
private volatile HdfsConnectionManagerFactory factory; |
1330 |
01 Apr 11 |
nicklas |
45 |
|
1330 |
01 Apr 11 |
nicklas |
46 |
public HdfsConnectionManagerActionFactory() |
1330 |
01 Apr 11 |
nicklas |
47 |
{} |
1330 |
01 Apr 11 |
nicklas |
48 |
|
1330 |
01 Apr 11 |
nicklas |
49 |
/* |
1330 |
01 Apr 11 |
nicklas |
From the ActionFactory interface |
1330 |
01 Apr 11 |
nicklas |
51 |
--------------------------------- |
1330 |
01 Apr 11 |
nicklas |
52 |
*/ |
1330 |
01 Apr 11 |
nicklas |
53 |
@Override |
1330 |
01 Apr 11 |
nicklas |
54 |
public boolean prepareContext( |
1330 |
01 Apr 11 |
nicklas |
55 |
InvokationContext<? super ConnectionManagerFactory> context) |
1330 |
01 Apr 11 |
nicklas |
56 |
{ |
1330 |
01 Apr 11 |
nicklas |
57 |
return true; |
1330 |
01 Apr 11 |
nicklas |
58 |
} |
1330 |
01 Apr 11 |
nicklas |
59 |
|
1330 |
01 Apr 11 |
nicklas |
60 |
@Override |
1330 |
01 Apr 11 |
nicklas |
61 |
public ConnectionManagerFactory[] getActions( |
1330 |
01 Apr 11 |
nicklas |
62 |
InvokationContext<? super ConnectionManagerFactory> context) |
1330 |
01 Apr 11 |
nicklas |
63 |
{ |
1330 |
01 Apr 11 |
nicklas |
64 |
if (factory == null) |
1330 |
01 Apr 11 |
nicklas |
65 |
{ |
1330 |
01 Apr 11 |
nicklas |
66 |
initFactory(context); |
1330 |
01 Apr 11 |
nicklas |
67 |
} |
1330 |
01 Apr 11 |
nicklas |
68 |
return new ConnectionManagerFactory[] { factory }; |
1330 |
01 Apr 11 |
nicklas |
69 |
} |
1330 |
01 Apr 11 |
nicklas |
70 |
// -------------------------------------------- |
1330 |
01 Apr 11 |
nicklas |
71 |
|
1330 |
01 Apr 11 |
nicklas |
72 |
private synchronized void initFactory(InvokationContext context) |
1330 |
01 Apr 11 |
nicklas |
73 |
{ |
1330 |
01 Apr 11 |
nicklas |
74 |
if (factory != null) return; |
1330 |
01 Apr 11 |
nicklas |
75 |
Extension ext = context.getExtension(); |
1330 |
01 Apr 11 |
nicklas |
76 |
About about = ext.getAbout(); |
1330 |
01 Apr 11 |
nicklas |
77 |
|
1330 |
01 Apr 11 |
nicklas |
78 |
String id = ext.getId(); |
1330 |
01 Apr 11 |
nicklas |
79 |
String name = ExtensionsUtil.getName(ext); |
1330 |
01 Apr 11 |
nicklas |
80 |
String description = about != null ? about.getDescription() : null; |
1330 |
01 Apr 11 |
nicklas |
81 |
|
1330 |
01 Apr 11 |
nicklas |
82 |
HdfsConnectionManagerFactory tmp = new HdfsConnectionManagerFactory(); |
1330 |
01 Apr 11 |
nicklas |
83 |
tmp.init(id, name, description); |
1330 |
01 Apr 11 |
nicklas |
84 |
factory = tmp; |
1330 |
01 Apr 11 |
nicklas |
85 |
} |
1330 |
01 Apr 11 |
nicklas |
86 |
|
1330 |
01 Apr 11 |
nicklas |
87 |
} |