Java Code Examples for aQute.bnd.osgi.Analyzer#setProperty()

The following examples show how to use aQute.bnd.osgi.Analyzer#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setAnalyzerProperties(Analyzer analyzer) throws IOException {
    for (Map.Entry<String, Object> attribute : getAttributes().entrySet()) {
        String key = attribute.getKey();
        if (!"Manifest-Version".equals(key)) {
            analyzer.setProperty(key, attribute.getValue().toString());
        }
    }


    Map<String, List<String>> instructions = getInstructions();
    Set<String> instructionNames = instructions.keySet();
    if (!instructionNames.contains(Analyzer.IMPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.IMPORT_PACKAGE,
                "*, !org.apache.ant.*, !org.junit.*, !org.jmock.*, !org.easymock.*, !org.mockito.*");
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_VERSION)){
        analyzer.setProperty(Analyzer.BUNDLE_VERSION, getVersion());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_NAME)){
        analyzer.setProperty(Analyzer.BUNDLE_NAME, getName());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_SYMBOLICNAME)){
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, getSymbolicName());
    }
    if (!instructionNames.contains(Analyzer.EXPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + getVersion());
    }
    for (String instructionName : instructionNames) {
        String list = createPropertyStringFromList(instructionValue(instructionName));
        if (list != null && list.length() > 0) {
            analyzer.setProperty(instructionName, list);
        }
    }

    analyzer.setJar(getClassesDir());

    analyzer.setClasspath(getClasspath().getFiles().toArray(new File[getClasspath().getFiles().size()]));
}
 
Example 2
Source File: DefaultOsgiManifest.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setAnalyzerProperties(Analyzer analyzer) throws IOException {
    for (Map.Entry<String, Object> attribute : getAttributes().entrySet()) {
        String key = attribute.getKey();
        if (!"Manifest-Version".equals(key)) {
            analyzer.setProperty(key, attribute.getValue().toString());
        }
    }


    Map<String, List<String>> instructions = getInstructions();
    Set<String> instructionNames = instructions.keySet();
    if (!instructionNames.contains(Analyzer.IMPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.IMPORT_PACKAGE,
                "*, !org.apache.ant.*, !org.junit.*, !org.jmock.*, !org.easymock.*, !org.mockito.*");
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_VERSION)){
        analyzer.setProperty(Analyzer.BUNDLE_VERSION, getVersion());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_NAME)){
        analyzer.setProperty(Analyzer.BUNDLE_NAME, getName());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_SYMBOLICNAME)){
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, getSymbolicName());
    }
    if (!instructionNames.contains(Analyzer.EXPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + getVersion());
    }
    for (String instructionName : instructionNames) {
        String list = createPropertyStringFromList(instructionValue(instructionName));
        if (list != null && list.length() > 0) {
            analyzer.setProperty(instructionName, list);
        }
    }

    analyzer.setJar(getClassesDir());

    analyzer.setClasspath(getClasspath().getFiles().toArray(new File[getClasspath().getFiles().size()]));
}
 
Example 3
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setAnalyzerProperties(Analyzer analyzer) throws IOException {
    for (Map.Entry<String, Object> attribute : getAttributes().entrySet()) {
        String key = attribute.getKey();
        if (!"Manifest-Version".equals(key)) {
            analyzer.setProperty(key, attribute.getValue().toString());
        }
    }


    Map<String, List<String>> instructions = getInstructions();
    Set<String> instructionNames = instructions.keySet();
    if (!instructionNames.contains(Analyzer.IMPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.IMPORT_PACKAGE,
                "*, !org.apache.ant.*, !org.junit.*, !org.jmock.*, !org.easymock.*, !org.mockito.*");
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_VERSION)){
        analyzer.setProperty(Analyzer.BUNDLE_VERSION, getVersion());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_NAME)){
        analyzer.setProperty(Analyzer.BUNDLE_NAME, getName());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_SYMBOLICNAME)){
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, getSymbolicName());
    }
    if (!instructionNames.contains(Analyzer.EXPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + getVersion());
    }
    for (String instructionName : instructionNames) {
        String list = createPropertyStringFromList(instructionValue(instructionName));
        if (list != null && list.length() > 0) {
            analyzer.setProperty(instructionName, list);
        }
    }

    analyzer.setJar(getClassesDir());

    analyzer.setClasspath(getClasspath().getFiles().toArray(new File[getClasspath().getFiles().size()]));
}
 
Example 4
Source File: DefaultOsgiManifest.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setAnalyzerProperties(Analyzer analyzer) throws IOException {
    for (Map.Entry<String, Object> attribute : getAttributes().entrySet()) {
        String key = attribute.getKey();
        if (!"Manifest-Version".equals(key)) {
            analyzer.setProperty(key, attribute.getValue().toString());
        }
    }


    Map<String, List<String>> instructions = getInstructions();
    Set<String> instructionNames = instructions.keySet();
    if (!instructionNames.contains(Analyzer.IMPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.IMPORT_PACKAGE,
                "*, !org.apache.ant.*, !org.junit.*, !org.jmock.*, !org.easymock.*, !org.mockito.*");
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_VERSION)){
        analyzer.setProperty(Analyzer.BUNDLE_VERSION, getVersion());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_NAME)){
        analyzer.setProperty(Analyzer.BUNDLE_NAME, getName());
    }
    if(!instructionNames.contains(Analyzer.BUNDLE_SYMBOLICNAME)){
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, getSymbolicName());
    }
    if (!instructionNames.contains(Analyzer.EXPORT_PACKAGE)) {
        analyzer.setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + getVersion());
    }
    for (String instructionName : instructionNames) {
        String list = createPropertyStringFromList(instructionValue(instructionName));
        if (list != null && list.length() > 0) {
            analyzer.setProperty(instructionName, list);
        }
    }

    analyzer.setJar(getClassesDir());

    analyzer.setClasspath(getClasspath().getFiles().toArray(new File[getClasspath().getFiles().size()]));
}
 
