关于插件卸载后plugin文件下扔保留插件文件的解释

kootoye 2015-01-16

Butwhyaren'tuninstalledbundles/featuresimmediatelyremoved?

p2doesnotimmediatelyremovebundlesonuninstallforseveralreasons:

Minimizingwaste:Byretainingthebundles,p2cansavetimeandbandwidthtoshouldthesebundlesbere-installed.

Forsafety:Manybundlesdonotproperlysupporthot-swappingandremoval.Writingbundlesthatcanbeuninstalledcompletelyissurprisinglydifficult,andevenhardertotest.

Inpracticethetimingofdeletionshouldnotmatterasp2ensuresthatthebundleswillnotbere-installed(modulotheorg.eclipse.update.configuratorissuedescribedelsewhereinthisFAQ).

p2doesperiodicallyperformagarbagecollectionofuninstalledfeaturesandbundles,typicallyafterhavingperformedanotheruninstall.SeeelsewhereinthisFAQfordetailsonhowtoexplicitlyrequestagarbagecollect.

Whyaren'tbundlesbeingremovedwhentheirassociatedfeaturehasbeenremoved?

Therearetwoaspectstothisproblem.

First,youshouldensurethatfeaturesarerecordedwheninstallingafeaturebyspecifyingthe"org.eclipse.update.install.features=true"property,suchthatthebundleshavearecordeddependencyagainstthefeature.Thispropertyisnotthedefault,soifyouareusingthep2directormanuallyitisworthverifying.

Second,youmustinvokethep2garbagecollector.[1]Bydefault,p2onlyperformsagarbagecollectatitsdiscretion.Normallythisisfinesincetheactualbundlestobeloadedarestillknownandmanaged(eitherintheconfig.inifileorbythesimpleconfigurator).

Youcancauseagarbagecollectinoneof3ways:

ConfigureyourproducttoinvokeaGConstartupbyaddingthefollowinglinetoyourproduct'splugin_customization.ini(requirestheorg.eclipse.equinox.p2.ui.sdk.schedulerbundle):

org.eclipse.equinox.p2.ui.sdk.scheduler/gcOnStartup=true

Runthegarbagecollectorapplication:[2]

eclipse-applicationorg.eclipse.equinox.p2.garbagecollector.application-profileSDKProfile

Explicitlyinvokethep2garbagecollectionfromcode:

IProvisioningAgentProviderprovider=//obtaintheIProvisioningAgentProviderusingOSGiservices

IProvisioningAgentagent=provider.createAgent(null);//null=locationforrunningsystem

if(agent==null)thrownewRuntimeException("Locationwasnotprovisionedbyp2");

IProfileRegistryprofileRegistry=(IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);

if(profileRegistry==null)thrownewRuntimeException("Unabletoacquiretheprofileregistryservice.");

//canalsouseIProfileRegistry.SELFforthecurrentprofile

IProfileprofile=profileRegistry.getProfile("SDKProfile");

GarbageCollectorgc=(GarbageCollector)agent.getService(GarbageCollector.SERVICE_NAME);

gc.runGC(profile);

转自:https://wiki.eclipse.org/Equinox/p2/FAQ#cite_note-2

相关推荐

谁在哀伤望月 / 0评论 2013-06-04
干货集合 / 0评论 2018-11-15