本文整理汇总了Java中javax.jnlp.UnavailableServiceException类的典型用法代码示例。如果您正苦于以下问题:Java UnavailableServiceException类的具体用法?Java UnavailableServiceException怎么用?Java UnavailableServiceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnavailableServiceException类属于javax.jnlp包,在下文中一共展示了UnavailableServiceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookup
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
public Object lookup(final String name) throws UnavailableServiceException
{
if (name.equals("javax.jnlp.BasicService"))
{
// Create a basic service that uses Java SE 6 java.awt.Desktop class
return new StandaloneBasicService();
}
else if (name.equals("javax.jnlp.SingleInstanceService"))
{
// Create a server that waits for further Sweet Home 3D launches
return new StandaloneSingleInstanceService(this.mainClass);
}
else
{
throw new UnavailableServiceException(name);
}
}
示例2: browse
import javax.jnlp.UnavailableServiceException; //导入依赖的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;
}
示例3: proceed
import javax.jnlp.UnavailableServiceException; //导入依赖的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();
}
}
示例4: checkIntegration
import javax.jnlp.UnavailableServiceException; //导入依赖的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");
}
}
示例5: shouldReadTargetJavaURLRelativePath
import javax.jnlp.UnavailableServiceException; //导入依赖的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");
}
示例6: WebstartPersistence
import javax.jnlp.UnavailableServiceException; //导入依赖的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;
}
}
示例7: getWebAppContextUrl
import javax.jnlp.UnavailableServiceException; //导入依赖的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;
}
示例8: init
import javax.jnlp.UnavailableServiceException; //导入依赖的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;
}
}
示例9: lookup
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
@Override
public Object lookup(String service) throws UnavailableServiceException
{
if( BasicService.class.getName().equals(service) )
{
return basic;
}
return null;
}
示例10: getLocalService
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
private Object getLocalService(Class<?> clazz)
{
try
{
return ServiceManager.lookup(clazz.getName());
}
catch( UnavailableServiceException e )
{
throw new RuntimeException(e);
}
}
示例11: load
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
private void load() throws IOException, XMLException {
FileOpenService fos = null;
try {
fos = PhetServiceManager.getFileOpenService( module.getSimulationPanel() );
}
catch( UnavailableServiceException e ) {
e.printStackTrace();
}
FileContents open = fos.openFileDialog( null, null );
if ( open == null ) {
return;
}
InputStreamReader isr = new InputStreamReader( open.getInputStream() );
BufferedReader br = new BufferedReader( isr );
String str = "";
while ( br.ready() ) {
String read = br.readLine();
System.out.println( "read = " + read );
str += read;
}
IXMLParser parser = new StdXMLParser();
parser.setReader( new StdXMLReader( new StringReader( patchString( str ) ) ) );
parser.setBuilder( new StdXMLBuilder() );
parser.setValidator( new NonValidator() );
IXMLElement parsed = (IXMLElement) parser.parse();
Circuit circuit = CircuitXML.parseXML( parsed, module.getCircuitChangeListener(), module );
if ( isOldVersionCCK( str ) ) {
flipY( circuit );
PhetOptionPane.showMessageDialog( this, "<html>The file you loaded is from an earlier version of this program, <br>and some " +
"parts of the circuit may be oriented incorrectly. <br><br>Manually correct any problems, and be sure to save the new circuit.</html>" );
}
module.setCircuit( circuit );
}
示例12: save
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
private void save() throws IOException {
FileSaveService fos = null;
try {
fos = PhetServiceManager.getFileSaveService( module.getSimulationPanel() );
}
catch( UnavailableServiceException e ) {
e.printStackTrace();
}
XMLElement xml = CircuitXML.toXML( module.getCircuit() );
StringWriter sw = new StringWriter();
XMLWriter writer = new XMLWriter( sw );
writer.write( xml );
String circuitxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + sw.toString();
InputStream stream = new ByteArrayInputStream( circuitxml.getBytes() );
FileContents data = new InputStreamFileContents( "circuitxml", stream );
FileContents out = fos.saveFileDialog( null, null, data.getInputStream(), null );
if ( out != null ) {
System.out.println( "Saved to " + out.getName() + " as: " + out );
}
}
示例13: save
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
public static void save( AbstractEnergySkateParkModule module ) throws UnavailableServiceException, IOException {
Component component = module.getEnergySkateParkSimulationPanel();
String xml = toXMLString( module );
EnergySkateParkLogging.println( "xml = " + xml );
InputStream stream = new ByteArrayInputStream( xml.getBytes() );
FileContents data = new InputStreamFileContents( "esp_output", stream );
FileSaveService fos = PhetServiceManager.getFileSaveService( component );
FileContents out = fos.saveAsFileDialog( null, null, data );
EnergySkateParkLogging.println( "Saved file." );
}
示例14: getCodeBase
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
/**
* Gets the JNLP code base.
* Returns null if we don't have a JNLP code base.
*/
public static URL getCodeBase() {
URL codeBase = null;
if ( isJavaWebStart() ) {
try {
codeBase = getBasicService().getCodeBase();
}
catch ( UnavailableServiceException e ) {
// this shouldn't happen. if we're running from JWS, we must have a codebase.
e.printStackTrace();
}
}
return codeBase;
}
示例15: getBasicService
import javax.jnlp.UnavailableServiceException; //导入依赖的package包/类
public static BasicService getBasicService() throws UnavailableServiceException {
if ( isJavaWebStart() ) {
return (BasicService) ServiceManager.lookup( BasicService.class.getName() );
}
else {
return new LocalBasicService();
}
}