You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by wi...@apache.org on 2005/10/13 22:53:09 UTC
svn commit: r320910 - in
/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities:
./ metric/ metric/MetricCapable.java metric/MetricEnabledResourceImpl.java
metric/MetricType.java
Author: wire
Date: Thu Oct 13 13:53:05 2005
New Revision: 320910
URL: http://svn.apache.org/viewcvs?rev=320910&view=rev
Log:
-added Metric Capability interface, type and impl.
Added:
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricCapable.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricEnabledResourceImpl.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricType.java
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricCapable.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricCapable.java?rev=320910&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricCapable.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricCapable.java Thu Oct 13 13:53:05 2005
@@ -0,0 +1,35 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.ws.client.muse.client.impl.capabilities.metric;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.client.muse.client.impl.exceptions.FaultException;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.xmlbeans.XmlException;
+
+public interface MetricCapable {
+
+ public abstract MetricType getMetric(QName monitoredProperty)
+ throws FaultException, URISyntaxException, IOException,
+ XmlException, UnexpectedServerResponseException;
+
+}
\ No newline at end of file
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricEnabledResourceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricEnabledResourceImpl.java?rev=320910&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricEnabledResourceImpl.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricEnabledResourceImpl.java Thu Oct 13 13:53:05 2005
@@ -0,0 +1,77 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.ws.client.muse.client.impl.capabilities.metric;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.client.muse.client.impl.ManageableResourceImpl;
+import org.apache.ws.client.muse.client.impl.exceptions.FaultException;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.service.testresource.TestResourcePropertyQNames;
+import org.apache.ws.service.testresource.impl.TestMetricMetricTypeImpl;
+import org.apache.xmlbeans.GDuration;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDateTime;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.DestroyDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.DestroyResponseDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.SetTerminationTimeDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.SetTerminationTimeDocument.SetTerminationTime;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.impl.SetTerminationTimeResponseDocumentImpl;
+import org.xmlsoap.schemas.soap.envelope.impl.FaultImpl;
+
+public class MetricEnabledResourceImpl extends ManageableResourceImpl implements MetricCapable {
+
+ public MetricEnabledResourceImpl(EndpointReference epr)
+ throws MalformedURLException {
+ super(epr);
+ }
+
+ public MetricEnabledResourceImpl(URL url) throws MalformedURLException,
+ XmlException, IOException {
+ super(url);
+ }
+
+ public MetricEnabledResourceImpl(String txt) throws MalformedURLException,
+ XmlException, IOException {
+ super(txt);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.capabilities.metric.MetricCapable#getMetric(javax.xml.namespace.QName)
+ */
+ public MetricType getMetric(QName monitoredProperty) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+ MetricType metricWrapper = null;
+ //make the request for that metric
+ XmlObject[] rawResponse= getProperty(monitoredProperty);
+ metricWrapper = new MetricType(rawResponse[0]);
+
+// TestMetricMetricTypeImpl tm = (TestMetricMetricTypeImpl) rawResponse[0];
+// tm.l
+
+ return metricWrapper;
+ }
+}
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricType.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricType.java?rev=320910&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricType.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/capabilities/metric/MetricType.java Thu Oct 13 13:53:05 2005
@@ -0,0 +1,117 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.ws.client.muse.client.impl.capabilities.metric;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Calendar;
+
+import org.apache.ws.service.testresource.impl.TestMetricMetricTypeImpl;
+import org.apache.xmlbeans.GDuration;
+import org.apache.xmlbeans.XmlDateTime;
+import org.apache.xmlbeans.XmlObject;
+
+/** This class abstracts the specific XMLBeans TestMetric typ instance.
+ * Hides introspection.
+ *
+ * @author Simeon
+ */
+public class MetricType {
+ private String resetAt = "";
+ private String lastUpdated = "";
+ private String duration = "";
+ private String propValueAsString ="";
+ private long propValueAsLong = -1;
+ private float propValueAsFloat =-1.0f;
+ private double propValueAsDouble =.1d;
+ private boolean propValueAsBoolean = false;
+ private Calendar propValueAsCalendar = null;
+ private Object rawMetricObject = null;
+
+ public MetricType(XmlObject object) {
+// TestMetricMetricTypeImpl metric = new TestMetricMetricTypeImpl();
+ //make the request for that metric
+ rawMetricObject = object;
+ Class metricWrapper = object.getClass();
+ try {
+ //use introspection to get GDuration result
+ Method durationMethod = metricWrapper.getMethod("getDuration",null);
+ GDuration durationResponse = (GDuration) durationMethod.invoke(object,null);
+ if(durationResponse != null){
+ setDuration(durationResponse.toString());
+ }
+ //use introspection to get ResetAt Calendar result
+ Method resetAtMethod = metricWrapper.getMethod("getResetAt",null);
+ Calendar resetAtResponse = (Calendar) resetAtMethod.invoke(object,null);
+ if(resetAtResponse!=null){
+ setResetAt(resetAtResponse.toString());
+ }
+ //use introspection to get LastUpdated Calendar result
+ Method lastUpdatedMethod = metricWrapper.getMethod("getLastUpdated",null);
+ Calendar lastUpdatedResponse = (Calendar) lastUpdatedMethod.invoke(object,null);
+ if(lastUpdatedResponse!=null){
+ setLastUpdated(lastUpdatedResponse.toString());
+ }
+ //NOW parse out the metric property value
+ //use introspection to get LastUpdated Calendar result
+// Method longValueMethod = metricWrapper.getMethod("longValue",null);
+// long longValueResponse = ((Long)(longValueMethod.invoke(object,null))).longValue();
+// if(lastUpdatedResponse!=null){
+// setLastUpdated(lastUpdatedResponse.toString());
+// }
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public String getResetAt(){
+ return resetAt;
+ }
+
+ public String getLastUpdated(){
+ return lastUpdated;
+ }
+
+ public String getDuration(){
+ return duration;
+ }
+
+ public Object getRawMetricType(){
+ return rawMetricObject;
+ }
+
+ private void setDuration(String duration) {
+ this.duration = duration;
+ }
+
+ private void setLastUpdated(String lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ private void setResetAt(String resetAt) {
+ this.resetAt = resetAt;
+ }
+}