📄 ozoneservice.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// Copyright (C) 1997-@year@ by Per Nyfelt. All rights reserved.// $Id: OzoneService.java,v 1.3 2003/11/29 16:19:28 per_nyfelt Exp $package org.ozoneDB.embed.jboss;import javax.naming.Context;import javax.naming.InitialContext;import org.jboss.naming.NonSerializableFactory;import org.jboss.system.ServiceMBeanSupport;import org.ozoneDB.LocalDatabase;import org.ozoneDB.OzoneInterface;/** * Starts an Ozone Object server in the JMX context of JBoss. * Ozone is accessed through JNDI as follows: * <p> * <code> <br> * OzoneInterface db = new InitialContext().lookup(OzoneInterface.class.getName()); <br> * Object bla = db.objectForName("bla"); <br> * </code> * </p> * <br> Date: Sep 3, 2002 * @author Per Nyfelt */public class OzoneService extends ServiceMBeanSupport implements OzoneServiceMBean { private LocalDatabase db; private String dbLocation; private Context context; public OzoneService() { try { context = new InitialContext(); } catch (Exception e) { log.error("Failed to create JNDI context" + e); } } public String getDbLocation() { return dbLocation; } public void setDbLocation(String dbLocation) { this.dbLocation = dbLocation; } protected void startService() throws Exception { log.info("Ozone ObjectServer - Starting up..."); // we pin on the jboss directory to dbLocation to get the full path of the database String dbDir = System.getProperty("jboss.server.home.dir") + dbLocation; try { log.info("** Starting Database in " + dbDir + " **"); db = new LocalDatabase(); if (!db.exists(dbDir)) { log.info("\tNo DB found, creating new Database..."); db.create(dbDir); } String debugLevel = null; db.open(dbDir, debugLevel); log.info("** Database ready **"); } catch (Exception e) { throw new RuntimeException("Failed to start database: " + e.getMessage()); } NonSerializableFactory.rebind(context, OzoneInterface.class.getName(), db); } protected void stopService() throws Exception { NonSerializableFactory.unbind(OzoneInterface.class.getName()); db.close(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -