本文整理汇总了Java中gate.util.persistence.PersistenceManager类的典型用法代码示例。如果您正苦于以下问题:Java PersistenceManager类的具体用法?Java PersistenceManager怎么用?Java PersistenceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistenceManager类属于gate.util.persistence包,在下文中一共展示了PersistenceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setIndexer
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* Sets the Indexer to be used for indexing Datastore
*/
@Override
public void setIndexer(Indexer indexer, Map<String,Object> indexParameters)
throws IndexException {
this.indexer = indexer;
this.indexParameters = indexParameters;
this.indexURL = (URL)this.indexParameters.get(Constants.INDEX_LOCATION_URL);
this.indexer.createIndex(this.indexParameters);
// dump the version file
try {
File versionFile = getVersionFile();
OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream(versionFile));
osw.write(versionNumber + Strings.getNl());
String indexDirRelativePath =
PersistenceManager.getRelativePath(storageDir.toURI().toURL(),
indexURL);
osw.write(indexDirRelativePath);
osw.close();
} catch(IOException e) {
throw new IndexException("couldn't write version file: " + e);
}
}
示例2: extractDataFromSource
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* Populates this Persistence with the data that needs to be stored from the
* original source object.
*/
public void extractDataFromSource(Object source)throws PersistenceException{
if(! (source instanceof ScriptableController)){
throw new UnsupportedOperationException(
getClass().getName() + " can only be used for " +
ScriptableController.class.getName() +
" objects!\n" + source.getClass().getName() +
" is not a " + ScriptableController.class.getName());
}
super.extractDataFromSource(source);
ScriptableController sc = (ScriptableController)source;
corpus = PersistenceManager.getPersistentRepresentation(sc.getCorpus());
controlScript = PersistenceManager.getPersistentRepresentation(sc.getControlScript());
}
示例3: GateRESCALProcessing
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public GateRESCALProcessing(String gateAppPath, String baseFolder,
boolean createContentSlice, boolean useStemming) throws GateException, IOException {
matchingData = new WonMatchingData();
this.baseFolder = baseFolder;
this.createContentSlice = createContentSlice;
this.useStemming = useStemming;
// init Gate
logger.info("Initialising Gate");
Gate.init();
// load Gate application
logger.info("Loading Gate application: {}", gateAppPath);
gateApplication = (CorpusController)
PersistenceManager.loadObjectFromFile(new File(gateAppPath));
}
示例4: initializeAnnie
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public void initializeAnnie() throws GateException, MalformedURLException, IOException {
Gate.setGateHome(new File(GATE_HOME));
Gate.setPluginsHome(new File(GATE_PLUGIN_HOME));
Gate.setSiteConfigFile(new File(CONFIG_FILE));
Gate.init();
log("GATE initialised");
// Load ANNIE plugin
File pluginsHome = Gate.getPluginsHome();
File anniePlugin = new File(pluginsHome, "ANNIE");
File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
annieController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
log("ANNIE loaded successfully");
}
示例5: loadApp
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@BeforeClass
public static void loadApp() throws MalformedURLException, IOException, GateException {
if (!Gate.isInitialised()) {
Gate.init();
}
Properties sysProps = System.getProperties();
String appName = sysProps.getProperty("munpex.en.app.name");
munpexApp = (CorpusController) PersistenceManager.loadObjectFromFile(
new File(appName));
}
示例6: main
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* This is testing code used during development.
* TODO: delete it!
*/
public static void main(String[] args){
try {
Gate.init();
MainFrame.getInstance().setVisible(true);
Gate.getCreoleRegister().registerDirectories(new File(".").toURI().toURL());
File session = Gate.getUserSessionFile();
if(session == null) session = new File(System.getProperty("user.home") +
".gate.session");
if(session.exists()) PersistenceManager.loadObjectFromFile(session);
} catch(Exception e) {
e.printStackTrace();
}
}
示例7: initPlugins
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public void initPlugins() {
File annieGapp = new File(Gate.getGateHome(), "recruiterVision.gapp");
try {
corpusController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
} catch (PersistenceException | IOException | ResourceInstantiationException e) {
e.printStackTrace();
}
logger.info("Annie and plugins inited");
}
示例8: init
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public Resource init() throws ResourceInstantiationException {
// mix-in gate.Utils and gate.groovy.GateGroovyMethods
mixinGlobally(gate.Utils.class);
mixinGlobally(GateGroovyMethods.class);
// register the ScriptableController with the persistence mechanism
try {
PersistenceManager.registerPersistentEquivalent(ScriptableController.class,
ScriptableControllerPersistence.class);
}
catch(PersistenceException e) {
throw new ResourceInstantiationException(e);
}
return this;
}
示例9: createObject
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* Creates a new object from the data contained. This new object is supposed
* to be a copy for the original object used as source for data extraction.
*/
public Object createObject()throws PersistenceException,
ResourceInstantiationException{
ScriptableController sc = (ScriptableController)
super.createObject();
sc.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
sc.setControlScript((String)PersistenceManager.getTransientRepresentation(controlScript));
return sc;
}
示例10: initPersistentGateResources
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* Method which init application from GATE application stored on the local drive
*/
private void initPersistentGateResources() {
try {
Corpus corpus = Factory.newCorpus("New Corpus");
corpusController = (CorpusController) PersistenceManager.loadObjectFromFile(new File("application.xgapp"));
corpusController.setCorpus(corpus);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例11: loadApp
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@BeforeClass
public static void loadApp() throws MalformedURLException, IOException, GateException {
if (!Gate.isInitialised()) {
Gate.init();
}
Properties sysProps = System.getProperties();
String appName = sysProps.getProperty("reextraction.app.name");
rhetectorApp = (CorpusController) PersistenceManager.loadObjectFromFile(
new File(appName));
}
示例12: init
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public Resource init() throws ResourceInstantiationException {
//this needs to happen so the right listeners get registered
super.init();
try {
PersistenceManager.registerPersistentEquivalent(
at.ofai.gate.modularpipelines.ParametrizedCorpusController.class,
at.ofai.gate.modularpipelines.ParametrizedCorpusControllerPersistence.class);
} catch(PersistenceException ex) {
throw new ResourceInstantiationException("Could not register persistence",ex);
}
return this;
}
示例13: initAnnie
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
* Initialise the ANNIE system. This creates a "corpus pipeline"
* application that can be used to run sets of documents through
* the extraction system.
*/
public void initAnnie() throws GateException, IOException {
Out.prln("Initialising ANNIE...");
// load the ANNIE application from the saved state in plugins/ANNIE
File pluginsHome = Gate.getPluginsHome();
File anniePlugin = new File(pluginsHome, "ANNIE");
File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
annieController =
(CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
Out.prln("...ANNIE loaded");
}
示例14: actionPerformed
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (pipelineURL == null) {
System.err.println("The URL of the application has not been correctly set and cannot be loaded.");
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
lockGUI(name + " is being loaded...");
try {
long startTime = System.currentTimeMillis();
if (pipelineURL.toURI().getScheme().equals("creole")) {
String[] coordinates = pipelineURL.toURI().getAuthority().split(";");
Plugin plugin = new Plugin.Maven(coordinates[0],coordinates[1],coordinates[2]);
Gate.getCreoleRegister().registerPlugin(plugin);
}
// load LingPipe as an application from a gapp file
Resource controller =
(Resource)PersistenceManager.loadObjectFromUrl(pipelineURL.toURL());
if(!icon.equals(controller.getFeatures().get("gate.gui.icon"))) {
controller.getFeatures().put("gate.gui.icon", icon);
@SuppressWarnings("unchecked")
Enumeration<TreeNode> items =
applicationsRoot.depthFirstEnumeration();
while(items.hasMoreElements()) {
TreeNode n = items.nextElement();
if(n instanceof DefaultMutableTreeNode) {
Object userObject =
((DefaultMutableTreeNode)n).getUserObject();
if(userObject instanceof NameBearerHandle) {
if(((NameBearerHandle)userObject).getTarget().equals(
controller)) {
((NameBearerHandle)((DefaultMutableTreeNode)n)
.getUserObject())
.setIcon((Icon)LoadApplicationAction.this
.getValue(Action.SMALL_ICON));
resourcesTree.invalidate();
break;
}
}
}
}
}
long endTime = System.currentTimeMillis();
statusChanged(name
+ " loaded in "
+ NumberFormat.getInstance().format(
(double)(endTime - startTime) / 1000) + " seconds");
} catch(Exception error) {
String message =
"There was an error when loading the " + name
+ " application.";
error.printStackTrace();
log.error(message, error);
} finally {
unlockGUI();
}
}
};
Thread thread = new Thread(runnable, "LoadApplicationAction");
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
示例15: createObject
import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public Object createObject() throws PersistenceException, ResourceInstantiationException {
initParams = PersistenceManager.getTransientRepresentation(
initParams,containingControllerName,initParamOverrides);
FeatureMap ourParms = (FeatureMap)initParams;
logger.debug("=== Persistence START: "+ourParms);
// NOTE: in order to be able for a parent pipeline config file to override
// the config settings of a sub pipeline, INCLUDING the init time settings,
// we would need to be able to somehow know here at this point what the
// parent pipeline setting is. However, I cannot see any reasonably simple
// mechanism that would allow us to do this, so we need to stick with
// the general strategy of using the global system property for this.
// Unfortunately that strategy will affect all pipelines in the whole VM!
// NOTE2: one possible approach would be to allow the initParams object already to get
// passed to PersistenceManager.loadObjectFromUrl (e.g. as second, optional parameter).
// That would allow the Pipeline PR to set the initParams before loading this object,
// so what we get for configFileUrl would already be the overriden value.
URL theURL = (URL)ourParms.get("configFileUrl");
Config config = Utils.readConfigFile(theURL);
// if we could read the config file, set the parameter override map
// At this point we should have any config from either the config file
// configFileUrl or the file specified by the overriding system property.
if(config != null && config.prInitParms != null) {
if(initParamOverrides == null) {
initParamOverrides = new HashMap<String,Map<String,Object>>();
}
initParamOverrides.putAll(config.prInitParms);
}
// all the rest can be handled by the ConditionalSerialAnalyserControllerPersistence,
// but we should get a ParametrizedCorpusController instance.
// NOTE: This will eventually bubble up to the createObject() method for the Resource
// which in turns Factory.create which in turns calls the new resource's init
// method. However, not everythin will be in place at that point because the
// createObject method for the controller will only deserialize the PRs after
// the resource has been created.
ParametrizedCorpusController obj = (ParametrizedCorpusController)super.createObject();
// here we should not only have the init parameters but the object should actually
// have been created and initialized (our own init method has been called, but
// only with a partly initialized object, which did not yet have the PR list.
// To run any initialization which must happen after we have everything, we
// use our own afterLoadCompleted() method:
logger.debug("=== Persistence END: "+ourParms+" calling afterLoadCompleted");
obj.afterLoadCompleted();
return obj;
}
开发者ID:johann-petrak,项目名称:gateplugin-ModularPipelines,代码行数:49,代码来源:ParametrizedCorpusControllerPersistence.java