Author: aslom
Date: Mon Nov 28 14:02:42 2005
New Revision: 349519
URL: http://svn.apache.org/viewcvs?rev=349519&view=rev
Log:
applied ptach provided by Andrzej Taramina for
WSIF-80 - Support for Singletons in Java Provider
http://issues.apache.org/jira/browse/WSIF-81?page=all
WSIF-81 - Service caching fixes/enhancements
http://issues.apache.org/jira/browse/WSIF-80?page=all
Modified:
webservices/wsif/trunk/java/build.xml
webservices/wsif/trunk/java/src/org/apache/wsif/WSIFServiceFactory.java
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceCache.java
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceFactoryImpl.java
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java
Modified: webservices/wsif/trunk/java/build.xml
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/build.xml?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
--- webservices/wsif/trunk/java/build.xml (original)
+++ webservices/wsif/trunk/java/build.xml Mon Nov 28 14:02:42 2005
@@ -48,9 +48,9 @@
<property name="name" value="wsif"/>
<property name="dynamic.name" value="wsif-dynamic"/>
<property name="Name" value="wsif"/>
- <property name="wsif.version" value="2.0.1_IB3"/>
+ <property name="wsif.version" value="2.0.1_IB4"/>
<property name="year-from" value="2002"/>
- <property name="year-to" value="2004"/>
+ <property name="year-to" value="2005"/>
<property name="version.postfix" value="-${wsif.version}"/>
<property name="javadoc.title" value="${Name}"/>
Modified:
webservices/wsif/trunk/java/src/org/apache/wsif/WSIFServiceFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/src/org/apache/wsif/WSIFServiceFactory.java?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
--- webservices/wsif/trunk/java/src/org/apache/wsif/WSIFServiceFactory.java
(original)
+++ webservices/wsif/trunk/java/src/org/apache/wsif/WSIFServiceFactory.java Mon
Nov 28 14:02:42 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2003,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.
@@ -36,13 +36,14 @@
/**
* Abstract factory class to create instances of WSIFService. Call newInstance
* to get a instance of the factory.
- *
+ *
* @author Mark Whitlock
* @author Owen Burroughs
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andrzej Taramina</a>
*/
public abstract class WSIFServiceFactory {
- /**
+ /**
* Creates a new instance of an implementation the abstract
* WSIFServiceFactory class.
*/
@@ -125,20 +126,27 @@
String portTypeNS,
String portTypeName)
throws WSIFException;
-
+
/**
* Set caching on services on/off. Off is the default
* @param on Flag to indicate whether or not caching of services should be
used
* @deprecated Use
<code>setFeature(WSIFConstants.WSIF_FEATURE_SERVICE_CACHING, new
Boolean(true))</code>
* or <code>setFeature(WSIFConstants.WSIF_FEATURE_SERVICE_CACHING, new
Boolean(false))</code> instead
- */
+ */
public void cachingOn(boolean on) {
- }
-
+ }
+
+ /**
+ * Clear out the service cache. Useful if wsdl definitions can change
during runtime operations.
+ */
+ public void clearServiceCache()
+ {
+ }
+
/**
* Set a feature on the WSIFServiceFactory. The names of supported
features are stored as constants
- * in the [EMAIL PROTECTED] WSIFConstants} class. The names of these
constants have a convention of starting
- * <code>WSIF_FEATURE_</code>.
+ * in the [EMAIL PROTECTED] WSIFConstants} class. The names of these
constants have a convention of starting
+ * <code>WSIF_FEATURE_</code>.
* For more information about individual features, see the field details
for the feature constants.
* <br><br><b>Note:</b> features should be set before calls to the
getService methods.<br>
* @param name The name of the feature to set
@@ -150,23 +158,23 @@
* Set features on the WSIFServiceFactory. Calling this method will
replace the currently set features
* with those configured in the Map passed in.
* The names of supported features are stored as constants
- * in the [EMAIL PROTECTED] WSIFConstants} class. The names of these
constants have a convention of starting
- * <code>WSIF_FEATURE_</code>.
+ * in the [EMAIL PROTECTED] WSIFConstants} class. The names of these
constants have a convention of starting
+ * <code>WSIF_FEATURE_</code>.
* For more information about individual features, see the field details
for the feature constants.
* <br><br><b>Note:</b> features should be set before calls to the
getService methods.<br>
* @param map A Map containing all the features to set on the factory
- */
+ */
public abstract void setFeatures(Map map);
/**
* Get the map of features currently being used by the factory.
* @return The map of features
- */
+ */
public abstract Map getFeatures();
/**
* Get the value for a feature currently being used by the factory.
* @return The feature value
- */
- public abstract Object getFeature(String name);
+ */
+ public abstract Object getFeature(String name);
}
Modified:
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceCache.java
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceCache.java?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
--- webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceCache.java
(original)
+++ webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceCache.java
Mon Nov 28 14:02:42 2005
@@ -34,6 +34,7 @@
*
* @author Paul Harris
* @author Owen Burroughs
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andrzej Taramina</a>
*/
public class WSIFServiceCache extends Hashtable {
@@ -64,14 +65,12 @@
+ cushionSize);
}
- public void setCacheSize(int newSize) {
- synchronized (this) {
+ public synchronized void setCacheSize(int newSize) {
cacheLimit = newSize;
cushionSize = ((cacheLimit * CUSHION_PERCENT) / 100);
- }
}
- public Object put(Object key, Object value) {
+ public synchronized Object put(Object key, Object value) {
LRUWrapper newObject = new LRUWrapper(key, value);
if (currentSize >= cacheLimit)
@@ -93,7 +92,7 @@
return newObject.value; //to make this consistent with Hashtable
}
- public Object get(Object key) {
+ public synchronized Object get(Object key) {
LRUWrapper tempObject = (LRUWrapper) super.get(key);
//Adjust the LRU list
@@ -113,6 +112,18 @@
return tempObject.value;
}
}
+
+
+ public synchronized void clear()
+ {
+ oldestObject = null;
+ newestObject = null;
+
+ currentSize = 0;
+
+ super.clear();
+ }
+
private void addToTopOfLRUList(LRUWrapper newObject) {
newestObject.nextObject = newObject;
@@ -146,6 +157,7 @@
"WSIFServiceCache (put). Cache size after shrinkage: "
+ currentSize);
}
+
/**
* This class wraps whatever we're caching with some references used in a
double linked list.
Modified:
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceFactoryImpl.java
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceFactoryImpl.java?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
---
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceFactoryImpl.java
(original)
+++
webservices/wsif/trunk/java/src/org/apache/wsif/base/WSIFServiceFactoryImpl.java
Mon Nov 28 14:02:42 2005
@@ -355,6 +355,19 @@
setFeature(WSIFConstants.WSIF_FEATURE_SERVICE_CACHING, new
Boolean(on));
Trc.exit();
}
+
+
+ /**
+ * Clear out the service cache. Useful if wsdl definitions can change
during runtime operations.
+ */
+ public void clearServiceCache()
+ {
+ Trc.entry( this );
+
+ cache.clear();
+
+ Trc.exit();
+ }
/**
* @see org.apache.wsif.WSIFServiceFactory#setFeature(String, Object)
Modified:
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
---
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
(original)
+++
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
Mon Nov 28 14:02:42 2005
@@ -67,6 +67,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Gerhard Pfau</a>
* @author Owen Burroughs <[EMAIL PROTECTED]>
* @author Jeremy Hughes <[EMAIL PROTECTED]>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andrzej Taramina</a>
*/
public class WSIFOperation_Java
extends WSIFDefaultOperation
@@ -88,6 +89,7 @@
protected String fieldOutputMessageName = null;
protected boolean fieldIsStatic = false;
protected boolean fieldIsConstructor = false;
+ protected boolean fieldIsSingleton = false;
protected Map fieldTypeMaps = null;
protected boolean multiOutParts = false;
transient private Object returnClass = null;
@@ -141,6 +143,9 @@
fieldIsConstructor = true;
fieldConstructors = getConstructors();
} else {
+ if ("singleton".equals(methodType)) {
+ fieldIsSingleton = true;
+ }
// Assume instance method...
fieldMethods = getMethods(allMethods);
}
@@ -162,6 +167,7 @@
String outMName,
boolean isSttc,
boolean isCnstr,
+ boolean isSingle,
Map tMap,
boolean mulOP,
Object retCl) {
@@ -194,6 +200,7 @@
fieldOutputMessageName = outMName;
fieldIsStatic = isSttc;
fieldIsConstructor = isCnstr;
+ fieldIsSingleton = isSingle;
fieldTypeMaps = tMap;
multiOutParts = mulOP;
returnClass = retCl;
@@ -222,6 +229,7 @@
fieldOutputMessageName,
fieldIsStatic,
fieldIsConstructor,
+ fieldIsSingleton,
fieldTypeMaps,
multiOutParts,
returnClass);
@@ -1162,7 +1170,7 @@
break;
// Parts are compatible so invoke the method with
the compatible set
- Object objRef = fieldPort.getObjectReference();
+ Object objRef = fieldPort.getObjectReference(
fieldIsSingleton );
Trc.event(
this,
"Invoking object ",
@@ -1557,7 +1565,7 @@
break;
// Parts are compatible so invoke the method with
the compatible set
- Object objRef = fieldPort.getObjectReference();
+ Object objRef = fieldPort.getObjectReference(
fieldIsSingleton );
Trc.event(
this,
"Invoking object ",
Modified:
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java
URL:
http://svn.apache.org/viewcvs/webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java?rev=349519&r1=349518&r2=349519&view=diff
==============================================================================
---
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java
(original)
+++
webservices/wsif/trunk/java/src/org/apache/wsif/providers/java/WSIFPort_Java.java
Mon Nov 28 14:02:42 2005
@@ -30,6 +30,7 @@
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -65,6 +66,7 @@
* @author Owen Burroughs <[EMAIL PROTECTED]>
* @author Jeremy Hughes <[EMAIL PROTECTED]>
* @author <a href="mailto:[EMAIL PROTECTED]">Ant Elder</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andrzej Taramina</a>
*/
public class WSIFPort_Java extends WSIFDefaultPort implements Serializable {
@@ -280,12 +282,21 @@
* Gets the service object.
* @return Object the service object instance
*/
- public Object getObjectReference() throws WSIFException {
+ public Object getObjectReference( boolean getSingleton ) throws
WSIFException {
Trc.entry(this);
if (fieldObjectReference == null) {
Class c = getServiceObjectClass();
try {
- fieldObjectReference = c.newInstance();
+ if( getSingleton ) {
+ Method getInstanceMethod = c.getMethod(
"getInstance", null );
+ if( Modifier.isStatic(
getInstanceMethod.getModifiers() ) && getInstanceMethod.getReturnType() == c &&
getInstanceMethod.getParameterTypes().length == 0 ) {
+ fieldObjectReference =
getInstanceMethod.invoke( null, null );
+ } else {
+ throw( new
NoSuchMethodException( "Static getInstance() method not found in class: " +
c.getName() ) );
+ }
+ } else {
+ fieldObjectReference = c.newInstance();
+ }
} catch (Exception ex) {
Trc.exception(ex);
throw new WSIFException(