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();
27 @SuppressWarnings("rawtypes")
29 public synchronized void setInformation(Dictionary info
) {
34 @SuppressWarnings({ "rawtypes", "unchecked" })
36 public synchronized void addInformation(Dictionary info
) {
37 Enumeration
<String
> e
= info
.keys();
38 while (e
.hasMoreElements()) {
39 String key
= e
.nextElement();
40 map
.put(key
, info
.get(key
));
42 incrementProvisioningUpdateCount();
45 protected synchronized void incrementProvisioningUpdateCount() {
46 Integer current
= (Integer
) map
.get(PROVISIONING_UPDATE_COUNT
);
47 Integer newValue
= current
+ 1;
48 map
.put(PROVISIONING_UPDATE_COUNT
, newValue
);
52 public synchronized void addInformation(ZipInputStream zis
) throws IOException
{
53 throw new UnsupportedOperationException();
58 class Information
extends Dictionary
<String
, Object
> {
66 public boolean isEmpty() {
71 public Enumeration
<String
> keys() {
72 Iterator
<String
> it
= map
.keySet().iterator();
73 return new Enumeration
<String
>() {
76 public boolean hasMoreElements() {
81 public String
nextElement() {
89 public Enumeration
<Object
> elements() {
90 Iterator
<Object
> it
= map
.values().iterator();
91 return new Enumeration
<Object
>() {
94 public boolean hasMoreElements() {
99 public Object
nextElement() {
107 public Object
get(Object key
) {
112 public Object
put(String key
, Object value
) {
113 throw new UnsupportedOperationException();
117 public Object
remove(Object key
) {
118 throw new UnsupportedOperationException();