Examples of ExtensionClassLoader


Examples of com.sshtools.j2ssh.util.ExtensionClassLoader

    private static Log log = LogFactory.getLog(SessionProviderFactory.class);
    private static SessionProviderFactory instance;
    HashMap providers = new HashMap();

    SessionProviderFactory() {
        ExtensionClassLoader classloader = ConfigurationLoader.getExtensionClassLoader();

        try {
            Enumeration en = classloader.getResources("session.provider");
            URL url = null;
            Properties properties;
            InputStream in;
            SessionProvider provider;
            String name;
            String id;

            while (en.hasMoreElements()) {
                try {
                    url = (URL) en.nextElement();
                    in = url.openStream();
                    properties = new Properties();
                    properties.load(in);
                    IOUtil.closeStream(in);

                    if (properties.containsKey("provider.class") &&
                            properties.containsKey("provider.name")) {
                        Class cls = classloader.loadClass(properties.getProperty(
                                    "provider.class"));
                        String optionsClassName = properties.getProperty(
                                "provider.options");
                        Class optionsClass = ((optionsClassName == null) ||
                            optionsClassName.equals("")) ? null
                                                         : classloader.loadClass(optionsClassName);
                        String pageclass;
                        int num = 1;
                        Vector pages = new Vector();

                        do {
                            pageclass = properties.getProperty("property.page." +
                                    String.valueOf(num), null);

                            if (pageclass != null) {
                                pages.add(classloader.loadClass(pageclass));
                                num++;
                            }
                        } while (pageclass != null);

                        Class[] propertypages = new Class[pages.size()];
View Full Code Here

Examples of com.sshtools.j2ssh.util.ExtensionClassLoader

            context.initialize();
            contexts.add(context);

            if (ext == null) {
                // We need to setup the dynamic class loading with the extension jars
                ext = new ExtensionClassLoader(ConfigurationLoader.class.getClassLoader());

                try {
                    //  Jar files to add to the classpath
                    File dir = new File(homedir + "lib" + File.separator +
                            "ext");
View Full Code Here

Examples of com.sshtools.j2ssh.util.ExtensionClassLoader

            context.initialize();
            contexts.add(context);

            if (ext == null) {
                // We need to setup the dynamic class loading with the extension jars
                ext = new ExtensionClassLoader(ConfigurationLoader.class.getClassLoader());

                try {
                    //  Jar files to add to the classpath
                    File dir = new File(homedir + "lib" + File.separator +
                            "ext");
View Full Code Here

Examples of es.emergya.tools.ExtensionClassLoader

  protected void createAndShowGUI() {
  }

  protected void loadJobs() {
    try {
      ExtensionClassLoader ecl = new ExtensionClassLoader();
      List<File> jobs = ecl.getJobs();

      CustomScheduler scheduler = new CustomScheduler();

      for (File job : jobs) {
        Properties p = new Properties();
View Full Code Here

Examples of es.emergya.tools.ExtensionClassLoader

  }

  // TODO
  protected void configureUI() {
    try {
      ExtensionClassLoader ecl = new ExtensionClassLoader();
      List<File> ui_modules = ecl.getUIModules();

      for (File ui : ui_modules) {
        Properties p = new Properties();
        p.load(new FileReader(ui));
        for (Object key : p.keySet()) {
View Full Code Here

Examples of es.emergya.tools.ExtensionClassLoader

    }
  }

  protected void loadModules(PluginContainer container) {
    try {
      ExtensionClassLoader ecl = new ExtensionClassLoader();
      List<File> modules = ecl.getModules();
      for (File module : modules) {
        Properties p = new Properties();
        try {
          p.load(new FileReader(module));
          String _class = p.get("CLASS").toString();
View Full Code Here

Examples of scalaExec.ClassLoaders.ExtensionClassLoader

         fileStr.append(File.pathSeparator+(String)ce);
    }
    GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());
   
      ClassLoader parentClassLoader = getClass().getClassLoader();
      GlobalValues.extensionClassLoader = new  ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);
      
      // update GUI components to account for the updated ScalaSci classpath
                scalaExec.scalaLab.scalaLab.updateTree();
               
      boolean compilationSucccess = true;
  
      String tempFileName = "";
tempFileName = javaFile+".java";   // public classes and Java files should have the same name

      String [] command  = new String[6];
       command[0] "javac";
       command[1] = "-cp";
       command[2] =  GlobalValues.jarFilePath+File.pathSeparator+GlobalValues.homeDir;
       command[3] = "-d";   // where to place output class files
       command[4] = SelectedFilePathOnly;   //  the path to save the compiled class files
       command[5] =  javaFile;  // full filename to compile

       String compileCommandString = command[0]+"  "+command[1]+"  "+command[2]+" "+command[3]+" "+command[4]+" "+command[5];

       System.out.println("compileCommand Java= "+compileCommandString);

            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                int rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2];
                if (rv==0) {
                 System.out.println("Process:  "+commandString+"  exited successfully ");
                  generateScriptCodeButton.setEnabled(true);
                   statusAreaBottom.setText("Step5:  You can proceed now to create a draft script that utilizes your Java-based  ODE integrator");
                }
                else
                 System.out.println("Process:  "+commandString+"  exited with error, error value = "+rv);

                } catch (IOException exio) {
                    System.out.println("IOException trying to executing "+command);
                    exio.printStackTrace();

                }
               catch (InterruptedException ie) {
                    System.out.println("Interrupted Exception  trying to executing "+command);
                    ie.printStackTrace();
                }
  
                    }
         });
        
                 // Compile with the internal compiler
                 compileJavaInternalCompilerButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
        String currentWorkingDirectory = GlobalValues.workingDir;
          JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
          int ret = chooser.showOpenDialog(ODEWizardFrame);

          if (ret != JFileChooser.APPROVE_OPTION) {
                return;
              }
         File f = chooser.getSelectedFile();
         String javaFile=null;
         try {
            javaFile = f.getCanonicalPath();
            }
         catch (IOException ex) {
               System.out.println("I/O Exception in getCanonicalPath");
               ex.printStackTrace();
         }

   //   extract the path specification of the generated Java class that implements the ODE solution method,
  //    in order to update the ScalaSci class path
      String SelectedFileWithPath = f.getAbsolutePath();
      String SelectedFilePathOnly = SelectedFileWithPath.substring(0, SelectedFileWithPath.lastIndexOf(File.separatorChar));

      if (GlobalValues.ScalaSciClassPath.length()==0)
          GlobalValues.ScalaSciClassPath=".";
      if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly)==-1)  {
        GlobalValues.ScalaSciClassPathComponents.add(0,SelectedFilePathOnly);
        GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath+File.pathSeparator+SelectedFilePathOnly;
        }
          // update also the ScalaSciClassPath property
      StringBuilder fileStr = new StringBuilder();
      Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements();
      while (enumDirs.hasMoreElements())  {
         Object ce = enumDirs.nextElement();
         fileStr.append(File.pathSeparator+(String)ce);
    }
    GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());

      ClassLoader parentClassLoader = getClass().getClassLoader();
      GlobalValues.extensionClassLoader = new  ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);

      // update GUI components to account for the updated ScalaSci classpath
                scalaExec.scalaLab.scalaLab.updateTree();
               
      String [] command  = new String[11];
View Full Code Here

Examples of scalaExec.ClassLoaders.ExtensionClassLoader

                return;
            }
       File f = chooser.getSelectedFile();
      
                JavaCompile javaCompileObj = new JavaCompile();
                ExtensionClassLoader  extClassLoader = GlobalValues.extensionClassLoader;
                String javaFile = f.getAbsolutePath();
                String packageName = "";   // do not place the new Java Classes within some package !!
               if (javaFile.indexOf(".java")!=-1)  {   // file is a Java source file
         boolean compilationResult = javaCompileObj.compileFile(javaFile);
         if (compilationResult == true// success
         {
             System.out.println("Compilation success for file "+packageName+"."+javaFile);
             int lastPos = javaFile.length()-5// for ".java"
             String withoutExtJavaStr = javaFile.substring(0, lastPos);

                     // the class name without the path component
             String  classNameToLoad =withoutExtJavaStr.substring(withoutExtJavaStr.lastIndexOf(File.separatorChar)+1, withoutExtJavaStr.length());
             int javaNameIdx = javaFile.indexOf(classNameToLoad);
             String pathToAdd = javaFile.substring(0, javaNameIdx-1);   // path to add the the extension class loader class path
             extClassLoader.extendClassPath(pathToAdd)// append the path
                      
           try {   // try to load the class
                        Class  loadedClass = extClassLoader.loadClass(classNameToLoad);
                        Method m = null;
                        // used for invoking the main method of a Java class
                        try {
                            m = loadedClass.getMethod("main", formals);
                        }
View Full Code Here

Examples of scalaExec.ClassLoaders.ExtensionClassLoader

           JMenuItem compileRunItem = new JMenuItem("Compile .java file and run");
           compileRunItem.setFont(scalaExec.Interpreter.GlobalValues.puifont);
           compileRunItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath);
                JavaCompile javaCompileObj = new JavaCompile();
                ExtensionClassLoader  extClassLoader = GlobalValues.extensionClassLoader;
                String selectedValue = scalaLabPathsListener.selectedValue;
                String  pathComponent = selectedValue.substring(0, selectedValue.lastIndexOf(File.separatorChar));
                GlobalValues.selectedExplorerPath = pathComponent;
                String javaFile = selectedValue;
                String packageName = "";   // do not place the new Java Classes within some package !!
View Full Code Here

Examples of scalaExec.ClassLoaders.ExtensionClassLoader

        super("Load  All Classes from ScalaSciClassPath");
    }
   
    public  void actionPerformed(ActionEvent e)  {
       
                 ExtensionClassLoader  extClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath);
                
                 Enumeration enumElem = GlobalValues.ScalaSciClassPathComponents.elements();
        while  (enumElem.hasMoreElements())  {   // for all ScalaSciClassPath Components
               Object next = (Object)enumElem.nextElement();
                    String pathName = next.toString().trim();
                     File dir = new File(pathName);
                     String[] files = dir.list();
                     if (files != null) { 
              for (int k=0; k<files.length; k++)  {   // for all files in the current directory
                      String currentFile = files[k];
                     
                    int idx  = currentFile.indexOf(".class");
                    int idxOfBackup = currentFile.indexOf("~")// avoid using backup UNIX style files
                    if (idx != -1 && idxOfBackup==-1)  {  // file is a .class file
                        String  classNameToLoad = currentFile.substring(0, idx);
                        try {
                        Class  loadedClass = extClassLoader.loadClass(classNameToLoad);
                        Method m = null;
                        try {
                            m = loadedClass.getMethod("main", scalaExec.scalaLab.scalaLab.formals);
                        }
                        catch (NoSuchMethodException exc) {
                            System.out.println(" no main in  "+classNameToLoad);
                            exc.printStackTrace();
                            break;
                        }
                       
                        try {
                            m.invoke(null, scalaExec.scalaLab.scalaLab.actuals);
                        }
                        catch (Exception exc)  {
                            exc.printStackTrace();
                          }
                        }
                       
                        catch (ClassNotFoundException ex)  {
                            System.out.println("Class: "+classNameToLoad+" not found");
                            ex.printStackTrace();
                        }
                        System.out.println("pathName ="+pathName);
                    }   // file is a .class file
                   
                    int javaIdx = currentFile.indexOf(".java");
                    idxOfBackup = currentFile.indexOf("~");
                    if (javaIdx != -1 && idxOfBackup==-1)  {
                      JavaCompile javaCompileObj = new JavaCompile();
       
         String packageName = "";
         String javaFile = pathName+File.separatorChar+currentFile; 
         boolean compilationResult = javaCompileObj.compileFile(javaFile);
         if (compilationResult == true// success
         {
             System.out.println("Compilation success for file "+packageName+"."+javaFile);
             int lastPos = javaFile.length()-5// for ".java"
             String  classNameToLoad = javaFile.substring(javaFile.lastIndexOf(File.separatorChar)+1, lastPos);
                      
           try {   // try to load the class
                        Class  loadedClass = extClassLoader.loadClass(classNameToLoad);
                        Method m = null;
                        try {
                            m = loadedClass.getMethod("main", scalaExec.scalaLab.scalaLab.formals);
                        }
                        catch (NoSuchMethodException exc) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.