@Test public void testExecuteWithPmaSessionException() throws ExecutionException { when(m_adapterManager.getAdapterContext(any())).thenReturn(null); try { m_pmaRegistry.executeWithPmaSession("device1", session -> "response"); } catch (RuntimeException e) { assertEquals("Could not get session to Pma device1", e.getMessage()); } }
@Override public <RT> RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate) throws IllegalArgumentException, IllegalStateException, ExecutionException { PmaSession pmaSession = getPmaSession(deviceName); try { return sessionTemplate.execute(pmaSession); } finally { if (pmaSession != null) { m_pmaSessionPool.returnObject(deviceName, pmaSession); } } }
PmaRegistryImpl implements PmaRegistry { @Override public <RT> RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate) throws IllegalArgumentException, IllegalStateException, ExecutionException { PmaSession pmaSession = getPmaSession(deviceName); try { return sessionTemplate.execute(pmaSession); } finally { if (pmaSession != null) { m_pmaSessionPool.returnObject(deviceName, pmaSession); } } } }
PmaRegistryImpl implements PmaRegistry { @Override public <RT> RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate) throws IllegalArgumentException, IllegalStateException, ExecutionException { PmaSession pmaSession = getPmaSession(deviceName); try { return sessionTemplate.execute(pmaSession); } finally { if (pmaSession != null) { m_pmaSessionPool.returnObject(deviceName, pmaSession); } } } PmaRegistryImpl(DeviceManager deviceManager,
                           PmaSessionFactory factory); }
PmaRegistryImpl implements PmaRegistry { @Override public <RT> RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate) throws IllegalArgumentException, IllegalStateException, ExecutionException { PmaSession pmaSession = getPmaSession(deviceName); try { return sessionTemplate.execute(pmaSession); } finally { if (pmaSession != null) { m_pmaSessionPool.returnObject(deviceName, pmaSession); } } } PmaRegistryImpl(DeviceManager deviceManager,
                           PmaSessionFactory factory); @Override @Transactional(value = Transactional.TxType.REQUIRED, rollbackOn = {RuntimeException.class, Exception.class}) Map<NetConfResponse, List<Notification>> executeNC(String deviceName, String netconfRequest); @Override RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate); @Override void forceAlign(String deviceName); @Override void align(String deviceName); void deviceRemoved(String deviceName); @Override NetConfResponse getAllPersistCfg(String deviceName); }
PmaRegistryImpl implements PmaRegistry { @Override public <RT> RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate) throws IllegalArgumentException, IllegalStateException, ExecutionException { PmaSession pmaSession = getPmaSession(deviceName); try { return sessionTemplate.execute(pmaSession); } finally { if (pmaSession != null) { m_pmaSessionPool.returnObject(deviceName, pmaSession); } } } PmaRegistryImpl(DeviceManager deviceManager,
                           PmaSessionFactory factory); @Override @Transactional(value = Transactional.TxType.REQUIRED, rollbackOn = {RuntimeException.class, Exception.class}) Map<NetConfResponse, List<Notification>> executeNC(String deviceName, String netconfRequest); @Override RT executeWithPmaSession(String deviceName, PmaSessionTemplate<RT> sessionTemplate); @Override void forceAlign(String deviceName); @Override void align(String deviceName); void deviceRemoved(String deviceName); @Override NetConfResponse getAllPersistCfg(String deviceName); static final String COMPONENT_ID; }