aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1720175 - in /aries/trunk/subsystem: subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/...
Date Tue, 15 Dec 2015 14:28:11 GMT
Author: jwross
Date: Tue Dec 15 14:28:11 2015
New Revision: 1720175

URL: http://svn.apache.org/viewvc?rev=1720175&view=rev
Log:
[ARIES-1383] Provide option to disable the provisioning of dependencies at install time.

Composites in the INSTALLING state and having apache-aries-provision-dependencies:=resolve
must have their export sharing policies set in order for any offered capabilities
to be considered valid as part of computing the dependencies of another subsystem having the
same state and directive value. Currently, a brute force method is used whereby
all composites fitting the above criteria will have their export policies temporarily enabled.
Any that did not end up offering a capability used to resolve the other
subsystem will have their policies rolled back.

Plus test.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1383Test.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/BundleArchiveBuilder.java
    aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/SubsystemArchiveBuilder.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java?rev=1720175&r1=1720174&r2=1720175&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/StartAction.java
Tue Dec 15 14:28:11 2015
@@ -14,7 +14,6 @@
 package org.apache.aries.subsystem.core.internal;
 
 import java.io.IOException;
-import java.net.URISyntaxException;
 import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -50,7 +49,6 @@ import org.osgi.resource.Resource;
 import org.osgi.service.coordinator.Coordination;
 import org.osgi.service.coordinator.CoordinationException;
 import org.osgi.service.coordinator.Participant;
-import org.osgi.service.resolver.ResolutionException;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.Subsystem.State;
 import org.osgi.service.subsystem.SubsystemConstants;
@@ -134,6 +132,10 @@ public class StartAction extends Abstrac
 		    	// If necessary, install the dependencies.
 		    	if (State.INSTALLING.equals(target.getState()) && 
 		    			!Utils.isProvisionDependenciesInstall(target)) {
+		    		// The following line is necessary in order to ensure that
+		    		// the export sharing policies of composites are in place
+		    		// for capability validation.
+		    		setExportPolicyOfAllInstallingSubsystemsWithProvisionDependenciesResolve(coordination);
 		    		Collection<Subsystem> subsystems = new ArrayList<Subsystem>();
 		    		subsystems.addAll(Activator.getInstance().getSubsystems().getChildren(target));
 		    		subsystems.addAll(target.getParents());
@@ -302,7 +304,7 @@ public class StartAction extends Abstrac
 		}
 	}
 
