diff options
author | Thomas Watson | 2016-02-18 20:53:43 +0000 |
---|---|---|
committer | Thomas Watson | 2017-06-16 12:38:08 +0000 |
commit | f31b2c1056822bdc2e77b22f558a087943f7a22d (patch) | |
tree | eb96616921ad590f975a4d17077c2a71a64cd2bc | |
parent | 1bc1071713d4d94f1c7200fe1a90f806256b7554 (diff) | |
download | rt.equinox.framework-f31b2c1056822bdc2e77b22f558a087943f7a22d.tar.gz rt.equinox.framework-f31b2c1056822bdc2e77b22f558a087943f7a22d.tar.xz rt.equinox.framework-f31b2c1056822bdc2e77b22f558a087943f7a22d.zip |
Bug 487688 - [osgi R7] Implement FrameworkWiringDTO
7 files changed, 104 insertions, 13 deletions
diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF index 0f7985ae0..5ec09bbff 100644 --- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF @@ -63,7 +63,7 @@ Export-Package: org.eclipse.core.runtime.adaptor;x-friends:="org.eclipse.core.ru org.osgi.framework.startlevel;version="1.0";uses:="org.osgi.framework", org.osgi.framework.startlevel.dto;version="1.0";uses:="org.osgi.dto", org.osgi.framework.wiring;version="1.2";uses:="org.osgi.framework,org.osgi.resource", - org.osgi.framework.wiring.dto;version="1.2";uses:="org.osgi.dto,org.osgi.resource.dto", + org.osgi.framework.wiring.dto;version="1.3";uses:="org.osgi.dto,org.osgi.resource.dto", org.osgi.resource;version="1.0", org.osgi.resource.dto;version="1.0";uses:="org.osgi.dto", org.osgi.service.condpermadmin;version="1.1.1";uses:="org.osgi.framework", diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java index 556f89e4d..1a1d2d176 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java @@ -107,6 +107,17 @@ public class InternalUtils { return (Collection<Resource>) c; } + /** + * Coerce the generic type of a collection from Collection<? extends BundleWiring> + * to Collection<BundleWiring> + * @param c List to be coerced. + * @return c coerced to Collection<BundleWiring> + */ + @SuppressWarnings("unchecked") + public static Collection<BundleWiring> asCollectionBundleWiring(Collection<? extends BundleWiring> c) { + return (Collection<BundleWiring>) c; + } + public static void filterCapabilityPermissions(Collection<? extends BundleCapability> capabilities) { if (System.getSecurityManager() == null) { return; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java index ddf4a7409..ee034b6a2 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/DTOBuilder.java @@ -202,6 +202,17 @@ public class DTOBuilder { return dto; } + public static FrameworkWiringDTO newFrameworkWiringDTO(Collection<BundleWiring> allWirings) { + DTOBuilder builder = new DTOBuilder(); + for (BundleWiring wiring : allWirings) { + builder.getBundleWiringNodeDTO(wiring); + } + FrameworkWiringDTO dto = new FrameworkWiringDTO(); + dto.wirings = new HashSet<BundleWiringDTO.NodeDTO>(builder.wiringnodes.values()); + dto.resources = new HashSet<BundleRevisionDTO>(builder.resources.values()); + return dto; + } + private BundleWiringDTO getBundleWiringDTO(BundleWiring wiring) { if (wiring == null) { return null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java index b881e90c3..14f9cfe30 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java @@ -40,8 +40,7 @@ import org.osgi.framework.startlevel.FrameworkStartLevel; import org.osgi.framework.startlevel.dto.BundleStartLevelDTO; import org.osgi.framework.startlevel.dto.FrameworkStartLevelDTO; import org.osgi.framework.wiring.*; -import org.osgi.framework.wiring.dto.BundleRevisionDTO; -import org.osgi.framework.wiring.dto.BundleWiringDTO; +import org.osgi.framework.wiring.dto.*; public class EquinoxBundle implements Bundle, BundleReference { @@ -854,11 +853,11 @@ public class EquinoxBundle implements Bundle, BundleReference { } if (FrameworkStartLevel.class.equals(adapterType)) { - return (A) equinoxContainer.getStorage().getModuleContainer().getFrameworkStartLevel(); + return (A) module.getContainer().getFrameworkStartLevel(); } if (FrameworkWiring.class.equals(adapterType)) { - return (A) equinoxContainer.getStorage().getModuleContainer().getFrameworkWiring(); + return (A) module.getContainer().getFrameworkWiring(); } if (FrameworkDTO.class.equals(adapterType)) { @@ -873,7 +872,31 @@ public class EquinoxBundle implements Bundle, BundleReference { } if (FrameworkStartLevelDTO.class.equals(adapterType)) { - return (A) DTOBuilder.newFrameworkStartLevelDTO(equinoxContainer.getStorage().getModuleContainer().getFrameworkStartLevel()); + return (A) DTOBuilder.newFrameworkStartLevelDTO(module.getContainer().getFrameworkStartLevel()); + } + + if (FrameworkWiringDTO.class.equals(adapterType)) { + readLock(); + try { + Set<BundleWiring> allWirings = new HashSet<BundleWiring>(); + for (Module m : module.getContainer().getModules()) { + for (BundleRevision revision : m.getRevisions().getRevisions()) { + BundleWiring wiring = revision.getWiring(); + if (wiring != null) { + allWirings.add(wiring); + } + } + } + for (ModuleRevision revision : module.getContainer().getRemovalPending()) { + BundleWiring wiring = revision.getWiring(); + if (wiring != null) { + allWirings.add(wiring); + } + } + return (A) DTOBuilder.newFrameworkWiringDTO(allWirings); + } finally { + readUnlock(); + } } } diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/FrameworkWiringDTO.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/FrameworkWiringDTO.java new file mode 100755 index 000000000..50df41dd5 --- /dev/null +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/FrameworkWiringDTO.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.osgi.framework.wiring.dto; + +import java.util.Set; + +import org.osgi.dto.DTO; + +/** + * Data Transfer Object for the wiring graph of the framework. + * <p> + * The system bundle can be adapted to provide the {@code FrameworkWiringDTO}. + * Only the system bundle can be adapted to a {@code FrameworkWiringDTO} object + * + * @author $Id$ + * @NotThreadSafe + * @since 1.3 + */ +public class FrameworkWiringDTO extends DTO { + /** + * The set of wiring nodes referenced by the wiring graph of the framework. + * <p> + * All wiring nodes referenced by wiring node identifiers in the wiring + * graph are contained in this set. + */ + public Set<BundleWiringDTO.NodeDTO> wirings; + /** + * The set of resources referenced by the wiring graph of the framework. + * <p> + * All resources referenced by resource identifiers in the wiring graph are + * contained in this set. + */ + public Set<BundleRevisionDTO> resources; +} diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/package-info.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/package-info.java index 691bcdcde..8fb513b06 100644 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/package-info.java +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/package-info.java @@ -15,27 +15,25 @@ */ /** - * OSGi Data Transfer Object Framework Wiring Package Version 1.2. - * + * OSGi Data Transfer Object Framework Wiring Package Version 1.3. * <p> * Bundles wishing to use this package must list the package in the * Import-Package header of the bundle's manifest. This package has two types of * users: the consumers that use the API in this package and the providers that * implement the API in this package. - * * <p> * Example import for consumers using the API in this package: * <p> - * {@code Import-Package: org.osgi.framework.wiring.dto; version="[1.2,2.0)"} + * {@code Import-Package: org.osgi.framework.wiring.dto; version="[1.3,2.0)"} * <p> * Example import for providers implementing the API in this package: * <p> - * {@code Import-Package: org.osgi.framework.wiring.dto; version="[1.2,1.3)"} + * {@code Import-Package: org.osgi.framework.wiring.dto; version="[1.3,1.4)"} * * @author $Id$ */ -@Version("1.2") +@Version("1.3") package org.osgi.framework.wiring.dto; import org.osgi.annotation.versioning.Version; diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/packageinfo b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/packageinfo index ef7df68cb..0117a56c1 100644 --- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/packageinfo +++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/wiring/dto/packageinfo @@ -1 +1 @@ -version 1.2 +version 1.3 |