public static java.lang.String[] getServiceNames() { // should this return the required ones even though no stub?? if (stub == null) return new String[0]; return stub.getServiceNames(); }
/** * Returns the service, or null instead of an UnavailableServiceException */ private static Object getService(String name) { try { return ServiceManager.lookup(name); } catch (UnavailableServiceException ex) { return null; } }
/** * Get the Java WebStart codebase. * @return The codebase. */ public URL getCodeBase() { if (m_bs != null) return m_bs.getCodeBase(); return null; } /**
/** * Open this file. * @return */ public InputStream openFileStream(String pathHint, String[] extensions) { if (fos == null) { try { fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); } catch (UnavailableServiceException e) { fos = null; } } if (fos != null) { try { // ask user to select a file through this service FileContents fc = fos.openFileDialog(pathHint, extensions); return fc.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } return null; }
/** * Creates new MuffinManager. * @param applet The parent object (ignored). */ public void init(Object applet) { try { m_ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService"); m_bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); m_strCodeBase = m_bs.getCodeBase().toString(); } catch (UnavailableServiceException e) { m_ps = null; m_bs = null; } } /**
@Override public InputStream openInputFile(String fileName) throws IOException { checkBasics("openInputFile"); URL fileURL = fileNameToURL(fileName); try { return new BufferedInputStream(ps.get(fileURL).getInputStream()); } catch (Exception e) { throw new IOException("openInputFile \"" + fileName + "\" failed", e); } }
/** * Get data from the system clipboard. * @return */ public Transferable getClipboardContents() { if ((clipboardReadStatus & CLIPBOARD_DISABLED) == CLIPBOARD_DISABLED) return null; // Rejected it last time, don't ask again clipboardReadStatus = CLIPBOARD_DISABLED; if (cs == null) { try { cs = (ClipboardService)ServiceManager.lookup("javax.jnlp.ClipboardService"); } catch (UnavailableServiceException e) { cs = null; } } if (cs != null) { // get the contents of the system clipboard and print them Transferable tr = cs.getContents(); if (tr != null) clipboardReadStatus = CLIPBOARD_ENABLED; return tr; } return null; } /**
@Override public boolean deleteFile(String fileName) throws IOException { checkBasics("deleteFile"); URL fileURL = fileNameToURL(fileName); try { ps.delete(fileURL); return true; } catch (Exception e) { throw new IOException("openInputFile \"" + fileName + "\" failed", e); } } }
public static java.lang.Object lookup(java.lang.String name) throws UnavailableServiceException { if (stub == null) throw new UnavailableServiceException("service stub not set."); synchronized(lookupTable) { Object result = lookupTable.get(name); if (result == null) { result = stub.lookup(name); if (result != null) lookupTable.put(name, result); } if (result == null) throw new UnavailableServiceException("service not available (stub returned null)."); return result; } }
/** * Display this URL in a web browser. * @param url The URL to display. * @return True if successfully displayed. */ public boolean showTheDocument(URL url) { if (m_bs != null) return m_bs.showDocument(url); return false; } private ClipboardService cs = null;
/** */ private String getClue(FileContents fc, URL source) { if (fc != null) try { return fc.getName(); } catch (IOException x) {} // just fall through: failure _is_ an option in this case if (source != null) return source.getPath(); return "worksheet.hwks"; }
/** * Returns the service. * * @throws UnavailableServiceException if service is not available */ public Object lookup(String name) throws UnavailableServiceException { // exact match for (int i=0; i < serviceNames.length; i++) if (serviceNames[i].equals(name)) return services[i]; // substring match for (int i=0; i < serviceNames.length; i++) if (-1 != serviceNames[i].indexOf(name)) return services[i]; throw new UnavailableServiceException(""+name); }
final BasicService bs = (BasicService) ServiceManager.lookup( "javax.jnlp.BasicService"); final URL codeBase = bs.getCodeBase();
public InputStream openInputFile(String fileName) throws IOException { checkBasics("openInputFile"); URL fileURL = fileNameToURL(fileName); try { return new BufferedInputStream(ps.get(fileURL).getInputStream()); } catch(Exception e) { throw new LSException("openInputFile \"" + fileName + "\" failed", e); } }
PersistenceServiceIO() { try { bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService"); ps = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService"); } catch (UnavailableServiceException e) { logger.log(Level.SEVERE, initFailedMessage("ServiceManager.lookup"), e); bs = null; ps = null; } }
public boolean deleteFile(String fileName) throws IOException { checkBasics("deleteFile"); URL fileURL = fileNameToURL(fileName); try { ps.delete(fileURL); return true; } catch(Exception e) { throw new LSException("openInputFile \"" + fileName + "\" failed", e); } } }
import javax.jnlp.*; BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); URL codebase = bs.getCodeBase();
PersistenceServiceIO() { try { bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService"); } catch (UnavailableServiceException e) { logger.log(Level.SEVERE, initFailedMessage("ServiceManager.lookup"), e); bs = null; ps = null; } }
private URL fileNameToURL(String name) throws IOException { if (name == null) { throw new IOException("name is not set"); } try { return new URL(bs.getCodeBase(), name); } catch (MalformedURLException e) { throw new IOException("invalid filename \"" + name + "\"", e); } }
private URL fileNameToURL(String name) throws IOException { try { return new URL(bs.getCodeBase(), name); } catch (MalformedURLException e) { throw new LSException("invalid filename \"" + name + "\"", e); } }