Author: dims
Date: Tue Mar  4 11:13:31 2008
New Revision: 633594

URL: http://svn.apache.org/viewvc?rev=633594&view=rev
Log:
First pass at AXIS2-3566 - Ability to plugin a new Axiom LifecycleManager via 
axis2.xml

Modified:
    
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
    
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java

Modified: 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?rev=633594&r1=633593&r2=633594&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
 Tue Mar  4 11:13:31 2008
@@ -20,6 +20,7 @@
 package org.apache.axis2.builder;
 
 import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.attachments.lifecycle.LifecycleManager;
 import org.apache.axiom.attachments.utils.IOUtils;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
@@ -42,6 +43,7 @@
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisMessage;
 import org.apache.axis2.description.AxisOperation;
@@ -521,31 +523,45 @@
                 }
             }
         }
-        Attachments attachments = null;
-        if (contentLength > 0) {
-            if (log.isDebugEnabled()) {
+        if (log.isDebugEnabled()) {
+            if (contentLength > 0) {
                 log.debug("Creating an Attachments map.  The content-length 
is" + contentLength);
-            }
-            attachments =
-                new Attachments(inStream,
-                                contentTypeString,
-                                fileCacheForAttachments,
-                                attachmentRepoDir,
-                                attachmentSizeThreshold,
-                                contentLength);
-        } else {
-            if (log.isDebugEnabled()) {
+            } else {
                 log.debug("Creating an Attachments map.");
             }
-            attachments =
-                new Attachments(inStream,
-                                contentTypeString,
-                                fileCacheForAttachments,
-                                attachmentRepoDir,
-                                attachmentSizeThreshold);
         }
-
-        return attachments;
+        return createAttachments(msgContext,
+                inStream,
+                contentTypeString,
+                fileCacheForAttachments,
+                attachmentRepoDir,
+                attachmentSizeThreshold,
+                contentLength);
+    }
+
+    public static Attachments createAttachments(MessageContext msgContext, 
+                                                 InputStream inStream,
+                                                 String contentTypeString,
+                                                 boolean 
fileCacheForAttachments,
+                                                 String attachmentRepoDir,
+                                                 String 
attachmentSizeThreshold,
+                                                 int contentLength) {
+        LifecycleManager manager = null;
+        try {
+            manager = (LifecycleManager) 
msgContext.getRootContext().getAxisConfiguration()
+                    
.getParameterValue(DeploymentConstants.ATTACHMENTS_LIFECYCLE_MANAGER);
+        } catch (Exception e){
+            if(log.isDebugEnabled()){
+                log.debug("Exception getting Attachments LifecycleManager", e);
+            }
+        }
+        return new Attachments(manager, 
+                            inStream,
+                            contentTypeString,
+                            fileCacheForAttachments,
+                            attachmentRepoDir,
+                            attachmentSizeThreshold,
+                            contentLength);
     }
 
     /**

Modified: 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=633594&r1=633593&r2=633594&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
 Tue Mar  4 11:13:31 2008
@@ -23,6 +23,7 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.RolePlayer;
+import org.apache.axiom.attachments.lifecycle.LifecycleManager;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.builder.ApplicationXMLBuilder;
@@ -232,6 +233,15 @@
             if (deployerItr != null) {
                 processDeployers(deployerItr);
             }
+
+            //process Attachments Lifecycle manager configuration
+            OMElement attachmentsLifecycleManagerElement =
+                    config_element
+                            .getFirstChildWithName(new 
QName(ATTACHMENTS_LIFECYCLE_MANAGER));
+
+            if (attachmentsLifecycleManagerElement != null) {
+                processAttachmentsLifecycleManager(axisConfig, 
attachmentsLifecycleManagerElement);
+            }
         } catch (XMLStreamException e) {
             throw new DeploymentException(e);
         }
@@ -256,6 +266,21 @@
                                         e.getMessage());
                     }
                 }
+            }
+        }
+    }
+
+    private void processAttachmentsLifecycleManager(AxisConfiguration 
axisConfig, OMElement element) {
+        String className = element.getAttributeValue(new 
QName(TAG_CLASS_NAME));
+        try {
+            Class classInstance = Loader.loadClass(className);
+            LifecycleManager manager = (LifecycleManager) 
classInstance.newInstance();
+            
axisConfig.addParameter(DeploymentConstants.ATTACHMENTS_LIFECYCLE_MANAGER, 
manager);
+        } catch (Exception e) {
+            if (log.isTraceEnabled()) {
+                log.trace(
+                        "processAttachmentsLifecycleManager: Exception thrown 
initialising LifecycleManager: " +
+                                e.getMessage());
             }
         }
     }

Modified: 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=633594&r1=633593&r2=633594&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
 Tue Mar  4 11:13:31 2008
@@ -112,6 +112,9 @@
     String EXTENSION = "extension";
     String DEPLOYER = "deployer";
 
+    //Attachments LifecycleManager 
+    String ATTACHMENTS_LIFECYCLE_MANAGER = "attachmentsLifecycleManager";
+
     // for parameters
     String ATTRIBUTE_NAME = "name";
     String ATTRIBUTE_WSADDRESSING = "wsaddressing";



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to