当前位置: 首页>>代码示例>>Java>>正文


Java ServiceManager类代码示例

本文整理汇总了Java中javax.jnlp.ServiceManager的典型用法代码示例。如果您正苦于以下问题:Java ServiceManager类的具体用法?Java ServiceManager怎么用?Java ServiceManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceManager类属于javax.jnlp包,在下文中一共展示了ServiceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isWebstartAvailable

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Quick test to see if running through Java webstart
 * 
 * @return True if jws running
 */
private boolean isWebstartAvailable()
{
	try
	{
		Class.forName("javax.jnlp.ServiceManager");
		// this causes to go and see if the service is available
		ServiceManager.lookup("javax.jnlp.PersistenceService");
		Log.info("Webstart detected using Muffins");
	}
	catch (Exception e)
	{
		Log.info("Using Local File System");
		return false;
	}
	return true;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:SavedState.java

示例2: open

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Shows a dialog to select a file.
 *
 * @return InputStream
 * @throws FileChooserException
 */
public NamedInputStream open() throws FileChooserException {
    try {
        FileOpenService fos = (FileOpenService) ServiceManager.lookup(FileOpenService.class.getName());
        FileContents fc = null;
        if ((fc = fos.openFileDialog(getUserDirectory(), null)) != null) {
            logger.info("Loaded: " + fc.getName());
            return new NamedInputStream(fc.getName(), fc.getInputStream());
        } else {
            return null;
        }
    } catch (Exception e) {
        String message = "Failed open: " + e.getMessage();
        logger.warning(message);
        throw new FileChooserException(message);
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:23,代码来源:FileChooserJNLP.java

示例3: save

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Saves an input stream to a file.
 *
 * @param is
 * @param fileName
 * @return Boolean
 * @throws FileChooserException
 */
public boolean save(InputStream is, String fileName) throws FileChooserException {
    try {
        FileSaveService fss = (FileSaveService) ServiceManager.lookup(FileSaveService.class.getName());
        FileContents fc = fss.saveFileDialog(getUserDirectory(), null, is, fileName);
        if (fc != null) {
            logger.info("Saved: " + fc.getName());
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        String message = "Failed save: " + e.getMessage();
        logger.warning(message);
        throw new FileChooserException(message);
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:25,代码来源:FileChooserJNLP.java

示例4: replaceCopyAction

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Replaces the editor's default copy action in security restricted
 * environments with one messaging the ClipboardService. Does nothing 
 * if not restricted.
 * 
 * @param editor the editor to replace 
 */
public static void replaceCopyAction(final JEditorPane editor) {
    if (!isRestricted()) return;
    Action safeCopy = new AbstractAction() {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                ClipboardService cs = (ClipboardService)ServiceManager.lookup
                    ("javax.jnlp.ClipboardService");
                StringSelection transferable = new StringSelection(editor.getSelectedText());
                cs.setContents(transferable);
            } catch (Exception e1) {
                // do nothing
            }
        }
    };
    editor.getActionMap().put(DefaultEditorKit.copyAction, safeCopy);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:DemoUtils.java

示例5: browse

import javax.jnlp.ServiceManager; //导入依赖的package包/类
public static boolean browse(URI uri) throws IOException , UnavailableServiceException {
        // Try using the Desktop api first
        try {
            Desktop desktop = Desktop.getDesktop();
            desktop.browse(uri);

            return true;
        } catch (SecurityException e) {
//             Running in sandbox, try using WebStart service
            BasicService basicService =
                    (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");

            if (basicService.isWebBrowserSupported()) {
                return basicService.showDocument(uri.toURL());
            }
        }

        return false;
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:20,代码来源:DemoUtilities.java

示例6: getCodeBaseJavaws

import javax.jnlp.ServiceManager; //导入依赖的package包/类
public URL getCodeBaseJavaws() {
    try {
        BasicService bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
        URL codebase = bs.getCodeBase();
        if (codebase != null) {
            System.out.println("javaws codebase: " + codebase.toString());
            return codebase;
        } else {
            System.out.println("javaws codebase: null");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("javaws codebase: null");
    }
    return null;
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:17,代码来源:GifarMain.java

示例7: proceed

import javax.jnlp.ServiceManager; //导入依赖的package包/类
private void proceed() {

        try {
            SingleInstanceService testService = (SingleInstanceService) ServiceManager.lookup("javax.jnlp.SingleInstanceService");
            System.out.println("SingleInstanceChecker: Adding listener to service.");
            testService.addSingleInstanceListener(this);
            System.out.println("SingleInstanceChecker: Listener added.");
        } catch (UnavailableServiceException use) {
            System.err.println("SingleInstanceChecker: Service lookup failed.");
            use.printStackTrace();
        } finally {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        Thread.sleep(5000);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    } finally {
                        startKiller(2);
                    }
                }
            }).start();
        }
    }
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:27,代码来源:SingleInstanceChecker.java

示例8: checkSetup

import javax.jnlp.ServiceManager; //导入依赖的package包/类
public void checkSetup(String method) {
    try {
        BasicService basicService =
            (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
        // getCodeBase() will return null if ServiceManager does not 
        // have access to ApplicationInstance.
        String codebase = basicService.getCodeBase().toString();
        System.out.println("Codebase for applet was found in " + method
            + ": " + codebase);
    } catch (NullPointerException npe) {
        System.err.println("Exception occurred with null codebase in " + method);
        npe.printStackTrace();
    } catch (Exception ex) {
        System.err.println("Exception occurred (probably with ServiceManager).");
      ex.printStackTrace();
    }
}
 
开发者ID:GITNE,项目名称:icedtea-web,代码行数:18,代码来源:CheckServices.java

示例9: checkIntegration

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Checks that the application is integrated into the host.
 * 
 * @see http://docs.oracle.com/javase/7/docs/jre/api/javaws/jnlp/javax/jnlp/IntegrationService.html
 */
private static void checkIntegration() {
	System.out.println("Integration check");
	IntegrationService is = null;
	try {
		is = (IntegrationService) ServiceManager.lookup("javax.jnlp.IntegrationService");
		/* No shortcut atm
		// the shortcut string must match the <title> in the jnlp file
		if (!is.requestShortcut(true, false, "Desktop Sharing")) {
			// failed to install shortcuts
			System.err.println("Shortcut creation failed");
		}
		*/
		if (!is.hasAssociation("application/x-bigmarker-deskshare", new String[] { "bmdeskshare", "bmds" })) {
			if (!is.requestAssociation("application/x-bigmarker-deskshare", new String[] { "bmdeskshare", "bmds" })) {
				// failed to install shortcuts
				System.err.println("Association creation failed");
			}
		} else {
			// association already exists
			System.out.println("Mime-type association exists");
		}
	} catch (UnavailableServiceException use) {
		System.err.println("Integration service unavailable");
	}
}
 
开发者ID:BigMarker,项目名称:deskshare-public,代码行数:31,代码来源:Main.java

示例10: shouldReadTargetJavaURLRelativePath

import javax.jnlp.ServiceManager; //导入依赖的package包/类
@Test
public void shouldReadTargetJavaURLRelativePath() throws UnavailableServiceException, MalformedURLException {
    // given
    System.setProperty("jnlp.IceBoar.targetJavaURL", "myURL.zip");
    System.setProperty("jnlp.IceBoar.jar.0", "xyz.jar");
    BasicService service = mock(BasicService.class);
    when(service.getCodeBase()).thenReturn(new URL("http://example.com/codebase/"));
    ServiceManagerStub stub = mock(ServiceManagerStub.class);
    when(stub.lookup("javax.jnlp.BasicService")).thenReturn(service);
    ServiceManager.setServiceManagerStub(stub); //lookup("javax.jnlp.BasicService")).getCodeBase()

    // when
    GlobalSettings settings = GlobalSettingsFactory.getGlobalSettings(null);

    // then
    assertThat(settings.getTargetJavaURL())
            .isEqualTo("http://example.com/codebase/myURL.zip");
}
 
开发者ID:Roche,项目名称:IceBoar,代码行数:19,代码来源:GlobalSettingsFactoryTest.java

示例11: WebstartPersistence

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Creates a instance of class
 */
public WebstartPersistence() {
	try {
		ps = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService");
		bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");

		if (ps != null && bs != null) {
			codebase = bs.getCodeBase();
		}

	} catch (UnavailableServiceException e) {
		e.printStackTrace(System.err);
		ps = null;
		bs = null;
	}
}
 
开发者ID:arianne,项目名称:marauroa,代码行数:19,代码来源:WebstartPersistence.java

示例12: getWebAppContextUrl

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Uses the jnlp API to determine the webapp context.
 * If used outside of webstart, <code>fallBackWebAppContextUrl</code> is returned.
 * For example this could return <code>http://localhost:8080/mywebapp/</code>.
 *
 * @return the url to the webapp ending with a slash
 */
public String getWebAppContextUrl() {
    String webAppContextUrl;
    try {
        BasicService basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
        String codeBase = basicService.getCodeBase().toExternalForm();
        if (!codeBase.endsWith("/")) {
            codeBase += "/";
        }
        int webAppContextUrlLength = codeBase.lastIndexOf(jnlpRelativeDirectoryPathFromWebAppContext);
        webAppContextUrl = codeBase.substring(0, webAppContextUrlLength + 1);
    } catch (UnavailableServiceException e) {
        // TODO logging
        webAppContextUrl = fallBackWebAppContextUrl;
    }
    return webAppContextUrl;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:24,代码来源:JnlpPropertyPlaceholderConfigurer.java

示例13: open

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Shows a dialog to select a file.
 * 
 * @return InputStream
 * @throws FileChooserException
 */
public NamedInputStream open() throws FileChooserException {
	try {
	    FileOpenService fos = (FileOpenService) ServiceManager.lookup(FileOpenService.class.getName());
		FileContents fc = null;
		if ((fc = fos.openFileDialog(getUserDirectory(), null)) != null) {
		    logger.info("Loaded: " + fc.getName());
			return new NamedInputStream(fc.getName(), fc.getInputStream());
		} else {
			return null;
		}
	} catch (Exception e) {
	    String message = "Failed open: " + e.getMessage();
	    logger.warning(message);
	    throw new FileChooserException(message);
	}
}
 
开发者ID:ahmedmoustafa,项目名称:JAligner,代码行数:23,代码来源:FileChooserJNLP.java

示例14: save

import javax.jnlp.ServiceManager; //导入依赖的package包/类
/**
 * Saves an input stream to a file.
 * 
 * @param is
 * @param fileName
 * @return Boolean
 * @throws FileChooserException
 */
public boolean save(InputStream is, String fileName) throws FileChooserException {
	try {
	    FileSaveService fss = (FileSaveService) ServiceManager.lookup(FileSaveService.class.getName());
	    FileContents fc = fss.saveFileDialog(getUserDirectory(), null, is, fileName);
	    if (fc != null) {
	        logger.info("Saved: " + fc.getName());
	        return true;
	    } else {
	        return false;
	    }
	} catch (Exception e) {
	    String message = "Failed save: " + e.getMessage();
	    logger.warning(message);
	    throw new FileChooserException(message);
	}
}
 
开发者ID:ahmedmoustafa,项目名称:JAligner,代码行数:25,代码来源:FileChooserJNLP.java

示例15: init

import javax.jnlp.ServiceManager; //导入依赖的package包/类
public boolean init() {
    if (!super.init()) return false;
    try {
        fss = (FileSaveService)
            ServiceManager.lookup(FileSaveService.class.getName());
        return true;
    }
    catch (UnavailableServiceException e) {
        Object[] args = {
            prevExn.getLocalizedMessage(),
            e.getLocalizedMessage(),
            prevExn.toString(),
            e.toString()
        };
        JOptionPane.showMessageDialog
            (main, I18n._("File save service unavailable", args),
             I18n._("Export"), JOptionPane.ERROR_MESSAGE);
        return false;
    }
}
 
开发者ID:IMAGINARY,项目名称:morenaments-euc,代码行数:21,代码来源:ServiceExportMechanism.java


注:本文中的javax.jnlp.ServiceManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。