Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » StateObjectFactory's readState returns null state when the state is from Eclipse 3.3m5
StateObjectFactory's readState returns null state when the state is from Eclipse 3.3m5 [message #84827] Thu, 22 March 2007 16:48 Go to next message
Aaron Cohen is currently offline Aaron CohenFriend
Messages: 21
Registered: July 2009
Junior Member
I created an application to read information about the bundles in
Eclipse. The application was created in Eclipse 3.2.1 and works fine
against Eclipse 3.2.1. However, it fails against Eclipse 3.3M5. The
readState Method returns null. Is there something special I have to do
for Eclipse 3.3?


Sample Code:
package sample_state_reader;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;

/**
* This class controls all aspects of the application's execution
*/
public class Application implements IPlatformRunnable {

/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Obj ect)
*/
public Object run(Object args) throws Exception {
String path = ((String [])args)[0];
System.out.println("Searching: "+path);
File area = new File(path.trim());
File newFile = new File(System.getProperty("java.io.tmpdir")+".state");
copy(area,newFile);
newFile = new File(System.getProperty("java.io.tmpdir")+".lazy");
copy(new File(area.getAbsolutePath().replace(".state", ".lazy")),newFile);
StateObjectFactory aStateObjectfactory =
StateObjectFactory.defaultFactory;
State state = aStateObjectfactory.readState(newFile.getParentFile());
if (state==null){
System.out.println("No Bundles Found");
}
else {
for (BundleDescription bundle:state.getBundles()){
System.out.println("Found Bundle: "+bundle.getName());
}
}
return IPlatformRunnable.EXIT_OK;
}
private static void copy(File source, File destination) {
FileChannel sourceChannel = null;
FileChannel destinationChannel = null;
try {
sourceChannel = (new FileInputStream(source)).getChannel();
destinationChannel = (new FileOutputStream(destination))
.getChannel();
sourceChannel.transferTo(0L, sourceChannel.size(),
destinationChannel);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (sourceChannel != null)
try {
sourceChannel.close();
} catch (Exception exception1) {
}
if (destinationChannel != null)
try {
destinationChannel.close();
} catch (Exception exception2) {
}
}
return;
}
}


Thanks!
Re: StateObjectFactory's readState returns null state when the state is from Eclipse 3.3m5 [message #87368 is a reply to message #84827] Wed, 02 May 2007 19:19 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
This application works for me when run on a 3.3 platform against a 3.3
configuration. Are you running the application on the 3.2.1 platform
but against a 3.3 configuration. If that is the case then the
explanation is that the format of the state cache has changed from 3.2
to 3.3. The StateReader can only read one version of the state cache.
If you are running your application on a 3.3 platform then you will only
be able to read 3.3 state caches.

Hope that helps

Tom.
Previous Topic:hibernate
Next Topic:org.eclipse.ui.workbench.texteditor.rulerColumns Extension Point
Goto Forum:
  


Current Time: Fri Apr 26 03:41:50 GMT 2024

Powered by FUDForum. Page generated in 0.02375 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top