You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/12/11 06:56:31 UTC

[1/2] git commit: adding support to map marshalling/unmarshalling and annotating messaging component

Updated Branches:
  refs/heads/master cd1510802 -> e178cc2b7


adding support to map marshalling/unmarshalling and annotating messaging component


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/8ca73a34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/8ca73a34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/8ca73a34

Branch: refs/heads/master
Commit: 8ca73a341aa7116390fe04cdac7be96b7f4bf7a8
Parents: d56fb76
Author: Isuru <is...@wso2.com>
Authored: Wed Dec 11 11:25:25 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Wed Dec 11 11:25:25 2013 +0530

----------------------------------------------------------------------
 .../messaging/domain/topology/Cluster.java      |  6 +++
 .../messaging/domain/topology/Member.java       |  7 +++
 .../messaging/domain/topology/MemberStatus.java |  3 ++
 .../util/bean/type/map/MapAdapter.java          | 52 ++++++++++++++++++++
 .../util/bean/type/map/MapEntryType.java        | 32 ++++++++++++
 .../messaging/util/bean/type/map/MapType.java   | 28 +++++++++++
 .../endpoint/bean/util/type/map/MapAdapter.java | 52 ++++++++++++++++++++
 .../bean/util/type/map/MapEntryType.java        | 32 ++++++++++++
 .../endpoint/bean/util/type/map/MapType.java    | 28 +++++++++++
 9 files changed, 240 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
index f3bdf2a..7df2081 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
@@ -21,7 +21,10 @@ package org.apache.stratos.messaging.domain.topology;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.stratos.messaging.util.Util;
+import org.apache.stratos.messaging.util.bean.type.map.MapAdapter;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import java.io.Serializable;
 import java.util.*;
 
@@ -29,6 +32,7 @@ import java.util.*;
  * Defines a cluster of a service.
  * Key: serviceName, clusterId
  */
