You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/04/19 13:56:05 UTC

svn commit: r161875 - in webservices/axis/trunk/java/modules/core: src/org/apache/axis/engine/ src/org/apache/axis/storage/ src/org/apache/axis/storage/impl/ test/org/apache/axis/storage/ test/org/apache/axis/storage/impl/

Author: ajith
Date: Tue Apr 19 04:56:03 2005
New Revision: 161875

URL: http://svn.apache.org/viewcvs?view=rev&rev=161875
Log:
Adding the storages. Note that file storage is not complete yet!

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/AxisStorage.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AbstractStorage.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisFileStorage.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisMemoryStorage.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AbstractStorageTest.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisFileStorageTest.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisMemoryStorageTest.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/EngineConfiguration.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/EngineConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/EngineConfiguration.java?view=diff&r1=161874&r2=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/EngineConfiguration.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/EngineConfiguration.java Tue Apr 19 04:56:03 2005
@@ -130,7 +130,6 @@
     public  void addTransportIn(AxisTransportIn transport) throws AxisFault;
     public AxisTransportOut getTransportOut(QName name) throws AxisFault ;
     public  void addTransportOut(AxisTransportOut transport) throws AxisFault ;
-
     public HashMap getTransportsIn();
     public HashMap getTransportsOut();
 

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/AxisStorage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/AxisStorage.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/AxisStorage.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/AxisStorage.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,48 @@
+package org.apache.axis.storage;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public interface AxisStorage {
+
+    /**
+     * puts a value to the storage
+     * @param value
+     * @return the key as an Object
+     */
+    Object put(Object value);
+
+    /**
+     * get a value from the storage. The value is not removed
+     * @param key
+     * @return the value as an Object
+     */
+    Object get(Object key);
+
+    /**
+     * Removes an object from the storage given the key.
+     * @param key
+     * @return the value being removed as an object
+     */
+    Object remove(Object key);
+
+    /**
+     * Cleans the whole storage.
+     * @return a boolean saying whether the clean was successful or not
+     */
+    boolean clean();
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AbstractStorage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AbstractStorage.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AbstractStorage.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AbstractStorage.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,32 @@
+package org.apache.axis.storage.impl;
+
+import org.apache.axis.storage.AxisStorage;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public abstract class AbstractStorage implements AxisStorage{
+
+     private static int key=0;
+
+     protected String getUniqueKey(){
+        if (key==Integer.MAX_VALUE){
+            key=0;
+        }
+        return Integer.toString(key++);
+    }
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisFileStorage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisFileStorage.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisFileStorage.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisFileStorage.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,105 @@
+package org.apache.axis.storage.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectOutput;
+import java.util.Properties;
+import java.util.HashMap;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public class AxisFileStorage extends AbstractStorage{
+
+    private File file;
+    private FileOutputStream fos;
+    private HashMap map;
+
+    public AxisFileStorage() {
+        map = new HashMap();
+    }
+
+    public AxisFileStorage(File file) {
+        this();
+        this.setFile(file);
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public void setFile(File file) {
+        try {
+            this.file = file;
+            this.fos = new FileOutputStream(file);
+        } catch (FileNotFoundException e) {
+            throw new UnsupportedOperationException("No such file!");
+        }
+    }
+
+    public Object put(Object value) {
+
+        try {
+            String key = getUniqueKey();
+            map.put(key,value);
+
+            updateFileState();
+
+            return key;
+        } catch (IOException e) {
+            throw new UnsupportedOperationException(e.getMessage());
+        } catch (Exception e) {
+            throw new UnsupportedOperationException(e.getMessage());
+        }
+
+    }
+
+    public Object get(Object key) {
+        return map.get(key);
+    }
+
+    public Object remove(Object key) {
+        try {
+            Object objToRemove = map.remove(key);
+
+            updateFileState();
+
+            return objToRemove;
+        } catch (IOException e) {
+            throw new UnsupportedOperationException(" file writing failed!");
+        }
+    }
+
+    private void updateFileState() throws IOException {
+//        ObjectOutput out = new ObjectOutputStream(fos);
+//        out.writeObject(map);
+//        out.close();
+    }
+
+    public boolean clean() {
+       try {
+            map.clear();
+            updateFileState();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisMemoryStorage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisMemoryStorage.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisMemoryStorage.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/storage/impl/AxisMemoryStorage.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,58 @@
+package org.apache.axis.storage.impl;
+import java.util.HashMap;
+
+/*
+* Copyright 2004,2005 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.
+*
+*
+*/
+public class AxisMemoryStorage extends AbstractStorage{
+
+    private HashMap objectMap;
+
+
+    public AxisMemoryStorage() {
+        objectMap = new HashMap();
+    }
+
+    public Object put(Object value) {
+        String key = getUniqueKey();
+        objectMap.put(key,value);
+        return key;
+
+    }
+
+    public Object get(Object key) {
+        return objectMap.get(key);
+    }
+
+    public Object remove(Object key) {
+        return objectMap.remove(key);
+    }
+
+    public boolean clean() {
+        boolean returnValue = false;
+        try {
+            objectMap.clear();
+            returnValue = true;
+        }catch(Exception e){
+            returnValue = false;
+        }
+        return returnValue;
+    }
+
+
+
+}

Added: webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AbstractStorageTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AbstractStorageTest.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AbstractStorageTest.java (added)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AbstractStorageTest.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,43 @@
+package org.apache.axis.storage.impl;
+
+import junit.framework.TestCase;
+import org.apache.axis.storage.AxisStorage;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public abstract class AbstractStorageTest extends TestCase{
+    protected AxisStorage storage;
+    protected Object testValueObject; 
+
+    public void testPutAndGet(){
+        try {
+            Object key  = storage.put(testValueObject);
+            assertEquals(testValueObject,storage.get(key));
+            assertEquals(testValueObject,storage.remove(key));
+            assertNull(storage.get(key));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        storage.clean();
+        storage = null;
+
+    }
+}

Added: webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisFileStorageTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisFileStorageTest.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisFileStorageTest.java (added)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisFileStorageTest.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,59 @@
+package org.apache.axis.storage.impl;
+
+import java.io.File;
+import java.io.Serializable;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public class AxisFileStorageTest extends AbstractStorageTest {
+
+    protected void setUp() throws Exception {
+        File file = new File("temp.properties");
+        storage = new AxisFileStorage(file);
+        testValueObject = new TestBean("me",25);
+    }
+
+
+
+    private class TestBean implements Serializable{
+        private String name;
+        private int age;
+
+        public TestBean(String name, int age) {
+            this.name = name;
+            this.age = age;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public int getAge() {
+            return age;
+        }
+
+        public void setAge(int age) {
+            this.age = age;
+        }
+
+    }
+}

Added: webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisMemoryStorageTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisMemoryStorageTest.java?view=auto&rev=161875
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisMemoryStorageTest.java (added)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/storage/impl/AxisMemoryStorageTest.java Tue Apr 19 04:56:03 2005
@@ -0,0 +1,30 @@
+package org.apache.axis.storage.impl;
+
+import junit.framework.TestCase;
+import org.apache.axis.storage.AxisStorage;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * 
+ */
+public class AxisMemoryStorageTest extends AbstractStorageTest{
+
+    protected void setUp() throws Exception {
+        storage = new AxisMemoryStorage();
+        testValueObject = new Object();
+    }
+
+}