本文整理汇总了Java中javax.jnlp.BasicService类的典型用法代码示例。如果您正苦于以下问题:Java BasicService类的具体用法?Java BasicService怎么用?Java BasicService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicService类属于javax.jnlp包,在下文中一共展示了BasicService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browse
import javax.jnlp.BasicService; //导入依赖的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;
}
示例2: getCodeBaseJavaws
import javax.jnlp.BasicService; //导入依赖的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;
}
示例3: checkSetup
import javax.jnlp.BasicService; //导入依赖的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();
}
}
示例4: shouldReadTargetJavaURLRelativePath
import javax.jnlp.BasicService; //导入依赖的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");
}
示例5: WebstartPersistence
import javax.jnlp.BasicService; //导入依赖的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;
}
}
示例6: getWebAppContextUrl
import javax.jnlp.BasicService; //导入依赖的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;
}
示例7: loadProperties
import javax.jnlp.BasicService; //导入依赖的package包/类
private static void loadProperties() {
BasicService bService = getBasicService();
PersistenceService pService = getPersistenceService();
properties = new Properties();
try {
FileContents fc = pService.get(bService.getCodeBase());
properties.load(fc.getInputStream());
} catch (Exception ex) {
// no props will be loaded
LOGGER.info(Utils.exc2String(ex));
}
}
示例8: showDocument
import javax.jnlp.BasicService; //导入依赖的package包/类
/**
* Tries to open passed URL in system browser
* using JNLP BasicService
*/
public static boolean showDocument(String url) {
URL url2Show = null;
try {
url2Show = new java.net.URL(url);
} catch (MalformedURLException ex) {
// nothing much to do here
}
BasicService service = getBasicService();
if (service != null) {
return service.showDocument(url2Show);
}
return false;
}
示例9: lookup
import javax.jnlp.BasicService; //导入依赖的package包/类
@Override
public Object lookup(String service) throws UnavailableServiceException
{
if( BasicService.class.getName().equals(service) )
{
return basic;
}
return null;
}
示例10: getBasicService
import javax.jnlp.BasicService; //导入依赖的package包/类
public static BasicService getBasicService() throws UnavailableServiceException {
if ( isJavaWebStart() ) {
return (BasicService) ServiceManager.lookup( BasicService.class.getName() );
}
else {
return new LocalBasicService();
}
}
示例11: showURL
import javax.jnlp.BasicService; //导入依赖的package包/类
public static boolean showURL( URL url ) {
try {
// Lookup the javax.jnlp.BasicService object
BasicService bs = (BasicService) ServiceManager.lookup( "javax.jnlp.BasicService" );
// Invoke the showDocument method
return bs.showDocument( url );
}
catch ( UnavailableServiceException ue ) {
// Service is not supported
return false;
}
}
示例12: getBasicService
import javax.jnlp.BasicService; //导入依赖的package包/类
public static BasicService getBasicService() throws Exception {
if ( isJavaWebStart() ) {
return (BasicService) ServiceManager.lookup( BasicService.class.getName() );
}
else {
return new LocalBasicService();
}
}
示例13: getIconPath
import javax.jnlp.BasicService; //导入依赖的package包/类
public static String getIconPath() throws UnavailableServiceException{
BasicService basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
try {
return IcoEncoder.getIconPath(new java.net.URL(basicService.getCodeBase(), "icon48.png"), null);
} catch (MalformedURLException ex) {
Logger.getLogger(InstallUtil.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
示例14: getCodeBase
import javax.jnlp.BasicService; //导入依赖的package包/类
private static String getCodeBase() {
String codeBase = "";
try {
codeBase = ((BasicService) ServiceManager.lookup("javax.jnlp.BasicService")).getCodeBase()
.toString();
} catch (UnavailableServiceException e) {
System.out.println("BasicService is uninitialized. Do you started it from JNLP?");
}
return codeBase;
}
示例15: BasicServiceFacade
import javax.jnlp.BasicService; //导入依赖的package包/类
public BasicServiceFacade ()
{
try {
service = (BasicService) ServiceManager.lookup(
"javax.jnlp.BasicService");
logger.debug("Real BasicService available");
// Use JNLP cache for all downloads
JnlpResponseCache.init();
} catch (UnavailableServiceException ex) {
logger.debug("No BasicService available");
}
}