+@XmlRootElement
 public class Cluster implements Serializable {
 
 	private static final long serialVersionUID = -361960242360176077L;
@@ -41,8 +45,10 @@ public class Cluster implements Serializable {
     private String deploymentPolicyName = "economy-deployment";
     private boolean isLbCluster;
     // Key: Member.memberId
+    @XmlJavaTypeAdapter(MapAdapter.class)
     private Map<String, Member> memberMap;
     private String loadBalanceAlgorithmName;
+    @XmlJavaTypeAdapter(MapAdapter.class)
     private Properties properties;
 
     public Cluster(String serviceName, String clusterId, String autoscalePolicyName) {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
index dfe9ec5..a82b7a1 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
@@ -19,6 +19,10 @@
 
 package org.apache.stratos.messaging.domain.topology;
 
+import org.apache.stratos.messaging.util.bean.type.map.MapAdapter;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashMap;
@@ -29,6 +33,7 @@ import java.util.Properties;
  * Defines a member node in a cluster.
  * Key: serviceName, clusterId, memberId
  */
+@XmlRootElement
 public class Member implements Serializable {
     private static final long serialVersionUID = 4179661867903664661L;
 	private String serviceName;
@@ -36,7 +41,9 @@ public class Member implements Serializable {
     private String memberId;
     private MemberStatus status;
     private String memberIp;
+    @XmlJavaTypeAdapter(MapAdapter.class)
     private Map<String, Port> portMap;
+    @XmlJavaTypeAdapter(MapAdapter.class)
     private Properties properties;
     private String partitionId;
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java
index b59b08c..2b9ce0c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java
@@ -19,9 +19,12 @@
 
 package org.apache.stratos.messaging.domain.topology;
 
+import javax.xml.bind.annotation.XmlRootElement;
+
 /**
  * Represents status of a member during its lifecycle.
  */
+@XmlRootElement
 public enum MemberStatus {
     Created, Starting, Activated, Suspended, Terminated
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapAdapter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapAdapter.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapAdapter.java
new file mode 100644
index 0000000..68e69d0
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapAdapter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.stratos.messaging.util.bean.type.map;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapAdapter<S, T> extends XmlAdapter<MapType,Map<S, T>> {
+
+    @Override
+    public MapType marshal(Map<S, T> v) throws Exception {
+
+        MapType mapType = new MapType();
+
+        for(Map.Entry entry : v.entrySet()) {
+            MapEntryType myMapEntryType = new MapEntryType();
+            myMapEntryType.key = entry.getKey();
+            myMapEntryType.value = entry.getValue();
+            mapType.entry.add(myMapEntryType);
+        }
+        return mapType;
+    }
+
+    @Override
+    public Map<S, T> unmarshal(MapType v) throws Exception {
+
+        Map hashMap = new HashMap();
+
+        for(MapEntryType mapEntryType : v.entry) {
+            hashMap.put(mapEntryType.key, mapEntryType.value);
+        }
+        return hashMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapEntryType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapEntryType.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapEntryType.java
new file mode 100644
index 0000000..619be11
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapEntryType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.stratos.messaging.util.bean.type.map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+public class MapEntryType<S, T> {
+
+    @XmlAttribute
+    public S key;
+
+    @XmlValue
+    public T value;
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapType.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapType.java
new file mode 100644
index 0000000..4006d5c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/bean/type/map/MapType.java
@@ -0,0 +1,28 @@
+/*
+ * 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.stratos.messaging.util.bean.type.map;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MapType {
+
+    public List<MapEntryType> entry = new ArrayList<MapEntryType>();
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapAdapter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapAdapter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapAdapter.java
new file mode 100644
index 0000000..9545a5a
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapAdapter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.stratos.rest.endpoint.bean.util.type.map;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapAdapter<S, T> extends XmlAdapter<MapType,Map<S, T>> {
+
+    @Override
+    public MapType marshal(Map<S, T> v) throws Exception {
+
+        MapType mapType = new MapType();
+
+        for(Map.Entry entry : v.entrySet()) {
+            MapEntryType myMapEntryType = new MapEntryType();
+            myMapEntryType.key = entry.getKey();
+            myMapEntryType.value = entry.getValue();
+            mapType.entry.add(myMapEntryType);
+        }
+        return mapType;
+    }
+
+    @Override
+    public Map<S, T> unmarshal(MapType v) throws Exception {
+
+        Map hashMap = new HashMap();
+
+        for(MapEntryType mapEntryType : v.entry) {
+            hashMap.put(mapEntryType.key, mapEntryType.value);
+        }
+        return hashMap;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapEntryType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapEntryType.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapEntryType.java
new file mode 100644
index 0000000..e9bb344
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapEntryType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.stratos.rest.endpoint.bean.util.type.map;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+public class MapEntryType <S,T> {
+
+    @XmlAttribute
+    public S key;
+
+    @XmlValue
+    public T value;
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/8ca73a34/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapType.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapType.java
new file mode 100644
index 0000000..3fdd63f
--- /dev/null
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/type/map/MapType.java
@@ -0,0 +1,28 @@
+/*
+ * 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.stratos.rest.endpoint.bean.util.type.map;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MapType {
+
+    public List<MapEntryType> entry = new ArrayList<MapEntryType>();
+}


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos into rest_api

Posted by is...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos into rest_api


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/e178cc2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e178cc2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e178cc2b

Branch: refs/heads/master
Commit: e178cc2b7e7984b0e7c0c31ba6a92532d49f0222
Parents: 8ca73a3 cd15108
Author: Isuru <is...@wso2.com>
Authored: Wed Dec 11 11:25:46 2013 +0530
Committer: Isuru <is...@wso2.com>
Committed: Wed Dec 11 11:25:46 2013 +0530

----------------------------------------------------------------------
 ...oadBalancerInFlightRequestCountNotifier.java | 25 +++++++++++++++++---
 .../messaging/domain/topology/Cluster.java      | 21 ++++++++++++++++
 2 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e178cc2b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------