You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/02/24 22:11:21 UTC
svn commit: r380816 - in
/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice:
./ generator/ jaxrpc/ utils/
Author: cschoett
Date: Fri Feb 24 13:11:18 2006
New Revision: 380816
URL: http://svn.apache.org/viewcvs?rev=380816&view=rev
Log:
More javadoc cleanup, some minor refactoring, added ClientBindingLookupFactory to break dependency on AxisBindingLookupFactory in the wsc generator.
Added:
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java (with props)
Modified:
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/ServiceControl.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/MethodInfo.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ParameterInfo.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGenerator.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/GenericHolder.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/HolderUtils.java
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/ServiceControl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/ServiceControl.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/ServiceControl.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/ServiceControl.java Fri Feb 24 13:11:18 2006
@@ -32,21 +32,21 @@
/**
* <p>
- * Provides simplified access to web services. A service control provides an interface between an application and a
- * web service, which allows an application to invoke the service's operations. Using a web service control, you
+ * Provides simplified access to web services. A web service control provides an interface between an application and a
+ * web service, which allows an application to invoke the web service's operations. Using a web service control, you
* can connect to any web service for which a WSDL file is available.
* </p>
* <p>
- * Typically, a service control is used by creating the control from a WSDL file. Then, the target web service's
- * operations are exposed as methods of the control.
+ * A web service control is generated from a WSDL file. The target web service's operations are exposed as
+ * methods of the web service control.
* </p>
*/
@ControlInterface(defaultBinding = "org.apache.beehive.controls.system.webservice.jaxrpc.ServiceControlImpl")
public interface ServiceControl {
/**
- * OperationName is only used when the target WSDL defines operations with
- * names that are invalid as Java Method names.
+ * OperationName is the name of the operation as it appears in the WSDL file. It provides a means of
+ * mapping a web service control's method to the WSDL operation.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@@ -56,15 +56,32 @@
}
/**
- * Path to WSDL - required annotation.
+ * The WSDL annotation contains information pertinant to the WSDL used to generate the web service
+ * control.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@PropertySet(prefix = "WSDL", externalConfig = false, optional = false, hasSetters = false)
public @interface WSDL {
+
+ /**
+ * The path to the WSDL for use at runtime by the web service control.
+ */
@AnnotationMemberTypes.FilePath String path();
+
+ /**
+ * The portName of the service.
+ */
String portName();
+
+ /**
+ * The local name of the service in the WSDL.
+ */
String service();
+
+ /**
+ * The target namespace of the service .
+ */
String serviceTns();
}
@@ -112,19 +129,19 @@
*/
public URL getEndPoint();
- /**
- * Specifies the QName for the port within the WSDL which the Service Control should use.
- *
- * @param wsdlPortName The QName of the port to use.
- */
- public void setWsdlPort(QName wsdlPortName);
-
- /**
- * Returns the QName of the port that will be used by the Service Control to call the webservice.
- *
- * @return The QName of the port that will be used.
- */
- public QName getWsdlPort();
+// /**
+// * Specifies the name for the port within the service which the web service control should use.
+// *
+// * @param servicePortName The name of the port to use.
+// */
+// public void setServicePort(QName servicePortName);
+//
+// /**
+// * Returns the name of the port that will be used by the web service control.
+// *
+// * @return The name of the port that will be used.
+// */
+// public QName getServicePort();
/**
* Sets the username that will be sent with the next outgoing Service control method invocation. Used if the Service
@@ -162,21 +179,9 @@
*/
public void setHandlers(List<HandlerInfo> handlers);
- /**
- * Sets the timeout for the underlying HttpURLConnection (in millisecs, default is 0 which means no timeout,
- * negative values are converted to 0).
- */
- public void setTimeout(int timeout);
-
- /**
- * Gets the timeout that has been set by setTimeout() for the underlying HttpURLConnection (returned in millisecs, a
- * value of 0 means no timeout).
- */
- public int getTimeout();
-
- /**
- * Clears all parameters that were set by previous calls to the setOutputHeaders, setPassword, or setUsername
- * methods.
- */
- public void reset();
+// /**
+// * Clears all parameters that were set by previous calls to the setOutputHeaders, setPassword, or setUsername
+// * methods.
+// */
+// public void reset();
}
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/MethodInfo.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/MethodInfo.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/MethodInfo.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/MethodInfo.java Fri Feb 24 13:11:18 2006
@@ -38,7 +38,9 @@
}
/**
- * @param methodName
+ * Set the name of the wsc method.
+ *
+ * @param methodName Name of wsc method.
*/
void setMethodName(String methodName) {
@@ -48,7 +50,7 @@
m[0] = Character.toLowerCase(m[0]);
methodName = new String(m);
}
-
+
if (!GeneratorUtils.isValidJavaIdentifier(methodName)) {
_methodName = GeneratorUtils.transformInvalidJavaIdentifier(methodName);
System.out.println("Warning: method name " + methodName
@@ -61,7 +63,9 @@
}
/**
- * @param operationName
+ * Set the operation annotation's name, should be the same as the operation name in the WSDL.
+ *
+ * @param operationName Operation name.
*/
void setOperationName(String operationName) {
_operationName = operationName;
@@ -96,6 +100,11 @@
return _methodName;
}
+ /**
+ * Set the name of the return type.
+ *
+ * @param returnType
+ */
void setReturnTypeName(String returnType) {
_returnTypeName = returnType;
if (_returnTypeName.startsWith("java.lang.")) {
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ParameterInfo.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ParameterInfo.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ParameterInfo.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ParameterInfo.java Fri Feb 24 13:11:18 2006
@@ -20,11 +20,6 @@
import org.apache.beehive.controls.system.webservice.utils.HolderUtils;
-import javax.xml.namespace.QName;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Calendar;
-
/**
* Method parameter info for the Veclocity engine.
*/
@@ -41,47 +36,51 @@
/**
* package protected constructor.
- * @param name The parameter name, if null a name will be generated based on the position parameter.
+ *
+ * @param name The parameter name, if null a name will be generated based on the position parameter.
* @param position The position in the argument list of this parameter.
* @param typeName The class name of the parameter
- * @param mode Mode may be any of the values defined by the ParamMode enumeration.
+ * @param mode Mode may be any of the values defined by the ParamMode enumeration.
*/
- ParameterInfo(String name, int position, String typeName, ParamMode mode) {
+ protected ParameterInfo(String name, int position, String typeName, ParamMode mode) {
_className = resolveParameterType(typeName, mode);
if (name == null) {
_name = PARAM_BASE_NAME + position;
- } else if (!GeneratorUtils.isValidJavaIdentifier(name)) {
+ }
+ else if (!GeneratorUtils.isValidJavaIdentifier(name)) {
_name = GeneratorUtils.transformInvalidJavaIdentifier(name);
System.out.println("Warning: Parameter name " + name
+ " is not a valid Java method parameter name, changing to: " + _name);
- } else {
+ }
+ else {
_name = name;
}
}
/**
* Get the name of the parameter,
+ *
* @return The parameter name, guarenteed NOT to return null.
*/
- public String getName()
- {
+ public String getName() {
return _name;
}
/**
* The class name of the parameter type. The class name will be a fully qualified name
* unless the class is in the java.lang package (in which case the package name is truncated).
+ *
* @return String
*/
- public String getClassName()
- {
+ public String getClassName() {
return _className;
}
/**
* Given the class and mode of the parameter, generate the classname.
- * @param typeName Parameter class name.
+ *
+ * @param typeName Parameter class name.
* @param paramMode Mode.
* @return A string containing the class name of the parameter.
*/
@@ -90,7 +89,7 @@
return HolderUtils.getHolderForClass(typeName);
else {
if (typeName.startsWith("java.lang."))
- typeName = typeName.substring(typeName.lastIndexOf('.')+1);
+ typeName = typeName.substring(typeName.lastIndexOf('.') + 1);
return typeName;
}
}
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGenerator.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGenerator.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGenerator.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGenerator.java Fri Feb 24 13:11:18 2006
@@ -30,9 +30,10 @@
import org.apache.beehive.controls.system.webservice.wsdl.WsdlOpParameter;
import org.apache.beehive.controls.system.webservice.wsdl.WsdlOpReturnType;
import org.apache.beehive.controls.system.webservice.wsdl.WsdlOperation;
+import org.apache.beehive.controls.system.webservice.jaxrpc.ClientBindingLookupFactory;
+import org.apache.beehive.controls.system.webservice.ServiceControl;
import org.apache.beehive.webservice.utils.JavaClassUtils;
import org.apache.beehive.webservice.utils.databinding.BindingLookupStrategy;
-import org.apache.beehive.webservice.utils.databinding.AxisBindingLookupFactory;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
@@ -46,11 +47,6 @@
*/
public final class WebServiceControlGenerator {
- /*
- todo: it seems bad that the service control needs explicit knowledge of
- the type system used to implement the web service. Probably need to
- fix this.
- */
private static final FileFilter FILE_FILTER_WSDL = new WSDLFilter();
private static final String WSDL_FILE_EXTENSION = "wsdl";
private static final String SERVICE_CONTROL_FILE_EXTENSION = ".java";
@@ -273,10 +269,10 @@
}
/**
- *
- * @param xmlType
- * @param itemXmlType
- * @param isArray
+ * Find the class for the xmlType.
+ * @param xmlType XmlType to map to java class.
+ * @param itemXmlType If xmlType is an array type, itemXmlType specifies the component type of the array.
+ * @param isArray is xmlType an array type?
* @return The class which the xmlType maps to. void.class if xmlType is null.
*/
static private Class getClass(QName xmlType, QName itemXmlType, boolean isArray) {
@@ -285,7 +281,9 @@
return void.class;
}
- BindingLookupStrategy bindingLookupStrategy = (new AxisBindingLookupFactory()).getInstance();
+ // todo: if more jaxrpc client types are supported this the client type should become a parameter of the ant task
+ BindingLookupStrategy bindingLookupStrategy =
+ (new ClientBindingLookupFactory()).getInstance(ServiceControl.ServiceFactoryProviderType.APACHE_AXIS);
if (!isArray) {
return bindingLookupStrategy.qname2class(xmlType);
}
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java Fri Feb 24 13:11:18 2006
@@ -24,19 +24,28 @@
import javax.xml.namespace.QName;
import java.io.File;
-// todo: Add a bunch more JavaDoc on how this task works!
/**
- * The Webservice Control Generator task generates a web service control from a WSDL.
+ * The web service control generator Ant task generates a web service control from a WSDL.
+ * The following parameters are defined for this task:
+ * <ul>
+ * <li>copyWsdl, optional, defaults to false, if true WSDL file is copied to the same location as the generated control.</li>
+ * <li>destDir, required, Location of the generated control.</li>
+ * <li>destPackageName, optional, Java package name of the generated control.</li>
+ * <li>serviceName, optional, If not set the first service in the WSDL will be used to generate the control.</li>
+ * <li>serviceNamespace, optional, Used in conjunction with the serviceName parameter to specify a service in the WSDL.</li>
+ * <li>servicePort, optional, If not set the first port in the service will be used for control generation.</li>
+ * <li>srcDir, optional, If specfied all WSDL files in the directory will be processed. Either srcDir or srcFile must be set.</li>
+ * <li>srcFile, optional, If specified the WSDL file will be used to generate the control.</li>
+ * <li>wsdlRuntimePath, optional, Specifies the location of the WSDL for the control at runtime.</li>
+ * </ul>
+ *
* <xmp>
* <taskdef name="webservice-control-gen"
* classname="org.apache.beehive.controls.system.webservice.generate.ServiceControlGenerationTask"
* classpathref="wscgen.dependency.path"/>
* <p/>
* <p/>
- * <service-control-gen srcDir="${build.wsdls}"
- * destDir="${build.jcxgen}"
- * destPackageName="${pkg.name}"
- * wsdlRuntimePath=${annot}"/>
+ * <webservice-control-gen srcDir="${build.wsdls}" destDir="${build.jcxgen}" destPackageName="${pkg.name}"/>
* </xmp>
*/
public final class WebServiceControlGeneratorTask
Added: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java?rev=380816&view=auto
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java (added)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java Fri Feb 24 13:11:18 2006
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2006 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.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.system.webservice.jaxrpc;
+
+import org.apache.beehive.controls.system.webservice.ServiceControl;
+import org.apache.beehive.webservice.utils.databinding.BindingLookupFactory;
+import org.apache.beehive.webservice.utils.databinding.BindingLookupStrategy;
+import org.apache.beehive.webservice.utils.databinding.SchemaTypesLookupStrategy;
+import org.apache.beehive.webservice.utils.exception.BindingConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ */
+public class ClientBindingLookupFactory {
+
+ private static final Log LOG = LogFactory.getLog(ClientBindingLookupFactory.class);
+ private static final BindingLookupStrategy DEFAULT_STRATEGY = new SchemaTypesLookupStrategy();
+
+ public BindingLookupStrategy builtInTypes() {
+ return ClientBindingLookupFactory.DEFAULT_STRATEGY;
+ }
+
+ public BindingLookupStrategy getInstance(ServiceControl.ServiceFactoryProviderType hint) {
+
+ BindingLookupStrategy strategy;
+ Class factoryClass = null;
+
+ switch (hint) {
+ case APACHE_AXIS:
+ case DEFAULT:
+ try {
+ factoryClass = Class.forName("org.apache.beehive.webservice.utils.databinding.AxisBindingLookupFactory");
+ }
+ catch (ClassNotFoundException e) {
+ throw new BindingConfigurationException("Unable to locate binding lookup factory for AXIS 1.x", e);
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (factoryClass != null) {
+ strategy = createStrategy(factoryClass);
+ }
+ else {
+ strategy = ClientBindingLookupFactory.DEFAULT_STRATEGY;
+ }
+
+ assert strategy != null;
+ ClientBindingLookupFactory.LOG.debug("Using binding lookup strategy: " + strategy.getClass().getName());
+ return strategy;
+ }
+
+ private BindingLookupStrategy createStrategy(Class bindingLookupFactory) {
+ assert bindingLookupFactory != null;
+
+ BindingLookupStrategy strategy;
+ try {
+ BindingLookupFactory factory = (BindingLookupFactory) bindingLookupFactory.newInstance();
+ strategy = factory.getInstance();
+ }
+ catch (IllegalAccessException e) {
+ throw new BindingConfigurationException("Unable to create binding lookup from factory \"" + bindingLookupFactory + "\". Cause: " + e, e);
+ }
+ catch (InstantiationException e) {
+ throw new BindingConfigurationException("Unable to create binding lookup from factory \"" + bindingLookupFactory + "\". Cause: " + e, e);
+ }
+ return strategy;
+ }
+}
Propchange: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ClientBindingLookupFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java Fri Feb 24 13:11:18 2006
@@ -15,17 +15,6 @@
*/
package org.apache.beehive.controls.system.webservice.jaxrpc;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.Service;
-import javax.xml.rpc.ServiceException;
-import javax.xml.rpc.ServiceFactory;
-import javax.xml.rpc.handler.HandlerInfo;
-
import org.apache.beehive.controls.api.ControlException;
import org.apache.beehive.controls.api.bean.ControlImplementation;
import org.apache.beehive.controls.api.bean.Extensible;
@@ -33,22 +22,33 @@
import org.apache.beehive.controls.api.context.ResourceContext;
import org.apache.beehive.controls.api.events.EventHandler;
import org.apache.beehive.controls.system.webservice.ServiceControl;
+import org.apache.beehive.controls.system.webservice.wsdl.ControlWsdlLocator;
import org.apache.beehive.controls.system.webservice.wsdl.Wsdl;
import org.apache.beehive.controls.system.webservice.wsdl.WsdlOperation;
-import org.apache.beehive.controls.system.webservice.wsdl.ControlWsdlLocator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+import javax.xml.rpc.handler.HandlerInfo;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Web service control implementation class.
+ */
@ControlImplementation
public class ServiceControlImpl
- implements ServiceControl, Extensible, java.io.Serializable {
+ implements ServiceControl, Extensible, java.io.Serializable {
- private static final int TIMOUT_DEFAULT = 1000;
private static final Log LOGGER = LogFactory.getLog(ServiceControlImpl.class);
- //
// contexts provided by the beehive controls runtime
- //
@org.apache.beehive.controls.api.context.Context
protected ControlBeanContext _context;
@org.apache.beehive.controls.api.context.Context
@@ -56,13 +56,12 @@
private QName _portType;
private Wsdl _wsdl;
- private URL _endPoint;
- private QName _wsdlPort;
+ private URL _serviceEndpoint;
+// private QName _servicePortQName;
private QName _serviceName;
private String _username;
private String _password;
private String _serviceFactoryClassName;
- private int _timeout = TIMOUT_DEFAULT;
private List<HandlerInfo> _handlerChain;
private transient Service _service;
@@ -76,12 +75,14 @@
/**
* Invoked by the controls runtime when a new instance of this class is aquired by the runtime.
+ * Determine the JAX-RPC client type, and initialize the control.
*/
@EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onAcquire")
public void onAquire() {
- if (LOGGER.isDebugEnabled())
+ if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enter: onAquire()");
+ }
if (_service == null) {
ServiceControl.ServiceFactoryProvider sfp =
@@ -94,12 +95,14 @@
/**
* Invoked by the controls runtime when an instance of this class is released by the runtime.
+ * Release the service and clear the call cache.
*/
@EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onRelease")
public void onRelease() {
- if (LOGGER.isDebugEnabled())
+ if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enter: onRelease()");
+ }
_service = null;
_callCache = null;
@@ -124,12 +127,13 @@
GenericCall call;
if (getCallCache().containsKey(opName.value())) {
call = getCallCache().get(opName.value());
- } else {
+ }
+ else {
call = buildCallObject(method, op);
getCallCache().put(opName.value(), call);
}
- call.setUserDefinedProperties(getWsdlPort(),
+ call.setUserDefinedProperties(/*getServicePort()*/null,
getEndPoint().toExternalForm(),
getUsername(),
getPassword());
@@ -137,25 +141,30 @@
}
/**
- * @return Returns the endPoint.
+ * Get the service endpoint currently in use by this control.
+ *
+ * @return Returns the endpoint URL.
*/
public URL getEndPoint() {
- if (_endPoint == null) {
+ if (_serviceEndpoint == null) {
configureEndPoint();
}
- return _endPoint;
+ return _serviceEndpoint;
}
/**
+ * Set the service endpoint to be used by this control.
+ *
* @param endPoint The endPoint to set.
*/
public void setEndPoint(URL endPoint) {
- _endPoint = endPoint;
+ _serviceEndpoint = endPoint;
}
/**
- * Set a client side handler chain.
- * @param handlerChain
+ * Set a client side handler chain. Set to null to clear all previously set handlers.
+ *
+ * @param handlerChain A List of HandlerInfo objects.
*/
public void setHandlers(List<HandlerInfo> handlerChain) {
_handlerChain = handlerChain;
@@ -163,6 +172,9 @@
}
/**
+ * Get the password used for authentication with the web service.
+ * This value may only be set by the setPassword() method.
+ *
* @return Returns the password.
*/
public String getPassword() {
@@ -170,27 +182,18 @@
}
/**
- * @param password The password to set.
+ * Set the password used for authentication with the web service.
+ *
+ * @param password The password to set, null value to clear.
*/
public void setPassword(String password) {
_password = password;
}
/**
- * @return Returns the timeout.
- */
- public int getTimeout() {
- return _timeout;
- }
-
- /**
- * @param timeout The timeout to set.
- */
- public void setTimeout(int timeout) {
- _timeout = timeout;
- }
-
- /**
+ * Get the username for service authentication.
+ * Value may only be set by the setUsername() method.
+ *
* @return Returns the username.
*/
public String getUsername() {
@@ -198,38 +201,43 @@
}
/**
- * @param username The username to set.
+ * Set the username for service authentication.
+ *
+ * @param username The username to set, null value to clear.
*/
public void setUsername(String username) {
_username = username;
}
- /**
- * @return Returns the wsdlPort.
- */
- public QName getWsdlPort() {
- return _wsdlPort;
- }
-
- /**
- * @param wsdlPort The wsdlPort to set.
- */
- public void setWsdlPort(QName wsdlPort) {
- _wsdl.setPort(wsdlPort);
- _wsdlPort = wsdlPort;
- }
-
- /**
- *
- */
- public void reset() {
- _handlerChain = null;
- _endPoint = null;
- _wsdlPort = null;
- _username = null;
- _password = null;
- _timeout = TIMOUT_DEFAULT;
- }
+// /**
+// * Returns the name of the port that will be used by the web service control.
+// *
+// * @return Returns the QName of the service port.
+// */
+// public QName getServicePort() {
+// return _servicePortQName;
+// }
+//
+// /**
+// * Specifies the name for the port within the service which the web service control should use.
+// *
+// * @param servicePortName The wsdlPort to set.
+// */
+// public void setServicePort(QName servicePortName) {
+// _wsdl.setPort(servicePortName);
+// _servicePortQName = servicePortName;
+// }
+//
+// /**
+// *
+// */
+// public void reset() {
+// _handlerChain = null;
+// _serviceEndpoint = null;
+// _servicePortQName = null;
+// _username = null;
+// _password = null;
+// }
/* --------------------------------------------------------------------------------------- */
/* PRIVATE METHODS */
@@ -238,13 +246,12 @@
/**
* Build a call object for the specified web method.
*
- * @param method
- * @param op
- * @return Call
+ * @param method WSC method.
+ * @param op The WSDL operation which corresponds to the method.
+ * @return Call A JAX-RPC Call instance.
*/
private GenericCall buildCallObject(Method method, WsdlOperation op) {
-
ServiceControl.ServiceFactoryProviderType sfpt =
_context.getControlPropertySet(ServiceControl.ServiceFactoryProvider.class).value();
@@ -272,10 +279,11 @@
*/
private void configureEndPoint() {
- if (_endPoint == null) {
+ if (_serviceEndpoint == null) {
try {
setEndPoint(new URL(_wsdl.getServiceEndpoint()));
- } catch (MalformedURLException e) {
+ }
+ catch (MalformedURLException e) {
throw new ControlException(e.getMessage(), e);
}
}
@@ -284,7 +292,8 @@
/**
* The callCache is transient so may need to create a new one
* if a serialization has occured.
- * @return HashMap
+ *
+ * @return HashMap for call caching.
*/
private HashMap<String, GenericCall> getCallCache() {
if (_callCache == null) {
@@ -295,7 +304,7 @@
/**
* Get the service, service is transient so may need to create a new one
- * if a serialization has occurec.
+ * if a serialization has occurs.
*
* @param serviceName QName of service.
* @return Service
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/GenericHolder.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/GenericHolder.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/GenericHolder.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/GenericHolder.java Fri Feb 24 13:11:18 2006
@@ -22,7 +22,8 @@
import javax.xml.rpc.holders.Holder;
/**
- * Class that supports holding a value of some generic type.
+ * GenericHolder is a JAX-RPC Holder implementation for any class which does not
+ * have a holder type defined in the javax.xml.rpc.holders package.
*/
public class GenericHolder<T>
implements Holder {
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/HolderUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/HolderUtils.java?rev=380816&r1=380815&r2=380816&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/HolderUtils.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/utils/HolderUtils.java Fri Feb 24 13:11:18 2006
@@ -17,28 +17,29 @@
*/
package org.apache.beehive.controls.system.webservice.utils;
-import javax.xml.rpc.holders.Holder;
import javax.xml.namespace.QName;
+import javax.xml.rpc.holders.Holder;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-import java.math.BigDecimal;
-import java.math.BigInteger;
/**
- * Utilities for moving values into and out of jaxrpc Holders.
+ * Utilities for moving values into and out of JAX-RPC holders.
*/
public class HolderUtils {
private static Map<String, String> _holderMappings;
+
static {
_holderMappings = new HashMap<String, String>();
_holderMappings.put(BigDecimal.class.getName(), "javax.xml.rpc.holders.BigDecimalHolder");
@@ -53,20 +54,21 @@
_holderMappings.put(float.class.getName(), "javax.xml.rpc.holders.FloatHolder");
_holderMappings.put(Float.class.getName(), "javax.xml.rpc.holders.FloatWrapperHolder");
_holderMappings.put(Integer.class.getName(), "javax.xml.rpc.holders.IntegerWrapperHolder");
- _holderMappings.put(int.class.getName(), "javax.xml.rpc.holders.IntHolder");
+ _holderMappings.put(int.class.getName(), "javax.xml.rpc.holders.IntHolder");
_holderMappings.put(long.class.getName(), "javax.xml.rpc.holders.LongHolder");
_holderMappings.put(Long.class.getName(), "javax.xml.rpc.holders.LongWrapperHolder");
_holderMappings.put(QName.class.getName(), "javax.xml.rpc.holders.QNameHolder");
_holderMappings.put(short.class.getName(), "javax.xml.rpc.holders.ShortHolder");
- _holderMappings.put(Short.class.getName(), "javax.xml.rpc.holders.ShortWrapperHolder");
+ _holderMappings.put(Short.class.getName(), "javax.xml.rpc.holders.ShortWrapperHolder");
_holderMappings.put(String.class.getName(), "javax.xml.rpc.holders.StringHolder");
}
/**
- * Attempt to map a class name to a jax-rpc holder type. If a match cannot be found map
+ * Attempt to map a class name to a JAX-RPC holder type. If a match cannot be found map
* to the GenericHolder class.
+ *
* @param className Name of class.
- * @return String
+ * @return String Fully qualified name of JAX-RPC holder for class name.
*/
public static String getHolderForClass(String className) {
if (_holderMappings.containsKey(className)) {
@@ -138,9 +140,9 @@
else if (t instanceof Class) {
if (Holder.class.isAssignableFrom((Class) t)) {
Field[] publicFields = ((Class) t).getFields();
- for (int i = 0; i < publicFields.length; i++) {
- if (publicFields[i].getName().equals("value")) {
- return publicFields[i].getType();
+ for (Field field : publicFields) {
+ if (field.getName().equals("value")) {
+ return field.getType();
}
}
}
@@ -155,7 +157,7 @@
* Set the field value in the specified object.
*
* @param valueField Field to set.
- * @param destObject Object.
+ * @param destObject The destination object.
* @param value Field value.
* @throws IllegalArgumentException
* @throws IllegalAccessException
@@ -165,7 +167,7 @@
if (valueField.getType().isPrimitive()) {
if (value == null) {
- ; // Don't need to set anything
+ // Don't need to set anything
}
else {
valueField.set(destObject, value);
@@ -179,8 +181,8 @@
/**
* Convert value to the class of the holder field value.
*
- * @param value
- * @param classOfValueFieldInHolder
+ * @param value Value to convert.
+ * @param classOfValueFieldInHolder Target to convert value to.
* @return The converted value, null if value cannot be converted.
*/
private static Object convertToHolderType(Object value, Class classOfValueFieldInHolder) {