Changeset 23 for src


Ignore:
Timestamp:
10/08/20 16:02:48 (4 years ago)
Author:
bart
Message:

MOPAC support for timedependentparty, boulware, conceder, hardliner, linear

Location:
src
Files:
13 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/geniusweb/partiesserver/jarClassLoader1.java

    r1 r23  
    44import java.io.IOException;
    55import java.net.JarURLConnection;
     6import java.net.MalformedURLException;
     7import java.net.URISyntaxException;
    68import java.net.URL;
    79import java.net.URLClassLoader;
     
    1012/**
    1113 * Classloader that ensures loaded code is kept separate from other loaded code.
    12  * This is to prevent dependency conflicts between parties that we  load.
     14 * This is to prevent dependency conflicts between parties that we load.
    1315 *
    1416 */
     
    1719        private URL u;
    1820
     21        /**
     22         * @param url    The URL is like
     23         *               jar:file:/Web%20Servers/../partiesserver-1.4.1/partiesrepo/agentgg-1.5.5.jar!/
     24         *
     25         * @param parent the parent classloader.
     26         */
    1927        public JarClassLoader1(URL url, ClassLoader parent) {
    2028                super(new URL[] { url }, parent);
    2129                this.u = url;
    2230
    23                 String filename = url.getPath();
    24                 if (filename.startsWith("file:")) {
    25                         filename = filename.substring(5);
     31                // we need to get to the actual file. This is very tricky,
     32                // most solutions on the web don't work, throw, don't remove %20,etc
     33                // url.toURI throws for multi-protocol URLs like "jar:file://...".
     34
     35                // https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html
     36                // the syntax of a JAR URL is: jar:<url>!/{entry}
     37
     38                String filename = url.getPath(); // file:/bla%20bla/file.jar!/
     39                filename = filename.substring(0, filename.indexOf("!/"));
     40                File jarfile;
     41                try {
     42                        jarfile = new File(new URL(filename).toURI());
     43                } catch (MalformedURLException | URISyntaxException e) {
     44                        throw new IllegalArgumentException(
     45                                        "file " + filename + " seems malformed", e);
    2646                }
    27                 if (filename.endsWith("/")) {
    28                         filename = filename.substring(0, filename.length() - 1);
    29                 }
    30                 if (filename.endsWith("!")) {
    31                         filename = filename.substring(0, filename.length() - 1);
    32                 }
    33 
    34                 File jarfile = new File(filename);
    3547
    3648                if (jarfile == null || !jarfile.exists()) {
  • src/test/java/geniusweb/partiesserver/AvailablePartiesUpdaterTest.java

    r22 r23  
    3131
    3232public class AvailablePartiesUpdaterTest {
    33         private static final String RANDOMPARTY = "target/jars/randomparty-1.5.4.jar";
     33        private static final String RANDOMPARTY = "target/jars/randomparty-1.5.5.jar";
    3434        private static final int TESTRATE = 200; // check file changes every 200ms
    3535        @SuppressWarnings("unchecked")
  • src/test/java/geniusweb/partiesserver/JavaClientTest.java

    r22 r23  
    3939 */
    4040public class JavaClientTest {
    41         private static final String RANDOMPARTY = "http://localhost:8080/partiesserver/run/randomparty-1.5.4";
     41        private static final String RANDOMPARTY = "http://localhost:8080/partiesserver/run/randomparty-1.5.5";
    4242        private EmbeddedTomcat tomcat = new EmbeddedTomcat();
    4343        private JavaClient client = new JavaClient();
Note: See TracChangeset for help on using the changeset viewer.