コード例 #1
0
ファイル: TestBase.cs プロジェクト: Mazrick/jni4net
 public virtual void Setup()
 {
     var sp = new FileIOPermission(PermissionState.Unrestricted);
     sp.Assert();
     string prefix;
     if (Environment.CurrentDirectory.EndsWith("target"))
     {
         prefix = "../../";
     }
     else
     {
         prefix = "../../../";
     }
     sp.Deny();
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
     BridgeSetup setup=new BridgeSetup (false){Verbose = true, Debug = true};
     setup.IgnoreJavaHome = true;
     setup.AddJVMOption("-Xmx512m");
     setup.AddClassPath(prefix + "jni4net.j/target/classes");
     setup.AddClassPath(prefix + "jni4net.tested.j/target/classes");
     setup.AddClassPath(prefix + "jni4net.test.j/target/test-classes");
     //setup.JavaHome = @"c:\Program Files (x86)\Java\ibm_sdk60";
     env = Bridge.CreateJVM(setup);
     Bridge.RegisterAssembly(typeof(TestBase).Assembly);
     Bridge.RegisterAssembly(typeof(JavaInstanceFields).Assembly);
 }
コード例 #2
0
        public virtual void Setup()
        {
            var sp = new FileIOPermission(PermissionState.Unrestricted);

            sp.Assert();
            string prefix;

            if (Environment.CurrentDirectory.EndsWith("target"))
            {
                prefix = "../../";
            }
            else
            {
                prefix = "../../../";
            }
            sp.Deny();
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            BridgeSetup setup = new BridgeSetup(false)
            {
                Verbose = true, Debug = true
            };

            setup.IgnoreJavaHome = true;
            setup.AddJVMOption("-Xmx512m");
            setup.AddClassPath(prefix + "jni4net.j/target/classes");
            setup.AddClassPath(prefix + "jni4net.tested.j/target/classes");
            setup.AddClassPath(prefix + "jni4net.test.j/target/test-classes");
            //setup.JavaHome = @"c:\Program Files (x86)\Java\ibm_sdk60";
            env = Bridge.CreateJVM(setup);
            Bridge.RegisterAssembly(typeof(TestBase).Assembly);
            Bridge.RegisterAssembly(typeof(JavaInstanceFields).Assembly);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: samiei2/JAJEEM
        private static void Init()
        {
            BridgeSetup bridgeSetup = new BridgeSetup(true);

            bridgeSetup.AddClassPath(".");
            bridgeSetup.AddClassPath("work");
            Bridge.CreateJVM(bridgeSetup);
            Bridge.RegisterAssembly(typeof(Thread).Assembly);
        }
コード例 #4
0
ファイル: JPPFExtensions.cs プロジェクト: zeta1999/JPPF
 /// <summary>Add a list of semicolumn-separated files in the specified directory to the BridgeSetup JVM classpath.
 /// <para>This is a convenience method which calls <c>BridgeSetup.AddClassPath(dir + "/" + file)</c> for each file in the list</para></summary>
 /// <param name="setup">the <c>BridgeSetup</c> instance</param>
 /// <param name="dir">the path of the enclosing directory</param>
 /// <param name="files">A string containing file names separated by semicolumn characters</param>
 public static void AddClassPaths(this BridgeSetup setup, string dir, string files)
 {
     if ((dir != null) && (files != null))
     {
         foreach (string file in files.Split(';'))
         {
             setup.AddClassPath(dir + "/" + file);
         }
     }
 }
コード例 #5
0
ファイル: JPPFExtensions.cs プロジェクト: zeta1999/JPPF
 /// <summary>Add a list of semicolumn-separated paths to the BridgeSetup JVM classpath.
 /// <para>This is a convenience method which calls <c>BridgeSetup.AddClassPath(path)</c> for each path in the list</para></summary>
 /// <param name="setup">the <c>BridgeSetup</c> instance</param>
 /// <param name="paths">A string containing file paths separated by semicolumn characters</param>
 public static void AddClassPaths(this BridgeSetup setup, string paths)
 {
     if (paths != null)
     {
         foreach (string path in paths.Split(';'))
         {
             setup.AddClassPath(path);
         }
     }
 }
コード例 #6
0
        private static void SetupPhoenixClientJar(string phoenixClientJarPath)
        {
            var bridgeSetup = new BridgeSetup()
            {
                Verbose = true
            };

            bridgeSetup.AddClassPath(phoenixClientJarPath);
            Bridge.CreateJVM(bridgeSetup);
        }
コード例 #7
0
        private static void LoadClasspath()
        {
            BridgeSetup setup = new BridgeSetup(false);

            setup.BindNative = false;
            setup.BindStatic = true;

            if (config.ClassPath != null && config.ClassPath.Length > 0)
            {
                foreach (var classPath in config.ClassPath)
                {
                    setup.AddClassPath(Path.GetFullPath(classPath.Path));
                    if (classPath.Generate)
                    {
                        generateCp.Add(classPath.Path);
                    }
                }
            }
            setup.AddBridgeClassPath();
            Bridge.CreateJVM(setup);
            systemClassLoader = ClassLoader.getSystemClassLoader();
        }
コード例 #8
0
ファイル: TestBase.cs プロジェクト: tomgi/robocode
        public virtual void Setup()
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            var setup = new BridgeSetup(false)
            {
                Verbose = true, Debug = true
            };
            string prefix;

            if (Environment.CurrentDirectory.EndsWith("target"))
            {
                prefix = "../../";
            }
            else
            {
                prefix = "../../../";
            }
            string userHome = Environment.GetEnvironmentVariable("USERPROFILE");
            string version  = typeof(BridgeSetup).Assembly.GetName().Version.ToString();

            setup.AddClassPath(userHome + @"/.m2/repository/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar");
            setup.AddClassPath(userHome + @"/.m2/repository/net/sf/jni4net/jni4net.j/" + version + "/jni4net.j-" +
                               version + ".jar");
            setup.AddClassPath(prefix + "../../robocode.api/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.api/target/classes");
            setup.AddClassPath(prefix + "../../robocode.battle/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.battle/target/classes");
            setup.AddClassPath(prefix + "../../robocode.core/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.core/target/classes");
            setup.AddClassPath(prefix + "../../robocode.host/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.host/target/classes");
            setup.AddClassPath(prefix + "../../robocode.repository/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.repository/target/classes");
            setup.AddClassPath(prefix + "../../robocode.roborumble/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.roborumble/target/classes");
            setup.AddClassPath(prefix + "../../robocode.samples/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.samples/target/classes");
            setup.AddClassPath(prefix + "../../robocode.sound/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.sound/target/classes");
            setup.AddClassPath(prefix + "../../robocode.tests/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.tests/target/classes");
            setup.AddClassPath(prefix + "../../robocode.ui/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.ui/target/classes");
            setup.AddClassPath(prefix + "../../robocode.ui.editor/target/Test-classes");
            setup.AddClassPath(prefix + "../../robocode.ui.editor/target/classes");
            setup.AddClassPath(prefix + "robocode.dotnet.api/target/Test-classes");
            setup.AddClassPath(prefix + "robocode.dotnet.api/target/classes");
            setup.AddClassPath(prefix + "robocode.dotnet.host/target/Test-classes");
            setup.AddClassPath(prefix + "robocode.dotnet.host/target/classes");
            setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/Test-classes");
            setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/classes");
            setup.AddClassPath(prefix + "robocode.dotnet.samples/target/Test-classes");
            setup.AddClassPath(prefix + "robocode.dotnet.samples/target/classes");
            setup.AddClassPath(prefix + "robocode.dotnet.tests/target/Test-classes");
            setup.AddClassPath(prefix + "robocode.dotnet.tests/target/classes");
            env = Bridge.CreateJVM(setup);
            Bridge.RegisterAssembly(typeof(TestBase).Assembly);
            Bridge.RegisterAssembly(typeof(DllRootHelper).Assembly);
        }
