Search in sources :

Example 11 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class HttpClientProxyTest method assertSocks5Proxy.

@SuppressWarnings("resource")
void assertSocks5Proxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
    Processor p = new Processor();
    p.setProperty("-connectionsettings", "" + false);
    HttpClient hc = new HttpClient();
    ConnectionSettings cs = new ConnectionSettings(p, hc);
    if (socks5Proxy != null) {
        ProxyDTO proxy = new ProxyDTO();
        proxy.active = true;
        proxy.host = "localhost";
        proxy.port = socksProxyPort;
        proxy.protocol = Type.SOCKS;
        if (password != null) {
            proxy.username = "proxyuser";
            proxy.password = password;
        }
        hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
    }
    ServerDTO server = new ServerDTO();
    server.id = httpTestServer.getBaseURI().toString();
    server.verify = false;
    server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
    cs.add(server);
    URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
    TaggedData tag = hc.connectTagged(url);
    assertNotNull(tag);
    assertEquals("ABCDEFGH", tag.getTag());
    String s = IO.collect(tag.getInputStream());
    assertNotNull(s);
    assertTrue(s.trim().startsWith("{"));
// assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
Also used : ProxyDTO(aQute.bnd.connection.settings.ProxyDTO) ServerDTO(aQute.bnd.connection.settings.ServerDTO) Processor(aQute.bnd.osgi.Processor) HttpClient(aQute.bnd.http.HttpClient) TaggedData(aQute.bnd.service.url.TaggedData) ConnectionSettings(aQute.bnd.connection.settings.ConnectionSettings) URL(java.net.URL)

Example 12 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class bnd method _defaults.

/**
	 * Show all the defaults in bnd
	 */
public void _defaults(Options o) {
    Processor defaults = Workspace.getDefaults();
    out.println(Strings.join("\n", defaults.getProperties().entrySet()));
}
Also used : Processor(aQute.bnd.osgi.Processor)

Example 13 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class HttpClientProxyTest method assertHttpProxy.

@SuppressWarnings("resource")
void assertHttpProxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
    Processor p = new Processor();
    p.setProperty("-connectionsettings", "" + false);
    HttpClient hc = new HttpClient();
    ConnectionSettings cs = new ConnectionSettings(p, hc);
    if (httpProxy != null) {
        ProxyDTO proxy = new ProxyDTO();
        proxy.active = true;
        proxy.host = "localhost";
        proxy.port = httpProxyPort;
        proxy.protocol = Type.HTTP;
        if (password != null) {
            proxy.username = "proxyuser";
            proxy.password = password;
        }
        hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
    }
    ServerDTO server = new ServerDTO();
    server.id = httpTestServer.getBaseURI().toString();
    server.verify = false;
    server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
    cs.add(server);
    URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
    TaggedData tag = hc.connectTagged(url);
    assertNotNull(tag);
    if (tag.getState() != State.OTHER)
        assertEquals("ABCDEFGH", tag.getTag());
    String s = IO.collect(tag.getInputStream());
    assertNotNull(s);
    assertTrue(s.trim().startsWith("{"));
    assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
Also used : ProxyDTO(aQute.bnd.connection.settings.ProxyDTO) ServerDTO(aQute.bnd.connection.settings.ServerDTO) Processor(aQute.bnd.osgi.Processor) HttpClient(aQute.bnd.http.HttpClient) TaggedData(aQute.bnd.service.url.TaggedData) ConnectionSettings(aQute.bnd.connection.settings.ConnectionSettings) URL(java.net.URL)

Example 14 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class Workspace method getDefaults.

public static synchronized Processor getDefaults() {
    if (defaults != null)
        return defaults;
    UTF8Properties props = new UTF8Properties();
    try (InputStream propStream = Workspace.class.getResourceAsStream("defaults.bnd")) {
        if (propStream != null) {
            props.load(propStream);
        } else {
            System.err.println("Cannot load defaults");
        }
    } catch (IOException e) {
        throw new IllegalArgumentException("Unable to load bnd defaults.", e);
    }
    defaults = new Processor(props, false);
    return defaults;
}
Also used : Processor(aQute.bnd.osgi.Processor) JarInputStream(java.util.jar.JarInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) UTF8Properties(aQute.lib.utf8properties.UTF8Properties)

Example 15 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class BndrunResolveContext method init.

/**
	 * Initializes the resolver. Here we will load all the information from the
	 * model.
	 */
