felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r1365307 - in /felix/trunk/bundleplugin/src/main/java/aQute: bnd/component/ bnd/differ/ bnd/osgi/ bnd/service/repository/ lib/collections/ libg/reporter/
Date Tue, 24 Jul 2012 21:37:48 GMT
Author: mcculls
Date: Tue Jul 24 21:37:47 2012
New Revision: 1365307

URL: http://svn.apache.org/viewvc?rev=1365307&view=rev
Log:
Latest bndlib code (with potential fix for GF)

Added:
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
  (with props)
Modified:
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/differ/RepositoryElement.java
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java
    felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Constants.java
    felix/trunk/bundleplugin/src/main/java/aQute/lib/collections/ExtList.java
    felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java

Modified: felix/trunk/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/component/HeaderReader.java Tue Jul 24
21:37:47 2012
@@ -227,7 +227,9 @@ public class HeaderReader extends Proces
 		}
 		for (String lifecycle: LIFECYCLE_METHODS) {
 			//lifecycle methods were not specified.... check for non 1.0 signatures.
-			if (descriptors.containsKey(lifecycle) && rateLifecycle(descriptors.get(lifecycle),
"deactivate".equals(lifecycle)? allowedDeactivate: allowed) > 1) {
+			MethodDef test = descriptors.get(lifecycle);
+			if (descriptors.containsKey(lifecycle) && (!(test.isPublic() || test.isProtected())
|| 
+					rateLifecycle(test, "deactivate".equals(lifecycle)? allowedDeactivate: allowed) >
1)) {
 				return NAMESPACE_STEM + "/v1.1.0";
 			}
 		}
@@ -291,7 +293,7 @@ public class HeaderReader extends Proces
 	private int rateLifecycle(MethodDef test, Set<String> allowedParams) {
 		TypeRef[] prototype = test.getDescriptor().getPrototype();
 		if (prototype.length == 1 && ComponentContextTR.equals(prototype[0].getFQN()))
-			return 1;
+			    return 1;
 		if (prototype.length == 1 && BundleContextTR.equals(prototype[0].getFQN()))
 			return 2;
 		if (prototype.length == 1 && MapTR.equals(prototype[0].getFQN()))

Modified: felix/trunk/bundleplugin/src/main/java/aQute/bnd/differ/RepositoryElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/differ/RepositoryElement.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/differ/RepositoryElement.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/differ/RepositoryElement.java Tue Jul
24 21:37:47 2012
@@ -2,7 +2,6 @@ package aQute.bnd.differ;
 
 import java.util.*;
 
-import aQute.bnd.osgi.*;
 import aQute.bnd.service.*;
 import aQute.bnd.service.diff.*;
 import aQute.bnd.version.*;

Modified: felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Analyzer.java Tue Jul 24 21:37:47
2012
@@ -336,127 +336,135 @@ public class Analyzer extends Processor 
 	 * @throws IOException
 	 */
 	public Manifest calcManifest() throws Exception {
-		analyze();
-		Manifest manifest = new Manifest();
-		Attributes main = manifest.getMainAttributes();
+		try {
+			analyze();
+			Manifest manifest = new Manifest();
+			Attributes main = manifest.getMainAttributes();
 
-		main.put(Attributes.Name.MANIFEST_VERSION, "1.0");
-		main.putValue(BUNDLE_MANIFESTVERSION, "2");
+			main.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+			main.putValue(BUNDLE_MANIFESTVERSION, "2");
 
-		boolean noExtraHeaders = "true".equalsIgnoreCase(getProperty(NOEXTRAHEADERS));
+			boolean noExtraHeaders = "true".equalsIgnoreCase(getProperty(NOEXTRAHEADERS));
 
-		if (!noExtraHeaders) {
-			main.putValue(CREATED_BY, System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
-					+ ")");
-			main.putValue(TOOL, "Bnd-" + getBndVersion());
-			main.putValue(BND_LASTMODIFIED, "" + System.currentTimeMillis());
-		}
+			if (!noExtraHeaders) {
+				main.putValue(CREATED_BY, System.getProperty("java.version") + " (" + System.getProperty("java.vendor")
+						+ ")");
+				main.putValue(TOOL, "Bnd-" + getBndVersion());
+				main.putValue(BND_LASTMODIFIED, "" + System.currentTimeMillis());
+			}
 
-		String exportHeader = printClauses(exports, true);
+			String exportHeader = printClauses(exports, true);
 
-		if (exportHeader.length() > 0)
-			main.putValue(EXPORT_PACKAGE, exportHeader);
-		else
-			main.remove(EXPORT_PACKAGE);
+			if (exportHeader.length() > 0)
+				main.putValue(EXPORT_PACKAGE, exportHeader);
+			else
+				main.remove(EXPORT_PACKAGE);
 
-		// Remove all the Java packages from the imports
-		if (!imports.isEmpty()) {
-			main.putValue(IMPORT_PACKAGE, printClauses(imports));
-		} else {
-			main.remove(IMPORT_PACKAGE);
-		}
+			// Remove all the Java packages from the imports
+			if (!imports.isEmpty()) {
+				main.putValue(IMPORT_PACKAGE, printClauses(imports));
+			} else {
+				main.remove(IMPORT_PACKAGE);
+			}
 
-		Packages temp = new Packages(contained);
-		temp.keySet().removeAll(exports.keySet());
+			Packages temp = new Packages(contained);
+			temp.keySet().removeAll(exports.keySet());
 
-		if (!temp.isEmpty())
-			main.putValue(PRIVATE_PACKAGE, printClauses(temp));
-		else
-			main.remove(PRIVATE_PACKAGE);
+			if (!temp.isEmpty())
+				main.putValue(PRIVATE_PACKAGE, printClauses(temp));
+			else
+				main.remove(PRIVATE_PACKAGE);
 
-		Parameters bcp = getBundleClasspath();
-		if (bcp.isEmpty() || (bcp.containsKey(".") && bcp.size() == 1))
-			main.remove(BUNDLE_CLASSPATH);
-		else
-			main.putValue(BUNDLE_CLASSPATH, printClauses(bcp));
-
-		doNamesection(dot, manifest);
-
-		for (Enumeration< ? > h = getProperties().propertyNames(); h.hasMoreElements();)
{
-			String header = (String) h.nextElement();
-			if (header.trim().length() == 0) {
-				warning("Empty property set with value: " + getProperties().getProperty(header));
-				continue;
-			}
+			Parameters bcp = getBundleClasspath();
+			if (bcp.isEmpty() || (bcp.containsKey(".") && bcp.size() == 1))
+				main.remove(BUNDLE_CLASSPATH);
+			else
+				main.putValue(BUNDLE_CLASSPATH, printClauses(bcp));
 
-			if (isMissingPlugin(header.trim())) {
-				error("Missing plugin for command %s", header);
-			}
-			if (!Character.isUpperCase(header.charAt(0))) {
-				if (header.charAt(0) == '@')
-					doNameSection(manifest, header);
-				continue;
-			}
+			doNamesection(dot, manifest);
 
-			if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE) || header.equals(IMPORT_PACKAGE))
-				continue;
+			for (Enumeration< ? > h = getProperties().propertyNames(); h.hasMoreElements();)
{
+				String header = (String) h.nextElement();
+				if (header.trim().length() == 0) {
+					warning("Empty property set with value: " + getProperties().getProperty(header));
+					continue;
+				}
 
-			if (header.equalsIgnoreCase("Name")) {
-				error("Your bnd file contains a header called 'Name'. This interferes with the manifest
name section.");
-				continue;
-			}
+				if (isMissingPlugin(header.trim())) {
+					error("Missing plugin for command %s", header);
+				}
+				if (!Character.isUpperCase(header.charAt(0))) {
+					if (header.charAt(0) == '@')
+						doNameSection(manifest, header);
+					continue;
+				}
 
-			if (Verifier.HEADER_PATTERN.matcher(header).matches()) {
-				String value = getProperty(header);
-				if (value != null && main.getValue(header) == null) {
-					if (value.trim().length() == 0)
-						main.remove(header);
-					else if (value.trim().equals(EMPTY_HEADER))
-						main.putValue(header, "");
-					else
-						main.putValue(header, value);
+				if (header.equals(BUNDLE_CLASSPATH) || header.equals(EXPORT_PACKAGE) || header.equals(IMPORT_PACKAGE))
+					continue;
+
+				if (header.equalsIgnoreCase("Name")) {
+					error("Your bnd file contains a header called 'Name'. This interferes with the manifest
name section.");
+					continue;
 				}
-			} else {
-				// TODO should we report?
-			}
-		}
 
-		// Copy old values into new manifest, when they
-		// exist in the old one, but not in the new one
-		merge(manifest, dot.getManifest());
+				if (Verifier.HEADER_PATTERN.matcher(header).matches()) {
+					String value = getProperty(header);
+					if (value != null && main.getValue(header) == null) {
+						if (value.trim().length() == 0)
+							main.remove(header);
+						else if (value.trim().equals(EMPTY_HEADER))
+							main.putValue(header, "");
+						else
+							main.putValue(header, value);
+					}
+				} else {
+					// TODO should we report?
+				}
+			}
 
-		//
-		// Calculate the bundle symbolic name if it is
-		// not set.
-		// 1. set
-		// 2. name of properties file (must be != bnd.bnd)
-		// 3. name of directory, which is usualy project name
-		//
-		String bsn = getBsn();
-		if (main.getValue(BUNDLE_SYMBOLICNAME) == null) {
-			main.putValue(BUNDLE_SYMBOLICNAME, bsn);
+			// Copy old values into new manifest, when they
+			// exist in the old one, but not in the new one
+			merge(manifest, dot.getManifest());
+
+			//
+			// Calculate the bundle symbolic name if it is
+			// not set.
+			// 1. set
+			// 2. name of properties file (must be != bnd.bnd)
+			// 3. name of directory, which is usualy project name
+			//
+			String bsn = getBsn();
+			if (main.getValue(BUNDLE_SYMBOLICNAME) == null) {
+				main.putValue(BUNDLE_SYMBOLICNAME, bsn);
+			}
+
+			//
+			// Use the same name for the bundle name as BSN when
+			// the bundle name is not set
+			//
+			if (main.getValue(BUNDLE_NAME) == null) {
+				main.putValue(BUNDLE_NAME, bsn);
+			}
+
+			if (main.getValue(BUNDLE_VERSION) == null)
+				main.putValue(BUNDLE_VERSION, "0");
+
+			// Remove all the headers mentioned in -removeheaders
+			Instructions instructions = new Instructions(getProperty(REMOVEHEADERS));
+			Collection<Object> result = instructions.select(main.keySet(), false);
+			main.keySet().removeAll(result);
+
+			// We should not set the manifest here, this is in general done
+			// by the caller.
+			// dot.setManifest(manifest);
+			return manifest;
 		}
-
-		//
-		// Use the same name for the bundle name as BSN when
-		// the bundle name is not set
-		//
-		if (main.getValue(BUNDLE_NAME) == null) {
-			main.putValue(BUNDLE_NAME, bsn);
+		catch (Exception e) {
+			// This should not really happen. The code should never throw
+			// exceptions in normal situations. So if it happens we need more
+			// information. So to help diagnostics. We do a full property dump
+			throw new IllegalStateException("Calc manifest failed, state=\n"+getFlattenedProperties(),
e);
 		}
-
-		if (main.getValue(BUNDLE_VERSION) == null)
-			main.putValue(BUNDLE_VERSION, "0");
-
-		// Remove all the headers mentioned in -removeheaders
-		Instructions instructions = new Instructions(getProperty(REMOVEHEADERS));
-		Collection<Object> result = instructions.select(main.keySet(), false);
-		main.keySet().removeAll(result);
-
-		// We should not set the manifest here, this is in general done
-		// by the caller.
-		// dot.setManifest(manifest);
-		return manifest;
 	}
 
 	/**
@@ -1009,6 +1017,13 @@ public class Analyzer extends Processor 
 			PackageRef next = i.next();
 			Collection<PackageRef> usedByExportedPackage = this.uses.get(next);
 
+			// We had an NPE on usedByExportedPackage in GF.
+			// I guess this can happen with hard coded
+			// imports that do not match reality ...
+			if (usedByExportedPackage == null || usedByExportedPackage.isEmpty()) {
+				continue;
+			}
+
 			for (PackageRef privatePackage : privatePackages) {
 				if (usedByExportedPackage.contains(privatePackage)) {
 					i.remove();
@@ -2509,21 +2524,22 @@ public class Analyzer extends Processor 
 
 	/**
 	 * Create a cross reference from package source, to packages in dest
+	 * 
 	 * @param source
 	 * @param dest
 	 * @param sourceModifiers
 	 * @return
 	 * @throws Exception
 	 */
-	public Map<Clazz.Def, List<TypeRef>> getXRef(final PackageRef source, final
Collection<PackageRef> dest, final int sourceModifiers)
-			throws Exception {
-		final MultiMap<Clazz.Def,TypeRef> xref = new MultiMap<Clazz.Def, TypeRef>(Clazz.Def.class,
TypeRef.class, true);
+	public Map<Clazz.Def,List<TypeRef>> getXRef(final PackageRef source, final Collection<PackageRef>
dest,
+			final int sourceModifiers) throws Exception {
+		final MultiMap<Clazz.Def,TypeRef> xref = new MultiMap<Clazz.Def,TypeRef>(Clazz.Def.class,
TypeRef.class, true);
 
 		for (final Clazz clazz : getClassspace().values()) {
 			if ((clazz.accessx & sourceModifiers) == 0)
 				continue;
 
-			if (source!=null && source != clazz.getClassName().getPackageRef())
+			if (source != null && source != clazz.getClassName().getPackageRef())
 				continue;
 
 			clazz.parseClassFileWithCollector(new ClassDataCollector() {

Modified: felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Builder.java Tue Jul 24 21:37:47
2012
@@ -770,8 +770,8 @@ public class Builder extends Analyzer {
 			extractFromJar(jar, source.substring(1), parts.length == 1 ? "" : destination, absentIsOk);
 		} else if (extra.containsKey("cmd")) {
 			doCommand(jar, source, destination, extra, preprocess, absentIsOk);
-		} else if (extra.containsKey("literal")) {
-			String literal = extra.get("literal");
+		} else if (extra.containsKey(LITERAL_ATTRIBUTE)) {
+			String literal = extra.get(LITERAL_ATTRIBUTE);
 			Resource r = new EmbeddedResource(literal.getBytes("UTF-8"), 0);
 			String x = extra.get("extra");
 			if (x != null)

Modified: felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Constants.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Constants.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/osgi/Constants.java Tue Jul 24 21:37:47
2012
@@ -194,6 +194,7 @@ public interface Constants {
 	String							PATH_DIRECTIVE								= "path:";
 	String							SIZE_ATTRIBUTE								= "size";
 	String							LINK_ATTRIBUTE								= "link";
+	String							LITERAL_ATTRIBUTE							= "literal";
 	String							NAME_ATTRIBUTE								= "name";
 	String							DESCRIPTION_ATTRIBUTE						= "description";
 	String							OSNAME_ATTRIBUTE							= "osname";
@@ -219,7 +220,7 @@ public interface Constants {
 			SPLIT_PACKAGE_DIRECTIVE, NO_IMPORT_DIRECTIVE, IMPORT_DIRECTIVE, RESOLUTION_DIRECTIVE,
INCLUDE_DIRECTIVE,
 			USES_DIRECTIVE, EXCLUDE_DIRECTIVE, KEYSTORE_LOCATION_DIRECTIVE, KEYSTORE_PROVIDER_DIRECTIVE,
 			KEYSTORE_PASSWORD_DIRECTIVE, SIGN_PASSWORD_DIRECTIVE, COMMAND_DIRECTIVE, NOANNOTATIONS,
LIB_DIRECTIVE,
-			RUNPATH_LAUNCHER_DIRECTIVE, FROM_DIRECTIVE, PRIVATE_DIRECTIVE
+			RUNPATH_LAUNCHER_DIRECTIVE, FROM_DIRECTIVE, PRIVATE_DIRECTIVE, LITERAL_ATTRIBUTE
 
 																				// TODO
 																				};
@@ -290,7 +291,7 @@ public interface Constants {
 	public final static String		COMPONENT_ACTIVATE							= "activate:";
 	public final static String		COMPONENT_DEACTIVATE						= "deactivate:";
 
-	public final static String			COMPONENT_NAMESPACE				 		= "xmlns:";
+	public final static String		COMPONENT_NAMESPACE							= "xmlns:";
 
 	final static Map<String,String>	EMPTY										= Collections.emptyMap();
 
@@ -313,11 +314,6 @@ public interface Constants {
 																						COMPONENT_ACTIVATE,
 																						COMPONENT_DEACTIVATE));
 
-	public final static Set<String>		SET_COMPONENT_DIRECTIVES_1_2				= new HashSet<String>(
-																							Arrays.asList(COMPONENT_GREEDY));
+	public final static Set<String>	SET_COMPONENT_DIRECTIVES_1_2				= new HashSet<String>(
+																						Arrays.asList(COMPONENT_GREEDY));
 }
-
-
-
-
-

Added: felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java?rev=1365307&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
(added)
+++ felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
Tue Jul 24 21:37:47 2012
@@ -0,0 +1,24 @@
+package aQute.bnd.service.repository;
+
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import aQute.bnd.version.*;
+import aQute.service.reporter.*;
+
+public interface MinimalRepository {
+	public enum Gestalt {
+		ADD, REMOTE
+	};
+
+	Report add(File f) throws Exception;
+
+	Iterable<String> list(String globbing);
+
+	List<Version> versions(String bsn);
+
+	Future<File> get(String bsn, Version version, Map<String,String> attrs);
+	
+	boolean is(Gestalt gestalt);
+}

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/bundleplugin/src/main/java/aQute/bnd/service/repository/MinimalRepository.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: felix/trunk/bundleplugin/src/main/java/aQute/lib/collections/ExtList.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/lib/collections/ExtList.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/lib/collections/ExtList.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/lib/collections/ExtList.java Tue Jul 24 21:37:47
2012
@@ -16,6 +16,10 @@ public class ExtList<T> extends ArrayLis
 		super(size);
 	}
 
+	public ExtList(Collection<T> _) {
+		super(_);
+	}
+
 	public static ExtList<String> from(String s) {
 		// TODO make sure no \ before comma
 		return from(s, "\\s*,\\s*");

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java?rev=1365307&r1=1365306&r2=1365307&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java Tue Jul
24 21:37:47 2012
@@ -113,7 +113,10 @@ public class ReporterAdapter implements 
 	}
 
 	public SetLocation exception(Throwable t, String s, Object... args) {
-		String e = String.format(s, args);
+		StackTraceElement[] stackTrace = t.getStackTrace();
+		String method = stackTrace[0].getMethodName();
+		String cname = stackTrace[0].getClassName();
+		String e = String.format("["+shorten(cname) +"."+method+"] " +s, args);
 		errors.add(e);
 		trace("ERROR: %s", e);
 		if (isExceptions() || isTrace())
@@ -124,6 +127,14 @@ public class ReporterAdapter implements 
 		return location(e);
 	}
 
+	private String shorten(String cname) {
+		int index = cname.lastIndexOf('$');
+		if ( index < 0)
+			index = cname.lastIndexOf('.');
+		
+		return cname.substring(index+1);
+	}
+
 	public SetLocation warning(String s, Object... args) {
 		String e = String.format(s, args);
 		warnings.add(e);



Mime
View raw message