Eclipseはサーバに置いたプラグインをダウンロードし、アップデートことができますが、ダウンロードできるプラグインはサーバにあるsite.xmlの内容で制御されています。たとえば、こんな感じです。
<?xml version="1.0" encoding="UTF-8"?> <site> <feature url="features/nu.mine.kino.plugin.google_1.0.6.jar" id="nu.mine.kino.plugin.google" version="1.0.6"> <category name="google"/> </feature> <feature url="features/nu.mine.kino.plugin.google_1.0.7.jar" id="nu.mine.kino.plugin.google" version="1.0.7"> <category name="google"/> </feature> <feature url="features/nu.mine.kino.plugin.google_1.0.9.jar" id="nu.mine.kino.plugin.google" version="1.0.9"> <category name="google"/> </feature> <category-def name="google" label="Google Plugin"/> </site>
さて、RCPで普通のアプリを作る場合、あるユーザはhogehogeプラグインのみ使用可能、で特定のユーザはさらにfugaプラグインも使用可能にする、なんてことをやりたくなりますね。しかしsite.xmlは通常静的なファイルであること、さらにこれをServletなどで動的に生成し、パラメータによって返すsite.xmlを変えるなんてことをやったとしても、アップデートサイトへのリクエスト(HTTP)にパラメタを載せる方法がわかりませんでした。 まあサーバ側はIPアドレスとかで判断することもできなくないですが、あんまりエレガントではないですね。
BusyIndicator.showWhile(window.getShell().getDisplay(), new Runnable() { public void run() { logger.debug("run() - start"); // UpdateManagerUI.openInstaller(window.getShell()); UpdateJob job = new UpdateJob("Search for new extensions.", getSearchRequest()); UpdateManagerUI.openInstaller(window.getShell(), job); logger.debug("run() - end"); } }); private UpdateSearchRequest getSearchRequest() { URL url = null; try { url = new URL("http://hogehoge.com/site.xml");// <-site.xmlのURL } catch (MalformedURLException e) { e.printStackTrace(); } UpdateSearchRequest result = new UpdateSearchRequest( UpdateSearchRequest.createDefaultSiteSearchCategory(), new UpdateSearchScope()); result.addFilter(new BackLevelFilter()); result.addFilter(new EnvironmentFilter()); UpdateSearchScope scope = new UpdateSearchScope(); scope.addSearchSite("HogeApp Site", url, null); // scope.addSearchSite("aaa", url, null); 複数追加すると複数サーチする result.setScope(scope); return result; }
この記事は
現在のアクセス:10072