Skip to content

Commit 5681edd

Browse files
committed
Fixes issue #77 #77
1 parent ab4725f commit 5681edd

File tree

8 files changed

+159
-11
lines changed

8 files changed

+159
-11
lines changed

VRL/src/eu/mihosoft/vrl/io/VJarUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
package eu.mihosoft.vrl.io;
5858

5959
import eu.mihosoft.vrl.system.Constants;
60+
import eu.mihosoft.vrl.system.PluginConfigurator;
6061
import eu.mihosoft.vrl.system.VParamUtil;
62+
import eu.mihosoft.vrl.system.WithJarFileLocationInfo;
6163
import java.io.BufferedInputStream;
6264
import java.io.ByteArrayInputStream;
6365
import java.io.ByteArrayOutputStream;

VRL/src/eu/mihosoft/vrl/resources/changelog/changelog.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
-----------------------------------------------
2+
Version: v0.4.4.0.1
3+
Date: Tue, 30 Oct 2018 22:33:18 +0100
4+
-----------------------------------------------
5+
6+
pluign content installation should work on linux again
7+
8+
-----------------------------------------------
9+
Version: v0.4.4.0.0
10+
Date: Mon, 29 Oct 2018 14:48:57 +0100
11+
-----------------------------------------------
12+
13+
deployment prepared for release
14+
115
-----------------------------------------------
216
Version: v0.4.3.2.4
317
Date: Sat, 21 Apr 2018 19:42:27 +0200

