use of aQute.libg.glob.Glob in project bnd by bndtools.
the class Analyzer method getJarsFromName.
public List<Jar> getJarsFromName(String name, String from) {
Jar j = super.getJarFromName(name, from);
if (j != null)
return Collections.singletonList(j);
Glob g = new Glob(name);
List<Jar> result = new ArrayList<>();
for (Iterator<Jar> cp = getClasspath().iterator(); cp.hasNext(); ) {
Jar entry = cp.next();
if (entry.getSource() == null)
continue;
if (g.matcher(entry.getSource().getName()).matches()) {
result.add(entry);
}
}
return result;
}
use of aQute.libg.glob.Glob in project bnd by bndtools.
the class bnd method _find.
public void _find(FindOptions options) throws Exception {
List<File> files = new ArrayList<File>();
List<String> args = options._arguments();
if (args.size() == 0) {
Project p = getProject();
if (p == null) {
error("This is not a project directory and you have specified no jar files ...");
return;
}
File output = p.getOutput();
if (output.exists()) {
files.add(output);
}
for (Container c : p.getBuildpath()) {
files.add(c.getFile());
}
} else {
for (String f : args) {
File file = getFile(f);
files.add(file);
}
}
for (File f : files) {
logger.debug("find {}", f);
try (Jar jar = new Jar(f)) {
Manifest m = jar.getManifest();
if (m != null) {
Domain domain = Domain.domain(m);
if (options.exports() != null) {
Parameters ep = domain.getExportPackage();
for (Glob g : options.exports()) {
for (Entry<String, Attrs> exp : ep.entrySet()) {
if (g.matcher(exp.getKey()).matches()) {
String v = exp.getValue().get(VERSION_ATTRIBUTE);
if (v == null)
v = "0";
out.printf(">%s: %s-%s%n", f.getPath(), exp.getKey(), v);
}
}
}
}
if (options.imports() != null) {
Parameters ip = domain.getImportPackage();
for (Glob g : options.imports()) {
for (Entry<String, Attrs> imp : ip.entrySet()) {
if (g.matcher(imp.getKey()).matches()) {
String v = imp.getValue().get(VERSION_ATTRIBUTE);
if (v == null)
v = "0";
out.printf("<%s: %s-%s%n", f.getPath(), imp.getKey(), v);
}
}
}
}
}
}
}
}
use of aQute.libg.glob.Glob in project bnd by bndtools.
the class WorkspaceRepository method list.
public List<String> list(String pattern) throws Exception {
List<String> names = new ArrayList<String>();
Collection<Project> projects = workspace.getAllProjects();
for (Project project : projects) {
for (String bsn : project.getBsns()) {
if (pattern != null) {
Glob glob = new Glob(pattern);
Matcher matcher = glob.matcher(bsn);
if (matcher.matches()) {
if (!names.contains(bsn)) {
names.add(bsn);
}
}
} else {
if (!names.contains(bsn)) {
names.add(bsn);
}
}
}
}
return names;
}
use of aQute.libg.glob.Glob in project bnd by bndtools.
the class BridgeRepository method list.
public List<String> list(String pattern) throws Exception {
List<String> bsns = new ArrayList<>();
if (pattern == null || pattern.equals("*") || pattern.equals("")) {
bsns.addAll(index.keySet());
} else {
String[] split = pattern.split("\\s+");
Glob[] globs = new Glob[split.length];
for (int i = 0; i < split.length; i++) {
globs[i] = new Glob(split[i]);
}
outer: for (String bsn : index.keySet()) {
for (Glob g : globs) {
if (g.matcher(bsn).find()) {
bsns.add(bsn);
continue outer;
}
}
}
}
return bsns;
}
use of aQute.libg.glob.Glob in project bnd by bndtools.
the class ConnectionSettings method createProxyHandler.
/**
* Create Proxy Handler from ProxyDTO
*/
public static ProxyHandler createProxyHandler(final ProxyDTO proxyDTO) {
return new ProxyHandler() {
Glob[] globs;
private ProxySetup proxySetup;
@Override
public ProxySetup forURL(URL url) throws Exception {
switch(proxyDTO.protocol) {
case DIRECT:
break;
case HTTP:
String scheme = url.getProtocol();
if (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https")) {
// ok
} else
return null;
break;
case SOCKS:
break;
default:
break;
}
String host = url.getHost();
if (host != null) {
if (isNonProxyHost(host))
return null;
}
if (proxySetup == null) {
proxySetup = new ProxySetup();
if (proxyDTO.username != null && proxyDTO.password != null)
proxySetup.authentication = new PasswordAuthentication(proxyDTO.username, proxyDTO.password.toCharArray());
SocketAddress socketAddress;
if (proxyDTO.host != null)
socketAddress = new InetSocketAddress(proxyDTO.host, proxyDTO.port);
else
socketAddress = new InetSocketAddress(proxyDTO.port);
proxySetup.proxy = new Proxy(proxyDTO.protocol, socketAddress);
}
return proxySetup;
}
public boolean isNonProxyHost(String host) {
Glob[] globs = getNonProxyHosts(proxyDTO);
for (Glob glob : globs) {
if (glob.matcher(host).matches())
return true;
}
return false;
}
public Glob[] getNonProxyHosts(final ProxyDTO proxyDTO) {
// not synchronized because conflicts only do some double work
if (globs == null) {
if (proxyDTO.nonProxyHosts == null)
globs = new Glob[0];
else {
String[] parts = proxyDTO.nonProxyHosts.split("\\s*\\|\\s*");
globs = new Glob[parts.length];
for (int i = 0; i < parts.length; i++) globs[i] = new Glob(parts[i]);
}
}
return globs;
}
};
}
Aggregations