-	private static void setExportIsolationPolicy(BasicSubsystem subsystem, Coordination coordination)
throws InvalidSyntaxException, IOException, BundleException, URISyntaxException, ResolutionException
{
+	private static void setExportIsolationPolicy(final BasicSubsystem subsystem, Coordination
coordination) throws InvalidSyntaxException {
 		if (!subsystem.isComposite())
 			return;
 		final Region from = ((BasicSubsystem)subsystem.getParents().iterator().next()).getRegion();
@@ -317,15 +319,39 @@ public class StartAction extends Abstrac
 		if (logger.isDebugEnabled())
 			logger.debug("Establishing region connection: from=" + from
 					+ ", to=" + to + ", filter=" + regionFilter);
-		from.connectRegion(to, regionFilter);
+		try {
+			from.connectRegion(to, regionFilter);
+		}
+		catch (BundleException e) {
+			// TODO Assume this means that the export sharing policy has already
+			// been set. Bad assumption?
+			return;
+		}
 		coordination.addParticipant(new Participant() {
 			@Override
 			public void ended(Coordination coordination) throws Exception {
-				// Nothing.
+				// It may be necessary to rollback the export sharing policy
+				// even when the coordination did not fail. For example, this
+				// might have been a subsystem whose export sharing policy was
+				// set just in case it offered dependencies for some other
+				// subsystem.
+				unsetExportIsolationPolicyIfNecessary();
 			}
 
 			@Override
 			public void failed(Coordination coordination) throws Exception {
+				// Nothing to do because a coordination is always ended.
+			}
+			
+			private void unsetExportIsolationPolicyIfNecessary() throws BundleException, InvalidSyntaxException
{
+				if (!EnumSet.of(State.INSTALLING, State.INSTALLED).contains(subsystem.getState())) {
+					// The subsystem is either RESOLVED or ACTIVE and therefore
+					// does not require a rollback.
+					return;
+				}
+				// The subsystem is either INSTALLING or INSTALLED and therefore
+				// requires a rollback since the export sharing policy must only
+				// be set upon entering the RESOLVED state.
 				RegionUpdater updater = new RegionUpdater(from, to);
 				updater.addRequirements(null);
 			}
@@ -533,4 +559,14 @@ public class StartAction extends Abstrac
 		}
 		logger.error(diagnostics.toString());
 	}
+	
+	private static void setExportPolicyOfAllInstallingSubsystemsWithProvisionDependenciesResolve(Coordination
coordination) throws InvalidSyntaxException {
+		for (BasicSubsystem subsystem : Activator.getInstance().getSubsystems().getSubsystems())
{
+			if (!State.INSTALLING.equals(subsystem.getState())
+					|| Utils.isProvisionDependenciesInstall(subsystem)) {
+				continue;
+			}
+			setExportIsolationPolicy(subsystem, coordination);
+		}
+	}
 }

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1720175&r1=1720174&r2=1720175&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Tue Dec 15 14:28:11 2015
@@ -194,13 +194,14 @@ public abstract class SubsystemTest exte
 	@SuppressWarnings("rawtypes")
     protected Collection<ServiceRegistration> serviceRegistrations = new ArrayList<ServiceRegistration>();
 
-	protected final List<Region> deletableRegions = new ArrayList<Region>();
-	protected final List<Subsystem> stoppableSubsystems = new ArrayList<Subsystem>();
-	protected final List<Bundle> uninstallableBundles = new ArrayList<Bundle>();
-    protected final List<Subsystem> uninstallableSubsystems = new ArrayList<Subsystem>();
+	protected final List<Region> deletableRegions = Collections.synchronizedList(new ArrayList<Region>());
+	protected final List<Subsystem> stoppableSubsystems = Collections.synchronizedList(new
ArrayList<Subsystem>());
+	protected final List<Bundle> uninstallableBundles = Collections.synchronizedList(new
ArrayList<Bundle>());
+    protected final List<Subsystem> uninstallableSubsystems = Collections.synchronizedList(new
ArrayList<Subsystem>());
 	
 	@Before
 	public void setUp() throws Exception {
+		serviceRegistrations.clear();
 		deletableRegions.clear();
 		stoppableSubsystems.clear();
 		uninstallableBundles.clear();
@@ -232,7 +233,6 @@ public abstract class SubsystemTest exte
 		bundleContext.removeServiceListener(subsystemEvents);
 		for (ServiceRegistration registration : serviceRegistrations)
 			Utils.unregisterQuietly(registration);
-		serviceRegistrations.clear();
 	}
 
 	protected void createApplications() throws Exception {

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1383Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1383Test.java?rev=1720175&r1=1720174&r2=1720175&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1383Test.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1383Test.java
Tue Dec 15 14:28:11 2015
@@ -121,7 +121,7 @@ public class Aries1383Test extends Subsy
 				new Callable<Subsystem>() {
 					@Override
 					public Subsystem call() throws Exception {
-						return installSubsystem(
+						Subsystem result = installSubsystem(
 								c1,
 								"a1", 
 								new SubsystemArchiveBuilder()
@@ -137,13 +137,15 @@ public class Aries1383Test extends Subsy
 														.build())
 										.build(),
 								false);
+						uninstallableSubsystems.add(result);
+						return result;
 					}
 					
 				},
 				new Callable<Subsystem>() {
 					@Override
 					public Subsystem call() throws Exception {
-						return installSubsystem(
+						Subsystem result = installSubsystem(
 								c1,
 								"f1", 
 								new SubsystemArchiveBuilder()
@@ -160,13 +162,15 @@ public class Aries1383Test extends Subsy
 														.build())
 										.build(),
 								false);
+						uninstallableSubsystems.add(result);
+						return result;
 					}
 					
 				},
 				new Callable<Subsystem>() {
 					@Override
 					public Subsystem call() throws Exception {
-						return installSubsystem(
+						Subsystem result = installSubsystem(
 								c1,
 								"f2", 
 								new SubsystemArchiveBuilder()
@@ -184,13 +188,15 @@ public class Aries1383Test extends Subsy
 														.build())
 										.build(),
 								false);
+						uninstallableSubsystems.add(result);
+						return result;
 					}
 					
 				},
 				new Callable<Subsystem>() {
 					@Override
 					public Subsystem call() throws Exception {
-						return installSubsystem(
+						Subsystem result = installSubsystem(
 								c1,
 								"c2", 
 								new SubsystemArchiveBuilder()
@@ -209,6 +215,8 @@ public class Aries1383Test extends Subsy
 														.build())
 										.build(),
 								false);
+						uninstallableSubsystems.add(result);
+						return result;
 					}
 					
 				}
@@ -216,16 +224,12 @@ public class Aries1383Test extends Subsy
 		ExecutorService executor = Executors.newFixedThreadPool(4);
 		List<Future<Subsystem>> installFutures = executor.invokeAll(Arrays.asList(installCallables));
 		final Subsystem a1 = installFutures.get(0).get();
-		uninstallableSubsystems.add(a1);
 		assertConstituent(a1, "b1");
 		final Subsystem f1 = installFutures.get(1).get();
-		uninstallableSubsystems.add(f1);
 		assertConstituent(f1, "b2");
 		final Subsystem f2 = installFutures.get(2).get();
-		uninstallableSubsystems.add(f2);
 		assertConstituent(f2, "b4");
 		final Subsystem c2 = installFutures.get(3).get();
-		uninstallableSubsystems.add(c2);
 		assertConstituent(c2, "b3");
 		@SuppressWarnings("unchecked")
 		Callable<Null>[] startCallables = new Callable[] {
@@ -236,6 +240,7 @@ public class Aries1383Test extends Subsy
 					assertEvent(a1, State.INSTALLED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
 					assertEvent(a1, State.RESOLVING, subsystemEvents.poll(a1.getSubsystemId(), 5000));
 					assertEvent(a1, State.RESOLVED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					stoppableSubsystems.add(a1);
 					return null;
 				}
 			},
@@ -246,6 +251,7 @@ public class Aries1383Test extends Subsy
 					assertEvent(f1, State.INSTALLED, subsystemEvents.poll(f1.getSubsystemId(), 5000));
 					assertEvent(f1, State.RESOLVING, subsystemEvents.poll(f1.getSubsystemId(), 5000));
 					assertEvent(f1, State.RESOLVED, subsystemEvents.poll(f1.getSubsystemId(), 5000));
+					stoppableSubsystems.add(f1);
 					return null;
 				}
 			},
@@ -256,6 +262,7 @@ public class Aries1383Test extends Subsy
 					assertEvent(f2, State.INSTALLED, subsystemEvents.poll(f2.getSubsystemId(), 5000));
 					assertEvent(f2, State.RESOLVING, subsystemEvents.poll(f2.getSubsystemId(), 5000));
 					assertEvent(f2, State.RESOLVED, subsystemEvents.poll(f2.getSubsystemId(), 5000));
+					stoppableSubsystems.add(f2);
 					return null;
 				}
 			},