コード例 #9
0
        /// <summary>Initialize the jni4net bridge, including creation of the JVM, loading of the appropriate jar files
        /// and registration of the .Net DLLs.</summary>
        /// <param name="verbose">whether this method should output verbose statements to the conosle, for debugging puproses</param>
        public static void Init(bool verbose)
        {
            if (verbose)
            {
                Console.WriteLine("[JPPFDotnet.Init()]");
            }
            NameValueCollection settings = ConfigurationManager.AppSettings;
            string jvmOptions            = settings["jppf.jvm.option"];

            BridgeSetup bridgeSetup = (jvmOptions != null) ? new BridgeSetup(jvmOptions) : new BridgeSetup(true);

            foreach (string key in settings.AllKeys)
            {
                //if (verbose) Console.WriteLine("[JPPFDotnet.Init() : processing " + key + " = " + settings[key]);
                if (key.StartsWith("ClassPath."))
                {
                    if (verbose)
                    {
                        Console.WriteLine("[JPPFDotnet.Init()] adding single classpath for key = '" + key + "' : " + settings[key]);
                    }
                    bridgeSetup.AddClassPath(settings[key]);
                }
                else if (key.StartsWith("ClassPaths."))
                {
                    string[] parsed = settings[key].Split('|');
                    if (verbose)
                    {
                        Console.WriteLine("[JPPFDotnet.Init()] adding multiple classpaths for key = '" + key + "' : dir = '" + parsed[0] + "', paths = " + parsed[1]);
                    }
                    bridgeSetup.AddClassPaths(parsed[0], parsed[1]);
                }
                else if (key.StartsWith("ClassPathDir."))
                {
                    string[] files = Directory.GetFiles(settings[key]);
                    foreach (string file in files)
                    {
                        FileInfo info        = new FileInfo(file);
                        bool     isDirectory = (info.Attributes & FileAttributes.Directory) == FileAttributes.Directory;
                        if (isDirectory || file.EndsWith(".jar") || file.EndsWith(".zip"))
                        {
                            if (verbose)
                            {
                                Console.WriteLine("[JPPFDotnet.Init()] adding classpath for key = '" + key + "' : " + (isDirectory ? "dir" : "file") + " = '" + file);
                            }
                            bridgeSetup.AddClassPath(file);
                        }
                    }
                }
            }
            if (verbose)
            {
                Console.WriteLine("[JPPFDotnet.Init()] bridgeSetup : " + bridgeSetup.JVMCLassPath);
                foreach (String s in bridgeSetup.JVMCLassPath)
                {
                    Console.WriteLine(s);
                }
            }

            Bridge.CreateJVM(bridgeSetup);
            foreach (string key in settings.AllKeys)
            {
                if (key.StartsWith("AssemblyPath."))
                {
                    if (verbose)
                    {
                        Console.WriteLine("[JPPFDotnet.Init()] adding single assembly for key = '" + key + "' : " + settings[key]);
                    }
                    Bridge.LoadAndRegisterAssemblyByName(settings[key]);
                }
                else if (key.StartsWith("AssemblyPaths."))
                {
                    string[] parsed = settings[key].Split('|');
                    if (verbose)
                    {
                        Console.WriteLine("[JPPFDotnet.Init()] registering multiple assemblies for key = '" + key + "' : dir = '" + parsed[0] + "', paths = " + parsed[1]);
                    }
                    Bridge.LoadAndRegisterAssemblyByName(parsed[0] + "\\" + parsed[1]);
                }
            }
        }
コード例 #10
0
ファイル: Repository.Helpers.cs プロジェクト: Mazrick/jni4net
        private static void LoadClasspath()
        {
            BridgeSetup setup=new BridgeSetup(false);
            setup.BindNative = false;
            setup.BindStatic = true;

            if (config.ClassPath != null && config.ClassPath.Length > 0)
            {
                foreach (var classPath in config.ClassPath)
                {
                    setup.AddClassPath(Path.GetFullPath(classPath.Path));
                    if (classPath.Generate)
                    {
                        generateCp.Add(classPath.Path);
                    }
                }
            }
            setup.AddBridgeClassPath();
            Bridge.CreateJVM(setup);
            systemClassLoader = ClassLoader.getSystemClassLoader();
        }