Skip to content

Commit

Permalink
FELIX-4736 Refactor R4Library and R4LibraryClause to NativeLibrary an…
Browse files Browse the repository at this point in the history
…d NativeLibraryClause respectively.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1647710 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bobpaulin committed Dec 24, 2014
1 parent 5f2b70e commit 8cc415e
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.apache.felix.framework.security.util.LocalPermissions;
import org.apache.felix.framework.security.util.Permissions;
import org.apache.felix.framework.security.util.PropertiesCache;
import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.NativeLibrary;

/*
import org.apache.felix.moduleloader.ICapability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.felix.framework.util.SecureAction;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.ManifestParser;
import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.NativeLibrary;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class BundleRevisionImpl implements BundleRevision, Resource

private final List<BundleCapability> m_declaredCaps;
private final List<BundleRequirement> m_declaredReqs;
private final List<R4Library> m_declaredNativeLibs;
private final List<NativeLibrary> m_declaredNativeLibs;
private final int m_declaredActivationPolicy;
private final List<String> m_activationIncludes;
private final List<String> m_activationExcludes;
Expand Down Expand Up @@ -283,7 +283,7 @@ public String getManifestVersion()
return m_manifestVersion;
}

public List<R4Library> getDeclaredNativeLibraries()
public List<NativeLibrary> getDeclaredNativeLibraries()
{
return m_declaredNativeLibs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.apache.felix.framework.util.SecurityManagerEx;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.ManifestParser;
import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.NativeLibrary;
import org.apache.felix.framework.wiring.BundleRequirementImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
Expand Down Expand Up @@ -99,7 +99,7 @@ public class BundleWiringImpl implements BundleWiring
private final Map<String, List<List<String>>> m_includedPkgFilters;
private final Map<String, List<List<String>>> m_excludedPkgFilters;
private final List<BundleRequirement> m_resolvedReqs;
private final List<R4Library> m_resolvedNativeLibs;
private final List<NativeLibrary> m_resolvedNativeLibs;
private final List<Content> m_fragmentContents;

private volatile List<BundleRequirement> m_wovenReqs = null;
Expand Down Expand Up @@ -401,14 +401,14 @@ else if (!cap.getNamespace().equals(BundleRevision.HOST_NAMESPACE) && !cap.getNa
m_excludedPkgFilters = (excludedPkgFilters.isEmpty())
? Collections.EMPTY_MAP : excludedPkgFilters;

List<R4Library> libList = (m_revision.getDeclaredNativeLibraries() == null)
? new ArrayList<R4Library>()
: new ArrayList<R4Library>(m_revision.getDeclaredNativeLibraries());
List<NativeLibrary> libList = (m_revision.getDeclaredNativeLibraries() == null)
? new ArrayList<NativeLibrary>()
: new ArrayList<NativeLibrary>(m_revision.getDeclaredNativeLibraries());
for (int fragIdx = 0;
(m_fragments != null) && (fragIdx < m_fragments.size());
fragIdx++)
{
List<R4Library> libs =
List<NativeLibrary> libs =
((BundleRevisionImpl) m_fragments.get(fragIdx))
.getDeclaredNativeLibraries();
for (int reqIdx = 0;
Expand Down Expand Up @@ -586,7 +586,7 @@ public List<BundleRequirement> getRequirements(String namespace)
return null;
}

public List<R4Library> getNativeLibraries()
public List<NativeLibrary> getNativeLibraries()
{
return m_resolvedNativeLibs;
}
Expand Down Expand Up @@ -2581,7 +2581,7 @@ protected String findLibrary(String name)
// native library.
if (result == null)
{
List<R4Library> libs = m_wiring.getNativeLibraries();
List<NativeLibrary> libs = m_wiring.getNativeLibraries();
for (int libIdx = 0; (libs != null) && (libIdx < libs.size()); libIdx++)
{
if (libs.get(libIdx).match(m_wiring.m_configMap, name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.apache.felix.framework.util.StringMap;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.ManifestParser;
import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.R4LibraryClause;
import org.apache.felix.framework.util.manifestparser.NativeLibrary;
import org.apache.felix.framework.util.manifestparser.NativeLibraryClause;
import org.apache.felix.framework.wiring.BundleCapabilityImpl;
import org.apache.felix.framework.wiring.BundleWireImpl;
import org.osgi.framework.AdminPermission;
Expand Down Expand Up @@ -258,17 +258,17 @@ protected BundleCapability buildNativeCapabilites() {

if( osArchitecture != null )
{
attributes.put(NativeNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE, R4LibraryClause.getProcessorWithAliases(osArchitecture));
attributes.put(NativeNamespace.CAPABILITY_PROCESSOR_ATTRIBUTE, NativeLibraryClause.getProcessorWithAliases(osArchitecture));
}

if( osName != null)
{
attributes.put(NativeNamespace.CAPABILITY_OSNAME_ATTRIBUTE, R4LibraryClause.getOsNameWithAliases(osName));
attributes.put(NativeNamespace.CAPABILITY_OSNAME_ATTRIBUTE, NativeLibraryClause.getOsNameWithAliases(osName));
}

if( osVersion != null)
{
osVersion = R4LibraryClause.formatOSVersion(osVersion);
osVersion = NativeLibraryClause.formatOSVersion(osVersion);
attributes.put(NativeNamespace.CAPABILITY_OSVERSION_ATTRIBUTE, Version.parseVersion(osVersion));
}

Expand Down Expand Up @@ -877,7 +877,7 @@ public List<BundleCapability> getCapabilities(String namespace)
}

@Override
public List<R4Library> getNativeLibraries()
public List<NativeLibrary> getNativeLibraries()
{
return Collections.EMPTY_LIST;
}
Expand Down
6 changes: 3 additions & 3 deletions framework/src/main/java/org/apache/felix/framework/Felix.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import org.apache.felix.framework.util.StringMap;
import org.apache.felix.framework.util.ThreadGate;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.R4LibraryClause;
import org.apache.felix.framework.util.manifestparser.NativeLibraryClause;
import org.apache.felix.framework.wiring.BundleRequirementImpl;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
Expand Down Expand Up @@ -4553,9 +4553,9 @@ private void initializeFrameworkProperties()
"false");

String s = null;
s = R4LibraryClause.normalizeOSName(System.getProperty("os.name"));
s = NativeLibraryClause.normalizeOSName(System.getProperty("os.name"));
m_configMutableMap.put(FelixConstants.FRAMEWORK_OS_NAME, s);
s = R4LibraryClause.normalizeProcessor(System.getProperty("os.arch"));
s = NativeLibraryClause.normalizeProcessor(System.getProperty("os.arch"));
m_configMutableMap.put(FelixConstants.FRAMEWORK_PROCESSOR, s);
m_configMutableMap.put(
FelixConstants.FELIX_VERSION_PROPERTY, getFrameworkVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.apache.felix.framework.resolver.ResolverWire;
import org.apache.felix.framework.util.ShrinkableCollection;
import org.apache.felix.framework.util.Util;
import org.apache.felix.framework.util.manifestparser.R4Library;
import org.apache.felix.framework.util.manifestparser.NativeLibrary;
import org.apache.felix.framework.wiring.BundleRequirementImpl;
import org.apache.felix.framework.wiring.BundleWireImpl;
import org.osgi.framework.Bundle;
Expand Down Expand Up @@ -1482,7 +1482,7 @@ void checkNativeLibraries(BundleRevision revision) throws ResolveException
{
// Next, try to resolve any native code, since the revision is
// not resolvable if its native code cannot be loaded.
List<R4Library> libs = ((BundleRevisionImpl) revision).getDeclaredNativeLibraries();
List<NativeLibrary> libs = ((BundleRevisionImpl) revision).getDeclaredNativeLibraries();
if (libs != null)
{
String msg = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class ManifestParser
private volatile Version m_bundleVersion;
private volatile List<BundleCapability> m_capabilities;
private volatile List<BundleRequirement> m_requirements;
private volatile List<R4LibraryClause> m_libraryClauses;
private volatile List<NativeLibraryClause> m_libraryClauses;
private volatile boolean m_libraryHeadersOptional = false;

public ManifestParser(Logger logger, Map configMap, BundleRevision owner, Map headerMap)
Expand Down Expand Up @@ -607,15 +607,15 @@ private static List<BundleRequirement> convertRequireCapabilities(
return reqList;
}

static List<BundleRequirement> convertNativeCode(BundleRevision owner, List<R4LibraryClause> nativeLibraryClauses, boolean hasOptionalLibraryDirective)
static List<BundleRequirement> convertNativeCode(BundleRevision owner, List<NativeLibraryClause> nativeLibraryClauses, boolean hasOptionalLibraryDirective)
{
List<BundleRequirement> result = new ArrayList<BundleRequirement>();

List<SimpleFilter> nativeFilterClauseList = new ArrayList<SimpleFilter>();

if(nativeLibraryClauses != null)
{
for(R4LibraryClause clause: nativeLibraryClauses)
for(NativeLibraryClause clause: nativeLibraryClauses)
{
String[] osNameArray = clause.getOSNames();
String[] osVersionArray = clause.getOSVersions();
Expand Down Expand Up @@ -1071,7 +1071,7 @@ public List<BundleRequirement> getRequirements()
return m_requirements;
}

public List<R4LibraryClause> getLibraryClauses()
public List<NativeLibraryClause> getLibraryClauses()
{
return m_libraryClauses;
}
Expand All @@ -1093,25 +1093,25 @@ public List<R4LibraryClause> getLibraryClauses()
* <li><tt>null</tt> - if the are no native libraries for this module;
* this may also indicate the native libraries are optional and
* did not match the current platform.</li>
* <li>Zero-length <tt>R4Library</tt> array - if no matching native library
* <li>Zero-length <tt>NativeLibrary</tt> array - if no matching native library
* clause was found; this bundle should not resolve.</li>
* <li>Nonzero-length <tt>R4Library</tt> array - the native libraries
* <li>Nonzero-length <tt>NativeLibrary</tt> array - the native libraries
* associated with the matching native library clause.</li>
* </ul>
*
* @return <tt>null</tt> if there are no native libraries, a zero-length
* array if no libraries matched, or an array of selected libraries.
**/
public List<R4Library> getLibraries()
public List<NativeLibrary> getLibraries()
{
ArrayList<R4Library> libs = null;
ArrayList<NativeLibrary> libs = null;
try
{
R4LibraryClause clause = getSelectedLibraryClause();
NativeLibraryClause clause = getSelectedLibraryClause();
if (clause != null)
{
String[] entries = clause.getLibraryEntries();
libs = new ArrayList<R4Library>(entries.length);
libs = new ArrayList<NativeLibrary>(entries.length);
int current = 0;
for (int i = 0; i < entries.length; i++)
{
Expand All @@ -1123,7 +1123,7 @@ public List<R4Library> getLibraries()
}
if (!found)
{
libs.add(new R4Library(
libs.add(new NativeLibrary(
clause.getLibraryEntries()[i],
clause.getOSNames(), clause.getProcessors(), clause.getOSVersions(),
clause.getLanguages(), clause.getSelectionFilter()));
Expand All @@ -1134,7 +1134,7 @@ public List<R4Library> getLibraries()
}
catch (Exception ex)
{
libs = new ArrayList<R4Library>(0);
libs = new ArrayList<NativeLibrary>(0);
}
return libs;
}
Expand All @@ -1149,14 +1149,14 @@ private String getName(String path)
return path;
}

private R4LibraryClause getSelectedLibraryClause() throws BundleException
private NativeLibraryClause getSelectedLibraryClause() throws BundleException
{
if ((m_libraryClauses != null) && (m_libraryClauses.size() > 0))
{
List clauseList = new ArrayList();

// Search for matching native clauses.
for (R4LibraryClause libraryClause : m_libraryClauses)
for (NativeLibraryClause libraryClause : m_libraryClauses)
{
if (libraryClause.match(m_configMap))
{
Expand Down Expand Up @@ -1186,13 +1186,13 @@ else if (clauseList.size() > 1)
{
selected = firstSortedClause(clauseList);
}
return ((R4LibraryClause) clauseList.get(selected));
return ((NativeLibraryClause) clauseList.get(selected));
}

return null;
}

private int firstSortedClause(List<R4LibraryClause> clauseList)
private int firstSortedClause(List<NativeLibraryClause> clauseList)
{
ArrayList indexList = new ArrayList();
ArrayList selection = new ArrayList();
Expand All @@ -1209,7 +1209,7 @@ private int firstSortedClause(List<R4LibraryClause> clauseList)
for (int i = 0; i < indexList.size(); i++)
{
int index = Integer.parseInt(indexList.get(i).toString());
String[] osversions = ((R4LibraryClause) clauseList.get(index)).getOSVersions();
String[] osversions = ((NativeLibraryClause) clauseList.get(index)).getOSVersions();
if (osversions != null)
{
selection.add("" + indexList.get(i));
Expand Down Expand Up @@ -1237,7 +1237,7 @@ else if (selection.size() > 1)
for (int i = 0; i < indexList.size(); i++)
{
int index = Integer.parseInt(indexList.get(i).toString());
String[] osversions = ((R4LibraryClause) clauseList.get(index)).getOSVersions();
String[] osversions = ((NativeLibraryClause) clauseList.get(index)).getOSVersions();
for (int k = 0; k < osversions.length; k++)
{
VersionRange range = VersionRange.parse(osversions[k]);
Expand Down Expand Up @@ -1273,7 +1273,7 @@ else if (selection.size() == 1)
for (int i = 0; i < indexList.size(); i++)
{
int index = Integer.parseInt(indexList.get(i).toString());
if (((R4LibraryClause) clauseList.get(index)).getLanguages() != null)
if (((NativeLibraryClause) clauseList.get(index)).getLanguages() != null)
{
selection.add("" + indexList.get(i));
}
Expand Down Expand Up @@ -2164,20 +2164,20 @@ else if ((expecting & CHAR) > 0)
* @return an array of <tt>LibraryInfo</tt> objects for the
* passed in strings.
**/
private static List<R4LibraryClause> parseLibraryStrings(
private static List<NativeLibraryClause> parseLibraryStrings(
Logger logger, List<String> libStrs)
throws IllegalArgumentException
{
if (libStrs == null)
{
return new ArrayList<R4LibraryClause>(0);
return new ArrayList<NativeLibraryClause>(0);
}

List<R4LibraryClause> libList = new ArrayList(libStrs.size());
List<NativeLibraryClause> libList = new ArrayList(libStrs.size());

for (int i = 0; i < libStrs.size(); i++)
{
R4LibraryClause clause = R4LibraryClause.parse(logger, libStrs.get(i));
NativeLibraryClause clause = NativeLibraryClause.parse(logger, libStrs.get(i));
libList.add(clause);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Map;
import org.osgi.framework.Constants;

public class R4Library
public class NativeLibrary
{
private String m_libraryFile;
private String[] m_osnames;
Expand All @@ -32,7 +32,7 @@ public class R4Library
private String[] m_languages;
private String m_selectionFilter;

public R4Library(
public NativeLibrary(
String libraryFile, String[] osnames, String[] processors, String[] osversions,
String[] languages, String selectionFilter) throws Exception
{
Expand Down
Loading

0 comments on commit 8cc415e

Please sign in to comment.