@@ -266,19 +273,16 @@ public class Aries1383Test extends Subsy
 					assertEvent(c2, State.INSTALLED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
 					assertEvent(c2, State.RESOLVING, subsystemEvents.poll(c2.getSubsystemId(), 5000));
 					assertEvent(c2, State.RESOLVED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					stoppableSubsystems.add(c2);
 					return null;
 				}
 			}
 		};
 		List<Future<Null>> startFutures = executor.invokeAll(Arrays.asList(startCallables));
 		startFutures.get(0).get();
-		stoppableSubsystems.add(a1);
 		startFutures.get(1).get();
-		stoppableSubsystems.add(f1);
 		startFutures.get(2).get();
-		stoppableSubsystems.add(f2);
 		startFutures.get(3).get();
-		stoppableSubsystems.add(c2);
 	}
 	
 	/*
@@ -1813,6 +1817,27 @@ public class Aries1383Test extends Subsy
 				.build();
 	}
 	
+	public static interface TestService {}
+	
+	public static class TestServiceImpl implements TestService {}
+	
+	public static class TestServiceActivator implements BundleActivator {
+		private ServiceRegistration<TestService> reg;
+		
+		@Override
+		public void start(BundleContext context) throws Exception {
+			reg = context.registerService(
+					TestService.class, 
+					new TestServiceImpl(), 
+					null);
+		}
+
+		@Override
+		public void stop(BundleContext context) throws Exception {
+			reg.unregister();
+		}
+	}
+	
 	private static class BundleStartFailureActivator implements BundleActivator {
 		@Override
 		public void start(BundleContext context) throws Exception {
@@ -1875,6 +1900,7 @@ public class Aries1383Test extends Subsy
 		startSubsystem(c1, false);
 		stoppableSubsystems.add(c1);
 		assertState(EnumSet.of(State.RESOLVED, State.ACTIVE), c2);
+		stoppableSubsystems.add(c2);
 	}
 	
 	@Test
@@ -1901,6 +1927,7 @@ public class Aries1383Test extends Subsy
 						.build(),
 				false
 		);
+		uninstallableSubsystems.add(c1);
 		Subsystem c2 = installSubsystem(
 				root,
 				"c2",
@@ -1922,6 +1949,7 @@ public class Aries1383Test extends Subsy
 						.build(),
 				false
 		);
+		uninstallableSubsystems.add(c2);
 		assertChild(root, "c1", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
 		assertChild(root, "c2", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
 		restartSubsystemsImplBundle();
@@ -2196,12 +2224,177 @@ public class Aries1383Test extends Subsy
 						.type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)
 						.provideCapability("y")
 						.build());
+		uninstallableSubsystems.add(c1);
 		try {
 			startSubsystem(c1);
+			stoppableSubsystems.add(c1);
 		}
 		catch (SubsystemException e) {
 			e.printStackTrace();
 			fail("Subsystem should have started");
 		}
 	}
+	
+	@Test
+	public void testComApiComImplAppClient() throws Exception {
+		Subsystem root = getRootSubsystem();
+		final Subsystem shared = installSubsystem(
+				root,
+				"shared", 
+				new SubsystemArchiveBuilder()
+						.symbolicName("shared")
+						.type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE 
+								+ ';' 
+								+ AriesProvisionDependenciesDirective.RESOLVE.toString()
+								+ ';'
+								+ SubsystemConstants.PROVISION_POLICY_DIRECTIVE
+								+ ":="
+								+ SubsystemConstants.PROVISION_POLICY_ACCEPT_DEPENDENCIES)
+						.importPackage("org.osgi.framework")
+						.build(),
+				false
+		);
+		uninstallableSubsystems.add(shared);
+		shared.start();
+		stoppableSubsystems.add(shared);
+		@SuppressWarnings("unchecked")
+		Callable<Subsystem>[] installCallables = new Callable[] {
+				new Callable<Subsystem>() {
+					@Override
+					public Subsystem call() throws Exception {
+						Subsystem result = installSubsystem(
+								shared,
+								"client", 
+								new SubsystemArchiveBuilder()
+										.symbolicName("client")
+										.type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION)
+										.bundle(
+												"client", 
+												new BundleArchiveBuilder()
+														.symbolicName("client")
+														.importPackage("org.apache.aries.subsystem.itests.defect")
+														.requireCapability("osgi.service;filter:=\"(objectClass="
+																+ TestService.class.getName()
+																+ ")\";effective:=active")
+														.build())
+										.build(),
+								false);
+						uninstallableSubsystems.add(result);
+						return result;
+					}
+					
+				},
+				new Callable<Subsystem>() {
+					@Override
+					public Subsystem call() throws Exception {
+						Subsystem result = installSubsystem(
+								shared,
+								"impl", 
+								new SubsystemArchiveBuilder()
+										.symbolicName("impl")
+										.type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)
+										.content("impl;version=\"[0,0]\"")
+										.provideCapability("osgi.service;objectClass:List<String>=\"" 
+												+ TestService.class.getName() 
+												+ "\"")
+										.importPackage("org.osgi.framework")
+										.requireBundle("api")
+										.bundle(
+												"impl", 
+												new BundleArchiveBuilder()
+														.symbolicName("impl")
+														.provideCapability("osgi.service;objectClass:List<String>=\"" 
+																+ TestService.class.getName() 
+																+ "\"")
+														.importPackage("org.osgi.framework")
+														.requireBundle("api")
+														.clazz(TestServiceImpl.class)
+														.activator(TestServiceActivator.class)
+														.build())
+										.build(),
+								false);
+						uninstallableSubsystems.add(result);
+						return result;
+					}
+					
+				},
+				new Callable<Subsystem>() {
+					@Override
+					public Subsystem call() throws Exception {
+						Subsystem result = installSubsystem(
+								shared,
+								"api", 
+								new SubsystemArchiveBuilder()
+										.symbolicName("api")
+										.type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)
+										.content("api;version=\"[0,0]\"")
+										.exportPackage("org.apache.aries.subsystem.itests.defect")
+										.provideCapability("osgi.wiring.bundle;osgi.wiring.bundle=api;bundle-version=0")
+										.bundle(
+												"api", 
+												new BundleArchiveBuilder()
+														.symbolicName("api")
+														.exportPackage("org.apache.aries.subsystem.itests.defect")
+														.clazz(TestService.class)
+														.build())
+										.build(),
+								false);
+						uninstallableSubsystems.add(result);
+						return result;
+					}
+					
+				}
+		};
+		ExecutorService executor = Executors.newFixedThreadPool(3);
+		List<Future<Subsystem>> installFutures = executor.invokeAll(Arrays.asList(installCallables));
+		final Subsystem a1 = installFutures.get(0).get();
+		final Subsystem c1 = installFutures.get(1).get();
+		final Subsystem c2 = installFutures.get(2).get();
+		@SuppressWarnings("unchecked")
+		Callable<Void>[] startCallables = new Callable[] {
+			new Callable<Void>() {
+				@Override
+				public Void call() throws Exception {
+					a1.start();
+					stoppableSubsystems.add(a1);
+					assertEvent(a1, State.INSTALLED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					assertEvent(a1, State.RESOLVING, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					assertEvent(a1, State.RESOLVED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					assertEvent(a1, State.STARTING, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					assertEvent(a1, State.ACTIVE, subsystemEvents.poll(a1.getSubsystemId(), 5000));
+					return null;
+				}
+			},
+			new Callable<Void>() {
+				@Override
+				public Void call() throws Exception {
+					c1.start();
+					stoppableSubsystems.add(c1);
+					assertEvent(c1, State.INSTALLED, subsystemEvents.poll(c1.getSubsystemId(), 5000));
+					assertEvent(c1, State.RESOLVING, subsystemEvents.poll(c1.getSubsystemId(), 5000));
+					assertEvent(c1, State.RESOLVED, subsystemEvents.poll(c1.getSubsystemId(), 5000));
+					assertEvent(c1, State.STARTING, subsystemEvents.poll(c1.getSubsystemId(), 5000));
+					assertEvent(c1, State.ACTIVE, subsystemEvents.poll(c1.getSubsystemId(), 5000));
+					return null;
+				}
+			},
+			new Callable<Void>() {
+				@Override
+				public Void call() throws Exception {
+					c2.start();
+					stoppableSubsystems.add(c2);
+					assertEvent(c2, State.INSTALLED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					assertEvent(c2, State.RESOLVING, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					assertEvent(c2, State.RESOLVED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					assertEvent(c2, State.STARTING, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					assertEvent(c2, State.ACTIVE, subsystemEvents.poll(c2.getSubsystemId(), 5000));
+					return null;
+				}
+			}
+		};
+		List<Future<Void>> startFutures = executor.invokeAll(Arrays.asList(startCallables));
+		startFutures.get(0).get();
+		startFutures.get(1).get();
+		startFutures.get(2).get();
+	}
 }

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/BundleArchiveBuilder.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/BundleArchiveBuilder.java?rev=1720175&r1=1720174&r2=1720175&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/BundleArchiveBuilder.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/BundleArchiveBuilder.java
Tue Dec 15 14:28:11 2015
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.ops4j.pax.tinybundles.core.InnerClassStrategy;
 import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
 
@@ -18,6 +19,12 @@ public class BundleArchiveBuilder {
 		bundle = TinyBundles.bundle();
 	}
 	
+	public BundleArchiveBuilder activator(Class<?> clazz) {
+		bundle.set(Constants.BUNDLE_ACTIVATOR, clazz.getName());
+		bundle.add(clazz, InnerClassStrategy.NONE);
+		return this;
+	}
+	
 	public InputStream build() {
 		return bundle.build();
 	}
@@ -35,6 +42,11 @@ public class BundleArchiveBuilder {
 		return baos.toByteArray();
 	}
 	
+	public BundleArchiveBuilder clazz(Class<?> clazz) {
+		bundle.add(clazz, InnerClassStrategy.NONE);
+		return this;
+	}
+	
 	public BundleArchiveBuilder exportPackage(String value) {
 		return header(Constants.EXPORT_PACKAGE, value);
 	}
@@ -48,6 +60,18 @@ public class BundleArchiveBuilder {
 		return header(Constants.IMPORT_PACKAGE, value);
 	}
 	
+	public BundleArchiveBuilder provideCapability(String value) {
+		return header(Constants.PROVIDE_CAPABILITY, value);
+	}
+	
+	public BundleArchiveBuilder requireBundle(String value) {
+		return header(Constants.REQUIRE_BUNDLE, value);
+	}
+	
+	public BundleArchiveBuilder requireCapability(String value) {
+		return header(Constants.REQUIRE_CAPABILITY, value);
+	}
+	
 	public BundleArchiveBuilder symbolicName(String value) {
 		return header(Constants.BUNDLE_SYMBOLICNAME, value);
 	}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/SubsystemArchiveBuilder.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/SubsystemArchiveBuilder.java?rev=1720175&r1=1720174&r2=1720175&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/SubsystemArchiveBuilder.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/SubsystemArchiveBuilder.java
Tue Dec 15 14:28:11 2015
@@ -63,6 +63,10 @@ public class SubsystemArchiveBuilder {
 		return header(Constants.IMPORT_PACKAGE, value);
 	}
 	
+	public SubsystemArchiveBuilder requireBundle(String value) {
+		return header(Constants.REQUIRE_BUNDLE, value);
+	}
+	
 	public SubsystemArchiveBuilder provideCapability(String value) {
 		return header(Constants.PROVIDE_CAPABILITY, value);
 	}



Mime
View raw message