Subversion Repositories SmartDukaan

Rev

Rev 35236 | Rev 35527 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35236 Rev 35390
Line 25... Line 25...
25
public class Mongo {
25
public class Mongo {
26
 
26
 
27
    private static final Logger LOGGER = LogManager.getLogger(Mongo.class);
27
    private static final Logger LOGGER = LogManager.getLogger(Mongo.class);
28
 
28
 
29
    private static final String CONTENT = "CONTENT";
29
    private static final String CONTENT = "CONTENT";
-
 
30
    private volatile boolean closed = false;
30
    private static final String SITE_CONTENT = "siteContent";
31
    private static final String SITE_CONTENT = "siteContent";
31
    private static final String CATALOG_DB = "Catalog";
32
    private static final String CATALOG_DB = "Catalog";
32
    private static final String MASTER_DATA = "MasterData";
33
    private static final String MASTER_DATA = "MasterData";
33
    private static final String FOFO_DB = "Fofo";
34
    private static final String FOFO_DB = "Fofo";
34
    private static final String FOFO_BRANDS = "brands";
35
    private static final String FOFO_BRANDS = "brands";
Line 325... Line 326...
325
        Gson gs = new Gson();
326
        Gson gs = new Gson();
326
        DBObject dbObject = (DBObject) JSON.parse(gs.toJson(ff));
327
        DBObject dbObject = (DBObject) JSON.parse(gs.toJson(ff));
327
        collection.save(dbObject);
328
        collection.save(dbObject);
328
    }
329
    }
329
 
330
 
-
 
331
    /**
-
 
332
     * Close MongoDB connections to prevent memory leaks on shutdown
-
 
333
     */
-
 
334
    public void close() {
-
 
335
        if (closed) {
-
 
336
            return;
-
 
337
        }
-
 
338
        closed = true;
-
 
339
        LOGGER.info("Closing MongoDB connections...");
-
 
340
        try {
-
 
341
            if (mongoClient != null) {
-
 
342
                mongoClient.close();
-
 
343
                LOGGER.info("Main MongoClient closed");
-
 
344
            }
-
 
345
        } catch (Exception e) {
-
 
346
            LOGGER.error("Error closing mongoClient", e);
-
 
347
        }
-
 
348
        try {
-
 
349
            if (contentMongoClient != null) {
-
 
350
                contentMongoClient.close();
-
 
351
                LOGGER.info("Content MongoClient closed");
-
 
352
            }
-
 
353
        } catch (Exception e) {
-
 
354
            LOGGER.error("Error closing contentMongoClient", e);
-
 
355
        }
-
 
356
    }
-
 
357
 
330
}
358
}