/** * Deserialize the wallet extension with the supplied data and then install it, replacing any existing extension * that may have existed with the same ID. If an exception is thrown then the extension is removed from the wallet, * if already present. */ public void deserializeExtension(WalletExtension extension, byte[] data) throws Exception { lock.lock(); keyChainGroupLock.lock(); try { // This method exists partly to establish a lock ordering of wallet > extension. extension.deserializeWalletExtension(this, data); extensions.put(extension.getWalletExtensionID(), extension); } catch (Throwable throwable) { log.error("Error during extension deserialization", throwable); extensions.remove(extension.getWalletExtensionID()); Throwables.propagate(throwable); } finally { keyChainGroupLock.unlock(); lock.unlock(); } }
private static void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder) { for (WalletExtension extension : wallet.getExtensions().values()) { Protos.Extension.Builder proto = Protos.Extension.newBuilder(); proto.setId(extension.getWalletExtensionID()); proto.setMandatory(extension.isWalletExtensionMandatory()); proto.setData(ByteString.copyFrom(extension.serializeWalletExtension())); walletBuilder.addExtension(proto); } }
/** * Either adds extension as a new extension or replaces the existing extension if one already exists with the same * id. This also triggers wallet auto-saving, so may be useful even when called with the same extension as is * already present. */ public void addOrUpdateExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
private static void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder) { for (WalletExtension extension : wallet.getExtensions().values()) { Protos.Extension.Builder proto = Protos.Extension.newBuilder(); proto.setId(extension.getWalletExtensionID()); proto.setMandatory(extension.isWalletExtensionMandatory()); proto.setData(ByteString.copyFrom(extension.serializeWalletExtension())); walletBuilder.addExtension(proto); } }
/** * Either adds extension as a new extension or replaces the existing extension if one already exists with the same * id. This also triggers wallet auto-saving, so may be useful even when called with the same extension as is * already present. */ public void addOrUpdateExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
private static void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder) { for (WalletExtension extension : wallet.getExtensions().values()) { Protos.Extension.Builder proto = Protos.Extension.newBuilder(); proto.setId(extension.getWalletExtensionID()); proto.setMandatory(extension.isWalletExtensionMandatory()); proto.setData(ByteString.copyFrom(extension.serializeWalletExtension())); walletBuilder.addExtension(proto); } }
/** * Either adds extension as a new extension or replaces the existing extension if one already exists with the same * id. This also triggers wallet auto-saving, so may be useful even when called with the same extension as is * already present. */ public void addOrUpdateExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Deserialize the wallet extension with the supplied data and then install it, replacing any existing extension * that may have existed with the same ID. If an exception is thrown then the extension is removed from the wallet, * if already present. */ public void deserializeExtension(WalletExtension extension, byte[] data) throws Exception { lock.lock(); keyChainGroupLock.lock(); try { // This method exists partly to establish a lock ordering of wallet > extension. extension.deserializeWalletExtension(this, data); extensions.put(extension.getWalletExtensionID(), extension); } catch (Throwable throwable) { log.error("Error during extension deserialization", throwable); extensions.remove(extension.getWalletExtensionID()); Throwables.propagate(throwable); } finally { keyChainGroupLock.unlock(); lock.unlock(); } }
private static void populateExtensions(Wallet wallet, Protos.Wallet.Builder walletBuilder) { for (WalletExtension extension : wallet.getExtensions().values()) { Protos.Extension.Builder proto = Protos.Extension.newBuilder(); proto.setId(extension.getWalletExtensionID()); proto.setMandatory(extension.isWalletExtensionMandatory()); proto.setData(ByteString.copyFrom(extension.serializeWalletExtension())); walletBuilder.addExtension(proto); } }
/** * Either adds extension as a new extension or replaces the existing extension if one already exists with the same * id. This also triggers wallet auto-saving, so may be useful even when called with the same extension as is * already present. */ public void addOrUpdateExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Deserialize the wallet extension with the supplied data and then install it, replacing any existing extension * that may have existed with the same ID. If an exception is thrown then the extension is removed from the wallet, * if already present. */ public void deserializeExtension(WalletExtension extension, byte[] data) throws Exception { lock.lock(); keyChainGroupLock.lock(); try { // This method exists partly to establish a lock ordering of wallet > extension. extension.deserializeWalletExtension(this, data); extensions.put(extension.getWalletExtensionID(), extension); } catch (Throwable throwable) { log.error("Error during extension deserialization", throwable); extensions.remove(extension.getWalletExtensionID()); Throwables.propagate(throwable); } finally { keyChainGroupLock.unlock(); lock.unlock(); } }
/** * By providing an object implementing the {@link WalletExtension} interface, you can save and load arbitrary * additional data that will be stored with the wallet. Each extension is identified by an ID, so attempting to * add the same extension twice (or two different objects that use the same ID) will throw an IllegalStateException. */ public void addExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { if (extensions.containsKey(id)) throw new IllegalStateException("Cannot add two extensions with the same ID: " + id); extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Deserialize the wallet extension with the supplied data and then install it, replacing any existing extension * that may have existed with the same ID. If an exception is thrown then the extension is removed from the wallet, * if already present. */ public void deserializeExtension(WalletExtension extension, byte[] data) throws Exception { lock.lock(); keyChainGroupLock.lock(); try { // This method exists partly to establish a lock ordering of wallet > extension. extension.deserializeWalletExtension(this, data); extensions.put(extension.getWalletExtensionID(), extension); } catch (Throwable throwable) { log.error("Error during extension deserialization", throwable); extensions.remove(extension.getWalletExtensionID()); Throwables.propagate(throwable); } finally { keyChainGroupLock.unlock(); lock.unlock(); } }
/** * Atomically adds extension or returns an existing extension if there is one with the same id already present. */ public WalletExtension addOrGetExistingExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { WalletExtension previousExtension = extensions.get(id); if (previousExtension != null) return previousExtension; extensions.put(id, extension); saveNow(); return extension; } finally { lock.unlock(); } }
/** * By providing an object implementing the {@link WalletExtension} interface, you can save and load arbitrary * additional data that will be stored with the wallet. Each extension is identified by an ID, so attempting to * add the same extension twice (or two different objects that use the same ID) will throw an IllegalStateException. */ public void addExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { if (extensions.containsKey(id)) throw new IllegalStateException("Cannot add two extensions with the same ID: " + id); extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Atomically adds extension or returns an existing extension if there is one with the same id already present. */ public WalletExtension addOrGetExistingExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { WalletExtension previousExtension = extensions.get(id); if (previousExtension != null) return previousExtension; extensions.put(id, extension); saveNow(); return extension; } finally { lock.unlock(); } }
/** * By providing an object implementing the {@link WalletExtension} interface, you can save and load arbitrary * additional data that will be stored with the wallet. Each extension is identified by an ID, so attempting to * add the same extension twice (or two different objects that use the same ID) will throw an IllegalStateException. */ public void addExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { if (extensions.containsKey(id)) throw new IllegalStateException("Cannot add two extensions with the same ID: " + id); extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Atomically adds extension or returns an existing extension if there is one with the same id already present. */ public WalletExtension addOrGetExistingExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { WalletExtension previousExtension = extensions.get(id); if (previousExtension != null) return previousExtension; extensions.put(id, extension); saveNow(); return extension; } finally { lock.unlock(); } }
/** * By providing an object implementing the {@link WalletExtension} interface, you can save and load arbitrary * additional data that will be stored with the wallet. Each extension is identified by an ID, so attempting to * add the same extension twice (or two different objects that use the same ID) will throw an IllegalStateException. */ public void addExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { if (extensions.containsKey(id)) throw new IllegalStateException("Cannot add two extensions with the same ID: " + id); extensions.put(id, extension); saveNow(); } finally { lock.unlock(); } }
/** * Atomically adds extension or returns an existing extension if there is one with the same id already present. */ public WalletExtension addOrGetExistingExtension(WalletExtension extension) { String id = checkNotNull(extension).getWalletExtensionID(); lock.lock(); try { WalletExtension previousExtension = extensions.get(id); if (previousExtension != null) return previousExtension; extensions.put(id, extension); saveNow(); return extension; } finally { lock.unlock(); } }