axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/test/wsdd PackageTests.java
Date Mon, 12 Nov 2001 16:04:06 GMT
gdaniels    01/11/12 08:04:06

  Modified:    java/src/org/apache/axis/deployment/wsdd WSDDChain.java
                        WSDDDeployableItem.java
                        WSDDGlobalConfiguration.java WSDDHandler.java
                        WSDDService.java WSDDTargetedChain.java
               java/test/wsdd PackageTests.java
  Log:
  Add "scope" option for WSDD deployable items.  Default scope
  right now is hardcoded to "singleton", which gets you the exact same
  object every time you ask for one.   Setting the scope attribute on a
  <handler>, <chain>, <transport>, or <service> deployment to "per-access"
  will instead return a brand new copy each time one is asked for.
  
  Add unit tests for this.
  
  TODO: Support a "request" scope which will allow one instance per
  MessageContext, and a "session" scope which will allow one instance
  per Axis session.
  
  Revision  Changes    Path
  1.17      +1 -1      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDChain.java
  
  Index: WSDDChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDChain.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WSDDChain.java	2001/11/07 21:04:20	1.16
  +++ WSDDChain.java	2001/11/12 16:04:06	1.17
  @@ -158,7 +158,7 @@
        * @return XXX
        * @throws Exception XXX
        */
  -    public Handler getInstance(DeploymentRegistry registry)
  +    public Handler makeNewInstance(DeploymentRegistry registry)
           throws Exception
       {
           try {
  
  
  
  1.17      +40 -3     xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployableItem.java
  
  Index: WSDDDeployableItem.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployableItem.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WSDDDeployableItem.java	2001/11/07 21:04:20	1.16
  +++ WSDDDeployableItem.java	2001/11/12 16:04:06	1.17
  @@ -80,6 +80,13 @@
       extends WSDDElement
       implements DeployableItem
   {
  +    public static final int SCOPE_PER_ACCESS = 0;
  +    public static final int SCOPE_PER_REQUEST = 1;
  +    public static final int SCOPE_SINGLETON = 2;
  +    public static String [] scopeStrings = { "per-access",
  +                                             "per-request",
  +                                             "singleton" };
  +    
       /** Our parameters */
       LockableHashtable parameters;
   
  @@ -88,6 +95,12 @@
       
       /** Our type */
       QName type;
  +    
  +    /** Scope for this item (default is singleton) */
  +    int scope = SCOPE_SINGLETON;
  +    
  +    /** Placeholder for hanging on to singleton object */
  +    Handler singletonInstance = null;
   
       /**
        * Default constructor
  @@ -118,6 +131,19 @@
           String typeStr = e.getAttribute("type");
           if (typeStr != null && !typeStr.equals(""))
               type = XMLUtils.getQNameFromString(typeStr, e);
  +        
  +        // Figure out our scope - right now if a non-recognized scope
  +        // attribute appears, we will ignore it and use the default
  +        // scope.  Is this right, or should we throw an error?
  +        String scopeStr = e.getAttribute("scope");
  +        if (scopeStr != null) {
  +            for (int i = 0; i < scopeStrings.length; i++) {
  +                if (scopeStr.equals(scopeStrings[i])) {
  +                    scope = i;
  +                    break;
  +                }
  +            }
  +        }
   
           if (parameters == null)
               parameters = new LockableHashtable();
  @@ -257,8 +283,19 @@
        * @return XXX
        * @throws Exception XXX
        */
  -    abstract public Handler getInstance(DeploymentRegistry registry)
  -        throws Exception;
  +    public final Handler getInstance(DeploymentRegistry registry)
  +        throws Exception
  +    {
  +        if (scope == SCOPE_SINGLETON) {
  +            synchronized (this) {
  +                if (singletonInstance == null)
  +                    singletonInstance = makeNewInstance(registry);
  +            }
  +            return singletonInstance;
  +        }
  +        
  +        return makeNewInstance(registry);
  +    }
   
       /**
        * Creates a new instance of this deployable.  if the
  @@ -268,7 +305,7 @@
        * @return XXX
        * @throws Exception XXX
        */
  -    Handler makeNewInstance(DeploymentRegistry registry)
  +    protected Handler makeNewInstance(DeploymentRegistry registry)
           throws Exception
       {
           try {
  
  
  
  1.15      +1 -1      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDGlobalConfiguration.java
  
  Index: WSDDGlobalConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDGlobalConfiguration.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WSDDGlobalConfiguration.java	2001/11/07 21:04:20	1.14
  +++ WSDDGlobalConfiguration.java	2001/11/12 16:04:06	1.15
  @@ -166,7 +166,7 @@
        * @param registry XXX
        * @return XXX
        */
  -    public Handler getInstance(DeploymentRegistry registry)
  +    public Handler makeNewInstance(DeploymentRegistry registry)
       {
           return null;
       }
  
  
  
  1.10      +0 -12     xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDHandler.java
  
  Index: WSDDHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WSDDHandler.java	2001/11/07 21:04:20	1.9
  +++ WSDDHandler.java	2001/11/12 16:04:06	1.10
  @@ -112,16 +112,4 @@
           writeParamsToContext(context);
           context.endElement();
       }
  -
  -    /**
  -     *
  -     * @param registry XXX
  -     * @return XXX
  -     * @throws Exception XXX
  -     */
  -    public Handler getInstance(DeploymentRegistry registry)
  -        throws Exception
  -    {
  -        return makeNewInstance(registry);
  -    }
   }
  
  
  
  1.22      +1 -1      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
  
  Index: WSDDService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- WSDDService.java	2001/11/09 23:13:01	1.21
  +++ WSDDService.java	2001/11/12 16:04:06	1.22
  @@ -191,7 +191,7 @@
        * @return XXX
        * @throws Exception XXX
        */
  -    public Handler getInstance(DeploymentRegistry registry)
  +    public Handler makeNewInstance(DeploymentRegistry registry)
           throws Exception
       {
           if (cachedService != null) {
  
  
  
  1.2       +1 -1      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java
  
  Index: WSDDTargetedChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSDDTargetedChain.java	2001/11/07 21:04:20	1.1
  +++ WSDDTargetedChain.java	2001/11/12 16:04:06	1.2
  @@ -182,7 +182,7 @@
        * @return XXX
        * @throws Exception XXX
        */
  -    public Handler getInstance(DeploymentRegistry registry)
  +    public Handler makeNewInstance(DeploymentRegistry registry)
           throws Exception
       {
           TargetedChain c = new org.apache.axis.SimpleTargetedChain();
  
  
  
  1.2       +1 -0      xml-axis/java/test/wsdd/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdd/PackageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTests.java	2001/11/09 18:44:23	1.1
  +++ PackageTests.java	2001/11/12 16:04:06	1.2
  @@ -17,6 +17,7 @@
           TestSuite suite = new TestSuite();
   
           suite.addTestSuite(TestGlobalConfiguration.class);
  +        suite.addTestSuite(TestScopeOption.class);
           
           return suite;
       }
  
  
  

Mime
View raw message