aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075096 [4/13] - in /aries/tags/jmx-0.1-incubating: ./ jmx-api/ jmx-api/src/ jmx-api/src/main/ jmx-api/src/main/appended-resources/ jmx-api/src/main/appended-resources/META-INF/ jmx-api/src/main/java/ jmx-api/src/main/java/org/ jmx-api/src...
Date Sun, 27 Feb 2011 17:58:23 GMT
Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.BeanArgument;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+
+public class BPBeanMetadata extends BPComponentMetadata implements BPTarget {
+
+    private String className;
+
+    private String destroyMethod;
+
+    private String factoryMethod;
+
+    private String initMethod;
+
+    private String scope;
+
+    private BPBeanArgument[] arguments;
+
+    private BPBeanProperty[] properties;
+
+    private BPTarget factoryComponent;
+
+    public BPBeanMetadata(CompositeData bean) {
+        super(bean);
+        className = (String) bean.get(BlueprintMetadataMBean.CLASS_NAME);
+        destroyMethod = (String) bean.get(BlueprintMetadataMBean.DESTROY_METHOD);
+        factoryMethod = (String) bean.get(BlueprintMetadataMBean.FACTORY_METHOD);
+        initMethod = (String) bean.get(BlueprintMetadataMBean.INIT_METHOD);
+        scope = (String) bean.get(BlueprintMetadataMBean.SCOPE);
+
+        Byte[] buf = (Byte[]) bean.get(BlueprintMetadataMBean.FACTORY_COMPONENT);
+        factoryComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
+
+        CompositeData[] cd_args = (CompositeData[]) bean.get(BlueprintMetadataMBean.ARGUMENTS);
+        arguments = new BPBeanArgument[cd_args.length];
+        for (int i = 0; i < arguments.length; i++) {
+            arguments[i] = new BPBeanArgument(cd_args[i]);
+        }
+
+        CompositeData[] cd_props = (CompositeData[]) bean.get(BlueprintMetadataMBean.PROPERTIES);
+        properties = new BPBeanProperty[cd_props.length];
+        for (int i = 0; i < properties.length; i++) {
+            properties[i] = new BPBeanProperty(cd_props[i]);
+        }
+
+    }
+
+    public BPBeanMetadata(BeanMetadata bean) {
+        super(bean);
+        className = bean.getClassName();
+        destroyMethod = bean.getDestroyMethod();
+        factoryMethod = bean.getFactoryMethod();
+        initMethod = bean.getInitMethod();
+        scope = bean.getScope();
+
+        factoryComponent = (BPTarget) Util.metadata2BPMetadata(bean.getFactoryComponent());
+
+        arguments = new BPBeanArgument[bean.getArguments().size()];
+        int i = 0;
+        for (Object arg : bean.getArguments()) {
+            arguments[i++] = new BPBeanArgument((BeanArgument) arg);
+        }
+
+        properties = new BPBeanProperty[bean.getProperties().size()];
+        i = 0;
+        for (Object prop : bean.getProperties()) {
+            properties[i++] = new BPBeanProperty((BeanProperty) prop);
+        }
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        Map<String, Object> items = super.getItemsMap();
+
+        // add its fields to the map
+        items.put(BlueprintMetadataMBean.CLASS_NAME, className);
+        items.put(BlueprintMetadataMBean.DESTROY_METHOD, destroyMethod);
+        items.put(BlueprintMetadataMBean.FACTORY_METHOD, factoryMethod);
+        items.put(BlueprintMetadataMBean.INIT_METHOD, initMethod);
+        items.put(BlueprintMetadataMBean.SCOPE, scope);
+
+        items.put(BlueprintMetadataMBean.FACTORY_COMPONENT, Util.bpMetadata2BoxedBinary(factoryComponent));
+
+        CompositeData[] cd_args = new CompositeData[arguments.length];
+        for (int i = 0; i < arguments.length; i++) {
+            cd_args[i] = arguments[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.ARGUMENTS, cd_args);
+
+        CompositeData[] cd_props = new CompositeData[properties.length];
+        for (int i = 0; i < properties.length; i++) {
+            cd_props[i] = properties[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.PROPERTIES, cd_props);
+
+        return items;
+    }
+
+    public CompositeData asCompositeData() {
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.BEAN_METADATA_TYPE, getItemsMap());
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BPBeanArgument[] getArguments() {
+        return arguments;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public String getDestroyMethod() {
+        return destroyMethod;
+    }
+
+    public BPTarget getFactoryComponent() {
+        return factoryComponent;
+    }
+
+    public String getFactoryMethod() {
+        return factoryMethod;
+    }
+
+    public String getInitMethod() {
+        return initMethod;
+    }
+
+    public BPBeanProperty[] getProperties() {
+        return properties;
+    }
+
+    public String getScope() {
+        return scope;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanProperty.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanProperty.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanProperty.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPBeanProperty.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+
+public class BPBeanProperty implements TransferObject {
+    private String name;
+    private BPMetadata value;
+
+    public BPBeanProperty(CompositeData property) {
+        name = (String) property.get(BlueprintMetadataMBean.NAME);
+
+        Byte[] buf = (Byte[]) property.get(BlueprintMetadataMBean.VALUE);
+        value = Util.boxedBinary2BPMetadata(buf);
+    }
+
+    public BPBeanProperty(BeanProperty property) {
+        name = property.getName();
+
+        value = Util.metadata2BPMetadata(property.getValue());
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.NAME, name);
+        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2BoxedBinary(value));
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.BEAN_PROPERTY_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public BPMetadata getValue() {
+        return value;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPCollectionMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPCollectionMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPCollectionMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPCollectionMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+public class BPCollectionMetadata implements BPNonNullMetadata {
+    private String collectionClass;
+
+    private String valueType;
+
+    private BPMetadata[] values;
+
+    public BPCollectionMetadata(CompositeData collection) {
+        collectionClass = (String) collection.get(BlueprintMetadataMBean.COLLECTION_CLASS);
+        valueType = (String) collection.get(BlueprintMetadataMBean.VALUE_TYPE);
+
+        Byte[][] arrays = (Byte[][]) collection.get(BlueprintMetadataMBean.VALUES);
+        values = new BPMetadata[arrays.length];
+        for (int i = 0; i < values.length; i++) {
+            values[i] = Util.boxedBinary2BPMetadata((Byte[]) arrays[i]);
+        }
+    }
+
+    public BPCollectionMetadata(CollectionMetadata collection) {
+        collectionClass = collection.getCollectionClass().getCanonicalName();
+        valueType = collection.getValueType();
+
+        values = new BPMetadata[collection.getValues().size()];
+        int i = 0;
+        for (Object value : collection.getValues()) {
+            values[i++] = Util.metadata2BPMetadata((Metadata) value);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.COLLECTION_CLASS, collectionClass);
+        items.put(BlueprintMetadataMBean.VALUE_TYPE, valueType);
+
+        Byte[][] arrays = new Byte[values.length][];
+        for (int i = 0; i < arrays.length; i++) {
+            arrays[i] = Util.bpMetadata2BoxedBinary(values[i]);
+        }
+        items.put(BlueprintMetadataMBean.VALUES, arrays);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.COLLECTION_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getCollectionClass() {
+        return collectionClass;
+    }
+
+    public String getValueType() {
+        return valueType;
+    }
+
+    public BPMetadata[] getValues() {
+        return values;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPComponentMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPComponentMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPComponentMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPComponentMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+public abstract class BPComponentMetadata implements BPNonNullMetadata {
+    private int activation;
+
+    private String[] dependsOn;
+
+    private String id;
+
+    @SuppressWarnings("boxing")
+    protected BPComponentMetadata(CompositeData component) {
+        activation = (Integer) component.get(BlueprintMetadataMBean.ACTIVATION);
+        dependsOn = (String[]) component.get(BlueprintMetadataMBean.DEPENDS_ON);
+        id = (String) component.get(BlueprintMetadataMBean.ID);
+    }
+
+    protected BPComponentMetadata(ComponentMetadata component) {
+        activation = component.getActivation();
+        dependsOn =  (String[])component.getDependsOn().toArray(new String[0]);
+        id = (String) component.getId();
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.ACTIVATION, activation);
+        items.put(BlueprintMetadataMBean.DEPENDS_ON, dependsOn);
+        items.put(BlueprintMetadataMBean.ID, id);
+
+        return items;
+    }
+
+    public int getActivation() {
+        return activation;
+    }
+
+    public String[] getDependsOn() {
+        return dependsOn;
+    }
+
+    public String getId() {
+        return id;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPIdRefMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPIdRefMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPIdRefMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPIdRefMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+
+public class BPIdRefMetadata implements BPNonNullMetadata {
+    private String componentId;
+
+    public BPIdRefMetadata(CompositeData idRef) {
+        componentId = (String) idRef.get(BlueprintMetadataMBean.COMPONENT_ID);
+    }
+
+    public BPIdRefMetadata(IdRefMetadata idRef) {
+        componentId = idRef.getComponentId();
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.COMPONENT_ID, componentId);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.ID_REF_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getComponentId() {
+        return componentId;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapEntry.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapEntry.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapEntry.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapEntry.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.MapEntry;
+
+public class BPMapEntry implements TransferObject {
+    private BPNonNullMetadata key;
+
+    private BPMetadata value;
+
+    public BPMapEntry(CompositeData entry) {
+        Byte[] buf = (Byte[]) entry.get(BlueprintMetadataMBean.KEY);
+        key = (BPNonNullMetadata) Util.boxedBinary2BPMetadata(buf);
+
+        buf = (Byte[]) entry.get(BlueprintMetadataMBean.VALUE);
+        value = Util.boxedBinary2BPMetadata(buf);
+    }
+
+    public BPMapEntry(MapEntry entry) {
+        key = (BPNonNullMetadata) Util.metadata2BPMetadata(entry.getKey());
+        value = Util.metadata2BPMetadata(entry.getValue());
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.KEY, Util.bpMetadata2BoxedBinary(key));
+        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2BoxedBinary(value));
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.MAP_ENTRY_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BPNonNullMetadata getKey() {
+        return key;
+    }
+
+    public BPMetadata getValue() {
+        return value;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMapMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+
+public class BPMapMetadata implements BPNonNullMetadata {
+    private String keyType;
+
+    private String valueType;
+
+    private BPMapEntry[] entries;
+
+    public BPMapMetadata(CompositeData map) {
+        keyType = (String) map.get(BlueprintMetadataMBean.KEY_TYPE);
+        valueType = (String) map.get(BlueprintMetadataMBean.VALUE_TYPE);
+
+        CompositeData[] cd_entries = (CompositeData[]) map.get(BlueprintMetadataMBean.ENTRIES);
+        entries = new BPMapEntry[cd_entries.length];
+        for (int i = 0; i < entries.length; i++) {
+            entries[i] = new BPMapEntry(cd_entries[i]);
+        }
+    }
+
+    public BPMapMetadata(MapMetadata map) {
+        keyType = map.getKeyType();
+        valueType = map.getValueType();
+
+        entries = new BPMapEntry[map.getEntries().size()];
+        int i = 0;
+        for (Object arg : map.getEntries()) {
+            entries[i++] = new BPMapEntry((MapEntry) arg);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.KEY_TYPE, keyType);
+        items.put(BlueprintMetadataMBean.VALUE_TYPE, valueType);
+
+        CompositeData[] cd_entries = new CompositeData[entries.length];
+        for (int i = 0; i < entries.length; i++) {
+            cd_entries[i] = entries[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.ENTRIES, cd_entries);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.MAP_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BPMapEntry[] getEntries() {
+        return entries;
+    }
+
+    public String getKeyType() {
+        return keyType;
+    }
+
+    public String getValueType() {
+        return valueType;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+public interface BPMetadata extends TransferObject{
+    // marker interface
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNonNullMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNonNullMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNonNullMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNonNullMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+public interface BPNonNullMetadata extends BPMetadata {
+    // marker interface
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNullMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNullMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNullMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPNullMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.NullMetadata;
+
+public class BPNullMetadata implements BPMetadata {
+    public BPNullMetadata(CompositeData Null) {
+        //do nothing ?
+    }
+
+    public BPNullMetadata(NullMetadata Null) {
+        //do nothing ?
+    }
+
+    public CompositeData asCompositeData() {
+        try {
+			return new CompositeDataSupport(
+					BlueprintMetadataMBean.NULL_METADATA_TYPE,
+					new String[]{BlueprintMetadataMBean.PLACEHOLDER},
+					new Object[]{null});
+		} catch (OpenDataException e) {
+			throw new RuntimeException(e);
+		}
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPPropsMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPPropsMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPPropsMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPPropsMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+
+public class BPPropsMetadata implements BPNonNullMetadata {
+    BPMapEntry[] entries;
+
+    public BPPropsMetadata(CompositeData props) {
+        CompositeData[] cd_entries = (CompositeData[]) props.get(BlueprintMetadataMBean.ENTRIES);
+        entries = new BPMapEntry[cd_entries.length];
+        for (int i = 0; i < entries.length; i++) {
+            entries[i] = new BPMapEntry(cd_entries[i]);
+        }
+    }
+
+    public BPPropsMetadata(PropsMetadata props) {
+        entries = new BPMapEntry[props.getEntries().size()];
+        int i = 0;
+        for (Object arg : props.getEntries()) {
+            entries[i++] = new BPMapEntry((MapEntry) arg);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        CompositeData[] cd_entries = new CompositeData[entries.length];
+        for (int i = 0; i < entries.length; i++) {
+            cd_entries[i] = entries[i].asCompositeData();
+        }
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.ENTRIES, cd_entries);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.PROPS_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BPMapEntry[] getEntries() {
+        return entries;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRefMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRefMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRefMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRefMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+
+public class BPRefMetadata implements BPNonNullMetadata, BPTarget {
+    private String componentId;
+
+    public BPRefMetadata(CompositeData ref) {
+        componentId = (String) ref.get(BlueprintMetadataMBean.COMPONENT_ID);
+    }
+
+    public BPRefMetadata(RefMetadata ref) {
+        componentId = ref.getComponentId();
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.COMPONENT_ID, componentId);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.REF_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getComponentId() {
+        return componentId;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
+
+public class BPReferenceListMetadata extends BPServiceReferenceMetadata {
+    private int memberType;
+
+    public BPReferenceListMetadata(CompositeData ref_list) {
+        super(ref_list);
+        memberType = (Integer) ref_list.get(BlueprintMetadataMBean.MEMBER_TYPE);
+    }
+
+    public BPReferenceListMetadata(ReferenceListMetadata ref_list) {
+        super(ref_list);
+        memberType = ref_list.getMemberType();
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        Map<String, Object> items = super.getItemsMap();
+        items.put(BlueprintMetadataMBean.MEMBER_TYPE, memberType);
+
+        return items;
+    }
+
+    public CompositeData asCompositeData() {
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.REFERENCE_LIST_METADATA_TYPE, getItemsMap());
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public int getMemberType() {
+        return memberType;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListener.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListener.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListener.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceListener.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
+
+public class BPReferenceListener implements TransferObject {
+    private String bindMethod;
+
+    private String unbindMethod;
+
+    private BPTarget listenerComponent;
+
+    public BPReferenceListener(CompositeData listener) {
+        bindMethod = (String) listener.get(BlueprintMetadataMBean.BIND_METHOD);
+        unbindMethod = (String) listener.get(BlueprintMetadataMBean.UNBIND_METHOD);
+
+        Byte[] buf = (Byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
+        listenerComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
+    }
+
+    public BPReferenceListener(ReferenceListener listener) {
+        bindMethod = listener.getBindMethod();
+        unbindMethod = listener.getUnbindMethod();
+
+        listenerComponent = (BPTarget) Util.metadata2BPMetadata(listener.getListenerComponent());
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.BIND_METHOD, bindMethod);
+        items.put(BlueprintMetadataMBean.UNBIND_METHOD, unbindMethod);
+
+        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2BoxedBinary(listenerComponent));
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.REFERENCE_LISTENER_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getBindMethod() {
+        return bindMethod;
+    }
+
+    public BPTarget getListenerComponent() {
+        return listenerComponent;
+    }
+
+    public String getUnbindMethod() {
+        return unbindMethod;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPReferenceMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+
+public class BPReferenceMetadata extends BPServiceReferenceMetadata implements BPTarget {
+
+    private long timeout;
+
+    public BPReferenceMetadata(CompositeData reference) {
+        super(reference);
+        timeout = (Long) reference.get(BlueprintMetadataMBean.TIMEOUT);
+    }
+
+    public BPReferenceMetadata(ReferenceMetadata reference) {
+        super(reference);
+        timeout = reference.getTimeout();
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        Map<String, Object> items = super.getItemsMap();
+        items.put(BlueprintMetadataMBean.TIMEOUT, timeout);
+
+        return items;
+    }
+
+    public CompositeData asCompositeData() {
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.REFERENCE_METADATA_TYPE, getItemsMap());
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRegistrationListener.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRegistrationListener.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRegistrationListener.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPRegistrationListener.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+
+public class BPRegistrationListener implements TransferObject {
+    private BPTarget listenerComponent;
+
+    private String registrationMethod;
+
+    private String unregistrationMethod;
+
+    public BPRegistrationListener(CompositeData listener) {
+        registrationMethod = (String) listener.get(BlueprintMetadataMBean.REGISTRATION_METHOD);
+        unregistrationMethod = (String) listener.get(BlueprintMetadataMBean.UNREGISTRATION_METHOD);
+
+        Byte[] buf = (Byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
+        listenerComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
+    }
+
+    public BPRegistrationListener(RegistrationListener listener) {
+        registrationMethod = listener.getRegistrationMethod();
+        unregistrationMethod = listener.getUnregistrationMethod();
+
+        listenerComponent = (BPTarget) Util.metadata2BPMetadata(listener.getListenerComponent());
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.REGISTRATION_METHOD, registrationMethod);
+        items.put(BlueprintMetadataMBean.UNREGISTRATION_METHOD, unregistrationMethod);
+
+        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2BoxedBinary(listenerComponent));
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.REGISTRATION_LISTENER_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public BPTarget getListenerComponent() {
+        return listenerComponent;
+    }
+
+    public String getRegistrationMethod() {
+        return registrationMethod;
+    }
+
+    public String getUnregistrationMethod() {
+        return unregistrationMethod;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+
+public class BPServiceMetadata extends BPComponentMetadata {
+
+    private int autoExport;
+
+    private String[] interfaces;
+
+    private int ranking;
+
+    private BPRegistrationListener[] listeners;
+
+    private BPMapEntry[] properties;
+
+    private BPTarget serviceComponent;
+
+    public BPServiceMetadata(CompositeData service) {
+        super(service);
+        autoExport = (Integer) service.get(BlueprintMetadataMBean.AUTO_EXPORT);
+        interfaces = (String[]) service.get(BlueprintMetadataMBean.INTERFACES);
+        ranking = (Integer) service.get(BlueprintMetadataMBean.RANKING);
+
+        CompositeData[] cd_listeners = (CompositeData[]) service.get(BlueprintMetadataMBean.REGISTRATION_LISTENERS);
+        listeners = new BPRegistrationListener[cd_listeners.length];
+        for (int i = 0; i < listeners.length; i++) {
+            listeners[i] = new BPRegistrationListener(cd_listeners[i]);
+        }
+
+        CompositeData[] cd_props = (CompositeData[]) service.get(BlueprintMetadataMBean.SERVICE_PROPERTIES);
+        properties = new BPMapEntry[cd_props.length];
+        for (int i = 0; i < properties.length; i++) {
+            properties[i] = new BPMapEntry(cd_props[i]);
+        }
+
+        Byte[] buf = (Byte[]) service.get(BlueprintMetadataMBean.SERVICE_COMPONENT);
+        serviceComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
+    }
+
+    public BPServiceMetadata(ServiceMetadata service) {
+        super(service);
+        autoExport = service.getAutoExport();
+        interfaces = (String[])service.getInterfaces().toArray(new String[0]);
+        ranking = service.getRanking();
+
+        listeners = new BPRegistrationListener[service.getRegistrationListeners().size()];
+        int i = 0;
+        for (Object listener : service.getRegistrationListeners()) {
+            listeners[i++] = new BPRegistrationListener((RegistrationListener) listener);
+        }
+
+        properties = new BPMapEntry[service.getServiceProperties().size()];
+        i = 0;
+        for (Object prop : service.getServiceProperties()) {
+            properties[i++] = new BPMapEntry((MapEntry) prop);
+        }
+
+        serviceComponent = (BPTarget) Util.metadata2BPMetadata(service.getServiceComponent());
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        Map<String, Object> items = super.getItemsMap();
+        items.put(BlueprintMetadataMBean.AUTO_EXPORT, autoExport);
+        items.put(BlueprintMetadataMBean.INTERFACES, interfaces);
+        items.put(BlueprintMetadataMBean.RANKING, ranking);
+
+        CompositeData[] cd_listeners = new CompositeData[listeners.length];
+        for (int i = 0; i < listeners.length; i++) {
+            cd_listeners[i] = listeners[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.REGISTRATION_LISTENERS, cd_listeners);
+
+        CompositeData[] cd_props = new CompositeData[properties.length];
+        for (int i = 0; i < properties.length; i++) {
+            cd_props[i] = properties[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.SERVICE_PROPERTIES, cd_props);
+
+        items.put(BlueprintMetadataMBean.SERVICE_COMPONENT, Util.bpMetadata2BoxedBinary(serviceComponent));
+
+        return items;
+    }
+
+    public CompositeData asCompositeData() {
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.SERVICE_METADATA_TYPE, getItemsMap());
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public int getAutoExport() {
+        return autoExport;
+    }
+
+    public String[] getInterfaces() {
+        return interfaces;
+    }
+
+    public int getRanking() {
+        return ranking;
+    }
+
+    public BPRegistrationListener[] getRegistrationListeners() {
+        return listeners;
+    }
+
+    public BPTarget getServiceComponent() {
+        return serviceComponent;
+    }
+
+    public BPMapEntry[] getServiceProperties() {
+        return properties;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceReferenceMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceReferenceMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceReferenceMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPServiceReferenceMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+
+public abstract class BPServiceReferenceMetadata extends BPComponentMetadata {
+
+    private int availability;
+
+    private String componentName;
+
+    private String filter;
+
+    private String $interface;
+
+    private BPReferenceListener[] listeners;
+
+    protected BPServiceReferenceMetadata(CompositeData reference) {
+        super(reference);
+        availability = (Integer) reference.get(BlueprintMetadataMBean.AVAILABILITY);
+        componentName = (String) reference.get(BlueprintMetadataMBean.COMPONENT_NAME);
+        filter = (String) reference.get(BlueprintMetadataMBean.FILTER);
+        $interface = (String) reference.get(BlueprintMetadataMBean.INTERFACE);
+
+        CompositeData[] cd_listeners = (CompositeData[]) reference.get(BlueprintMetadataMBean.REFERENCE_LISTENERS);
+        listeners = new BPReferenceListener[cd_listeners.length];
+        for (int i = 0; i < listeners.length; i++) {
+            listeners[i] = new BPReferenceListener(cd_listeners[i]);
+        }
+    }
+
+    protected BPServiceReferenceMetadata(ServiceReferenceMetadata reference) {
+        super(reference);
+        availability = reference.getAvailability();
+        componentName = reference.getComponentName();
+        filter = reference.getFilter();
+        $interface = reference.getInterface();
+
+        listeners = new BPReferenceListener[reference.getReferenceListeners().size()];
+        int i = 0;
+        for (Object listener : reference.getReferenceListeners()) {
+            listeners[i++] = new BPReferenceListener((ReferenceListener) listener);
+        }
+    }
+
+    protected Map<String, Object> getItemsMap() {
+        Map<String, Object> items = super.getItemsMap();
+
+        // itself
+        items.put(BlueprintMetadataMBean.AVAILABILITY, availability);
+        items.put(BlueprintMetadataMBean.COMPONENT_NAME, componentName);
+        items.put(BlueprintMetadataMBean.FILTER, filter);
+        items.put(BlueprintMetadataMBean.INTERFACE, $interface);
+
+        CompositeData[] cd_listeners = new CompositeData[listeners.length];
+        for (int i = 0; i < listeners.length; i++) {
+            cd_listeners[i] = listeners[i].asCompositeData();
+        }
+        items.put(BlueprintMetadataMBean.REFERENCE_LISTENERS, cd_listeners);
+
+        return items;
+    }
+
+    public int getAvailability() {
+        return availability;
+    }
+
+    public String getComponentName() {
+        return componentName;
+    }
+
+    public String getFilter() {
+        return filter;
+    }
+
+    public String getInterface() {
+        return $interface;
+    }
+
+    public BPReferenceListener[] getReferenceListeners() {
+        return listeners;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPTarget.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPTarget.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPTarget.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPTarget.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+public interface BPTarget extends BPNonNullMetadata{
+	// marker interface
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPValueMetadata.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPValueMetadata.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPValueMetadata.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/BPValueMetadata.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+public class BPValueMetadata implements BPNonNullMetadata {
+    private String stringValue;
+
+    private String type;
+
+    public BPValueMetadata(CompositeData value) {
+        stringValue = (String) value.get(BlueprintMetadataMBean.STRING_VALUE);
+        type = (String) value.get(BlueprintMetadataMBean.TYPE);
+    }
+
+    public BPValueMetadata(ValueMetadata value) {
+        stringValue = value.getStringValue();
+        type = value.getType();
+    }
+
+    public CompositeData asCompositeData() {
+        HashMap<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintMetadataMBean.STRING_VALUE, stringValue);
+        items.put(BlueprintMetadataMBean.TYPE, type);
+
+        try {
+            return new CompositeDataSupport(BlueprintMetadataMBean.VALUE_METADATA_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public String getStringValue() {
+        return stringValue;
+    }
+
+    public String getType() {
+        return type;
+    }
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/OSGiBlueprintEvent.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/OSGiBlueprintEvent.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/OSGiBlueprintEvent.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/OSGiBlueprintEvent.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+
+import org.apache.aries.jmx.blueprint.BlueprintStateMBean;
+import org.osgi.service.blueprint.container.BlueprintEvent;
+
+/**
+ * <p>
+ * This class represents the CODEC for the composite data representing a OSGi
+ * <link>BlueprintEvent</link>
+ * <p>
+ * It serves as both the documentation of the type structure and as the
+ * codification of the mechanism to convert to/from the CompositeData.
+ * <p>
+ * The structure of the composite data is:
+ * <table border="1">
+ * <tr>
+ * <td>bundleId</td>
+ * <td>long</td>
+ * </tr>
+ * <tr>
+ * <td>extenderBundleId</td>
+ * <td>long</td>
+ * </tr>
+ * <tr>
+ * <td>eventType</td>
+ * <td>int</td>
+ * </tr>
+ * <tr>
+ * <td>replay</td>
+ * <td>boolean</td>
+ * </tr>
+ * <tr>
+ * <td>timestamp</td>
+ * <td>long</td>
+ * </tr>
+ * <tr>
+ * <td>dependencies</td>
+ * <td>String[]</td>
+ * </tr>
+ * <tr>
+ * <td>exceptionMessage</td>
+ * <td>String</td>
+ * </tr>
+ * </table>
+ */
+
+public class OSGiBlueprintEvent implements TransferObject{
+
+    private long bundleId;
+
+    private long extenderBundleId;
+
+    private int eventType;
+
+    private boolean replay;
+
+    private long timestamp;
+
+    private String[] dependencies;
+
+    private String exceptionMessage;
+
+
+    /**
+     * Construct an OSGiBlueprintEvent from the supplied <link>BlueprintEvent</link>
+     *
+     * @param event
+     *            - the event to represent
+     */
+    public OSGiBlueprintEvent(BlueprintEvent event) {
+        this(event.getBundle().getBundleId(),
+                event.getExtenderBundle().getBundleId(),
+                event.getType(),
+                event.isReplay(),
+                event.getTimestamp(),
+                event.getDependencies(),
+                (event.getCause() == null) ? null : event.getCause().getMessage());
+    }
+
+    /**
+     * Construct an OSGiBlueprintEvent from the CompositeData representing the
+     * event
+     *
+     * @param data
+     *            - the CompositeData representing the event.
+     */
+    @SuppressWarnings("boxing")
+    public OSGiBlueprintEvent(CompositeData data) {
+        this((Long) data.get(BlueprintStateMBean.BUNDLE_ID),
+                (Long) data.get(BlueprintStateMBean.EXTENDER_BUNDLE_ID),
+                (Integer) data.get(BlueprintStateMBean.EVENT_TYPE),
+                (Boolean) data.get(BlueprintStateMBean.REPLAY),
+                (Long) data.get(BlueprintStateMBean.TIMESTAMP),
+                (String[]) data.get(BlueprintStateMBean.DEPENDENCIES),
+                (String) data.get(BlueprintStateMBean.EXCEPTION_MESSAGE));
+    }
+
+    /**
+     * Construct the OSGiBlueprintEvent
+     *
+     * @param bundleId
+     * @param extenderBundleId
+     * @param eventType
+     * @param replay
+     * @param timestamp
+     * @param dependencies
+     * @param exceptionMessage
+     */
+    public OSGiBlueprintEvent(long bundleId, long extenderBundleId, int eventType, boolean replay, long timestamp, String[] dependencies, String exceptionMessage){
+        this.bundleId = bundleId;
+        this.extenderBundleId = extenderBundleId;
+        this.eventType = eventType;
+        this.replay = replay;
+        this.timestamp = timestamp;
+        this.dependencies = dependencies;
+        this.exceptionMessage = exceptionMessage;
+    }
+
+    /**
+     * Answer the receiver encoded as CompositeData
+     *
+     * @return the CompositeData encoding of the receiver.
+     */
+    @SuppressWarnings("boxing")
+    public CompositeData asCompositeData() {
+        Map<String, Object> items = new HashMap<String, Object>();
+        items.put(BlueprintStateMBean.BUNDLE_ID, bundleId);
+        items.put(BlueprintStateMBean.EXTENDER_BUNDLE_ID, extenderBundleId);
+        items.put(BlueprintStateMBean.EVENT_TYPE, eventType);
+        items.put(BlueprintStateMBean.REPLAY, replay);
+        items.put(BlueprintStateMBean.TIMESTAMP, timestamp);
+        items.put(BlueprintStateMBean.DEPENDENCIES, dependencies);
+        items.put(BlueprintStateMBean.EXCEPTION_MESSAGE, exceptionMessage);
+        try {
+            return new CompositeDataSupport(BlueprintStateMBean.OSGI_BLUEPRINT_EVENT_TYPE, items);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Cannot form blueprint event open data", e);
+        }
+    }
+
+    public long getBundleId() {
+        return bundleId;
+    }
+
+    public long getExtenderBundleId() {
+        return extenderBundleId;
+    }
+
+    public int getEventType() {
+        return eventType;
+    }
+
+    public boolean isReplay() {
+        return replay;
+    }
+
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+    public String[] getDependencies() {
+        return dependencies;
+    }
+
+    public String getExceptionMessage() {
+        return exceptionMessage;
+    }
+
+
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/TransferObject.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/TransferObject.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/TransferObject.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/TransferObject.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import javax.management.openmbean.CompositeData;
+
+public interface TransferObject {
+	CompositeData asCompositeData();
+}

Added: aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/Util.java
URL: http://svn.apache.org/viewvc/aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/Util.java?rev=1075096&view=auto
==============================================================================
--- aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/Util.java (added)
+++ aries/tags/jmx-0.1-incubating/jmx-blueprint-core/src/main/java/org/apache/aries/jmx/blueprint/codec/Util.java Sun Feb 27 17:58:16 2011
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jmx.blueprint.codec;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.management.openmbean.CompositeData;
+
+import org.apache.aries.jmx.blueprint.BlueprintMetadataMBean;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.NullMetadata;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+public class Util {
+
+    public static BPMetadata metadata2BPMetadata(Metadata metadata) {
+        if(null == metadata)
+            return null;
+        // target first
+        if (metadata instanceof BeanMetadata)
+            return new BPBeanMetadata((BeanMetadata) metadata);
+
+        if (metadata instanceof ReferenceMetadata)
+            return new BPReferenceMetadata((ReferenceMetadata) metadata);
+
+        if (metadata instanceof RefMetadata)
+            return new BPRefMetadata((RefMetadata) metadata);
+
+        // others
+        if (metadata instanceof CollectionMetadata)
+            return new BPCollectionMetadata((CollectionMetadata) metadata);
+
+        if (metadata instanceof ServiceMetadata)
+            return new BPServiceMetadata((ServiceMetadata) metadata);
+
+        if (metadata instanceof ReferenceListMetadata)
+            return new BPReferenceListMetadata((ReferenceListMetadata) metadata);
+
+        if (metadata instanceof IdRefMetadata)
+            return new BPIdRefMetadata((IdRefMetadata) metadata);
+
+        if (metadata instanceof MapMetadata)
+            return new BPMapMetadata((MapMetadata) metadata);
+
+        if (metadata instanceof PropsMetadata)
+            return new BPPropsMetadata((PropsMetadata) metadata);
+
+        if (metadata instanceof ValueMetadata)
+            return new BPValueMetadata((ValueMetadata) metadata);
+
+        // null last
+        if (metadata instanceof NullMetadata)
+            return new BPNullMetadata((NullMetadata) metadata);
+
+        throw new RuntimeException("Unknown metadata type");
+    }
+
+    public static BPMetadata binary2BPMetadata(byte[] buf) {
+        if(null == buf)
+            return null;
+
+        ByteArrayInputStream inBytes = new ByteArrayInputStream(buf);
+        ObjectInputStream inObject;
+        CompositeData metadata;
+        try {
+            inObject = new ObjectInputStream(inBytes);
+            metadata = (CompositeData) inObject.readObject();
+            inObject.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            return null;
+        }
+
+        String typename = metadata.getCompositeType().getTypeName();
+
+        // target first
+        if (typename.equals(BlueprintMetadataMBean.BEAN_METADATA))
+            return new BPBeanMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.REFERENCE_METADATA))
+            return new BPReferenceMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.REF_METADATA))
+            return new BPRefMetadata(metadata);
+
+        // others
+        if (typename.equals(BlueprintMetadataMBean.COLLECTION_METADATA))
+            return new BPCollectionMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.SERVICE_METADATA))
+            return new BPServiceMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.REFERENCE_LIST_METADATA))
+            return new BPReferenceListMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.ID_REF_METADATA))
+            return new BPIdRefMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.MAP_METADATA))
+            return new BPMapMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.PROPS_METADATA))
+            return new BPPropsMetadata(metadata);
+
+        if (typename.equals(BlueprintMetadataMBean.VALUE_METADATA))
+            return new BPValueMetadata(metadata);
+
+        // null last
+        if (metadata instanceof NullMetadata)
+            return new BPNullMetadata(metadata);
+
+        throw new RuntimeException("Unknown metadata type");
+    }
+
+    public static byte[] bpMetadata2Binary(BPMetadata metadata) {
+        if(null == metadata)
+            return null;
+
+        ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
+        ObjectOutputStream outObject;
+        try {
+            outObject = new ObjectOutputStream(outBytes);
+            outObject.writeObject(metadata.asCompositeData());
+            outObject.close();
+        } catch (IOException e) {// there is no io op
+            throw new RuntimeException(e);
+        }
+
+        return outBytes.toByteArray();
+    }
+    public static Byte[] bpMetadata2BoxedBinary(BPMetadata metadata)
+    {
+        if(null == metadata)
+            return null;
+
+        byte [] src = bpMetadata2Binary(metadata);
+        Byte [] res = new Byte[src.length];
+        for(int i=0;i<src.length;i++)
+        {
+            res[i] = src[i];
+        }
+        return res;
+    }
+    public static BPMetadata boxedBinary2BPMetadata(Byte[] buf) {
+        if(null == buf)
+            return null;
+
+        byte [] unbox = new byte[buf.length];
+        for(int i=0;i<buf.length;i++)
+        {
+            unbox[i] = buf[i];
+        }
+        return binary2BPMetadata(unbox);
+    }
+}



Mime
View raw message