Package java.net

Examples of java.net.URL


            log.log(   LoggerChannel.LT_INFORMATION, "        " + msg + "Download from "+
                  sf_plugin_download);
           
            ResourceDownloaderFactory rdf =  plugin_interface.getUtilities().getResourceDownloaderFactory();
           
            ResourceDownloader direct_rdl = rdf.create( new URL( sf_plugin_download ));

              // work out what the torrent download will be, if it exists
              // sf_plugin_download will be something like ../plugins/safepeer_2.4.zip
              //     torrent is safepeer_2.4.zip.torrent
           
            String  torrent_download = Constants.AELITIS_TORRENTS;
           
            int  slash_pos = sf_plugin_download.lastIndexOf("/");
           
            if ( slash_pos == -1 ){
             
              torrent_download += sf_plugin_download;
             
            }else{
             
              torrent_download += sf_plugin_download.substring( slash_pos + 1 );
            }
           
            torrent_download  += ".torrent";
           
            ResourceDownloader torrent_rdl = rdf.create( new URL( torrent_download ));

            torrent_rdl  = rdf.getSuffixBasedDownloader( torrent_rdl );
           
              // create an alternate downloader with torrent attempt first
           
View Full Code Here


     * @throws RuntimeException ...
     */
    public INode convert(String desc, INode helmaNode)
                  throws RuntimeException {
        try {
            return convert(new URL(desc), helmaNode);
        } catch (MalformedURLException notanurl) {
            try {
                return convert(new File(desc), helmaNode);
            } catch (FileNotFoundException notfound) {
                throw new RuntimeException("couldn't read xml: " + desc);
View Full Code Here

   */
  public static File findFileOnClasspath( String filename )
  {
    ClassLoader cl               = null ;
    File file                    = null ;
    URL url                      = null ;

    try
    {
      cl = FileFinder.class.getClassLoader() ;
      if ( cl == null )
      {
        // System.out.println( "No classloader found !\n<P>" ) ;
        return null ;
      }
      url = cl.getResource( filename ) ;
      if ( url == null )
      {
        // System.out.println( "Settings file '" + filename + "' not found in CLASSPATH !!!" ) ;
      }
      else
      {
        file = new File( url.getFile() ) ;
        // System.out.println( "Settings file '" + file.getAbsolutePath() + "' exists: " + file.exists() ) ;
        if ( ! fileExists( file ) )
          file = null ;
      }
    }
View Full Code Here

          if ( plugin_class_loader instanceof URLClassLoader ){

            URLClassLoader  current = (URLClassLoader)plugin_class_loader;

            URL url = current.findResource("plugin.properties");

            if ( url != null ){
              URLConnection connection = url.openConnection();

              InputStream is = connection.getInputStream();

              props.load(is);

            }else{

              throw( new Exception( "failed to load plugin.properties from jars"));
            }
          }else{

            throw( new Exception( "failed to load plugin.properties from dir or jars"));

          }
        }
      }catch( Throwable e ){

        Debug.printStackTrace( e );

        String  msg =  "Can't read 'plugin.properties' for plugin '" + pluginName + "': file may be missing";

        Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));

        System.out.println( msg );

        throw( new PluginException( msg, e ));
      }

      checkJDKVersion( pluginName, props, true );
      checkAzureusVersion(pluginName, props, true);

      plugin_class_string = (String)props.get( "plugin.class");

      if ( plugin_class_string == null ){

        plugin_class_string = (String)props.get( "plugin.classes");

        if ( plugin_class_string == null ){

          // set so we don't bork later will npe

          plugin_class_string = "";
        }
      }

      String  plugin_name_string = (String)props.get( "plugin.name");

      if ( plugin_name_string == null ){

        plugin_name_string = (String)props.get( "plugin.names");
      }

      int  pos1 = 0;
      int  pos2 = 0;

      while(true){
        int  p1 = plugin_class_string.indexOf( ";", pos1 );

        String  plugin_class;

        if ( p1 == -1 ){
          plugin_class = plugin_class_string.substring(pos1).trim();
        }else{
          plugin_class  = plugin_class_string.substring(pos1,p1).trim();
          pos1 = p1+1;
        }

        PluginInterfaceImpl existing_pi = getPluginFromClass( plugin_class );

        if ( existing_pi != null ){

          if (bSkipAlreadyLoaded) {
            break;
          }

          // allow user dir entries to override app dir entries without warning

          File  this_parent   = directory.getParentFile();
          File  existing_parent = null;

          if ( existing_pi.getInitializerKey() instanceof File ){

            existing_parent  = ((File)existing_pi.getInitializerKey()).getParentFile();
          }

          if (   this_parent.equals( FileUtil.getApplicationFile("plugins")) &&
              existing_parent  != null &&
              existing_parent.equals( FileUtil.getUserFile( "plugins" ))){

            // skip this overridden plugin

            if (Logger.isEnabled())
              Logger.log(new LogEvent(LOGID, "Plugin '" + plugin_name_string
                  + "/" + plugin_class
                  + ": shared version overridden by user-specific one"));

            return( new ArrayList());

          }else{
            Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_WARNING,
                "Error loading '" + plugin_name_string + "', plugin class '"
                + plugin_class + "' is already loaded"));
          }

        }else{

          String  plugin_name = null;

          if ( plugin_name_string != null ){

            int  p2 = plugin_name_string.indexOf( ";", pos2 );


            if ( p2 == -1 ){
              plugin_name = plugin_name_string.substring(pos2).trim();
            }else{
              plugin_name  = plugin_name_string.substring(pos2,p2).trim();
              pos2 = p2+1;
            }   
          }

          Properties new_props = (Properties)props.clone();

          for (int j=0;j<default_version_details.length;j++){

            if ( plugin_class.equals( default_version_details[j][0] )){

              if ( new_props.get( "plugin.id") == null ){

                new_props.put( "plugin.id", default_version_details[j][1])
              }

              if ( plugin_name == null ){

                plugin_name  = default_version_details[j][2];
              }

              if ( new_props.get( "plugin.version") == null ){

                // no explicit version. If we've derived one then use that, otherwise defaults

                if ( plugin_version[0] != null ){

                  new_props.put( "plugin.version", plugin_version[0]);

                }else{

                  new_props.put( "plugin.version", default_version_details[j][3]);
                }
              }
            }
          }

          new_props.put( "plugin.class", plugin_class );

          if ( plugin_name != null ){

            new_props.put( "plugin.name", plugin_name );
          }

          // System.out.println( "loading plugin '" + plugin_class + "' using cl " + classLoader);

          // if the plugin load fails we still need to generate a plugin entry
          // as this drives the upgrade process


          Throwable  load_failure  = null;

          String pid = plugin_id[0]==null?directory.getName():plugin_id[0];

          List<File>  verified_files = null;

          Plugin plugin = null;

          if ( vc_disabled_plugins.contains ( pid )){

            log( "Plugin '" + pid + "' has been administratively disabled" );

          }else{
            try{
              String cl_key = "plugin.cl.ext." + pid;
             
              String str = COConfigurationManager.getStringParameter( cl_key, null );

              if ( str != null && str.length() > 0 ){

                COConfigurationManager.removeParameter( cl_key );
               
                plugin_class_loader = PluginLauncherImpl.extendClassLoader( root_class_loader, plugin_class_loader, new URL( str ));
              }
            }catch( Throwable e ){ 
            }

            if ( pid.endsWith( "_v" )){
View Full Code Here

        InputStream in = null;
        try {
          String name = args[index++];
          System.out.print(name + ";");
          if (name.startsWith("http://")) {
            in = new URL(name).openConnection().getInputStream();
          } else {
            in = new FileInputStream(name);
          }
          run(name, in, imageInfo, verbose);
          in.close();
View Full Code Here

        Document doc;

        if (obj instanceof String) {
            try {
                // first try to interpret string as URL
                new URL(obj.toString());

                doc = parser.parse(obj.toString());
            } catch (MalformedURLException nourl) {
                // if not a URL, maybe it is the XML itself
                doc = parser.parse(new InputSource(new StringReader(obj.toString())));
View Full Code Here

        }

        if (obj instanceof String) {
            try {
                // first try to interpret string as URL
                URL url = new URL(obj.toString());
                return getHtmlDocument(new InputStreamReader(url.openStream()));
            } catch (MalformedURLException nourl) {
                // if not a URL, maybe it is the XML itself
                return getHtmlDocument(new StringReader(obj.toString()));
            }
        } else if (obj instanceof InputStream) {
View Full Code Here

   * @param url the url to load from
   * @throws IOException if the url can't be set.
   */
  public void setURL(String url) throws IOException {
    m_URL = url;
    setSource(new URL(url));
  }
View Full Code Here

   * @deprecated
   */
  public void openTorrentURL(String url) {
    PluginDeprecation.call("openTorrentURL", this.getPluginID());
    try{
      getDownloadManager().addDownload( new URL( url ));
    }catch( Throwable e ){
      throw( new RuntimeException(e));
    }
  }
View Full Code Here

 
  public URL[]
  getURLs()
  {
    try{
      URL  url = new URL((server.isSSL()?"https":"http") + "://" +  server.getHost() + ":" + server.getPort() + "/" );
       
        // quick fix for badly specified host whereby a valid URL is constructed but the port lost. For example, if#
        // someone has entered http://1.2.3.4 as the host
     
      if ( url.getPort() != server.getPort()){
       
        Debug.out( "Invalid URL '" + url + "' - check tracker configuration" );
       
        url = new URL( "http://i.am.invalid:" + server.getPort() + "/" );
      }
     
      returnnew URL[]{ url });
     
    }catch( MalformedURLException e ){
View Full Code Here

TOP

Related Classes of java.net.URL

Copyright © 2015 www.massapicom. 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.