Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merging trunk into the branch from r1189798-1199347 in preparation to…

… reintegration

git-svn-id: https://svn.apache.org/repos/asf/aries/branches/oct-2011-release@1199354 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 51a00623f8cfef7217e32a9359dfbd6a44eeaea9 2 parents 236562f + c8116cd
@hughesj hughesj authored
Showing with 2,149 additions and 219 deletions.
  1. +5 −0 application/application-itests/pom.xml
  2. +41 −27 ...n/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java
  3. +100 −0 ...ication/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java
  4. +8 −0 application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF
  5. +8 −0 application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF
  6. +30 −0 application/application-itests/src/test/resources/isolated/config/blueprint.xml
  7. +3 −0  ...ion/application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java
  8. +7 −1 ...ication-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
  9. +203 −0 application/application-resolve-transform-cm-itests/LICENSE
  10. +8 −0 application/application-resolve-transform-cm-itests/NOTICE
  11. +177 −0 application/application-resolve-transform-cm-itests/pom.xml
  12. +312 −0 ...ts/src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java
  13. +203 −0 application/application-resolve-transform-cm/LICENSE
  14. +8 −0 application/application-resolve-transform-cm/NOTICE
  15. +64 −0 application/application-resolve-transform-cm/pom.xml
  16. +131 −0 ...rc/main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java
  17. +26 −0 application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml
  18. +2 −10 ...nagement/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
  19. +2 −0  application/pom.xml
  20. +47 −20 blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmNamespaceHandler.java
  21. +1 −5 blueprint/blueprint-cm/src/main/resources/OSGI-INF/blueprint/blueprint-cm.xml
  22. +4 −0 blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
  23. +81 −0 ...lueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
  24. +10 −22 ...t/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
  25. +7 −21 ...nt/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
  26. +29 −7 proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/AbstractWovenProxyAdapter.java
  27. +53 −0 proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/ConstructorFinder.java
  28. +28 −0 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassStaticInitOfChild.java
  29. +34 −0 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassStaticInitOfChildParent.java
  30. +36 −4 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
  31. +13 −8 sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/JmxConstants.java
  32. +9 −2 sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java
  33. +15 −9 sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/ServiceStateMBean.java
  34. +32 −3 sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java
  35. +30 −12 sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/ServiceData.java
  36. +25 −2 sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java
  37. +61 −5 sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
  38. +10 −6 sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/util/TypeUtils.java
  39. +114 −42 sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java
  40. +74 −8 sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
  41. +98 −5 sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
