You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2008/03/04 18:51:14 UTC
svn commit: r633569 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments:
./ impl/ lifecycle/ lifecycle/impl/
Author: dims
Date: Tue Mar 4 09:51:05 2008
New Revision: 633569
URL: http://svn.apache.org/viewvc?rev=633569&view=rev
Log:
getting started on AXIS2-3566. trying to set/create an instance of LifecycleManager in attachments and propagate it everywhere it is needed.
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/LifecycleManagerFactory.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartOnFile.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/FileAccessor.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java?rev=633569&r1=633568&r2=633569&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java Tue Mar 4 09:51:05 2008
@@ -20,7 +20,8 @@
package org.apache.axiom.attachments;
import org.apache.axiom.attachments.impl.PartFactory;
-import org.apache.axiom.attachments.lifecycle.LifecycleManagerFactory;
+import org.apache.axiom.attachments.lifecycle.LifecycleManager;
+import org.apache.axiom.attachments.lifecycle.impl.LifecycleManagerImpl;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.om.util.UUIDGenerator;
@@ -31,7 +32,6 @@
import javax.mail.MessagingException;
import javax.mail.internet.ContentType;
import javax.mail.internet.ParseException;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
@@ -110,16 +110,19 @@
private int fileStorageThreshold;
- private static LifecycleManagerFactory lmf = new LifecycleManagerFactory();
+ private LifecycleManager manager;
protected static Log log = LogFactory.getLog(Attachments.class);
- public static LifecycleManagerFactory getLifcycleManagerFactory() {
- return lmf;
+ public LifecycleManager getLifecycleManager() {
+ if(manager == null) {
+ manager = new LifecycleManagerImpl();
+ }
+ return manager;
}
- public static void setlifeCycleManagerFactory(LifecycleManagerFactory lifeCycleManagerFactory) {
- lmf = lifeCycleManagerFactory;
+ public void setLifecycleManager(LifecycleManager manager) {
+ this.manager = manager;
}
/**
@@ -573,7 +576,7 @@
PUSHBACK_SIZE);
// The PartFactory will determine which Part implementation is most appropriate.
- Part part = PartFactory.createPart(partStream,
+ Part part = PartFactory.createPart(getLifecycleManager(), partStream,
isSOAPPart,
threshhold,
attachmentRepoDir,
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java?rev=633569&r1=633568&r2=633569&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java Tue Mar 4 09:51:05 2008
@@ -20,6 +20,7 @@
import org.apache.axiom.attachments.MIMEBodyPartInputStream;
import org.apache.axiom.attachments.Part;
+import org.apache.axiom.attachments.lifecycle.LifecycleManager;
import org.apache.axiom.attachments.utils.BAAInputStream;
import org.apache.axiom.attachments.utils.BAAOutputStream;
import org.apache.axiom.om.OMException;
@@ -61,7 +62,7 @@
* @return Part
* @throws OMException if any exception is encountered while processing.
*/
- public static Part createPart(MIMEBodyPartInputStream in,
+ public static Part createPart(LifecycleManager manager, MIMEBodyPartInputStream in,
boolean isSOAPPart,
int threshholdSize,
String attachmentDir,
@@ -113,7 +114,7 @@
BAAInputStream baais =
new BAAInputStream(baaos.buffers(), baaos.length());
- return new PartOnFile(headers,
+ return new PartOnFile(manager, headers,
baais,
in,
attachmentDir);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartOnFile.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartOnFile.java?rev=633569&r1=633568&r2=633569&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartOnFile.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartOnFile.java Tue Mar 4 09:51:05 2008
@@ -18,18 +18,16 @@
*/
package org.apache.axiom.attachments.impl;
+import org.apache.axiom.attachments.lifecycle.LifecycleManager;
+import org.apache.axiom.attachments.lifecycle.impl.FileAccessor;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Hashtable;
-import javax.activation.DataHandler;
-import javax.mail.MessagingException;
-
-import org.apache.axiom.attachments.lifecycle.LifecycleManager;
-import org.apache.axiom.attachments.lifecycle.LifecycleManagerFactory;
-import org.apache.axiom.attachments.lifecycle.impl.FileAccessor;
-
/**
* PartOnFile stores that attachment in a file.
* This implementation is used for very large attachments to reduce
@@ -41,6 +39,7 @@
public class PartOnFile extends AbstractPart {
FileAccessor fileAccessor;
+ LifecycleManager manager;
/**
@@ -50,10 +49,9 @@
* @param in2 InputStream containing data
* @param attachmentDir String
*/
- PartOnFile(Hashtable headers, InputStream is1, InputStream is2, String attachmentDir) throws IOException {
+ PartOnFile(LifecycleManager manager, Hashtable headers, InputStream is1, InputStream is2, String attachmentDir) throws IOException {
super(headers);
- LifecycleManager lm = LifecycleManagerFactory.getLifeCycleManager();
- fileAccessor = lm.create(attachmentDir);
+ fileAccessor = manager.create(attachmentDir);
// Now write the data to the backing file
OutputStream fos = fileAccessor.getOutputStream();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/FileAccessor.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/FileAccessor.java?rev=633569&r1=633568&r2=633569&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/FileAccessor.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/FileAccessor.java Tue Mar 4 09:51:05 2008
@@ -21,13 +21,11 @@
import org.apache.axiom.attachments.CachedFileDataSource;
import org.apache.axiom.attachments.lifecycle.LifecycleManager;
-import org.apache.axiom.attachments.lifecycle.LifecycleManagerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.activation.DataHandler;
import javax.mail.MessagingException;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -47,10 +45,13 @@
private static final Log log = LogFactory.getLog(FileAccessor.class);
File file = null;
String id = null;
+ LifecycleManager manager;
+
//TODO remove hard coded time interval, 30 mins/1800 secs
private final static int DELETE_INTERVAL = 1800;
- public FileAccessor(File file, String id) {
+ public FileAccessor(LifecycleManager manager, File file, String id) {
super();
+ this.manager = manager;
this.file = file;
this.id = id;
}
@@ -90,7 +91,6 @@
}
public void handleEvent(int eventId) throws IOException {
- LifecycleManager manager = LifecycleManagerFactory.getLifeCycleManager();
switch (eventId) {
case LifecycleEventDefinitions.DELETE_ON_EXIT:
manager.deleteOnExit(id);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java?rev=633569&r1=633568&r2=633569&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java Tue Mar 4 09:51:05 2008
@@ -34,7 +34,7 @@
private Map table = new Hashtable();
public static LifecycleManager manager = new LifecycleManagerImpl();
- protected LifecycleManagerImpl() {
+ public LifecycleManagerImpl() {
super();
}
@@ -68,7 +68,7 @@
file = new File(dir, fileString);
//add the file to table
table.put(id, file);
- FileAccessor fa = new FileAccessor(file, id);
+ FileAccessor fa = new FileAccessor(manager, file, id);
//TODO: change deleteOnExit call such that it's sent as an event to
//LifecycleEventHandler. example fa.handleEvent(LifeCycleDefinition.DELETE_ON_EXIT)
//This is the default behaviour. Delete file on VM Exit.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org