Package java.net

Examples of java.net.URL


        if (location ==  null) {
            return null;
        }

        try {
            URL url = new URL(location);
            URLConnection con = url.openConnection();

            // do we have if-modified-since or etag headers to set?
            if (condition != null && condition != Undefined.instance) {
                if (condition instanceof Scriptable) {
                    Scriptable scr = (Scriptable) condition;
                    if ("Date".equals(scr.getClassName())) {
                        Date date = new Date((long) ScriptRuntime.toNumber(scr));

                        con.setIfModifiedSince(date.getTime());

                        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",
                                                                   Locale.UK);

                        format.setTimeZone(TimeZone.getTimeZone("GMT"));
                        con.setRequestProperty("If-Modified-Since", format.format(date));
                    }else {
                        con.setRequestProperty("If-None-Match", scr.toString());
                    }
                } else {
                    con.setRequestProperty("If-None-Match", condition.toString());
                }
            }

            String httpUserAgent = app.getProperty("httpUserAgent");

            if (httpUserAgent != null) {
                con.setRequestProperty("User-Agent", httpUserAgent);
            }

            if (timeout != null && timeout != Undefined.instance) {
                int time = ScriptRuntime.toInt32(timeout);
                con.setConnectTimeout(time);
                con.setReadTimeout(time);
            }

            con.setAllowUserInteraction(false);

            String filename = url.getFile();
            String contentType = con.getContentType();
            long lastmod = con.getLastModified();
            String etag = con.getHeaderField("ETag");
            int length = con.getContentLength();
            int resCode = 0;
View Full Code Here


                    img = generator.createImage((byte[]) arg);
                } else if (arg instanceof String) {
                    // the string could either be a url or a local filename, let's try both:
                    String str = arg.toString();
                    try {
                        URL url = new URL(str);
                        img = generator.createImage(url);
                    } catch (MalformedURLException e) {
                        // try the local file now:
                        img = generator.createImage(str);
                    }
View Full Code Here

                    String str = (String) arg;
                    // try to interpret argument as URL if it contains a colon,
                    // otherwise or if URL is malformed interpret as file name.
                    if (str.indexOf(":") > -1) {
                        try {
                            URL url = new URL(str);
                            in = url.openStream();
                        } catch (MalformedURLException mux) {
                            in = new FileInputStream(str);
                        }
                    } else {
                        in = new FileInputStream(str);
View Full Code Here

    infoPanel.setText(generateHtml(doc));

    infoPanel.addHyperlinkListener(new HyperlinkListener() {
      public void hyperlinkUpdate(HyperlinkEvent evt) {
        if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          URL url = evt.getURL();
          if (url != null) {
              Launch.openURL(url.toString());
          }
        }
      }
    });
View Full Code Here

     * {@link HttpTransportOptions}.
     */
    public Channel buildDuplexChannel(String endpoint, TransportOptions transportOptions)
            throws WsConfigurationException {
        try {
            URL url = new URL(endpoint);
            return new HttpChannel(url, (HttpTransportOptions)transportOptions);
        } catch (MalformedURLException e) {
            throw new WsConfigurationException("Unable to create URL for endpoint '" + endpoint + '\'', e);
        }
    }
View Full Code Here

  private static final URL WSDL_URL = createURL(WSDL_LOCATION);

  private static URL createURL(String location) {
    try {
      return new URL(location);
    }
    catch (MalformedURLException e) {
      throw new IllegalArgumentException(location, e);
    }
  }
View Full Code Here

    private SecureServiceTestHarness_SecureServiceTestHarnessPort_Client() {
    }

    public static void main(String args[]) throws Exception {
        URL wsdlURL = SecureServiceTestHarnessService.WSDL_LOCATION;
        if (args.length > 0) {
            File wsdlFile = new File(args[0]);
            try {
                if (wsdlFile.exists()) {
                    wsdlURL = wsdlFile.toURI().toURL();
                } else {
                    wsdlURL = new URL(args[0]);
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        }
View Full Code Here

    public boolean runTest(int arg0) {
      LOG.info("Executing operation runTest("+arg0+")");

      try {
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = SecureServiceTestHarnessImpl.class.getResource("/wssec.xml");

        Bus bus = bf.createBus(busFile.toString());
        bf.setThreadDefaultBus(bus);

        QName portName=new QName("http://www.jboss.org/bpel/examples/wsdl", "SecureHelloPort");
       
        URL wsdlURL = new URL("http://127.0.0.1:8080/Quickstart_bpel_secure_serviceWS?wsdl");
       
        Service service = Service.create(wsdlURL, SERVICE_NAME);
        Dispatch<SOAPMessage> dispatcher = service.createDispatch(
            portName, SOAPMessage.class, Service.Mode.MESSAGE);
      
View Full Code Here

    private JAXWSDispatcherClient() {
    }

    public static void main(String args[]) throws Exception {
        URL wsdlURL = null;
       
        if (args.length != 2) {
          System.err.println("Usage: JAXWSDispatcherClient wsdlURL messageFile");
          System.exit(1);
        }
       
        File wsdlFile = new File(args[0]);
        try {
            if (wsdlFile.exists()) {
                wsdlURL = wsdlFile.toURI().toURL();
            } else {
                wsdlURL = new URL(args[0]);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
            System.exit(2);
        }
     
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = ClassLoader.getSystemResource("wssec.xml");
        Bus bus = bf.createBus(busFile.toString());
        bf.setDefaultBus(bus);
       
        QName portName=new QName("http://www.jboss.org/bpel/examples/wsdl", "SecureHelloPort");
       
       
View Full Code Here

  @Override
  public void createPartControl(Composite parent) {
    _browser = new Browser(parent, SWT.NONE);
    Bundle plugin = WGADesignerPlugin.getDefault().getBundle();
    IPath relativePagePath = new Path("resources/html/gettingStarted/step1.1.html");
    URL fileInPlugin = FileLocator.find(plugin, relativePagePath, null);
    if (fileInPlugin != null) {
      try {
        URL pageUrl = FileLocator.toFileURL(fileInPlugin);
        _browser.setUrl(pageUrl.toString());
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
View Full Code Here

TOP

Related Classes of java.net.URL

Copyright © 2018 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.