1 package org
.argeo
.osgi
.provisioning
;
3 import java
.io
.IOException
;
4 import java
.util
.Collections
;
5 import java
.util
.Dictionary
;
6 import java
.util
.Enumeration
;
7 import java
.util
.Iterator
;
9 import java
.util
.TreeMap
;
10 import java
.util
.zip
.ZipInputStream
;
12 import org
.osgi
.service
.provisioning
.ProvisioningService
;
14 public class SimpleProvisioningService
implements ProvisioningService
{
15 private Map
<String
, Object
> map
= Collections
.synchronizedSortedMap(new TreeMap
<>());
17 public SimpleProvisioningService() {
19 map
.put(PROVISIONING_UPDATE_COUNT
, 0);
23 public Dictionary
<String
, Object
> getInformation() {
24 return new Information();
28 public synchronized void setInformation(Dictionary
<String
, ?
> info
) {
34 public synchronized void addInformation(Dictionary
<String
, ?
> info
) {
35 Enumeration
<String
> e
= info
.keys();
36 while (e
.hasMoreElements()) {
37 String key
= e
.nextElement();
38 map
.put(key
, info
.get(key
));
40 incrementProvisioningUpdateCount();
43 protected synchronized void incrementProvisioningUpdateCount() {
44 Integer current
= (Integer
) map
.get(PROVISIONING_UPDATE_COUNT
);
45 Integer newValue
= current
+ 1;
46 map
.put(PROVISIONING_UPDATE_COUNT
, newValue
);
50 public synchronized void addInformation(ZipInputStream zis
) throws IOException
{
51 throw new UnsupportedOperationException();
54 class Information
extends Dictionary
<String
, Object
> {
62 public boolean isEmpty() {
67 public Enumeration
<String
> keys() {
68 Iterator
<String
> it
= map
.keySet().iterator();
69 return new Enumeration
<String
>() {
72 public boolean hasMoreElements() {
77 public String
nextElement() {
85 public Enumeration
<Object
> elements() {
86 Iterator
<Object
> it
= map
.values().iterator();
87 return new Enumeration
<Object
>() {
90 public boolean hasMoreElements() {
95 public Object
nextElement() {
103 public Object
get(Object key
) {
108 public Object
put(String key
, Object value
) {
109 throw new UnsupportedOperationException();
113 public Object
remove(Object key
) {
114 throw new UnsupportedOperationException();