Hi
I wanted to run the equinox framework from a main method.
this part is pretty easy to do. However when I did this, I had a problem that i had no access to the equinox console.
So my question is this:
How can I run the equinox framework from a main class and have access to the console (by access I mean to send commands and receive the results in Java console).
I have tried to access the console via a socket but when I want to read the results I got stuck at the end of the first results that I get (Since the InputStream.read() is blocking).
Anyone could help me?
_________________________________________________________________________
This is my code:
public static void main(String[] args) {
FrameworkFactory ff = ServiceLoader.load(FrameworkFactory.class).iterator().next();
Map<String, String> configMap = new HashMap<String, String>();
// Turn on the Equinox console on port 6666 (Equinox only)
configMap.put("osgi.console", "6666");
Framework fwk = ff.newFramework(configMap);
try {
fwk.start();
} catch (BundleException e) {
System.err.println("Exc. occured while Starting Framework");
e.printStackTrace();
}
BundleContext context = fwk.getBundleContext();
List<Bundle> installedBundles = new LinkedList<Bundle>();
try {
installedBundles.add(context.installBundle("file:C:\\Users\\Administrator\\Eclipse Workspace\\JAR File\\TestEQ.jar"));
installedBundles.add(context.installBundle("file:C:\\Users\\Administrator\\Eclipse Workspace\\JAR File\\printerBundle.jar"));
} catch (BundleException e) {
e.printStackTrace();
}
int i = 0;
try {
for (Bundle bundle : installedBundles) {
i++;
bundle.start();
}
} catch (BundleException e) {
System.err.println("Exc. occured at level:" + i);
e.printStackTrace();
}
// ______________________Socket Tester___________________________//
try {
Socket socket = new Socket(InetAddress.getByName("0.0.0.0"), 6666);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
System.out.println("[INFO] Connection recieved: " + socket.getInetAddress().getHostName());
while (true) {
String userInput = "";
while ((userInput = stdIn.readLine()) != null) {
out.print(userInput);
int osgiResponse = -1;
while ((osgiResponse = in.read()) != -1) {
System.out.print((char)osgiResponse);
}
System.out.println("OUT OF HELL!");
}
}
} catch (UnknownHostException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}