@Override
public synchronized void init() {
    if (initialized)
        return;
    initialized = true;
    try {
        if (getLevel() <= 0) {
            Integer level = Converter.cnv(Integer.class, properties.getProperty("-resolvedebug", "0"));
            if (level != null)
                setLevel(level);
        }
        loadPreferences();
        Processor augments = loadRepositories();
        constructBlacklist(augments);
        Map<String, Set<String>> effectiveSet = loadEffectiveSet();
        if (effectiveSet != null)
            addEffectiveSet(effectiveSet);
        //
        // Create a resource from the -runrequire that contains
        // all the requirement
        //
        setInputResource(constructInputRequirements());
        //
        // We gradually build up the system resource that contains
        // the system packages, the EE, etc.
        //
        ResourceBuilder system = new ResourceBuilder();
        //
        // Let's identify the system resource to make it look less
        // ugly
        //
        //
        // If we have a distro, we do not load the environment
        // settings
        //
        String distro = properties.mergeProperties(Constants.DISTRO);
        if (distro != null && !distro.trim().isEmpty()) {
            loadPath(system, distro, Constants.DISTRO);
            loadProvidedCapabilities(system);
        } else {
            //
            // Load the EE's and packages that belong to it.
            //
            EE tmp = EE.parse(properties.getProperty(Constants.RUNEE));
            EE ee = (tmp != null) ? tmp : EE.JavaSE_1_6;
            system.addAllExecutionEnvironments(ee);
            //
            // We make the system packages as coming from the system
            // resource
            //
            Parameters systemPackages = new Parameters(properties.mergeProperties(Constants.RUNSYSTEMPACKAGES), project);
            system.addExportPackages(systemPackages);
            //
            // We make the system capabilities as coming from the system
            // resource
            //
            Parameters systemCapabilities = new Parameters(properties.mergeProperties(Constants.RUNSYSTEMCAPABILITIES), project);
            system.addProvideCapabilities(systemCapabilities);
            loadProvidedCapabilities(system);
            //
            // Load the frameworks capabilities
            //
            loadFramework(system);
            //
            // Analyze the path and add all exported packages and provided
            // capabilities
            // to the system resource
            //
            String runpath = properties.mergeProperties(Constants.RUNPATH);
            if (runpath != null && !runpath.trim().isEmpty())
                loadPath(system, runpath, Constants.RUNPATH);
        }
        //
        // We've not gathered all the capabilities of the system
        // so we can create the resource and set it as the system resource
        //
        //
        // TODO Add osgi.wiring.bundle + osgi.wiring.host
        // filed a bug about using the impl version for the system
        // capabilities
        //
        List<Capability> frameworkPackages = system.findCapabilities(PackageNamespace.PACKAGE_NAMESPACE, "(" + PackageNamespace.PACKAGE_NAMESPACE + "=org.osgi.framework)");
        if (!frameworkPackages.isEmpty()) {
            Capability c = frameworkPackages.get(0);
            Version version = (Version) c.getAttributes().get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            CapReqBuilder crb = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE);
            crb.addAttribute(IdentityNamespace.IDENTITY_NAMESPACE, "system.bundle");
            crb.addAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
            system.addCapability(crb);
        }
        setSystemResource(system.build());
    } catch (Exception e) {
        log.log(LogService.LOG_ERROR, e.getMessage(), e);
        throw new RuntimeException(e);
    }
    super.init();
}
Also used : EE(aQute.bnd.build.model.EE) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Processor(aQute.bnd.osgi.Processor) Set(java.util.Set) HashSet(java.util.HashSet) Parameters(aQute.bnd.header.Parameters) Capability(org.osgi.resource.Capability) Version(org.osgi.framework.Version)

Aggregations

Processor (aQute.bnd.osgi.Processor)185 HashMap (java.util.HashMap)43 File (java.io.File)37 Macro (aQute.bnd.osgi.Macro)29 Workspace (aQute.bnd.build.Workspace)27 Jar (aQute.bnd.osgi.Jar)17 HttpClient (aQute.bnd.http.HttpClient)14 Baseline (aQute.bnd.differ.Baseline)12 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)12 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)10 IOException (java.io.IOException)10 Resource (org.osgi.resource.Resource)10 Info (aQute.bnd.differ.Baseline.Info)8 Version (aQute.bnd.version.Version)8 ArrayList (java.util.ArrayList)8 List (java.util.List)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Collection (java.util.Collection)6 Properties (java.util.Properties)6 Parameters (aQute.bnd.header.Parameters)5