View
5 application/application-itests/pom.xml
@@ -197,6 +197,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.default.local.platform</artifactId>
<version>0.3.1-SNAPSHOT</version>
View
68 ...pplication-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java
@@ -20,8 +20,11 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Hashtable;
@@ -146,6 +149,42 @@ public int getCost() {
repoAdmin.addRepository(new File("repo.xml").toURI().toString());
}
+ public static HelloWorld findHelloWorldService(BundleContext ctx) throws Exception
+ {
+ if (ctx != null)
+ {
+ // Dive into the context and pull out the composite bundle for the app
+ Filter osgiFilter = FrameworkUtil.createFilter("(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")");
+ ServiceTracker tracker = new ServiceTracker(ctx,
+ osgiFilter,
+ null);
+
+ tracker.open();
+ final Object hw = tracker.waitForService(DEFAULT_TIMEOUT);
+ tracker.close();
+
+ if (hw != null) {
+ // proxy because the class space between the sample app and the test bundle is not consistent
+ return new HelloWorld() {
+ public String getMessage() {
+ try {
+ Method m = hw.getClass().getMethod("getMessage");
+ return (String) m.invoke(hw);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ } else {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
/**
* Find the {@link HelloWorld} service for the isolated app
* @return the service object, suitably proxied so that it can be actually used, or null if the service is not present
@@ -156,34 +195,9 @@ public static HelloWorld findHelloWorldService(BundleContext runtimeCtx, String
BundleContext appContext = IsolationTestUtils.findIsolatedAppBundleContext(runtimeCtx, appName);
if (appContext != null) {
- // Dive into the context and pull out the composite bundle for the app
- Filter osgiFilter = FrameworkUtil.createFilter("(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")");
- ServiceTracker tracker = new ServiceTracker(appContext,
- osgiFilter,
- null);
-
- tracker.open();
- final Object hw = tracker.waitForService(DEFAULT_TIMEOUT);
- tracker.close();
-
- if (hw != null) {
- // proxy because the class space between the sample app and the test bundle is not consistent
- return new HelloWorld() {
- public String getMessage() {
- try {
- Method m = hw.getClass().getMethod("getMessage");
- return (String) m.invoke(hw);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- };
- } else {
- return null;
- }
-
+ return findHelloWorldService(appContext);
} else {
throw new IllegalStateException("Expected to find isolated app ctx, but didn't");
}
}
-}
+}
View
100 ...tion/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.isolated.config;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.apache.aries.isolated.sample.HelloWorld;
+import org.apache.aries.isolated.sample.HelloWorldImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+public class HelloWorldManagedServiceImpl implements BundleActivator, ManagedService
+{
+ private BundleContext context;
+ private HelloWorldImpl hw;
+ private ServiceRegistration msRegistration;
+ private ServiceRegistration hwRegistration;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ Properties props = new Properties();
+ props.put(Constants.SERVICE_PID, "helloworld-mn");
+ this.context = context;
+ this.msRegistration = context.registerService(ManagedService.class.getName(), this, props);
+ this.hwRegistration = null;
+
+ //manually call our update to make sure the HW service is exposed out
+ updated(null);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public synchronized void stop(BundleContext context) throws Exception
+ {
+ this.msRegistration.unregister();
+
+ if (this.hwRegistration != null)
+ {
+ this.hwRegistration.unregister();
+ }
+
+ this.context = null;
+ this.hwRegistration = null;
+ this.msRegistration = null;
+ }
+
+ /**
+ * This method will re-register the helloworld service to easily track when updates
+ * occur to configuration.
+ */
+ public synchronized void updated(Dictionary properties) throws ConfigurationException
+ {
+ if (context != null) //means we have been stopped
+ {
+ if (hwRegistration != null)
+ {
+ hwRegistration.unregister();
+ }
+
+ if (hw == null)
+ {
+ hw = new HelloWorldImpl();
+ }
+
+ if (properties != null)
+ {
+ hw.setMessage((String)properties.get("message"));
+ }
+
+ hwRegistration = context.registerService(HelloWorld.class.getName(), hw, null);
+ }
+ }
+}
View
8 application/application-itests/src/test/resources/isolated/config/APPLICATION-BP.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: HelloWorld BluePrint
+Application-SymbolicName: org.apache.aries.helloworldbpapp
+Application-Version: 1.0
+Application-Content: org.apache.aries.isolated.helloworldbp;version=1.0.0,
+ org.apache.felix.configadmin
+
View
8 application/application-itests/src/test/resources/isolated/config/APPLICATION-MN.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: HelloWorld Manual
+Application-SymbolicName: org.apache.aries.helloworldmnapp
+Application-Version: 1.0
+Application-Content: org.apache.aries.isolated.helloworldmn;version=1.0.0,
+ org.apache.felix.configadmin
+
View
30 application/application-itests/src/test/resources/isolated/config/blueprint.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <cm:property-placeholder persistent-id="helloworld-bp" update-strategy="reload"/>
+
+ <bean id="hello" class="org.apache.aries.isolated.sample.HelloWorldImpl">
+ <property name="message" value="${message}" />
+ </bean>
+ <service interface="org.apache.aries.isolated.sample.HelloWorld" ref="hello" />
+
+</blueprint>
View
3  .../application-modeller/src/main/java/org/apache/aries/application/modelling/impl/AbstractParserProxy.java
@@ -323,6 +323,9 @@ protected boolean isBlacklisted (String iface, String blueprintFilter) {
blacklisted |= iface.equals("javax.transaction.UserTransaction");
blacklisted |= iface.equals("javax.transaction.TransactionSynchronizationRegistry");
+ // ConfigurationAdmin - detect interface
+ blacklisted |= iface.equals("org.osgi.service.cm.ConfigurationAdmin");
+
// Don't provision against JNDI references
if (blueprintFilter != null && blueprintFilter.trim().length() != 0) {
Map<String, String> filter = ManifestHeaderProcessor.parseFilter(blueprintFilter);
View
8 ...tion-modeller/src/main/java/org/apache/aries/application/modelling/impl/ModelledResourceManagerImpl.java
@@ -233,7 +233,13 @@ private ModelledResource model(String uri, BundleManifest bm, ParsedServiceEleme
String directoryName = "";
String fileName = "";
if (directoryFullPath.lastIndexOf("/") != -1) {
- directoryName = directoryFullPath.substring(0, directoryFullPath.lastIndexOf("/"));
+ // This bundle may be nested within another archive. In that case, we need to trim
+ // /bundleFileName.jar from the front of the directory.
+ int bundleNameLength = bundle.getName().length();
+ directoryName = directoryFullPath.substring(bundleNameLength, directoryFullPath.lastIndexOf("/"));
+ if (directoryName.startsWith("/") && directoryName.length() > 1) {
+ directoryName = directoryName.substring(1);
+ }
fileName = directoryFullPath.substring(directoryFullPath.lastIndexOf("/") + 1);
} else {
if (file.isFile()) {
View
203 application/application-resolve-transform-cm-itests/LICENSE
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
View
8 application/application-resolve-transform-cm-itests/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
View
177 application/application-resolve-transform-cm-itests/pom.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>java6-parent</artifactId>
+ <version>0.4</version>
+ <relativePath />
+ </parent>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolve.transform.cm.itests</artifactId>
+ <packaging>bundle</packaging>
+ <version>0.3.1-SNAPSHOT</version>
+ <name>Apache Aries Application Resolve CM Transform iTests</name>
+ <description>Apache Aries Application Resolve CM Transformer iTests</description>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm-itests</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm-itests</developerConnection>
+ <url>http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm-itests</url>
+ </scm>
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.import.pkg>
+ org.apache.aries.*;version="$&lt;range;[==,=+)&gt;",
+ *
+ </aries.osgi.import.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.resolve.transform.cm.itests;
+ </aries.osgi.private.pkg>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint</artifactId>
+ <version>0.3.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0.v20090520</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-service</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.testsupport</groupId>
+ <artifactId>org.apache.aries.testsupport.unit</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ <configuration>
+ <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <excludes>
+ <exclude>**/*$*</exclude>
+ <exclude>**/Abstract*.java</exclude>
+ </excludes>
+ <includes>
+ <include>**/Test*.java</include>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
312 ...src/test/java/org/apache/aries/application/resolve/transform/cm/itest/ConfigurationPostResolverTest.java
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.application.resolve.transform.cm.itest;
+
+import static org.apache.aries.itest.ExtraOptions.mavenBundle;
+import static org.apache.aries.itest.ExtraOptions.paxLogging;
+import static org.apache.aries.itest.ExtraOptions.testOptions;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.spi.resolve.PostResolveTransformer;
+import org.apache.aries.application.modelling.DeployedBundles;
+import org.apache.aries.application.modelling.ExportedBundle;
+import org.apache.aries.application.modelling.ExportedPackage;
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ImportedBundle;
+import org.apache.aries.application.modelling.ImportedPackage;
+import org.apache.aries.application.modelling.ImportedService;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.Provider;
+import org.apache.aries.application.modelling.ResourceType;
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.itest.RichBundleContext;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class ConfigurationPostResolverTest extends AbstractIntegrationTest
+{
+ /**
+ * This test validates that the transformer is correctly detecting the config admin package. Checks
+ * are performed to validate that an existing import package is still honored etc.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void validatePostResolveTransform() throws Exception {
+
+ RichBundleContext ctx = new RichBundleContext(bundleContext);
+ PostResolveTransformer transformer = ctx.getService(PostResolveTransformer.class);
+ Assert.assertNotNull("Unable to locate transformer", transformer);
+
+ /**
+ * Try processing deployed content that doesn't have any import for the
+ * org.osgi.service.cm package, the resultant imports should be unaffected.
+ */
+ ApplicationMetadata mockApplicationMetadata = Skeleton.newMock(ApplicationMetadata.class);
+ MockDeployedBundles originalDeployedBundles = new MockDeployedBundles();
+ originalDeployedBundles.setDeployedContent(getNonConfigModelledResources());
+ DeployedBundles transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+ Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+ Assert.assertEquals(originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+
+ /**
+ * Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
+ * modelled resources with an empty import package set in the mock deployed bundles instance.
+ */
+ originalDeployedBundles = new MockDeployedBundles();
+ originalDeployedBundles.setDeployedContent(getConfigModelledResources());
+ transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+ Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+ Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+ Assert.assertEquals("Missing config package", "org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
+
+ /**
+ * Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
+ * modelled resources with a populated import package set in the mock deployed bundles instance.
+ */
+ originalDeployedBundles = new MockDeployedBundles();
+ originalDeployedBundles.setDeployedContent(getConfigModelledResources());
+ originalDeployedBundles.setImportPackage("org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\"");
+ transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
+ Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
+ Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
+ Assert.assertEquals("Missing config package", "org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\",org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
+ }
+
+ private static Collection<ModelledResource> getNonConfigModelledResources() {
+ Collection<ModelledResource> modelledResources = new ArrayList<ModelledResource>();
+ MockModelledResource ms1 = new MockModelledResource();
+ ms1.setImportedPackages(Arrays.asList(new MockImportedPackage("org.foo.bar", "1.0.0"), new MockImportedPackage("org.bar.foo", "1.0.0")));
+
+ return modelledResources;
+ }
+
+ private static Collection<ModelledResource> getConfigModelledResources() {
+ Collection<ModelledResource> resources = getNonConfigModelledResources();
+ MockModelledResource mmr1 = new MockModelledResource();
+ mmr1.setImportedPackages(Arrays.asList(new MockImportedPackage("org.osgi.service.cm", "1.2.0")));
+ resources.add(mmr1);
+ MockModelledResource mmr2 = new MockModelledResource();
+ mmr2.setImportedPackages(Arrays.asList(new MockImportedPackage("org.osgi.service.cm", "1.2.0")));
+ resources.add(mmr2);
+ return resources;
+ }
+ /**
+ * Create the configuration for the PAX container
+ *
+ * @return the various required options
+ * @throws Exception
+ */
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() throws Exception {
+ return testOptions(
+ repository("http://repository.ops4j.org/maven2"),
+ paxLogging("DEBUG"),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("asm", "asm-all"),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm"),
+ //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+ equinox().version("3.5.0"));
+ }
+
+ private static class MockDeployedBundles implements DeployedBundles
+ {
+ private Collection<ModelledResource> deployedContent;
+ private String importPackage;
+
+ public void addBundle(ModelledResource arg0) {
+ }
+
+ public String getContent() {
+ return null;
+ }
+
+ public Collection<ModelledResource> getDeployedContent() {
+ return deployedContent;
+ }
+
+ public void setDeployedContent(Collection<ModelledResource> deployedContent) {
+ this.deployedContent = deployedContent;
+ }
+
+ public String getDeployedImportService() {
+ return null;
+ }
+
+ public Collection<ModelledResource> getDeployedProvisionBundle() {
+ return null;
+ }
+
+ public Map<String, String> getExtraHeaders() {
+ return null;
+ }
+
+ public void setImportPackage(String importPackage) {
+ this.importPackage = importPackage;
+ }
+
+ /**
+ * Used to reflect external packages required
+ */
+ public String getImportPackage() throws ResolverException {
+ return importPackage;
+ }
+
+ public String getProvisionBundle() {
+ return null;
+ }
+
+ public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException {
+ return null;
+ }
+
+ public String getUseBundle() {
+ return null;
+ }
+
+ }
+
+ private static class MockModelledResource implements ModelledResource {
+
+ private Collection<? extends ImportedPackage> importedPackages;
+
+ public String toDeploymentString() {
+ return null;
+ }
+
+ public ExportedBundle getExportedBundle() {
+ return null;
+ }
+
+ public Collection<? extends ExportedPackage> getExportedPackages() {
+ return null;
+ }
+
+ public Collection<? extends ExportedService> getExportedServices() {
+ return null;
+ }
+
+ public ImportedBundle getFragmentHost() {
+ return null;
+ }
+
+ public Collection<? extends ImportedPackage> getImportedPackages() {
+ return importedPackages;
+ }
+
+ public void setImportedPackages(Collection<? extends ImportedPackage> importedPackages) {
+ this.importedPackages = importedPackages;
+ }
+
+ public Collection<? extends ImportedService> getImportedServices() {
+ return null;
+ }
+
+ public String getLocation() {
+ return null;
+ }
+
+ public Collection<? extends ImportedBundle> getRequiredBundles() {
+ return null;
+ }
+
+ public String getSymbolicName() {
+ return null;
+ }
+
+ public ResourceType getType() {
+ return null;
+ }
+
+ public String getVersion() {
+ return null;
+ }
+
+ public boolean isFragment() {
+ return false;
+ }
+
+ }
+
+ private static class MockImportedPackage implements ImportedPackage {
+
+ private String packageName;
+ private String versionRange;
+
+ public MockImportedPackage(String packageName, String versionRange) {
+ this.packageName = packageName;
+ this.versionRange = versionRange;
+ }
+
+ public String getAttributeFilter() {
+ return null;
+ }
+
+ public ResourceType getType() {
+ return null;
+ }
+
+ public boolean isMultiple() {
+ return false;
+ }
+
+ public boolean isOptional() {
+ return false;
+ }
+
+ public boolean isSatisfied(Provider provider) {
+ return false;
+ }
+
+ public String toDeploymentString() {
+ return packageName + ";version=\"" + versionRange + "\"";
+ }
+
+ public Map<String, String> getAttributes() {
+ return null;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public String getVersionRange() {
+ return versionRange;
+ }
+
+ }
+}
View
203 application/application-resolve-transform-cm/LICENSE
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
View
8 application/application-resolve-transform-cm/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
View
64 application/application-resolve-transform-cm/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>java6-parent</artifactId>
+ <version>0.4</version>
+ <relativePath />
+ </parent>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolve.transform.cm</artifactId>
+ <packaging>bundle</packaging>
+ <version>0.3.1-SNAPSHOT</version>
+ <name>Apache Aries Application Resolve CM Transform</name>
+ <description>Apache Aries Application Resolve CM Transformers</description>
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/application/application-resolve-transform-cm</developerConnection>
+ <url>http://svn.apache.org/viewvc/aries/trunk/application/application-resolve-transform-cm</url>
+ </scm>
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.import.pkg>
+ org.apache.aries.*;version="$&lt;range;[==,=+)&gt;",
+ *
+ </aries.osgi.import.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.resolve.transform.cm
+ </aries.osgi.private.pkg>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
View
131 ...main/java/org/apache/aries/application/resolve/transform/cm/ConfigurationPostResolveTransformerImpl.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.application.resolve.transform.cm;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.management.spi.resolve.PostResolveTransformer;
+import org.apache.aries.application.modelling.DeployedBundles;
+import org.apache.aries.application.modelling.ImportedPackage;
+import org.apache.aries.application.modelling.ModelledResource;
+
+public class ConfigurationPostResolveTransformerImpl implements PostResolveTransformer
+{
+ /*
+ * (non-Javadoc)
+ * @see org.apache.aries.application.management.spi.resolve.PostResolveTransformer#postResolveProcess(org.apache.aries.application.ApplicationMetadata, org.apache.aries.application.modelling.DeployedBundles)
+ */
+ public DeployedBundles postResolveProcess(ApplicationMetadata appMetaData, DeployedBundles deployedBundles) throws ResolverException {
+ return new ConfigAwareDeployedBundles(deployedBundles);
+ }
+
+ /**
+ * This class serves as a wrapper for a DeployedBundles instance, if the delegate instance
+ * does not import the configuration management package and the deployed content contains the
+ * configuration admin bundle, then the necessary import will be added. This is required so that the
+ * blueprint-cm bundle will not encounter class casting issues from a ConfigurationAdmin service
+ * that has been loaded in an isolated application scope, rather all *.cm related classes are
+ * referenced by the same class loader.
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+ private static class ConfigAwareDeployedBundles implements DeployedBundles
+ {
+ private static final String CONFIG_PACKAGE = "org.osgi.service.cm";
+
+ private DeployedBundles deployedBundles;
+
+ public ConfigAwareDeployedBundles(DeployedBundles deployedBundles) {
+ this.deployedBundles = deployedBundles;
+ }
+
+ public void addBundle(ModelledResource resource) {
+ deployedBundles.addBundle(resource);
+ }
+
+ public String getContent() {
+ return deployedBundles.getContent();
+ }
+
+ public Collection<ModelledResource> getDeployedContent() {
+ return deployedBundles.getDeployedContent();
+ }
+
+ public String getDeployedImportService() {
+ return deployedBundles.getDeployedImportService();
+ }
+
+ public Collection<ModelledResource> getDeployedProvisionBundle() {
+ return deployedBundles.getDeployedProvisionBundle();
+ }
+
+ public Map<String, String> getExtraHeaders() {
+ return deployedBundles.getExtraHeaders();
+ }
+
+ public String getImportPackage() throws ResolverException {
+ String currentImportPackage = deployedBundles.getImportPackage();
+ StringBuffer rawImportPackage = new StringBuffer((currentImportPackage != null ? currentImportPackage : ""));
+
+ if (! rawImportPackage.toString().contains(CONFIG_PACKAGE)) {
+ Collection<ModelledResource> deployedContent = deployedBundles.getDeployedContent();
+
+ if (deployedContent != null) {
+ modelledResourceCheck:
+ for (ModelledResource mr : deployedContent) {
+ Collection<? extends ImportedPackage> importedPackages = mr.getImportedPackages();
+
+ if (importedPackages != null) {
+ for (ImportedPackage importedPackage : importedPackages) {
+ if (CONFIG_PACKAGE.equals(importedPackage.getPackageName())) {
+ if (rawImportPackage.length() > 0) {
+ rawImportPackage.append(",");
+ }
+
+ rawImportPackage.append(importedPackage.toDeploymentString());
+ break modelledResourceCheck;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return (rawImportPackage.length() > 0 ? rawImportPackage.toString() : currentImportPackage);
+ }
+
+ public String getProvisionBundle() {
+ return deployedBundles.getProvisionBundle();
+ }
+
+ public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException {
+ return deployedBundles.getRequiredUseBundle();
+ }
+
+ public String getUseBundle() {
+ return deployedBundles.getUseBundle();
+ }
+ }
+
+}
View
26 application/application-resolve-transform-cm/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="configPostTransformer" class="org.apache.aries.application.resolve.transform.cm.ConfigurationPostResolveTransformerImpl" scope="singleton"/>
+ <service id="configPostTransformer-service" ref="configPostTransformer" interface="org.apache.aries.application.management.spi.resolve.PostResolveTransformer"/>
+
+</blueprint>
+
View
12 ...ement/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
@@ -19,23 +19,15 @@
package org.apache.aries.application.runtime.framework.management;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
-import java.util.Set;
-import java.util.jar.Attributes;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.aries.application.Content;
-import org.apache.aries.application.management.BundleInfo;
import org.apache.aries.application.management.spi.framework.BundleFramework;
import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
import org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory;
@@ -57,7 +49,7 @@
* org.osgi.service.blueprint package is deliberately unversioned as it is
* not part of the osgi compendium.
*/
- private static final String RUNTIME_PACKAGES = "org.osgi.service.blueprint,org.osgi.service.blueprint.container;version=\"[1.0.0,1.0.1]\",org.osgi.service.blueprint.reflect;version=\"[1.0.0,1.0.1]\",org.apache.aries.transaction.exception;version=\"[0.1,1.0.0)\"";
+ private static final String RUNTIME_PACKAGES = "org.osgi.service.blueprint,org.osgi.service.blueprint.container;version=\"[1.0.0,1.0.1]\",org.osgi.service.blueprint.reflect;version=\"[1.0.0,1.0.1]\",org.apache.aries.transaction.exception;version=\"[0.1,1.0.0)\",org.osgi.service.cm;resolution:=optional";
/**
* create using any bundle context in EBA App framework as we want to create
@@ -145,7 +137,7 @@ public Properties getFrameworkManifest()
Properties compositeManifest = basicConfig.getFrameworkManifest();
compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, BundleFramework.SHARED_BUNDLE_FRAMEWORK);
-
+
// Add blueprint so that it is available to applications, unless configuration has already been provided.
String existingImports = (String) compositeManifest.get(Constants.IMPORT_PACKAGE);
if (existingImports == null){
View
2  application/pom.xml
@@ -49,6 +49,8 @@
<module>application-modeller-common-test</module>
<module>application-noop-resolver</module>
<module>application-obr-resolver</module>
+ <module>application-resolve-transform-cm</module>
+ <module>application-resolve-transform-cm-itests</module>
<module>application-runtime</module>
<module>application-runtime-isolated</module>
<module>application-runtime-framework</module>
View
67 blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/CmNamespaceHandler.java
@@ -42,9 +42,12 @@
import org.apache.aries.blueprint.mutable.MutableIdRefMetadata;
import org.apache.aries.blueprint.mutable.MutableMapMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
+import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
import org.apache.aries.blueprint.mutable.MutableValueMetadata;
+import org.apache.aries.blueprint.reflect.PassThroughMetadataImpl;
import org.apache.aries.blueprint.utils.PlaceholdersUtils;
import org.apache.aries.blueprint.utils.ServiceListener;
+import org.osgi.framework.BundleContext;
import org.osgi.service.blueprint.container.ComponentDefinitionException;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.BeanProperty;
@@ -54,6 +57,7 @@
import org.osgi.service.blueprint.reflect.MapMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
import org.osgi.service.blueprint.reflect.RegistrationListener;
import org.osgi.service.blueprint.reflect.ServiceMetadata;
import org.osgi.service.blueprint.reflect.ValueMetadata;
@@ -202,7 +206,7 @@ private ComponentMetadata parsePropertyPlaceholder(ParserContext context, Elemen
metadata.setInitMethod("init");
metadata.setDestroyMethod("destroy");
metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
- metadata.addProperty("configAdmin", createConfigAdminProxy(context));
+ metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
metadata.addProperty("persistentId", createValue(context, element.getAttribute(PERSISTENT_ID_ATTRIBUTE)));
String prefix = element.hasAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
? element.getAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
@@ -318,7 +322,7 @@ private ComponentMetadata parseManagedServiceFactory(ParserContext context, Elem
factoryMetadata.setRuntimeClass(CmManagedServiceFactory.class);
factoryMetadata.setInitMethod("init");
factoryMetadata.setDestroyMethod("destroy");
- factoryMetadata.addProperty("configAdmin", createConfigAdminProxy(context));
+ factoryMetadata.addProperty("configAdmin", createConfigurationAdminRef(context));
factoryMetadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
factoryMetadata.addProperty("factoryPid", createValue(context, element.getAttribute(FACTORY_PID_ATTRIBUTE)));
String autoExport = element.hasAttribute(AUTO_EXPORT_ATTRIBUTE) ? element.getAttribute(AUTO_EXPORT_ATTRIBUTE) : AUTO_EXPORT_DEFAULT;
@@ -422,7 +426,7 @@ private ComponentMetadata decorateCmProperties(ParserContext context, Element el
metadata.setDestroyMethod("destroy");
}
metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
- metadata.addProperty("configAdmin", createConfigAdminProxy(context));
+ metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
metadata.addProperty("persistentId", createValue(context, persistentId));
if (element.hasAttribute(UPDATE_ATTRIBUTE)) {
@@ -451,7 +455,7 @@ private ComponentMetadata decorateManagedProperties(ParserContext context, Eleme
metadata.setDestroyMethod("destroy");
}
metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
- metadata.addProperty("configAdmin", createConfigAdminProxy(context));
+ metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
metadata.addProperty("persistentId", createValue(context, persistentId));
String updateStrategy = element.getAttribute(UPDATE_STRATEGY_ATTRIBUTE);
@@ -468,22 +472,6 @@ private ComponentMetadata decorateManagedProperties(ParserContext context, Eleme
return component;
}
- /**
- * Create a reference to the ConfigurationAdmin service if not already done
- * and add it to the registry.
- *
- * @param context the parser context
- * @return a metadata pointing to the config admin
- */
- private Metadata createConfigAdminProxy(ParserContext context) {
- MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
- bean.setRuntimeClass(CmNamespaceHandler.class);
- bean.setFactoryMethod("getConfigAdmin");
- bean.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
- bean.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
- return bean;
- }
-
private void registerManagedObjectManager(ParserContext context, ComponentDefinitionRegistry registry) {
if (registry.getComponentDefinition(MANAGED_OBJECT_MANAGER_NAME) == null) {
MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
@@ -494,6 +482,10 @@ private void registerManagedObjectManager(ParserContext context, ComponentDefini
}
}
+ private MutableReferenceMetadata createConfigurationAdminRef(ParserContext context) {
+ return createServiceRef(getBlueprintBundleContext(context), context, ConfigurationAdmin.class, "(objectClass=" + ConfigurationAdmin.class.getName() + ")");
+ }
+
private static ValueMetadata createValue(ParserContext context, String value) {
return createValue(context, value, null);
}
@@ -510,6 +502,21 @@ private static RefMetadata createRef(ParserContext context, String value) {
m.setComponentId(value);
return m;
}
+
+ private MutableReferenceMetadata createServiceRef(BundleContext ctx, ParserContext context, Class<?> cls, String filter) {
+ MutableReferenceMetadata m = context.createMetadata(MutableReferenceMetadata.class);
+ m.setRuntimeInterface(cls);
+ m.setInterface(cls.getName());
+ m.setBundleContext(ctx);
+ m.setActivation(ReferenceMetadata.ACTIVATION_EAGER);
+ m.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
+
+ if (filter != null) {
+ m.setFilter(filter);
+ }
+
+ return m;
+ }
private static IdRefMetadata createIdRef(ParserContext context, String value) {
MutableIdRefMetadata m = context.createMetadata(MutableIdRefMetadata.class);
@@ -590,4 +597,24 @@ private String generateId(ParserContext context) {
return interfaceNames;
}
+ /**
+ * Returns the bundle context within the parser context
+ *
+ * @param parserContext the parser context
+ * @return the bundle context within the parser context (if it exists)
+ */
+ private BundleContext getBlueprintBundleContext(ParserContext parserContext)
+ {
+ BundleContext blueprintContext = null;
+
+ if (parserContext != null) {
+ ComponentMetadata metaData = parserContext.getComponentDefinitionRegistry().getComponentDefinition("blueprintBundleContext");
+
+ if (metaData != null) {
+ blueprintContext = (BundleContext)((PassThroughMetadataImpl)metaData).getObject();
+ }
+ }
+
+ return blueprintContext;
+ }
}
View
6 blueprint/blueprint-cm/src/main/resources/OSGI-INF/blueprint/blueprint-cm.xml
@@ -28,11 +28,7 @@
</array>
</entry>
</service-properties>
- <bean class="org.apache.aries.blueprint.compendium.cm.CmNamespaceHandler">
- <property name="configAdmin">
- <reference interface="org.osgi.service.cm.ConfigurationAdmin"/>
- </property>
- </bean>
+ <bean class="org.apache.aries.blueprint.compendium.cm.CmNamespaceHandler"/>
</service>
</blueprint>
View
4 blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
@@ -563,6 +563,10 @@ private void untrackServiceReferences() {
}
}
}
+
+ synchronized (satisfiablesLock) {
+ satisfiables = null;
+ }
}
private void untrackServiceReference(SatisfiableRecipe recipe, Set<String> stopped, Map<String, List<SatisfiableRecipe>> dependencies) {
View
81 ...print-itests/src/test/java/org/apache/aries/blueprint/itests/BaseBlueprintContainerBTCustomizerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.blueprint.itests;
+
+import static org.apache.aries.itest.ExtraOptions.mavenBundleInTest;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.itest.RichBundleContext;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+public abstract class BaseBlueprintContainerBTCustomizerTest extends AbstractIntegrationTest
+{
+ protected Map<String, String> getCompositeManifest() {
+ Map<String, String> compositeManifest = new HashMap<String, String>();
+ compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test-composite");
+ compositeManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+ // this import-package is used by the blueprint.sample
+ compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0, org.osgi.service.cm");
+ // this export-package is used by pax junit runner as it needs to see the blueprint sample package
+ // for the test after the blueprint sample is started.
+ compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
+
+ return compositeManifest;
+ }
+
+ protected Bundle installConfigurationAdmin(BundleContext ctx) throws Exception {
+
+ Bundle configAdminBundle = null;
+ // make sure we don't have a config admin already present
+ ServiceTracker tracker = new ServiceTracker(ctx, ctx.createFilter("(" + Constants.OBJECTCLASS + "=" + ConfigurationAdmin.class.getName() + ")"), null);
+ tracker.open();
+ Object cfgAdminService = tracker.waitForService(5000);
+ tracker.close();
+
+ if (cfgAdminService == null) {
+ MavenArtifactProvisionOption cfgAdminOption = mavenBundleInTest(getClass().getClassLoader(), "org.apache.felix", "org.apache.felix.configadmin");
+ InputStream cfgAdminStream = new URL(cfgAdminOption.getURL()).openStream();
+
+ configAdminBundle = ctx.installBundle(cfgAdminOption.getURL(), cfgAdminStream);
+ }
+
+ return configAdminBundle;
+ }
+
+ protected void applyCommonConfiguration(BundleContext ctx) throws Exception {
+
+ ConfigurationAdmin ca = (new RichBundleContext(ctx)).getService(ConfigurationAdmin.class);
+ Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
+ Hashtable props = new Hashtable();
+ props.put("key.b", "10");
+ cf.update(props);
+ }
+}
View
32 ...lueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainer2BTCustomizerTest.java
@@ -24,10 +24,8 @@
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
-import org.apache.aries.itest.AbstractIntegrationTest;
import org.apache.aries.itest.RichBundleContext;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,8 +36,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.framework.CompositeBundle;
import org.osgi.service.framework.CompositeBundleFactory;
@@ -52,17 +48,10 @@
*
*/
@RunWith(JUnit4TestRunner.class)
-public class BlueprintContainer2BTCustomizerTest extends AbstractIntegrationTest {
+public class BlueprintContainer2BTCustomizerTest extends BaseBlueprintContainerBTCustomizerTest {
@Test
public void test() throws Exception {
- // Create a config to check the property placeholder
- ConfigurationAdmin ca = context().getService(ConfigurationAdmin.class);
- Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
- Hashtable props = new Hashtable();
- props.put("key.b", "10");
- cf.update(props);
-
ServiceReference sr = bundleContext.getServiceReference("org.osgi.service.framework.CompositeBundleFactory");
if (sr != null) {
@@ -74,14 +63,7 @@ public void test() throws Exception {
// frameworkConfig.put("osgi.console", "10000");
// construct composite bundle information
- Map<String, String> compositeManifest = new HashMap<String, String>();
- compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test-composite");
- compositeManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
- // this import-package is used by the blueprint.sample
- compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
- // this export-package is used by pax junit runner as it needs to see the blueprint sample package
- // for the test after the blueprint sample is started.
- compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
+ Map<String, String> compositeManifest = getCompositeManifest();
CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);
@@ -92,9 +74,15 @@ public void test() throws Exception {
InputStream is = new URL(mapo.getURL()).openStream();
Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
assertNotNull(bundle);
+ // install and start the cfg admin bundle in the isolated framework
+ Bundle cfgAdminBundle = installConfigurationAdmin(compositeBundleContext);
+ assertNotNull(cfgAdminBundle);
- // start the composite bundle then the blueprint sample
+ // start the composite bundle, the config admin then the blueprint sample
cb.start();
+ cfgAdminBundle.start();
+ // create a config to check the property placeholder
+ applyCommonConfiguration(compositeBundleContext);
bundle.start();
// start the blueprint bundle and it should detect the previously started blueprint sample
@@ -115,7 +103,7 @@ public void test() throws Exception {
return testOptions(
paxLogging("DEBUG"),
Helper.blueprintBundles(false),
-// vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+ //vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
equinox().version("3.5.0")
);
}
View
28 ...blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
@@ -24,10 +24,8 @@
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
-import org.apache.aries.itest.AbstractIntegrationTest;
import org.apache.aries.itest.RichBundleContext;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,8 +36,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.framework.CompositeBundle;
import org.osgi.service.framework.CompositeBundleFactory;
@@ -53,17 +49,10 @@
*
*/
@RunWith(JUnit4TestRunner.class)
-public class BlueprintContainerBTCustomizerTest extends AbstractIntegrationTest {
+public class BlueprintContainerBTCustomizerTest extends BaseBlueprintContainerBTCustomizerTest {
@Test
public void test() throws Exception {
- // Create a config to check the property placeholder
- ConfigurationAdmin ca = context().getService(ConfigurationAdmin.class);
- Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
- Hashtable props = new Hashtable();
- props.put("key.b", "10");
- cf.update(props);
-
ServiceReference sr = bundleContext.getServiceReference("org.osgi.service.framework.CompositeBundleFactory");
if (sr != null) {
@@ -75,14 +64,7 @@ public void test() throws Exception {
// frameworkConfig.put("osgi.console", "10000");
// construct composite bundle information
- Map<String, String> compositeManifest = new HashMap<String, String>();
- compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test-composite");
- compositeManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
- // this import-package is used by the blueprint.sample
- compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
- // this export-package is used by pax junit runner as it needs to see the blueprint sample package
- // for the test after the blueprint sample is started.
- compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
+ Map<String, String> compositeManifest = getCompositeManifest();
CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);
@@ -93,9 +75,13 @@ public void test() throws Exception {
InputStream is = new URL(mapo.getURL()).openStream();
Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
assertNotNull(bundle);
+ Bundle configAdminBundle = installConfigurationAdmin(compositeBundleContext);
+ assertNotNull(configAdminBundle);
- // start the composite bundle then the blueprint sample
+ // start the composite bundle, config admin then the blueprint sample
cb.start();
+ configAdminBundle.start();
+ applyCommonConfiguration(compositeBundleContext);
bundle.start();
// do the test
View
36 proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/AbstractWovenProxyAdapter.java
@@ -19,6 +19,7 @@
package org.apache.aries.proxy.impl.common;
import java.io.IOException;
+import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
@@ -241,13 +242,9 @@ public final void visit(int version, int access, String name, String signature,
nonObjectSupers.add(nextSuper);
nextSuper = nextSuper.getSuperclass();
}
- try {
- superHasNoArgsConstructor = (superClass.getDeclaredConstructor().
- getModifiers() & Modifier.PRIVATE) == 0;
- } catch (NoSuchMethodException nsme) {
- // This is a no-op here, but means we need to add a no-Args that
- // delegates to Object#<init>() yuck :(
- }
+ //Don't use reflection - it can be dangerous
+ superHasNoArgsConstructor = superHasNoArgsConstructor(superName, name);
+
} else {
superHasNoArgsConstructor = true;
}
@@ -274,6 +271,31 @@ public final void visit(int version, int access, String name, String signature,
}
}
+ /**
+ * This method allows us to determine whether a superclass has a
+ * non-private no-args constructor without causing it to initialize.
+ * This avoids a potential ClassCircularityError on Mac VMs if the
+ * initialization references the subclass being woven. Odd, but seen
+ * in the wild!
+ */
+ private final boolean superHasNoArgsConstructor(String superName, String name) {
+
+ ConstructorFinder cf = new ConstructorFinder();
+
+ try {
+ InputStream is = loader.getResourceAsStream(superName +".class");
+
+ if(is == null)
+ throw new IOException();
+
+ new ClassReader(is).accept(cf, ClassReader.SKIP_FRAMES + ClassReader.SKIP_DEBUG + ClassReader.SKIP_CODE);
+ } catch (IOException ioe) {
+ UnableToProxyException u = new UnableToProxyException(name, ioe);
+ throw new RuntimeException(NLS.MESSAGES.getMessage("cannot.load.superclass", superName.replace('/', '.'), typeBeingWoven.getClassName()), u);
+ }
+ return cf.hasNoArgsConstructor();
+ }
+
private boolean checkInterfacesForSerializability(String[] interfaces) throws ClassNotFoundException {
for(String iface : interfaces)
{
View
53 proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/common/ConstructorFinder.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.proxy.impl.common;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.EmptyVisitor;
+
+import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
+
+public class ConstructorFinder extends ClassAdapter
+{
+
+ private boolean hasNoArgsConstructor = false;
+
+ public boolean hasNoArgsConstructor()
+ {
+ return hasNoArgsConstructor;
+ }
+
+ public ConstructorFinder()
+ {
+ super(new EmptyVisitor());
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature,
+ String[] exceptions)
+ {
+ if("<init>".equals(name)) {
+ if(Type.getArgumentTypes(desc).length == 0 && (access & ACC_PRIVATE) == 0)
+ hasNoArgsConstructor = true;
+ }
+ return null;
+ }
+}
View
28 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassStaticInitOfChild.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.blueprint.proxy;
+
+public class ProxyTestClassStaticInitOfChild extends ProxyTestClassStaticInitOfChildParent
+{
+
+ public ProxyTestClassStaticInitOfChild(){
+ super("test");
+ }
+
+}
View
34 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassStaticInitOfChildParent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.aries.blueprint.proxy;
+
+public class ProxyTestClassStaticInitOfChildParent
+{
+
+ private static final ProxyTestClassStaticInitOfChildParent child = new ProxyTestClassStaticInitOfChild();
+
+ public static void doStuff() {
+ //Do silly stuff;
+ child.toString();
+ }
+
+ public ProxyTestClassStaticInitOfChildParent(String s){
+
+ }
+}
View
40 proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
@@ -30,6 +30,7 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -70,7 +71,7 @@
}
/** An array of classes that will be woven - note no UnweavableParents should be in here! */
- private static final Class<?>[] CLASSES = new Class<?>[]{TEST_CLASS, ProxyTestClassSuper.class,
+ private static final List<Class<?>> CLASSES = Arrays.asList(new Class<?>[]{TEST_CLASS, ProxyTestClassSuper.class,
ProxyTestClassFinalMethod.class, ProxyTestClassFinal.class, ProxyTestClassGeneric.class,
ProxyTestClassGenericSuper.class, ProxyTestClassCovariant.class, ProxyTestClassCovariantOverride.class,
ProxyTestClassUnweavableChild.class, ProxyTestClassUnweavableSibling.class, ProxyTestClassInner.class,
@@ -78,7 +79,11 @@
ProxyTestClassUnweavableChildWithFinalMethodParent.class,
ProxyTestClassUnweavableChildWithDefaultMethodWrongPackageParent.class,
ProxyTestClassSerializable.class, ProxyTestClassSerializableWithSVUID.class,
- ProxyTestClassSerializableChild.class, ProxyTestClassSerializableInterface.class};
+ ProxyTestClassSerializableChild.class, ProxyTestClassSerializableInterface.class,
+ ProxyTestClassStaticInitOfChild.class});
+
+ /** An array of classes that are loaded by the WeavingLoader, but not actually woven **/
+ private static final List<Class<?>> OTHER_CLASSES = Arrays.asList(new Class<?>[] {ProxyTestClassStaticInitOfChildParent.class});
private static final Map<String, byte[]> rawClasses = new HashMap<String, byte[]>();
@@ -101,7 +106,16 @@
if(bytes == null)
return super.loadClass(className, b);
- bytes = WovenProxyGenerator.getWovenProxy(bytes, className, this);
+ boolean weave = false;
+
+ for(Class<?> c : CLASSES) {
+ if(c.getName().equals(className)) {
+ weave = true;
+ break;
+ }
+ }
+ if(weave)
+ bytes = WovenProxyGenerator.getWovenProxy(bytes, className, this);
return defineClass(className, bytes, 0, bytes.length);
}
@@ -117,7 +131,12 @@ protected URL findResource(String resName) {
@BeforeClass
public static void setUp() throws Exception
{
- for(Class<?> clazz : CLASSES) {
+ List<Class<?>> classes = new ArrayList(CLASSES.size() + OTHER_CLASSES.size());
+
+ classes.addAll(CLASSES);
+ classes.addAll(OTHER_CLASSES);
+
+ for(Class<?> clazz : classes) {
InputStream is = clazz.getClassLoader().getResourceAsStream(
clazz.getName().replace('.', '/') + ".class");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -383,6 +402,19 @@ public void testGeneratedSVUIDisSynthetic() throws Exception {
assertFalse(woven.getDeclaredField("serialVersionUID").isSynthetic());
}
+ /**
+ * This test covers a weird case on Mac VMs where we sometimes
+ * get a ClassCircularityError if a static initializer in a
+ * non-woven superclass references a subclass that's being
+ * woven, and gets triggered by the weaving process. Not known
+ * to fail on IBM or Sun/Oracle VMs
+ */
+ @Test
+ public void testSuperStaticInitOfChild() throws Exception {
+ Class<?> parent = weavingLoader.loadClass(ProxyTestClassStaticInitOfChildParent.class.getName());
+ parent.getMethod("doStuff").invoke(null);
+ }
+
@Override