All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.lib.json.FileHandler Maven / Gradle / Ivy

Go to download

A main program (executable JAR) that will listen to port 29998. At first, it can only answer that it is an Envoy (a limited agent). The only function it supports is installing a -runpath. It will then create a framework + agent and transfer the connection to the just installed agent who will then install the bundles. This JAR is a main command for JPM called bndremote. In JPM, it will start up with debug enabled. This JAR does some highly complicated class loading wizardy to ensure that it does not enforce any constraints on the -runpath.

The newest version!
package aQute.lib.json;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.util.Map;

import aQute.lib.base64.Base64;
import aQute.lib.io.IO;

public class FileHandler extends Handler {

	@Override
	public void encode(Encoder app, Object object, Map visited) throws IOException, Exception {
		File f = (File) object;
		if (!f.isFile())
			throw new RuntimeException("Encoding a file requires the file to exist and to be a normal file " + f);

		try (InputStream in = IO.stream(f)) {
			app.append('"');
			Base64.encode(in, app);
			app.append('"');
		}
	}

	@Override
	public Object decode(Decoder dec, String s) throws Exception {
		File tmp = File.createTempFile("json", ".bin");
		try (OutputStream fout = IO.outputStream(tmp)) {
			Base64.decode(new StringReader(s), fout);
		}
		return tmp;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy