Revision 49
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.prov.installer/src/main/java/org/gvsig/educa/thematicmap/lib/prov/installer/ThematicMapInstallerProviderLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.educa.thematicmap.lib.prov.installer; |
|
29 |
|
|
30 |
import org.gvsig.educa.thematicmap.lib.prov.installer.execution.ThematicMapInstallerExecutionProviderFactory; |
|
31 |
import org.gvsig.installer.lib.api.InstallerLibrary; |
|
32 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
33 |
import org.gvsig.tools.library.AbstractLibrary; |
|
34 |
import org.gvsig.tools.library.LibraryException; |
|
35 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
36 |
|
|
37 |
public class ThematicMapInstallerProviderLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
@Override |
|
40 |
public void doRegistration() { |
|
41 |
registerAsServiceOf(InstallerLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doInitialize() throws LibraryException { |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doPostInitialize() throws LibraryException { |
|
51 |
ProviderManager providerManager = |
|
52 |
InstallerProviderLocator.getProviderManager(); |
|
53 |
providerManager |
|
54 |
.addProviderFactory(new ThematicMapInstallerExecutionProviderFactory()); |
|
55 |
} |
|
56 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.prov.installer/src/main/java/org/gvsig/educa/thematicmap/lib/prov/installer/execution/ThematicMapInstallerExecutionProvider.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.educa.thematicmap.lib.prov.installer.execution; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
32 |
import java.io.InputStream; |
|
33 |
|
|
34 |
import org.gvsig.educa.thematicmap.ThematicMapLocator; |
|
35 |
import org.gvsig.educa.thematicmap.ThematicMapManager; |
|
36 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
37 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
|
38 |
import org.gvsig.installer.lib.spi.InstallPackageProviderServices; |
|
39 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
40 |
import org.gvsig.installer.lib.spi.InstallerProviderManager; |
|
41 |
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider; |
|
42 |
import org.gvsig.tools.service.spi.AbstractProvider; |
|
43 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
44 |
|
|
45 |
public class ThematicMapInstallerExecutionProvider extends AbstractProvider |
|
46 |
implements InstallPackageProvider { |
|
47 |
|
|
48 |
private static final InstallerProviderManager installerProviderManager = |
|
49 |
InstallerProviderLocator.getProviderManager(); |
|
50 |
private final ThematicMapManager tmManager; |
|
51 |
|
|
52 |
public ThematicMapInstallerExecutionProvider( |
|
53 |
ProviderServices providerServices) { |
|
54 |
super(providerServices); |
|
55 |
tmManager = ThematicMapLocator.getManager(); |
|
56 |
} |
|
57 |
|
|
58 |
public void install(File applicationDirectory, InputStream inputStream, |
|
59 |
PackageInfo packageInfo) throws InstallPackageServiceException { |
|
60 |
|
|
61 |
try { |
|
62 |
File installationFolder = |
|
63 |
new File(tmManager.getInstallationMapFolder()); |
|
64 |
|
|
65 |
InstallPackageProviderServices installerProviderServices = |
|
66 |
installerProviderManager.createInstallerProviderServices(); |
|
67 |
|
|
68 |
installerProviderServices.decompress(inputStream, |
|
69 |
installationFolder); |
|
70 |
|
|
71 |
} catch (Exception e) { |
|
72 |
try { |
|
73 |
// if there is an exception, installLater is called |
|
74 |
installLater(applicationDirectory, inputStream, packageInfo); |
|
75 |
} catch (IOException e1) { |
|
76 |
e1.printStackTrace(); |
|
77 |
throw new InstallPackageServiceException(e1); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* This function will is called when an exception is produced during the |
|
84 |
* installation of a plugin. It will prepare the package to be installed on |
|
85 |
* the next gvSIG restart. |
|
86 |
*/ |
|
87 |
public void installLater(File applicationDirectory, |
|
88 |
InputStream inputStream, PackageInfo packageInfo) |
|
89 |
throws InstallPackageServiceException, IOException { |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.prov.installer/src/main/java/org/gvsig/educa/thematicmap/lib/prov/installer/execution/ThematicMapInstallerExecutionProviderFactory.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.educa.thematicmap.lib.prov.installer.execution; |
|
29 |
|
|
30 |
import org.gvsig.tools.ToolsLocator; |
|
31 |
import org.gvsig.tools.dynobject.DynClass; |
|
32 |
import org.gvsig.tools.dynobject.DynObject; |
|
33 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
34 |
import org.gvsig.tools.service.spi.AbstractProviderFactory; |
|
35 |
import org.gvsig.tools.service.spi.Provider; |
|
36 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
37 |
|
|
38 |
/** |
|
39 |
* @author gvSIG Team |
|
40 |
* @version $Id$ |
|
41 |
* |
|
42 |
*/ |
|
43 |
public class ThematicMapInstallerExecutionProviderFactory extends |
|
44 |
AbstractProviderFactory { |
|
45 |
|
|
46 |
public static final String PROVIDER_NAME = "ThematicMap"; |
|
47 |
public static final String PROVIDER_DESCRIPTION = |
|
48 |
"Thematic Map installation provider"; |
|
49 |
|
|
50 |
private DynClass dynclass; |
|
51 |
|
|
52 |
@Override |
|
53 |
protected DynClass createParametersDynClass() { |
|
54 |
if (dynclass == null) { |
|
55 |
initialize(); |
|
56 |
} |
|
57 |
return dynclass; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
protected Provider doCreate(DynObject parameters, ProviderServices services) { |
|
62 |
return new ThematicMapInstallerExecutionProvider(services); |
|
63 |
} |
|
64 |
|
|
65 |
public void initialize() { |
|
66 |
if (dynclass == null) { |
|
67 |
DynObjectManager dynObjectManager = |
|
68 |
ToolsLocator.getDynObjectManager(); |
|
69 |
dynclass = |
|
70 |
dynObjectManager.createDynClass(PROVIDER_NAME, |
|
71 |
PROVIDER_DESCRIPTION); |
|
72 |
dynObjectManager.add(dynclass); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
} |
Also available in: Unified diff