Methods Summary |
---|
private void | createAdminAccount()
GDataAccount adminAccount = GDataAccount.createAdminAccount();
visiteInitialize();
Storage sto = this.getStorage();
try {
sto.getAccount(adminAccount.getName());
} catch (Exception e) {
this.getStorage().storeAccount(adminAccount);
} finally {
visiteDestroy();
}
|
public void | destroy()
this.containerPool.destroy();
this.idGenerator.stopIDGenerator();
this.server.close();
|
public int | getContainerPoolSize()
return this.containerPoolSize;
|
public java.lang.String | getFilePath()
return this.filePath;
|
public java.lang.String | getHost()
return this.host;
|
public java.lang.String | getPassword()
return this.password;
|
public int | getPort()
return this.port;
|
public org.apache.lucene.gdata.storage.Storage | getStorage()
Storage retVal = this.threadLocalStorage.get();
if (retVal != null)
return retVal;
retVal = new DB4oStorage(this.containerPool.aquire(), this);
this.threadLocalStorage.set(retVal);
return retVal;
|
public java.lang.String | getUser()
return this.user;
|
public void | initialize()
if (LOG.isInfoEnabled())
LOG.info("Initialize " + this.toString());
Db4o.configure().objectClass(DB4oEntry.class).objectField("updated")
.indexed(true);
Db4o.configure().objectClass(BaseEntry.class).objectField("id")
.indexed(true);
Db4o.configure().objectClass(BaseFeed.class).objectField("id").indexed(
true);
Db4o.configure().objectClass(GDataAccount.class).objectField("name")
.indexed(true);
Db4o.configure().objectClass(ServerBaseFeed.class).cascadeOnDelete(
false);
Db4o.configure().objectClass(ServerBaseFeed.class)
.maximumActivationDepth(0);
Db4o.configure().objectClass(BaseFeed.class).minimumActivationDepth(1);
Db4o.configure().objectClass(BaseEntry.class)
.minimumActivationDepth(1);
Db4o.configure().objectClass(BaseFeed.class).cascadeOnDelete(true);
Db4o.configure().objectClass(DB4oEntry.class).cascadeOnDelete(true);
Db4o.configure().objectClass(GDataAccount.class).cascadeOnDelete(true);
Db4o.configure().weakReferences(this.weakReferences);
Db4o.configure().optimizeNativeQueries(false);
if (this.runAsServer) {
this.server = Db4o.openServer(this.filePath, this.port);
if(this.server == null)
throw new RuntimeException("Can't create server at confiugred destination -- "+this.filePath);
this.server.grantAccess(this.user, this.password);
} else {
InvocationHandler handler = new ObjectServerDecorator(this.user,
this.password, this.host, this.port);
this.server = (ObjectServer) Proxy.newProxyInstance(this.getClass()
.getClassLoader(), new Class[] { ObjectServer.class },
handler);
}
PoolObjectFactory<ObjectContainer> factory = new ObjectContinerFactory(
this.server);
this.containerPool = new SimpleObjectPool<ObjectContainer>(
this.containerPoolSize, factory);
try {
createAdminAccount();
} catch (StorageException e) {
LOG.error("Can not create admin account -- ",e);
}
|
public boolean | isRunAsServer()
return this.runAsServer;
|
public boolean | isUseWeakReferences()
return this.weakReferences;
|
com.db4o.ObjectContainer | releaseContainer()
return this.server.openClient();
|
public java.lang.String | releaseId()
try{
return this.idGenerator.getUID();
}catch (InterruptedException e) {
throw new StorageException("ID producer has been interrupted",e);
}
|
public void | setContainerPoolSize(int containerPoolSize)
this.containerPoolSize = containerPoolSize < 1 ? 1 : containerPoolSize;
|
public void | setFilePath(java.lang.String filePath)
this.filePath = filePath;
|
public void | setHost(java.lang.String host)
this.host = host;
|
public void | setPassword(java.lang.String password)
this.password = password;
|
public void | setPort(int port)
this.port = port;
|
public void | setRunAsServer(boolean runAsServer)
this.runAsServer = runAsServer;
|
public void | setUseWeakReferences(boolean weakReferences)
this.weakReferences = weakReferences;
|
public void | setUser(java.lang.String user)
this.user = user;
|
public java.lang.String | toString()
StringBuilder builder = new StringBuilder(this.getClass().getName())
.append(" ");
builder.append("host: ").append(this.host).append(" ");
builder.append("port: ").append(this.port).append(" ");
builder.append("pool size: ").append(this.containerPoolSize)
.append(" ");
builder.append("runs as server: ").append(this.runAsServer).append(" ");
builder.append("use weak references: ").append(this.weakReferences)
.append(" ");
builder.append("user: ").append(this.user).append(" ");
builder.append("password length: ").append(
this.password == null ? "no password" : this.password.length())
.append(" ");
return builder.toString();
|
public void | visiteDestroy()
Storage storage = this.threadLocalStorage.get();
if (storage == null) {
LOG.warn("no Storage opened -- threadlocal returned null");
return;
}
this.containerPool.release(((DB4oStorage)storage).getContainer());
this.threadLocalStorage.remove();
if (LOG.isInfoEnabled())
LOG.info("Closed Storage -- request destroyed");
|
public void | visiteInitialize()
if (LOG.isInfoEnabled())
LOG.info("Opened Storage -- request initialized");
Storage storage = this.threadLocalStorage.get();
if (storage != null) {
LOG.warn("Storage already opened");
return;
}
storage = new DB4oStorage(this.containerPool.aquire(), this);
this.threadLocalStorage.set(storage);
|