VRL/src/eu/mihosoft/vrl/system/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class Constants {
7676
/**
7777
* VRL version number that indicates major and minor changes.
7878
*/
79-
public static final String VERSION_BASE = VERSION_MAJOR + ".0.2";
79+
public static final String VERSION_BASE = VERSION_MAJOR + ".0.3";
8080
// "-HEAD" or "-unstable" or "" for release etc.
8181
public static final String VERSION_SUFFIX = "";
8282
// full version (base+suffix+date)

VRL/src/eu/mihosoft/vrl/system/PluginCacheEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public PluginCacheEntry() {
8282

8383
public PluginCacheEntry(PluginConfigurator pConf) {
8484
configuratorClass = pConf.getClass().getName();
85-
File f = VJarUtil.getClassLocation(pConf.getClass());
85+
File f = VRL.getPluginJarFileLocation(pConf);
8686

8787
jarFile = f.getName();
8888

VRL/src/eu/mihosoft/vrl/system/PluginConfigurator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
import eu.mihosoft.vrl.reflection.VisualCanvas;
5959
import java.awt.image.BufferedImage;
60+
import java.io.File;
6061
import java.util.function.BooleanSupplier;
6162

6263
/**
@@ -67,7 +68,7 @@
6768
* @see eu.mihosoft.vrl.reflection.TypeRepresentationFactory
6869
* @author Michael Hoffer <info@michaelhoffer.de>
6970
*/
70-
public interface PluginConfigurator {
71+
public interface PluginConfigurator extends WithJarFileLocationInfo {
7172

7273
/**
7374
* Key for accessing the "installed" property of the plugin config.
@@ -205,5 +206,6 @@ public default InitFailure checkFailure(InitPluginAPI iApi) {
205206
* @param message message/reason
206207
*/
207208
public void failsInitIf(BooleanSupplier condition, String message);
209+
208210

209211
}

VRL/src/eu/mihosoft/vrl/system/VPluginConfigurator.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public abstract class VPluginConfigurator implements PluginConfigurator {
159159

160160
private BooleanSupplier failureCondition = () -> false;
161161
private String failureReason = "";
162+
163+
private File jarFileLocation;
162164

163165
public VPluginConfigurator() {
164166
}
@@ -537,6 +539,17 @@ public void failsInitIf(BooleanSupplier condition, String message) {
537539
failureCondition = condition;
538540
failureReason = message;
539541
}
542+
543+
@Override
544+
public File getJarFileLocation() {
545+
return this.jarFileLocation;
546+
}
547+
548+
549+
@Override
550+
public void setJarFileLocation(File f) {
551+
this.jarFileLocation = f;
552+
}
540553
}
541554

542555
class AccessPolicyImpl implements AccessPolicy {
@@ -632,4 +645,5 @@ public void setAllowAll(boolean allowAll) {
632645
public void addClass(String className) {
633646
classNames.add(className);
634647
}
648+
635649
}

VRL/src/eu/mihosoft/vrl/system/VRL.java

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ private static boolean needsInstall(
743743
String installedTimestamp = config.getProperty(
744744
PluginConfigurator.TIMESTAMP_KEY);
745745

746-
File pluginLocation = VJarUtil.getClassLocation(p.getClass());
746+
File pluginLocation = getPluginJarFileLocation(p);
747747

748748
String currentTimestamp = "" + pluginLocation.lastModified();
749749

@@ -761,6 +761,27 @@ private static boolean needsInstall(
761761
return needsInstall;
762762
}
763763

764+
/**
765+
* Returns the jar file locatino of the specified plugin. First, this
766+
* method tries to locate the plugin via {@code p.getJarFileLocation()}. If
767+
* that doesn't work, the class is used to locate the jar file via
768+
* {@code VJarUtil.getClassLocation(p.getClass)}.
769+
*
770+
* @param p plugin
771+
* @return plugin location or {@code null} if the location cannot be found
772+
*/
773+
public static File getPluginJarFileLocation(PluginConfigurator p){
774+
File pluginLocation = p.getJarFileLocation();
775+
if(pluginLocation==null) {
776+
try {
777+
pluginLocation = VJarUtil.getClassLocation(p.getClass());
778+
} catch(Exception ex) {
779+
ex.printStackTrace(System.err);
780+
}
781+
}
782+
return pluginLocation;
783+
}
784+
764785
/**
765786
* Calls the
766787
* {@link PluginConfigurator#install(eu.mihosoft.vrl.system.InitPluginAPI) }
@@ -779,7 +800,7 @@ private static boolean performConfiguratorInstall(
779800
= " --> " + p.getIdentifier().getName()
780801
+ ": installing/updating:";
781802

782-
File pluginLocation = VJarUtil.getClassLocation(p.getClass());
803+
File pluginLocation = getPluginJarFileLocation(p);
783804

784805
System.out.println(msg);
785806

@@ -869,7 +890,7 @@ private static void performContentInstall(String contentName,
869890
String archiveName = contentName + ".zip";
870891
File contentFolder = pD.getContentFolderByName(contentName);
871892

872-
File pluginLocation = VJarUtil.getClassLocation(p.getClass());
893+
File pluginLocation = getPluginJarFileLocation(p);
873894

874895
// native install
875896
if (needsInstall(p, pD)
@@ -1364,9 +1385,12 @@ static void addPlugin(final PluginConfigurator plugin, File f) {
13641385
allPlugins.add(plugin);
13651386

13661387
if (registeredPlugin != null) {
1388+
1389+
File regPFile = getPluginJarFileLocation(registeredPlugin);
1390+
File pFile = getPluginJarFileLocation(plugin);
13671391

1368-
String regPluginPath = VJarUtil.getClassLocation(registeredPlugin.getClass()).getAbsolutePath();
1369-
String pluginPath = VJarUtil.getClassLocation(plugin.getClass()).getAbsolutePath();
1392+
String regPluginPath = regPFile==null?"<path not found>":regPFile.getAbsolutePath();
1393+
String pluginPath = pFile==null?"<pasth not found>":pFile.getAbsolutePath();
13701394

13711395
if (regPluginPath.equals(pluginPath)) {
13721396
// TODO
@@ -1387,9 +1411,9 @@ static void addPlugin(final PluginConfigurator plugin, File f) {
13871411
+ registeredPlugin.getIdentifier()
13881412
+ "\". <br>"
13891413
+ "Please see <br>\""
1390-
+ VJarUtil.getClassLocation(plugin.getClass()).getAbsolutePath()
1414+
+ pluginPath
13911415
+ "\" and <br> \""
1392-
+ VJarUtil.getClassLocation(registeredPlugin.getClass()).getAbsolutePath()
1416+
+ regPluginPath
13931417
+ "\".";
13941418

13951419
if (registrationError != null) {
@@ -1535,6 +1559,13 @@ private static void loadPlugin(File f, PluginLoadAction pA,
15351559

15361560
PluginConfigurator pC
15371561
= (PluginConfigurator) cls.newInstance();
1562+
1563+
try {
1564+
// File jarfoileLocation = VJarUtil.getClassLocation(cls);
1565+
pC.setJarFileLocation(f);
1566+
} catch (Exception ex) {
1567+
throw new RuntimeException("Cannot locate jar file", ex);
1568+
}
15381569

15391570
if (platformSupported) {
15401571
pA.loaded(pC);
@@ -1715,8 +1746,9 @@ static File addNativesPath(
17151746
PluginConfigurator p,
17161747
PluginDataController dC,
17171748
boolean disableLibLoad) {
1749+
17181750

1719-
File f = VJarUtil.getClassLocation(p.getClass());
1751+
File f = getPluginJarFileLocation(p);
17201752

17211753
if (!providesContent(PluginDataController.NATIVELIB, f)) {
17221754
return null;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* WithJarFileLocationInfo.java
3+
*
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5+
*
6+
* Copyright (c) 2007–2018 by Michael Hoffer,
7+
* Copyright (c) 2015–2018 G-CSC, Uni Frankfurt,
8+
* Copyright (c) 2009–2015 Steinbeis Forschungszentrum (STZ Ölbronn)
9+
*
10+
* This file is part of Visual Reflection Library (VRL).
11+
*
12+
* VRL is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Lesser General Public License version 3
14+
* as published by the Free Software Foundation.
15+
*
16+
* see: http://opensource.org/licenses/LGPL-3.0
17+
* file://path/to/VRL/src/eu/mihosoft/vrl/resources/license/lgplv3.txt
18+
*
19+
* VRL is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU Lesser General Public License for more details.
23+
*
24+
* This version of VRL includes copyright notice and attribution requirements.
25+
* According to the LGPL this information must be displayed even if you modify
26+
* the source code of VRL. Neither the VRL Canvas attribution icon nor any
27+
* copyright statement/attribution may be removed.
28+
*
29+
* Attribution Requirements:
30+
*
31+
* If you create derived work you must do three things regarding copyright
32+
* notice and author attribution.
33+
*
34+
* First, the following text must be displayed on the Canvas:
35+
* "based on VRL source code". In this case the VRL canvas icon must be removed.
36+
*
37+
* Second, the copyright notice must remain. It must be reproduced in any
38+
* program that uses VRL.
39+
*
40+
* Third, add an additional notice, stating that you modified VRL. A suitable
41+
* notice might read
42+
* "VRL source code modified by YourName 2012".
43+
*
44+
* Note, that these requirements are in full accordance with the LGPL v3
45+
* (see 7. Additional Terms, b).
46+
*
47+
* Please cite the publication(s) listed below.
48+
*
49+
* Publications:
50+
*
51+
* M. Hoffer, C. Poliwoda, & G. Wittum. (2013). Visual reflection library:
52+
* a framework for declarative GUI programming on the Java platform.
53+
* Computing and Visualization in Science, 2013, 16(4),
54+
* 181–192. http://doi.org/10.1007/s00791-014-0230-y
55+
*/
56+
package eu.mihosoft.vrl.system;
57+
58+
import java.io.File;
59+
60+
/**
61+
*
62+
* @author Michael Hoffer &lt;info@michaelhoffer.de&gt;
63+
*/
64+
public interface WithJarFileLocationInfo {
65+
66+
/**
67+
* Retuens the Jar file location of this plugin (only works if the plugin
68+
* has been loaded from the local file system).
69+
*
70+
* @return jar file location
71+
*/
72+
default File getJarFileLocation() {
73+
return null;
74+
}
75+
76+
/**
77+
* Sets the jar file location of this plugin
78+
* (this method shouldn't be called by the plugin itself)
79+
* @param f file to set
80+
*/
81+
default void setJarFileLocation(File f) {
82+
throw new UnsupportedOperationException("setPluginJarLocation is not supported.");
83+
}
84+
}

0 commit comments

Comments
 (0)