22
22
import org .eclipse .core .runtime .IProgressMonitor ;
23
23
import org .eclipse .core .runtime .IStatus ;
24
24
import org .eclipse .equinox .internal .p2 .artifact .repository .CompositeArtifactRepository ;
25
- import org .eclipse .equinox .internal .p2 .core .helpers .LogHelper ;
26
25
import org .eclipse .equinox .internal .p2 .metadata .repository .CompositeMetadataRepository ;
27
26
import org .eclipse .equinox .internal .p2 .repository .helpers .RepositoryHelper ;
28
27
import org .eclipse .equinox .p2 .core .IProvisioningAgent ;
29
- import org .eclipse .equinox .p2 .core .IProvisioningAgentProvider ;
30
28
import org .eclipse .equinox .p2 .core .ProvisionException ;
31
29
import org .eclipse .equinox .p2 .internal .repository .tools .Messages ;
32
30
import org .eclipse .equinox .p2 .internal .repository .tools .RepositoryDescriptor ;
39
37
import org .eclipse .equinox .p2 .repository .metadata .IMetadataRepository ;
40
38
import org .eclipse .equinox .p2 .repository .metadata .IMetadataRepositoryManager ;
41
39
import org .eclipse .osgi .util .NLS ;
42
- import org .osgi .framework .BundleContext ;
43
- import org .osgi .framework .ServiceReference ;
44
40
45
41
public abstract class AbstractApplication {
46
42
protected boolean removeAddedRepositories = true ;
@@ -59,45 +55,10 @@ public abstract class AbstractApplication {
59
55
60
56
protected IProvisioningAgent agent ;
61
57
62
- public AbstractApplication () {
63
- super ();
64
- try {
65
- setupAgent ();
66
- } catch (ProvisionException e ) {
67
- LogHelper .log (e );
68
- }
69
- }
70
-
71
58
public AbstractApplication (IProvisioningAgent agent ) {
72
59
this .agent = agent ;
73
60
}
74
61
75
- private void setupAgent () throws ProvisionException {
76
- // note if we ever wanted these applications to act on a different agent than
77
- // the currently running system we would need to set it here
78
- BundleContext bundleContext = Activator .getBundleContext ();
79
- if (bundleContext == null ) {
80
- return ;
81
- }
82
- ServiceReference <IProvisioningAgent > agentRef = bundleContext .getServiceReference (IProvisioningAgent .class );
83
- if (agentRef != null ) {
84
- agent = bundleContext .getService (agentRef );
85
- if (agent != null )
86
- return ;
87
- }
88
- // there is no agent around so we need to create one
89
- ServiceReference <IProvisioningAgentProvider > providerRef = bundleContext
90
- .getServiceReference (IProvisioningAgentProvider .class );
91
- if (providerRef == null )
92
- throw new RuntimeException ("No provisioning agent provider is available" ); //$NON-NLS-1$
93
- IProvisioningAgentProvider provider = bundleContext .getService (providerRef );
94
- if (provider == null )
95
- throw new RuntimeException ("No provisioning agent provider is available" ); //$NON-NLS-1$
96
- // obtain agent for currently running system
97
- agent = provider .createAgent (null );
98
- bundleContext .ungetService (providerRef );
99
- }
100
-
101
62
public void setSourceIUs (List <IInstallableUnit > ius ) {
102
63
sourceIUs = ius ;
103
64
}
0 commit comments