本文整理汇总了Java中lotus.domino.Database.recycle方法的典型用法代码示例。如果您正苦于以下问题:Java Database.recycle方法的具体用法?Java Database.recycle怎么用?Java Database.recycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lotus.domino.Database
的用法示例。
在下文中一共展示了Database.recycle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLatestMessage
import lotus.domino.Database; //导入方法依赖的package包/类
@Override
public Response getLatestMessage() throws NotesException {
if(this.hasWebSocketConnection()){
throw new RuntimeException("This RESTful API can only be used when no websocket connection is open.");
}
SocketMessage msg = null;
Database db = XSPUtils.session().getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_MESSAGES_BY_USER);
ViewEntry entry = view.getEntryByKey(XSPUtils.session().getEffectiveUserName(),true);
if(entry!=null){
Document doc = entry.getDocument();
if(doc.isValid()){
msg = msgFactory.buildMessage(entry.getDocument());
//mark as sent.
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
doc.save();
}
}
//cleanup db should cleanup view, entry, and doc.
db.recycle();
return this.buildResponse(msg);
}
示例2: getSampleDataViewsDb
import lotus.domino.Database; //导入方法依赖的package包/类
public synchronized NotesDatabase getSampleDataViewsDb() throws NotesException {
Session session = getSession();
NotesDatabase db;
try {
db = new NotesDatabase(session, "", DBPATH_SAMPLEDATA_VIEWS_NSF);
return db;
}
catch (NotesError e) {
if (e.getId() != 259) { // file does not exist
throw e;
}
}
System.out.println("Looks like our sample database "+DBPATH_SAMPLEDATA_VIEWS_NSF+" to test private views does not exist. We will now (re)create it.");
Database dbSampleDataLegacy = session.getDatabase("", DBPATH_SAMPLEDATA_NSF, true);
Database dbSampleDataViewsLegacy = dbSampleDataLegacy.createFromTemplate("", DBPATH_SAMPLEDATA_VIEWS_NSF, true);
createSampleDbDirProfile(dbSampleDataViewsLegacy);
dbSampleDataLegacy.recycle();
dbSampleDataViewsLegacy.recycle();
db = new NotesDatabase(session, "", DBPATH_SAMPLEDATA_VIEWS_NSF);
db.setTitle("Domino JNA testcase views");
return db;
}
示例3: getMessages
import lotus.domino.Database; //导入方法依赖的package包/类
@Override
public Response getMessages() throws NotesException {
if(this.hasWebSocketConnection()){
throw new RuntimeException("This RESTful API can only be used when no websocket connection is open.");
}
Database db = XSPUtils.session().getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_MESSAGES_BY_USER);
ViewEntryCollection col = view.getAllEntriesByKey(XSPUtils.session().getEffectiveUserName(),true);
List<SocketMessage> list = msgFactory.buildMessages(col);
//mark the collection as sent
col.stampAll(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
//cleanup db should cleanup view, and col
db.recycle();
return this.buildResponse(list);
}
示例4: stampDocuments
import lotus.domino.Database; //导入方法依赖的package包/类
/**
* Stamp documents.
*
* @param search the search
* @param field the field
* @param value the value
*/
public void stampDocuments(String search, String field, Object value){
Session session = this.openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
DocumentCollection col = db.search(search);
if(col!=null && col.getCount() > 0){
col.stampAll(field, value);
col.recycle();
}
//cleanup
db.recycle();
} catch (NotesException e) {
if(!e.text.contains("No documents were categorized")){
LOG.log(Level.SEVERE,null,e);
}
}finally{
closeSession(session);
}
}
示例5: removeDocuments
import lotus.domino.Database; //导入方法依赖的package包/类
/**
* Removes the documents.
*
* @param search the search
*/
public void removeDocuments(String search){
Session session = openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
DocumentCollection col = db.search(search);
if(col!=null && col.getCount() > 0){
col.removeAll(true);
col.recycle();
}
//cleanup
db.recycle();
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
closeSession(session);
}
}
示例6: createLocalDatabaseReplica
import lotus.domino.Database; //导入方法依赖的package包/类
public static String createLocalDatabaseReplica(Database db, String destDbName) throws Throwable {
Database newDb = null;
String newDbPath = null;
try {
// Make a replica of the database
newDb = db.createReplica(null, destDbName);
newDbPath = newDb.getFilePath();
} finally {
if (newDb != null) {
try {
// Ensure db is flushed to disk
newDb.recycle();
// Add a pause for safety, just in case another thread handles the flush
Thread.sleep(1000);
} catch (NotesException e) {
if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
BluemixLogger.BLUEMIX_LOGGER.errorp(null, "createLocalDatabaseReplica", e, "Failed to recycle newDb"); // $NON-NLS-1$ $NLE-BluemixUtil.FailedtorecyclenewDb.1-2$
}
}
}
}
return newDbPath;
}
示例7: getSessionAddressBooks
import lotus.domino.Database; //导入方法依赖的package包/类
private static NABDb[] getSessionAddressBooks(Session session) throws NotesException {
if(session!=null) { // Unit tests
ArrayList<NABDb> nabs = new ArrayList<NABDb>();
Vector<?> vc = session.getAddressBooks();
if(vc!=null) {
for(int i=0; i<vc.size(); i++) {
Database db = (Database)vc.get(i);
try {
db.open();
try {
NABDb nab = new NABDb(db);
nabs.add(nab);
} finally {
db.recycle();
}
} catch(NotesException ex) {
// Opening the database can fail if the user doesn't sufficient
// rights. In this vase, we simply ignore this NAB and continue
// with the next one.
}
}
}
return nabs.toArray(new NABDb[nabs.size()]);
}
return null;
}
示例8: isReader
import lotus.domino.Database; //导入方法依赖的package包/类
/**
* Checks if is reader.
*
* @param user the user
* @return true, if is reader
*/
private boolean isReader(IUser user){
boolean b = true;
//make sure the user has access to the database referenced in the URI.
Session session = SessionFactory.openSessionDefaultToTrusted(cfg.getUsername(),cfg.getPassword());
try{
if(user.getUri().toLowerCase().contains(StringCache.DOT_NSF)){
Database target = this.db(session, new RoutingPath(user.getUri()));
int level = -1;
if(user.isAnonymous()){
level = target.queryAccess(StringCache.ANONYMOUS);
}else{
level= target.queryAccess(user.getUserId());
}
LOG.log(Level.INFO,"ACL level is " + level + " for user " + user.getUserId() + " in database " + target.getFilePath());
if(level<ACL.LEVEL_READER){
LOG.log(Level.SEVERE, "User " + user.getUserId() + " does not have permission to access " + target.getFilePath());
b = false;
}
target.recycle();
}
}catch(NotesException n){
LOG.log(Level.SEVERE,null , n);
}finally{
SessionFactory.closeSession(session);
}
return b;
}
示例9: createLocalDatabaseCopy
import lotus.domino.Database; //导入方法依赖的package包/类
public static String createLocalDatabaseCopy(Database db, String destDbName) throws Throwable {
Database newDb = null;
String newDbPath = null;
try {
// Make a copy of the database
newDb = db.createCopy(null, destDbName);
newDbPath = newDb.getFilePath();
// Copy all the docs
DocumentCollection col = db.getAllDocuments();
Document doc = col.getFirstDocument();
while (doc != null) {
doc.copyToDatabase(newDb);
doc = col.getNextDocument();
}
// Copy the profile docs
col = db.getProfileDocCollection(null);
doc = col.getFirstDocument();
while (doc != null) {
doc.copyToDatabase(newDb);
doc = col.getNextDocument();
}
} finally {
if (newDb != null) {
try {
// Ensure db is flushed to disk
newDb.recycle();
// Add a pause for safety, just in case another thread handles the flush
Thread.sleep(1000);
} catch (NotesException e) {
if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
BluemixLogger.BLUEMIX_LOGGER.errorp(null, "createLocalDatabaseCopy", e, "Failed to recycle newDb"); // $NON-NLS-1$ $NLE-BluemixUtil.FailedtorecyclenewDb-2$
}
}
}
}
return newDbPath;
}
示例10: run
import lotus.domino.Database; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
//if the message has already been persisted don't process it again.
if(!msg.isPersisted()){
Session session = this.openSession();
try {
//mark object as persisted so we don't keep persisting.
msg.setPersisted(true);
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
Document doc = db.createDocument();
doc.replaceItemValue("Form", "fmSocketMessage");
doc.replaceItemValue("text", msg.getText());
doc.replaceItemValue("to", msg.getTo());
doc.replaceItemValue("from", msg.getFrom());
doc.replaceItemValue("event", StringCache.EMPTY);
doc.replaceItemValue("durable", String.valueOf(msg.isDurable()));
doc.replaceItemValue("persisted", String.valueOf(msg.isPersisted()));
this.attach(doc, msg);
db.recycle();
doc.recycle();
} catch (NotesException e) {
LOG.log(Level.SEVERE,null, e);
}finally{
this.closeSession(session);
}
}
}
示例11: checkIfExists
import lotus.domino.Database; //导入方法依赖的package包/类
private IStatus checkIfExists() {
IStatus status = Status.OK_STATUS;
final Status[] arrayOfStatus = new Status[1];
Runnable runnable = new Runnable() {
@SuppressWarnings("unused")
public void run() {
Session session = null;
Database database = null;
try {
session = NotesFactory.createSession();
database = session.getDatabase(CreateNSFJob.this.serverName, CreateNSFJob.this.nsfName, false);
if (database != null) {
CreateNSFJob.this.alreadyExists = true;
}
} catch (NotesException e) {
String msg = StringUtil.format("NSF creation failed for {0} [server:{1}]",
new Object[] { CreateNSFJob.this.nsfName, CreateNSFJob.this.serverName });
arrayOfStatus[0] = new Status(4, "com.ibm.designer.domino", CommandLineJobManager.STATUSCODE_ERROR,
msg, e);
if (database != null) {
try {
database.recycle();
} catch (Exception localException1) {
}
}
if (session != null) {
try {
session.recycle();
} catch (Exception localException2) {
}
}
} finally {
if (database != null) {
try {
database.recycle();
} catch (Exception localException3) {
}
}
if (session != null) {
try {
session.recycle();
} catch (Exception localException4) {
}
}
}
}
};
try {
NotesPlatform.getInstance().syncExec(runnable);
} catch (Throwable localThrowable) {
String str = StringUtil.format("NSF existance check failed for {0} [server:{1}]",
new Object[] { this.nsfName, this.serverName });
arrayOfStatus[0] = new Status(4, "com.ibm.designer.domino", CommandLineJobManager.STATUSCODE_ERROR, str,
localThrowable);
}
if ((status.isOK()) && (arrayOfStatus[0] != null)) {
status = arrayOfStatus[0];
}
return status;
}