Java Code Examples for javax.jdo.PersistenceManager#isClosed()

The following examples show how to use javax.jdo.PersistenceManager#isClosed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDOPMRetriever.java    From seldon-server with Apache License 2.0 6 votes vote down vote up
public  Object getPersistenceManager(String client,PersistenceManagerFactory pmf) 
{
	Map<String,PersistenceManager> map = (Map<String,PersistenceManager>)super.get();
	PersistenceManager pm = null;
	if (map != null)
		pm = map.get(client);
	
    if(pm == null || pm.isClosed()) 
    {
        pm = pmf.getPersistenceManager( ); 
        pm.setUserObject(client);
        if (map == null)
        	map = new HashMap<>();
        map.put(client, pm);
        set(map);
    }

    return pm;
}
 
Example 2
Source File: JDOPMRetriever.java    From seldon-server with Apache License 2.0 5 votes vote down vote up
public void cleanup() {
	try
	{
		Map<String,PersistenceManager> map = (Map<String,PersistenceManager>)super.get();
		if (map != null)
    	for(PersistenceManager pm : map.values())
    	{
    		if(pm == null) return;

    		try 
    		{
    			if(!pm.isClosed()) 
           	 	{
    				TransactionPeer.closeReadOnlyTransaction(pm);
    				Transaction ts = pm.currentTransaction();
    				if(ts.isActive()) 
    				{
                   	 	logger.warn("transaction stil active");
                   	 	ts.rollback();
                	}
    				pm.close();
            	}
    			else
    			{
    				logger.warn("pm is closed");
    			}

    		} 
    		catch(Exception ex) 	
    		{
    			logger.warn("exception on cleanup",ex);
    		} 
    	}
	
	}
    finally {
        set(null);
    }

}
 
Example 3
Source File: SentryStore.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
public void rollbackTransaction(PersistenceManager pm) {
  if (pm == null || pm.isClosed()) {
    return;
  }
  Transaction currentTransaction = pm.currentTransaction();
  if (currentTransaction.isActive()) {
    try {
      currentTransaction.rollback();
    } finally {
      pm.close();
    }
  }
}