KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > exports > PluginExportOperation


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.exports;
12
13 import java.io.File JavaDoc;
14 import java.util.Dictionary JavaDoc;
15
16 import org.eclipse.osgi.service.resolver.BundleDescription;
17 import org.eclipse.osgi.service.resolver.State;
18 import org.eclipse.pde.core.plugin.TargetPlatform;
19 import org.eclipse.pde.internal.core.TargetPlatformHelper;
20
21 public class PluginExportOperation extends FeatureBasedExportOperation {
22
23     public PluginExportOperation(FeatureExportInfo info) {
24         super(info);
25     }
26     
27     protected void createPostProcessingFiles() {
28         createPostProcessingFile(new File JavaDoc(fFeatureLocation, PLUGIN_POST_PROCESSING));
29     }
30
31     protected State getState(String JavaDoc os, String JavaDoc ws, String JavaDoc arch) {
32         // the way plug-in export works, the os, ws and arch should ALWAYS equal the target settings.
33
if (os.equals(TargetPlatform.getOS())
34                 && ws.equals(TargetPlatform.getWS())
35                 && arch.equals(TargetPlatform.getOSArch())
36                 && fStateCopy != null) {
37             fStateCopy.resolve(true);
38             return fStateCopy;
39         }
40         return super.getState(os, ws, arch);
41     }
42
43     protected boolean shouldAddPlugin(BundleDescription bundle,
44             Dictionary JavaDoc environment) {
45         // if there is an environment conflict
46
boolean conflict = !super.shouldAddPlugin(bundle, environment);
47         if (conflict) {
48             // make a copy of the state if we haven't already
49
if (fStateCopy == null)
50                 copyState(TargetPlatformHelper.getState());
51             // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved
52
BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId());
53             BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(),
54                     desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(),
55                     desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null,
56                     desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities());
57             fStateCopy.addBundle(newDesc);
58         }
59         // always include plug-ins, even ones with environment conflicts
60
return true;
61     }
62     
63 }
64
Popular Tags