Example 5
Source File: RouteDedicatedJobManager.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
    Analyzer analyzer = super.createAnalyzer(libResource, processItem);
    if (bundleName != null && bundleName.length() > 0) {
        analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
    }
    if (bundleSymbolicName != null && bundleSymbolicName.length() > 0) {
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
    }
    return analyzer;
}
 
Example 6
Source File: AdaptedJobJavaScriptOSGIForESBManager.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
    Analyzer analyzer = super.createAnalyzer(libResource, processItem);
    if (bundleName != null && bundleName.length() > 0) {
        analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
    }
    if (bundleSymbolicName != null && bundleSymbolicName.length() > 0) {
        analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
    }
    return analyzer;
}
 
Example 7
Source File: RouteJavaScriptOSGIForESBManager.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected void addOsgiDependencies(Analyzer analyzer, ExportFileResource libResource, ProcessItem processItem)
        throws IOException {

    final DependenciesResolver resolver = new DependenciesResolver(processItem);

    // add manifest items
    analyzer.setProperty(Analyzer.REQUIRE_BUNDLE, resolver.getManifestRequireBundle(MANIFEST_ITEM_SEPARATOR));
    StringBuilder manifestImportPackage = new StringBuilder();
    if (subjobImportPackages != null && subjobImportPackages.containsKey(processItem.getProperty().getId())) {
        // Add subjob import packages
        manifestImportPackage.append(subjobImportPackages.get(processItem.getProperty().getId()));
        manifestImportPackage.append(MANIFEST_ITEM_SEPARATOR);
    }
    manifestImportPackage
            .append(resolver.getManifestImportPackage(MANIFEST_ITEM_SEPARATOR))
            .append(",*;resolution:=optional"); //$NON-NLS-1$

    analyzer.setProperty(Analyzer.IMPORT_PACKAGE, manifestImportPackage.toString());
    analyzer.setProperty(Analyzer.EXPORT_PACKAGE, resolver.getManifestExportPackage(MANIFEST_ITEM_SEPARATOR));

    if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        IRunProcessService processService = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
        if (talendProcessJavaProject != null) {
            final IPath libPath = talendProcessJavaProject.getLibFolder().getLocation();
            // process external libs
            final List<URL> list = new ArrayList<URL>();
            for (String s : resolver
                    .getManifestBundleClasspath(MANIFEST_ITEM_SEPARATOR)
                    .split(Character.toString(MANIFEST_ITEM_SEPARATOR))) {
                if (!s.isEmpty()) {
                    list.add(libPath.append(s).toFile().toURI().toURL());
                }
            }
            libResource.addResources(list);
        }
    }
}
 
Example 8
Source File: OSGiWrapper.java    From onos with Apache License 2.0 5 votes vote down vote up
private void setProperties(Analyzer analyzer) {
    analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
    analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
    analyzer.setProperty(Analyzer.BUNDLE_VERSION, bundleVersion.replace('-', '.'));

    analyzer.setProperty(Analyzer.BUNDLE_DESCRIPTION, bundleDescription);
    analyzer.setProperty(Analyzer.BUNDLE_LICENSE, bundleLicense);

    //TODO consider using stricter version policy
    //analyzer.setProperty("-provider-policy", "${range;[===,==+)}");
    //analyzer.setProperty("-consumer-policy", "${range;[===,==+)}");

    analyzer.setProperty(Analyzer.DYNAMICIMPORT_PACKAGE, dynamicimportPackages);
    analyzer.setProperty(Analyzer.DSANNOTATIONS_OPTIONS, "inherit");

    // TODO include version in export, but not in import
    analyzer.setProperty(Analyzer.EXPORT_PACKAGE, exportPackages);

    // TODO we may need INCLUDE_RESOURCE, or that might be done by Buck
    if (includeResources != null) {
        analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, includeResources);
    }

    // There are no good defaults so make sure you set the Import-Package
    analyzer.setProperty(Analyzer.IMPORT_PACKAGE, importPackages);

    if (isWab()) {
        analyzer.setProperty(Analyzer.WAB, webXmlRoot);
        analyzer.setProperty("Web-ContextPath", webContext);
        analyzer.setProperty(Analyzer.IMPORT_PACKAGE, importPackages +
                ",org.glassfish.jersey.servlet,org.jvnet.mimepull\n");
    }
    analyzer.setProperty("Karaf-Commands", karafCommands);

    analyzer.setProperty(Analyzer.FRAGMENT_HOST, fragmentHost);
}