You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2006/03/22 00:21:29 UTC
svn commit: r387665 [2/9] - in /incubator/activemq/trunk:
activecluster/src/java/org/apache/activecluster/impl/
activemq-core/src/main/java/org/apache/activemq/advisory/
activemq-core/src/main/java/org/apache/activemq/broker/jmx/
activemq-core/src/main...
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/MapContainerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/MapContainerImpl.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/MapContainerImpl.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/MapContainerImpl.java Tue Mar 21 15:20:55 2006
@@ -1,476 +1,476 @@
-/**
- *
- * Copyright 2005-2006 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.
- */
-package org.apache.activemq.kaha.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import org.apache.activemq.kaha.MapContainer;
-import org.apache.activemq.kaha.Marshaller;
-import org.apache.activemq.kaha.ObjectMarshaller;
-import org.apache.activemq.kaha.RuntimeStoreException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-/**
- * Implementation of a MapContainer
- *
- * @version $Revision: 1.2 $
- */
-public class MapContainerImpl implements MapContainer{
- private static final Log log=LogFactory.getLog(MapContainerImpl.class);
- protected StoreImpl store;
- protected LocatableItem root;
- protected Object id;
- protected Map map=new HashMap();
- protected Map valueToKeyMap=new HashMap();
- protected LinkedList list=new LinkedList();
- protected boolean loaded=false;
- protected Marshaller keyMarshaller=new ObjectMarshaller();
- protected Marshaller valueMarshaller=new ObjectMarshaller();
- protected final Object mutex=new Object();
- protected boolean closed=false;
-
- protected MapContainerImpl(Object id,StoreImpl rfs,LocatableItem root) throws IOException{
- this.id=id;
- this.store=rfs;
- this.root=root;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#load()
- */
- public void load(){
- checkClosed();
- if(!loaded){
- loaded=true;
- synchronized(mutex){
- try{
- long start=root.getNextItem();
- if(start!=Item.POSITION_NOT_SET){
- long nextItem=start;
- while(nextItem!=Item.POSITION_NOT_SET){
- LocatableItem item=new LocatableItem();
- item.setOffset(nextItem);
- Object key=store.readItem(keyMarshaller,item);
- map.put(key,item);
- valueToKeyMap.put(item,key);
- list.add(item);
- nextItem=item.getNextItem();
- }
- }
- }catch(IOException e){
- log.error("Failed to load container "+getId(),e);
- throw new RuntimeStoreException(e);
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#unload()
- */
- public void unload(){
- checkClosed();
- if(loaded){
- loaded=false;
- synchronized(mutex){
- map.clear();
- valueToKeyMap.clear();
- list.clear();
- }
- }
- }
-
- public void close(){
- unload();
- closed=true;
- }
-
- public void setKeyMarshaller(Marshaller keyMarshaller){
- checkClosed();
- this.keyMarshaller=keyMarshaller;
- }
-
- public void setValueMarshaller(Marshaller valueMarshaller){
- checkClosed();
- this.valueMarshaller=valueMarshaller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#isLoaded()
- */
- public boolean isLoaded(){
- checkClosed();
- return loaded;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#getId()
- */
- public Object getId(){
- checkClosed();
- return id;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#size()
- */
- public int size(){
- checkClosed();
- checkLoaded();
- return map.size();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#isEmpty()
- */
- public boolean isEmpty(){
- checkClosed();
- checkLoaded();
- return map.isEmpty();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#containsKey(java.lang.Object)
- */
- public boolean containsKey(Object key){
- checkClosed();
- checkLoaded();
- synchronized(mutex){
- return map.containsKey(key);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#get(java.lang.Object)
- */
- public Object get(Object key){
- checkClosed();
- checkLoaded();
- Object result=null;
- LocatableItem item=null;
- synchronized(mutex){
- item=(LocatableItem) map.get(key);
- }
- if(item!=null){
- result=getValue(item);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#containsValue(java.lang.Object)
- */
- public boolean containsValue(Object o){
- checkClosed();
- checkLoaded();
- boolean result=false;
- if(o!=null){
- synchronized(list){
- for(Iterator i=list.iterator();i.hasNext();){
- LocatableItem item=(LocatableItem) i.next();
- Object value=getValue(item);
- if(value!=null&&value.equals(o)){
- result=true;
- break;
- }
- }
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#putAll(java.util.Map)
- */
- public void putAll(Map t){
- checkClosed();
- checkLoaded();
- if(t!=null){
- synchronized(mutex){
- for(Iterator i=t.entrySet().iterator();i.hasNext();){
- Map.Entry entry=(Map.Entry) i.next();
- put(entry.getKey(),entry.getValue());
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#keySet()
- */
- public Set keySet(){
- checkClosed();
- checkLoaded();
- return new ContainerKeySet(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#values()
- */
- public Collection values(){
- checkClosed();
- checkLoaded();
- return new ContainerValueCollection(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#entrySet()
- */
- public Set entrySet(){
- checkClosed();
- checkLoaded();
- return new ContainerEntrySet(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object key,Object value){
- checkClosed();
- checkLoaded();
- Object result=null;
- synchronized(mutex){
- if(map.containsKey(key)){
- result=remove(key);
- }
- LocatableItem item=write(key,value);
- map.put(key,item);
- valueToKeyMap.put(item,key);
- list.add(item);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#remove(java.lang.Object)
- */
- public Object remove(Object key){
- checkClosed();
- checkLoaded();
- Object result=null;
- synchronized(mutex){
- LocatableItem item=(LocatableItem) map.get(key);
- if(item!=null){
- map.remove(key);
- valueToKeyMap.remove(item);
- result=getValue(item);
- int index=list.indexOf(item);
- LocatableItem prev=index>0?(LocatableItem) list.get(index-1):root;
- LocatableItem next=index<(list.size()-1)?(LocatableItem) list.get(index+1):null;
- list.remove(index);
- {
- delete(item,prev,next);
- }
- item=null;
- }
- }
- return result;
- }
-
- public boolean removeValue(Object o){
- checkClosed();
- checkLoaded();
- boolean result=false;
- if(o!=null){
- synchronized(list){
- for(Iterator i=list.iterator();i.hasNext();){
- LocatableItem item=(LocatableItem) i.next();
- Object value=getValue(item);
- if(value!=null&&value.equals(o)){
- result=true;
- // find the key
- Object key=valueToKeyMap.get(item);
- if(key!=null){
- remove(key);
- }
- break;
- }
- }
- }
- }
- return result;
- }
-
- protected void remove(LocatableItem item){
- Object key=valueToKeyMap.get(item);
- if(key!=null){
- remove(key);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.MapContainer#clear()
- */
- public void clear(){
- checkClosed();
- synchronized(mutex){
- loaded=true;
- synchronized(mutex){
- map.clear();
- valueToKeyMap.clear();
- list.clear();// going to re-use this
- try{
- long start=root.getNextItem();
- if(start!=Item.POSITION_NOT_SET){
- long nextItem=start;
- while(nextItem!=Item.POSITION_NOT_SET){
- LocatableItem item=new LocatableItem();
- item.setOffset(nextItem);
- list.add(item);
- nextItem=item.getNextItem();
- }
- }
- root.setNextItem(Item.POSITION_NOT_SET);
- store.updateItem(root);
- for(int i=0;i<list.size();i++){
- LocatableItem item=(LocatableItem) list.get(i);
- if(item.getReferenceItem()!=Item.POSITION_NOT_SET){
- Item value=new Item();
- value.setOffset(item.getReferenceItem());
- store.removeItem(value);
- }
-
- store.removeItem(item);
- }
- list.clear();
- }catch(IOException e){
- log.error("Failed to clear MapContainer "+getId(),e);
- throw new RuntimeStoreException(e);
- }
- }
- }
- }
-
- protected Set getInternalKeySet(){
- return new HashSet(map.keySet());
- }
-
- protected LinkedList getItemList(){
- return list;
- }
-
- protected Object getValue(LocatableItem item){
- Object result=null;
- if(item!=null&&item.getReferenceItem()!=Item.POSITION_NOT_SET){
- Item rec=new Item();
- rec.setOffset(item.getReferenceItem());
- try{
- result=store.readItem(valueMarshaller,rec);
- }catch(IOException e){
- log.error("Failed to get value for "+item,e);
- throw new RuntimeStoreException(e);
- }
- }
- return result;
- }
-
- protected LocatableItem write(Object key,Object value){
- long pos=Item.POSITION_NOT_SET;
- LocatableItem item=null;
- try{
- if(value!=null){
- Item valueItem=new Item();
- pos=store.storeItem(valueMarshaller,value,valueItem);
- }
- LocatableItem last=list.isEmpty()?null:(LocatableItem) list.getLast();
- last=last==null?root:last;
- long prev=last.getOffset();
- long next=Item.POSITION_NOT_SET;
- item=new LocatableItem(prev,next,pos);
- next=store.storeItem(keyMarshaller,key,item);
- if(last!=null){
- last.setNextItem(next);
- store.updateItem(last);
- }
- }catch(IOException e){
- e.printStackTrace();
- log.error("Failed to write "+key+" , "+value,e);
- throw new RuntimeStoreException(e);
- }
- return item;
- }
-
- protected void delete(LocatableItem key,LocatableItem prev,LocatableItem next){
- try{
- prev=prev==null?root:prev;
- if(next!=null){
- prev.setNextItem(next.getOffset());
- next.setPreviousItem(prev.getOffset());
- store.updateItem(next);
- }else{
- prev.setNextItem(Item.POSITION_NOT_SET);
- }
- store.updateItem(prev);
- if(key.getReferenceItem()!=Item.POSITION_NOT_SET){
- Item value=new Item();
- value.setOffset(key.getReferenceItem());
- store.removeItem(value);
- }
- store.removeItem(key);
- }catch(IOException e){
- log.error("Failed to delete "+key,e);
- throw new RuntimeStoreException(e);
- }
- }
-
- protected final void checkClosed(){
- if(closed){
- throw new RuntimeStoreException("The store is closed");
- }
- }
-
- protected final void checkLoaded(){
- if(!loaded){
- throw new RuntimeStoreException("The container is not loaded");
- }
- }
+/**
+ *
+ * Copyright 2005-2006 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.
+ */
+package org.apache.activemq.kaha.impl;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Marshaller;
+import org.apache.activemq.kaha.ObjectMarshaller;
+import org.apache.activemq.kaha.RuntimeStoreException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+/**
+ * Implementation of a MapContainer
+ *
+ * @version $Revision: 1.2 $
+ */
+public class MapContainerImpl implements MapContainer{
+ private static final Log log=LogFactory.getLog(MapContainerImpl.class);
+ protected StoreImpl store;
+ protected LocatableItem root;
+ protected Object id;
+ protected Map map=new HashMap();
+ protected Map valueToKeyMap=new HashMap();
+ protected LinkedList list=new LinkedList();
+ protected boolean loaded=false;
+ protected Marshaller keyMarshaller=new ObjectMarshaller();
+ protected Marshaller valueMarshaller=new ObjectMarshaller();
+ protected final Object mutex=new Object();
+ protected boolean closed=false;
+
+ protected MapContainerImpl(Object id,StoreImpl rfs,LocatableItem root) throws IOException{
+ this.id=id;
+ this.store=rfs;
+ this.root=root;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#load()
+ */
+ public void load(){
+ checkClosed();
+ if(!loaded){
+ loaded=true;
+ synchronized(mutex){
+ try{
+ long start=root.getNextItem();
+ if(start!=Item.POSITION_NOT_SET){
+ long nextItem=start;
+ while(nextItem!=Item.POSITION_NOT_SET){
+ LocatableItem item=new LocatableItem();
+ item.setOffset(nextItem);
+ Object key=store.readItem(keyMarshaller,item);
+ map.put(key,item);
+ valueToKeyMap.put(item,key);
+ list.add(item);
+ nextItem=item.getNextItem();
+ }
+ }
+ }catch(IOException e){
+ log.error("Failed to load container "+getId(),e);
+ throw new RuntimeStoreException(e);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#unload()
+ */
+ public void unload(){
+ checkClosed();
+ if(loaded){
+ loaded=false;
+ synchronized(mutex){
+ map.clear();
+ valueToKeyMap.clear();
+ list.clear();
+ }
+ }
+ }
+
+ public void close(){
+ unload();
+ closed=true;
+ }
+
+ public void setKeyMarshaller(Marshaller keyMarshaller){
+ checkClosed();
+ this.keyMarshaller=keyMarshaller;
+ }
+
+ public void setValueMarshaller(Marshaller valueMarshaller){
+ checkClosed();
+ this.valueMarshaller=valueMarshaller;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#isLoaded()
+ */
+ public boolean isLoaded(){
+ checkClosed();
+ return loaded;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#getId()
+ */
+ public Object getId(){
+ checkClosed();
+ return id;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#size()
+ */
+ public int size(){
+ checkClosed();
+ checkLoaded();
+ return map.size();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#isEmpty()
+ */
+ public boolean isEmpty(){
+ checkClosed();
+ checkLoaded();
+ return map.isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key){
+ checkClosed();
+ checkLoaded();
+ synchronized(mutex){
+ return map.containsKey(key);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#get(java.lang.Object)
+ */
+ public Object get(Object key){
+ checkClosed();
+ checkLoaded();
+ Object result=null;
+ LocatableItem item=null;
+ synchronized(mutex){
+ item=(LocatableItem) map.get(key);
+ }
+ if(item!=null){
+ result=getValue(item);
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object o){
+ checkClosed();
+ checkLoaded();
+ boolean result=false;
+ if(o!=null){
+ synchronized(list){
+ for(Iterator i=list.iterator();i.hasNext();){
+ LocatableItem item=(LocatableItem) i.next();
+ Object value=getValue(item);
+ if(value!=null&&value.equals(o)){
+ result=true;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#putAll(java.util.Map)
+ */
+ public void putAll(Map t){
+ checkClosed();
+ checkLoaded();
+ if(t!=null){
+ synchronized(mutex){
+ for(Iterator i=t.entrySet().iterator();i.hasNext();){
+ Map.Entry entry=(Map.Entry) i.next();
+ put(entry.getKey(),entry.getValue());
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#keySet()
+ */
+ public Set keySet(){
+ checkClosed();
+ checkLoaded();
+ return new ContainerKeySet(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#values()
+ */
+ public Collection values(){
+ checkClosed();
+ checkLoaded();
+ return new ContainerValueCollection(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#entrySet()
+ */
+ public Set entrySet(){
+ checkClosed();
+ checkLoaded();
+ return new ContainerEntrySet(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object key,Object value){
+ checkClosed();
+ checkLoaded();
+ Object result=null;
+ synchronized(mutex){
+ if(map.containsKey(key)){
+ result=remove(key);
+ }
+ LocatableItem item=write(key,value);
+ map.put(key,item);
+ valueToKeyMap.put(item,key);
+ list.add(item);
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#remove(java.lang.Object)
+ */
+ public Object remove(Object key){
+ checkClosed();
+ checkLoaded();
+ Object result=null;
+ synchronized(mutex){
+ LocatableItem item=(LocatableItem) map.get(key);
+ if(item!=null){
+ map.remove(key);
+ valueToKeyMap.remove(item);
+ result=getValue(item);
+ int index=list.indexOf(item);
+ LocatableItem prev=index>0?(LocatableItem) list.get(index-1):root;
+ LocatableItem next=index<(list.size()-1)?(LocatableItem) list.get(index+1):null;
+ list.remove(index);
+ {
+ delete(item,prev,next);
+ }
+ item=null;
+ }
+ }
+ return result;
+ }
+
+ public boolean removeValue(Object o){
+ checkClosed();
+ checkLoaded();
+ boolean result=false;
+ if(o!=null){
+ synchronized(list){
+ for(Iterator i=list.iterator();i.hasNext();){
+ LocatableItem item=(LocatableItem) i.next();
+ Object value=getValue(item);
+ if(value!=null&&value.equals(o)){
+ result=true;
+ // find the key
+ Object key=valueToKeyMap.get(item);
+ if(key!=null){
+ remove(key);
+ }
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ protected void remove(LocatableItem item){
+ Object key=valueToKeyMap.get(item);
+ if(key!=null){
+ remove(key);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.MapContainer#clear()
+ */
+ public void clear(){
+ checkClosed();
+ synchronized(mutex){
+ loaded=true;
+ synchronized(mutex){
+ map.clear();
+ valueToKeyMap.clear();
+ list.clear();// going to re-use this
+ try{
+ long start=root.getNextItem();
+ if(start!=Item.POSITION_NOT_SET){
+ long nextItem=start;
+ while(nextItem!=Item.POSITION_NOT_SET){
+ LocatableItem item=new LocatableItem();
+ item.setOffset(nextItem);
+ list.add(item);
+ nextItem=item.getNextItem();
+ }
+ }
+ root.setNextItem(Item.POSITION_NOT_SET);
+ store.updateItem(root);
+ for(int i=0;i<list.size();i++){
+ LocatableItem item=(LocatableItem) list.get(i);
+ if(item.getReferenceItem()!=Item.POSITION_NOT_SET){
+ Item value=new Item();
+ value.setOffset(item.getReferenceItem());
+ store.removeItem(value);
+ }
+
+ store.removeItem(item);
+ }
+ list.clear();
+ }catch(IOException e){
+ log.error("Failed to clear MapContainer "+getId(),e);
+ throw new RuntimeStoreException(e);
+ }
+ }
+ }
+ }
+
+ protected Set getInternalKeySet(){
+ return new HashSet(map.keySet());
+ }
+
+ protected LinkedList getItemList(){
+ return list;
+ }
+
+ protected Object getValue(LocatableItem item){
+ Object result=null;
+ if(item!=null&&item.getReferenceItem()!=Item.POSITION_NOT_SET){
+ Item rec=new Item();
+ rec.setOffset(item.getReferenceItem());
+ try{
+ result=store.readItem(valueMarshaller,rec);
+ }catch(IOException e){
+ log.error("Failed to get value for "+item,e);
+ throw new RuntimeStoreException(e);
+ }
+ }
+ return result;
+ }
+
+ protected LocatableItem write(Object key,Object value){
+ long pos=Item.POSITION_NOT_SET;
+ LocatableItem item=null;
+ try{
+ if(value!=null){
+ Item valueItem=new Item();
+ pos=store.storeItem(valueMarshaller,value,valueItem);
+ }
+ LocatableItem last=list.isEmpty()?null:(LocatableItem) list.getLast();
+ last=last==null?root:last;
+ long prev=last.getOffset();
+ long next=Item.POSITION_NOT_SET;
+ item=new LocatableItem(prev,next,pos);
+ next=store.storeItem(keyMarshaller,key,item);
+ if(last!=null){
+ last.setNextItem(next);
+ store.updateItem(last);
+ }
+ }catch(IOException e){
+ e.printStackTrace();
+ log.error("Failed to write "+key+" , "+value,e);
+ throw new RuntimeStoreException(e);
+ }
+ return item;
+ }
+
+ protected void delete(LocatableItem key,LocatableItem prev,LocatableItem next){
+ try{
+ prev=prev==null?root:prev;
+ if(next!=null){
+ prev.setNextItem(next.getOffset());
+ next.setPreviousItem(prev.getOffset());
+ store.updateItem(next);
+ }else{
+ prev.setNextItem(Item.POSITION_NOT_SET);
+ }
+ store.updateItem(prev);
+ if(key.getReferenceItem()!=Item.POSITION_NOT_SET){
+ Item value=new Item();
+ value.setOffset(key.getReferenceItem());
+ store.removeItem(value);
+ }
+ store.removeItem(key);
+ }catch(IOException e){
+ log.error("Failed to delete "+key,e);
+ throw new RuntimeStoreException(e);
+ }
+ }
+
+ protected final void checkClosed(){
+ if(closed){
+ throw new RuntimeStoreException("The store is closed");
+ }
+ }
+
+ protected final void checkLoaded(){
+ if(!loaded){
+ throw new RuntimeStoreException("The container is not loaded");
+ }
+ }
}
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/MapContainerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/RootContainer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/RootContainer.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/RootContainer.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/RootContainer.java Tue Mar 21 15:20:55 2006
@@ -1,97 +1,97 @@
-/**
- *
- * Copyright 2005-2006 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.
- */
-package org.apache.activemq.kaha.impl;
-
-import java.io.IOException;
-import org.apache.activemq.kaha.Marshaller;
-import org.apache.activemq.kaha.ObjectMarshaller;
-import org.apache.activemq.kaha.RuntimeStoreException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
-* A container of roots for other Containers
-*
-* @version $Revision: 1.2 $
-*/
-
-class RootContainer extends MapContainerImpl{
- private static final Log log=LogFactory.getLog(RootContainer.class);
- protected static final Marshaller rootMarshaller = new ObjectMarshaller();
-
- protected RootContainer(Object id,StoreImpl rfs,LocatableItem root) throws IOException{
- super(id,rfs,root);
- }
-
- protected void addRoot(Object key,LocatableItem er) throws IOException{
-
- if(map.containsKey(key)){
- remove(key);
- }
- LocatableItem entry=writeRoot(key,er);
- map.put(key,entry);
- synchronized(list){
- list.add(entry);
- }
-
- }
-
- protected LocatableItem writeRoot(Object key,LocatableItem value){
- long pos=Item.POSITION_NOT_SET;
- LocatableItem item=null;
- try{
- if(value!=null){
- pos=store.storeItem(rootMarshaller,value,value);
- }
- LocatableItem last=list.isEmpty()?null:(LocatableItem) list.getLast();
- last=last==null?root:last;
- long prev=last.getOffset();
- long next=Item.POSITION_NOT_SET;
- item=new LocatableItem(prev,next,pos);
- if(log.isDebugEnabled())
- log.debug("writing root ...");
- if(log.isDebugEnabled())
- log.debug("root = "+value);
- next=store.storeItem(rootMarshaller,key,item);
- if(last!=null){
- last.setNextItem(next);
- store.updateItem(last);
- }
- }catch(IOException e){
- e.printStackTrace();
- log.error("Failed to write root",e);
- throw new RuntimeStoreException(e);
- }
- return item;
- }
-
- protected Object getValue(LocatableItem item){
- LocatableItem result=null;
- if(item!=null&&item.getReferenceItem()!=Item.POSITION_NOT_SET){
- LocatableItem value=new LocatableItem();
- value.setOffset(item.getReferenceItem());
- try{
- result=(LocatableItem) store.readItem(rootMarshaller,value);
- //now read the item
- result.setOffset(item.getReferenceItem());
- store.readItem(rootMarshaller, result);
- }catch(IOException e){
- log.error("Could not read item "+item,e);
- throw new RuntimeStoreException(e);
- }
- }
- return result;
- }
-
+/**
+ *
+ * Copyright 2005-2006 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.
+ */
+package org.apache.activemq.kaha.impl;
+
+import java.io.IOException;
+import org.apache.activemq.kaha.Marshaller;
+import org.apache.activemq.kaha.ObjectMarshaller;
+import org.apache.activemq.kaha.RuntimeStoreException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+* A container of roots for other Containers
+*
+* @version $Revision: 1.2 $
+*/
+
+class RootContainer extends MapContainerImpl{
+ private static final Log log=LogFactory.getLog(RootContainer.class);
+ protected static final Marshaller rootMarshaller = new ObjectMarshaller();
+
+ protected RootContainer(Object id,StoreImpl rfs,LocatableItem root) throws IOException{
+ super(id,rfs,root);
+ }
+
+ protected void addRoot(Object key,LocatableItem er) throws IOException{
+
+ if(map.containsKey(key)){
+ remove(key);
+ }
+ LocatableItem entry=writeRoot(key,er);
+ map.put(key,entry);
+ synchronized(list){
+ list.add(entry);
+ }
+
+ }
+
+ protected LocatableItem writeRoot(Object key,LocatableItem value){
+ long pos=Item.POSITION_NOT_SET;
+ LocatableItem item=null;
+ try{
+ if(value!=null){
+ pos=store.storeItem(rootMarshaller,value,value);
+ }
+ LocatableItem last=list.isEmpty()?null:(LocatableItem) list.getLast();
+ last=last==null?root:last;
+ long prev=last.getOffset();
+ long next=Item.POSITION_NOT_SET;
+ item=new LocatableItem(prev,next,pos);
+ if(log.isDebugEnabled())
+ log.debug("writing root ...");
+ if(log.isDebugEnabled())
+ log.debug("root = "+value);
+ next=store.storeItem(rootMarshaller,key,item);
+ if(last!=null){
+ last.setNextItem(next);
+ store.updateItem(last);
+ }
+ }catch(IOException e){
+ e.printStackTrace();
+ log.error("Failed to write root",e);
+ throw new RuntimeStoreException(e);
+ }
+ return item;
+ }
+
+ protected Object getValue(LocatableItem item){
+ LocatableItem result=null;
+ if(item!=null&&item.getReferenceItem()!=Item.POSITION_NOT_SET){
+ LocatableItem value=new LocatableItem();
+ value.setOffset(item.getReferenceItem());
+ try{
+ result=(LocatableItem) store.readItem(rootMarshaller,value);
+ //now read the item
+ result.setOffset(item.getReferenceItem());
+ store.readItem(rootMarshaller, result);
+ }catch(IOException e){
+ log.error("Could not read item "+item,e);
+ throw new RuntimeStoreException(e);
+ }
+ }
+ return result;
+ }
+
}
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/RootContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreByteArrayInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreByteArrayOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreImpl.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreImpl.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreImpl.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreImpl.java Tue Mar 21 15:20:55 2006
@@ -1,380 +1,380 @@
-/**
- *
- * Copyright 2005-2006 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.
- */
-package org.apache.activemq.kaha.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.RandomAccessFile;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.activemq.kaha.ListContainer;
-import org.apache.activemq.kaha.MapContainer;
-import org.apache.activemq.kaha.Marshaller;
-import org.apache.activemq.kaha.RuntimeStoreException;
-import org.apache.activemq.kaha.Store;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-/**
- * Implementation of a Store
- *
- * @version $Revision: 1.2 $
- */
-public class StoreImpl implements Store{
- private static final Log log = LogFactory.getLog(StoreImpl.class);
-
- private final Object mutex=new Object();
- private RandomAccessFile dataFile;
- private Map mapContainers=new ConcurrentHashMap();
- private Map listContainers=new ConcurrentHashMap();
- private RootContainer rootMapContainer;
- private RootContainer rootListContainer;
- private String name;
- private StoreReader reader;
- private StoreWriter writer;
- private FreeSpaceManager freeSpaceManager;
- protected boolean closed=false;
- protected Thread shutdownHook;
-
- public StoreImpl(String name,String mode) throws IOException{
- this.name=name;
- this.dataFile=new RandomAccessFile(name,mode);
- this.reader = new StoreReader(this.dataFile);
- this.writer = new StoreWriter(this.dataFile);
- File file = new File(name);
- log.info("Kaha Store opened " + file.getAbsolutePath());
- freeSpaceManager=new FreeSpaceManager(this.writer,this.reader);
- initialization();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#close()
- */
- public void close() throws IOException{
- synchronized(mutex){
- if(!closed){
- for(Iterator i=mapContainers.values().iterator();i.hasNext();){
- MapContainerImpl container=(MapContainerImpl) i.next();
- container.close();
- }
- for(Iterator i=listContainers.values().iterator();i.hasNext();){
- ListContainerImpl container=(ListContainerImpl) i.next();
- container.close();
- }
- force();
- dataFile.close();
- closed=true;
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#force()
- */
- public void force() throws IOException{
- checkClosed();
- synchronized(mutex){
- dataFile.getFD().sync();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#clear()
- */
- public void clear(){
- checkClosed();
- for(Iterator i=mapContainers.values().iterator();i.hasNext();){
- MapContainer container=(MapContainer) i.next();
- container.clear();
- }
- for(Iterator i=listContainers.values().iterator();i.hasNext();){
- ListContainer container=(ListContainer) i.next();
- container.clear();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#delete()
- */
- public boolean delete() throws IOException{
- checkClosed();
- dataFile.close();
- File file=new File(name);
- return file.delete();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#doesMapContainerExist(java.lang.Object)
- */
- public boolean doesMapContainerExist(Object id){
- return mapContainers.containsKey(id);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#getContainer(java.lang.Object)
- */
- public MapContainer getMapContainer(Object id) throws IOException{
- checkClosed();
- synchronized(mutex){
- MapContainer result=(MapContainerImpl) mapContainers.get(id);
- if(result==null){
- LocatableItem root=new LocatableItem();
- rootMapContainer.addRoot(id,root);
- result=new MapContainerImpl(id,this,root);
- mapContainers.put(id,result);
- }
- return result;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#deleteContainer(java.lang.Object)
- */
- public void deleteMapContainer(Object id) throws IOException{
- checkClosed();
- synchronized(mutex){
- if(doesMapContainerExist(id)){
- MapContainer container=getMapContainer(id);
- if(container!=null){
- container.load();
- container.clear();
- rootMapContainer.remove(id);
- mapContainers.remove(id);
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#getContainerKeys()
- */
- public Set getMapContainerIds(){
- checkClosed();
- return java.util.Collections.unmodifiableSet(mapContainers.keySet());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#doesListContainerExist(java.lang.Object)
- */
- public boolean doesListContainerExist(Object id){
- return listContainers.containsKey(id);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#getListContainer(java.lang.Object)
- */
- public ListContainer getListContainer(Object id) throws IOException{
- checkClosed();
- synchronized(mutex){
- ListContainer result=(ListContainerImpl) listContainers.get(id);
- if(result==null){
- LocatableItem root=new LocatableItem();
- rootListContainer.addRoot(id,root);
- result=new ListContainerImpl(id,this,root);
- listContainers.put(id,result);
- }
- return result;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#deleteListContainer(java.lang.Object)
- */
- public void deleteListContainer(Object id) throws IOException{
- checkClosed();
- synchronized(mutex){
- if(doesListContainerExist(id)){
- ListContainer container=getListContainer(id);
- if(container!=null){
- container.load();
- container.clear();
- rootListContainer.remove(id);
- listContainers.remove(id);
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.activemq.kaha.Store#getListContainerIds()
- */
- public Set getListContainerIds(){
- checkClosed();
- return java.util.Collections.unmodifiableSet(listContainers.keySet());
- }
-
- public void dumpFreeSpace(PrintWriter printer){
- checkClosed();
- synchronized(mutex){
- freeSpaceManager.dump(printer);
- }
- }
-
-
- protected long storeItem(Marshaller marshaller,Object payload,Item item) throws IOException{
- synchronized(mutex){
- int payloadSize = writer.loadPayload(marshaller, payload, item);
- item.setSize(payloadSize);
- // free space manager will set offset and write any headers required
- // so the position should now be correct for writing
- item=freeSpaceManager.getFreeSpace(item);
- writer.storeItem(item,payloadSize);
- }
- return item.getOffset();
- }
-
- protected Object readItem(Marshaller marshaller,Item item) throws IOException{
- synchronized(mutex){
- return reader.readItem(marshaller, item);
- }
- }
-
- protected void readHeader(Item item) throws IOException{
- synchronized(mutex){
- reader.readHeader(item);
- }
- }
-
- protected void readLocation(Item item) throws IOException{
- synchronized(mutex){
- reader.readLocation(item);
- }
- }
-
- protected void updateItem(Item item) throws IOException{
- synchronized(mutex){
- writer.updatePayload(item);
- }
- }
-
- protected void removeItem(Item item) throws IOException{
- synchronized(mutex){
- freeSpaceManager.addFreeSpace(item);
- }
- }
-
- private void initialization() throws IOException{
- //add shutdown hook
- addShutdownHook();
- // check for new file
- LocatableItem mapRoot=new LocatableItem();
- LocatableItem listRoot=new LocatableItem();
- if(dataFile.length()==0){
- writer.allocateSpace(FreeSpaceManager.RESIZE_INCREMENT);
- storeItem(RootContainer.rootMarshaller,"mapRoot",mapRoot);
- storeItem(RootContainer.rootMarshaller,"listRoot",listRoot);
- }else{
- freeSpaceManager.scanStoredItems();
- dataFile.seek(FreeSpaceManager.ROOT_SIZE);
- mapRoot.setOffset(FreeSpaceManager.ROOT_SIZE);
- readItem(RootContainer.rootMarshaller,mapRoot);
- listRoot.setOffset(dataFile.getFilePointer());
- readItem(RootContainer.rootMarshaller,listRoot);
- }
- rootMapContainer=new RootContainer("root",this,mapRoot);
- rootMapContainer.load();
- Set keys=rootMapContainer.keySet();
- for(Iterator i=keys.iterator();i.hasNext();){
- Object id=i.next();
- if(id!=null){
- LocatableItem item=(LocatableItem) rootMapContainer.get(id);
- if(item!=null){
- MapContainer container=new MapContainerImpl(id,this,item);
- mapContainers.put(id,container);
- }
- }
- }
- rootListContainer=new RootContainer("root",this,listRoot);
- rootListContainer.load();
- keys=rootListContainer.keySet();
- for(Iterator i=keys.iterator();i.hasNext();){
- Object id=i.next();
- if(id!=null){
- LocatableItem item=(LocatableItem) rootListContainer.get(id);
- if(item!=null){
- ListContainer container=new ListContainerImpl(id,this,item);
- listContainers.put(id,container);
- }
- }
- }
- }
-
-
-
-
-
- protected void checkClosed(){
- if(closed){
- throw new RuntimeStoreException("The store is closed");
- }
- }
-
-
- protected void addShutdownHook() {
-
- shutdownHook = new Thread("Kaha Store implementation is shutting down") {
- public void run() {
- if (!closed){
- try{
- //this needs to be really quick so ...
- closed = true;
- dataFile.close();
- }catch(Throwable e){
- log.error("Failed to close data file",e);
- }
- }
- }
- };
- Runtime.getRuntime().addShutdownHook(shutdownHook);
-
- }
-
- protected void removeShutdownHook() {
- if (shutdownHook != null) {
- try {
- Runtime.getRuntime().removeShutdownHook(shutdownHook);
- }
- catch (Exception e) {
- log.warn("Failed to run shutdown hook",e);
- }
- }
- }
-
-}
+/**
+ *
+ * Copyright 2005-2006 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.
+ */
+package org.apache.activemq.kaha.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.RandomAccessFile;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import org.apache.activemq.kaha.ListContainer;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Marshaller;
+import org.apache.activemq.kaha.RuntimeStoreException;
+import org.apache.activemq.kaha.Store;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+/**
+ * Implementation of a Store
+ *
+ * @version $Revision: 1.2 $
+ */
+public class StoreImpl implements Store{
+ private static final Log log = LogFactory.getLog(StoreImpl.class);
+
+ private final Object mutex=new Object();
+ private RandomAccessFile dataFile;
+ private Map mapContainers=new ConcurrentHashMap();
+ private Map listContainers=new ConcurrentHashMap();
+ private RootContainer rootMapContainer;
+ private RootContainer rootListContainer;
+ private String name;
+ private StoreReader reader;
+ private StoreWriter writer;
+ private FreeSpaceManager freeSpaceManager;
+ protected boolean closed=false;
+ protected Thread shutdownHook;
+
+ public StoreImpl(String name,String mode) throws IOException{
+ this.name=name;
+ this.dataFile=new RandomAccessFile(name,mode);
+ this.reader = new StoreReader(this.dataFile);
+ this.writer = new StoreWriter(this.dataFile);
+ File file = new File(name);
+ log.info("Kaha Store opened " + file.getAbsolutePath());
+ freeSpaceManager=new FreeSpaceManager(this.writer,this.reader);
+ initialization();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#close()
+ */
+ public void close() throws IOException{
+ synchronized(mutex){
+ if(!closed){
+ for(Iterator i=mapContainers.values().iterator();i.hasNext();){
+ MapContainerImpl container=(MapContainerImpl) i.next();
+ container.close();
+ }
+ for(Iterator i=listContainers.values().iterator();i.hasNext();){
+ ListContainerImpl container=(ListContainerImpl) i.next();
+ container.close();
+ }
+ force();
+ dataFile.close();
+ closed=true;
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#force()
+ */
+ public void force() throws IOException{
+ checkClosed();
+ synchronized(mutex){
+ dataFile.getFD().sync();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#clear()
+ */
+ public void clear(){
+ checkClosed();
+ for(Iterator i=mapContainers.values().iterator();i.hasNext();){
+ MapContainer container=(MapContainer) i.next();
+ container.clear();
+ }
+ for(Iterator i=listContainers.values().iterator();i.hasNext();){
+ ListContainer container=(ListContainer) i.next();
+ container.clear();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#delete()
+ */
+ public boolean delete() throws IOException{
+ checkClosed();
+ dataFile.close();
+ File file=new File(name);
+ return file.delete();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#doesMapContainerExist(java.lang.Object)
+ */
+ public boolean doesMapContainerExist(Object id){
+ return mapContainers.containsKey(id);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#getContainer(java.lang.Object)
+ */
+ public MapContainer getMapContainer(Object id) throws IOException{
+ checkClosed();
+ synchronized(mutex){
+ MapContainer result=(MapContainerImpl) mapContainers.get(id);
+ if(result==null){
+ LocatableItem root=new LocatableItem();
+ rootMapContainer.addRoot(id,root);
+ result=new MapContainerImpl(id,this,root);
+ mapContainers.put(id,result);
+ }
+ return result;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#deleteContainer(java.lang.Object)
+ */
+ public void deleteMapContainer(Object id) throws IOException{
+ checkClosed();
+ synchronized(mutex){
+ if(doesMapContainerExist(id)){
+ MapContainer container=getMapContainer(id);
+ if(container!=null){
+ container.load();
+ container.clear();
+ rootMapContainer.remove(id);
+ mapContainers.remove(id);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#getContainerKeys()
+ */
+ public Set getMapContainerIds(){
+ checkClosed();
+ return java.util.Collections.unmodifiableSet(mapContainers.keySet());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#doesListContainerExist(java.lang.Object)
+ */
+ public boolean doesListContainerExist(Object id){
+ return listContainers.containsKey(id);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#getListContainer(java.lang.Object)
+ */
+ public ListContainer getListContainer(Object id) throws IOException{
+ checkClosed();
+ synchronized(mutex){
+ ListContainer result=(ListContainerImpl) listContainers.get(id);
+ if(result==null){
+ LocatableItem root=new LocatableItem();
+ rootListContainer.addRoot(id,root);
+ result=new ListContainerImpl(id,this,root);
+ listContainers.put(id,result);
+ }
+ return result;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#deleteListContainer(java.lang.Object)
+ */
+ public void deleteListContainer(Object id) throws IOException{
+ checkClosed();
+ synchronized(mutex){
+ if(doesListContainerExist(id)){
+ ListContainer container=getListContainer(id);
+ if(container!=null){
+ container.load();
+ container.clear();
+ rootListContainer.remove(id);
+ listContainers.remove(id);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.activemq.kaha.Store#getListContainerIds()
+ */
+ public Set getListContainerIds(){
+ checkClosed();
+ return java.util.Collections.unmodifiableSet(listContainers.keySet());
+ }
+
+ public void dumpFreeSpace(PrintWriter printer){
+ checkClosed();
+ synchronized(mutex){
+ freeSpaceManager.dump(printer);
+ }
+ }
+
+
+ protected long storeItem(Marshaller marshaller,Object payload,Item item) throws IOException{
+ synchronized(mutex){
+ int payloadSize = writer.loadPayload(marshaller, payload, item);
+ item.setSize(payloadSize);
+ // free space manager will set offset and write any headers required
+ // so the position should now be correct for writing
+ item=freeSpaceManager.getFreeSpace(item);
+ writer.storeItem(item,payloadSize);
+ }
+ return item.getOffset();
+ }
+
+ protected Object readItem(Marshaller marshaller,Item item) throws IOException{
+ synchronized(mutex){
+ return reader.readItem(marshaller, item);
+ }
+ }
+
+ protected void readHeader(Item item) throws IOException{
+ synchronized(mutex){
+ reader.readHeader(item);
+ }
+ }
+
+ protected void readLocation(Item item) throws IOException{
+ synchronized(mutex){
+ reader.readLocation(item);
+ }
+ }
+
+ protected void updateItem(Item item) throws IOException{
+ synchronized(mutex){
+ writer.updatePayload(item);
+ }
+ }
+
+ protected void removeItem(Item item) throws IOException{
+ synchronized(mutex){
+ freeSpaceManager.addFreeSpace(item);
+ }
+ }
+
+ private void initialization() throws IOException{
+ //add shutdown hook
+ addShutdownHook();
+ // check for new file
+ LocatableItem mapRoot=new LocatableItem();
+ LocatableItem listRoot=new LocatableItem();
+ if(dataFile.length()==0){
+ writer.allocateSpace(FreeSpaceManager.RESIZE_INCREMENT);
+ storeItem(RootContainer.rootMarshaller,"mapRoot",mapRoot);
+ storeItem(RootContainer.rootMarshaller,"listRoot",listRoot);
+ }else{
+ freeSpaceManager.scanStoredItems();
+ dataFile.seek(FreeSpaceManager.ROOT_SIZE);
+ mapRoot.setOffset(FreeSpaceManager.ROOT_SIZE);
+ readItem(RootContainer.rootMarshaller,mapRoot);
+ listRoot.setOffset(dataFile.getFilePointer());
+ readItem(RootContainer.rootMarshaller,listRoot);
+ }
+ rootMapContainer=new RootContainer("root",this,mapRoot);
+ rootMapContainer.load();
+ Set keys=rootMapContainer.keySet();
+ for(Iterator i=keys.iterator();i.hasNext();){
+ Object id=i.next();
+ if(id!=null){
+ LocatableItem item=(LocatableItem) rootMapContainer.get(id);
+ if(item!=null){
+ MapContainer container=new MapContainerImpl(id,this,item);
+ mapContainers.put(id,container);
+ }
+ }
+ }
+ rootListContainer=new RootContainer("root",this,listRoot);
+ rootListContainer.load();
+ keys=rootListContainer.keySet();
+ for(Iterator i=keys.iterator();i.hasNext();){
+ Object id=i.next();
+ if(id!=null){
+ LocatableItem item=(LocatableItem) rootListContainer.get(id);
+ if(item!=null){
+ ListContainer container=new ListContainerImpl(id,this,item);
+ listContainers.put(id,container);
+ }
+ }
+ }
+ }
+
+
+
+
+
+ protected void checkClosed(){
+ if(closed){
+ throw new RuntimeStoreException("The store is closed");
+ }
+ }
+
+
+ protected void addShutdownHook() {
+
+ shutdownHook = new Thread("Kaha Store implementation is shutting down") {
+ public void run() {
+ if (!closed){
+ try{
+ //this needs to be really quick so ...
+ closed = true;
+ dataFile.close();
+ }catch(Throwable e){
+ log.error("Failed to close data file",e);
+ }
+ }
+ }
+ };
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ }
+
+ protected void removeShutdownHook() {
+ if (shutdownHook != null) {
+ try {
+ Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ }
+ catch (Exception e) {
+ log.warn("Failed to run shutdown hook",e);
+ }
+ }
+ }
+
+}
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/StoreWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ConnectionFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/DataStreamMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/BaseDataStreamMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/DataStructureSupportMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterMarshaller.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterMarshaller.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterMarshaller.java (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterMarshaller.java Tue Mar 21 15:20:55 2006
@@ -1 +1,132 @@
-/**
*
* Copyright 2005-2006 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.
*/
package org.apache.activemq.openwire.v1;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.activemq.openwire.*;
import org.apache.activemq.command.*;
/**
* Marshalling code for Open Wire Format for NetworkBridgeFilterMarshaller
*
*
* NOTE!: This file is auto generated - do not modify!
* if
you need to make a change, please see the modify the groovy scripts in the
* under src/gram/script and then use maven openwire:generate to regenerate
* this file.
*
* @version $Revision$
*/
public class NetworkBridgeFilterMarshaller extends BaseDataStreamMarshaller {
/**
* Return the type of Data Structure we marshal
* @return short representation of the type data structure
*/
public byte getDataStructureType() {
return NetworkBridgeFilter.DATA_STRUCTURE_TYPE;
}
/**
* @return a new object instance
*/
public DataStructure createObject() {
return new NetworkBridgeFilter();
}
/**
* Un-marshal an object instance from the data input stream
*
* @param o the object to un-marshal
* @param dataIn the data input stream to build the object from
* @throws IOException
*/
public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInputStream dataIn, Bo
oleanStream bs) throws IOException {
super.tightUnmarshal(wireFormat, o, dataIn, bs);
NetworkBridgeFilter info = (NetworkBridgeFilter)o;
info.setNetworkTTL(dataIn.readInt());
info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
}
/**
* Write the booleans that this object uses to a BooleanStream
*/
public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
NetworkBridgeFilter info = (NetworkBridgeFilter)o;
int rc = super.tightMarshal1(wireFormat, o, bs);
rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getNetworkBrokerId(), bs);
return rc + 4;
}
/**
* Write a object instance to data output stream
*
* @param o the instance to be marshaled
* @param dataOut the output stream
* @throws IOException thrown if an error occurs
*/
pub
lic void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutputStream dataOut, BooleanStream bs) throws IOException {
super.tightMarshal2(wireFormat, o, dataOut, bs);
NetworkBridgeFilter info = (NetworkBridgeFilter)o;
dataOut.writeInt(info.getNetworkTTL());
tightMarshalCachedObject2(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut, bs);
}
/**
* Un-marshal an object instance from the data input stream
*
* @param o the object to un-marshal
* @param dataIn the data input stream to build the object from
* @throws IOException
*/
public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInputStream dataIn) throws IOException {
super.looseUnmarshal(wireFormat, o, dataIn);
NetworkBridgeFilter info = (NetworkBridgeFilter)o;
info.setNetworkTTL(dataIn.readInt());
info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) looseUnmarsalCachedObje
ct(wireFormat, dataIn));
}
/**
* Write the booleans that this object uses to a BooleanStream
*/
public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutputStream dataOut) throws IOException {
NetworkBridgeFilter info = (NetworkBridgeFilter)o;
super.looseMarshal(wireFormat, o, dataOut);
dataOut.writeInt(info.getNetworkTTL());
looseMarshalCachedObject(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut);
}
}
\ No newline at end of file
+/**
+ *
+ * Copyright 2005-2006 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.
+ */
+
+package org.apache.activemq.openwire.v1;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.*;
+import org.apache.activemq.command.*;
+
+
+
+/**
+ * Marshalling code for Open Wire Format for NetworkBridgeFilterMarshaller
+ *
+ *
+ * NOTE!: This file is auto generated - do not modify!
+ * if you need to make a change, please see the modify the groovy scripts in the
+ * under src/gram/script and then use maven openwire:generate to regenerate
+ * this file.
+ *
+ * @version $Revision$
+ */
+public class NetworkBridgeFilterMarshaller extends BaseDataStreamMarshaller {
+
+ /**
+ * Return the type of Data Structure we marshal
+ * @return short representation of the type data structure
+ */
+ public byte getDataStructureType() {
+ return NetworkBridgeFilter.DATA_STRUCTURE_TYPE;
+ }
+
+ /**
+ * @return a new object instance
+ */
+ public DataStructure createObject() {
+ return new NetworkBridgeFilter();
+ }
+
+ /**
+ * Un-marshal an object instance from the data input stream
+ *
+ * @param o the object to un-marshal
+ * @param dataIn the data input stream to build the object from
+ * @throws IOException
+ */
+ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInputStream dataIn, BooleanStream bs) throws IOException {
+ super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+ NetworkBridgeFilter info = (NetworkBridgeFilter)o;
+ info.setNetworkTTL(dataIn.readInt());
+ info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
+
+ }
+
+
+ /**
+ * Write the booleans that this object uses to a BooleanStream
+ */
+ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+
+ NetworkBridgeFilter info = (NetworkBridgeFilter)o;
+
+ int rc = super.tightMarshal1(wireFormat, o, bs);
+ rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getNetworkBrokerId(), bs);
+
+ return rc + 4;
+ }
+
+ /**
+ * Write a object instance to data output stream
+ *
+ * @param o the instance to be marshaled
+ * @param dataOut the output stream
+ * @throws IOException thrown if an error occurs
+ */
+ public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutputStream dataOut, BooleanStream bs) throws IOException {
+ super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+ NetworkBridgeFilter info = (NetworkBridgeFilter)o;
+ dataOut.writeInt(info.getNetworkTTL());
+ tightMarshalCachedObject2(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut, bs);
+
+ }
+
+ /**
+ * Un-marshal an object instance from the data input stream
+ *
+ * @param o the object to un-marshal
+ * @param dataIn the data input stream to build the object from
+ * @throws IOException
+ */
+ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInputStream dataIn) throws IOException {
+ super.looseUnmarshal(wireFormat, o, dataIn);
+
+ NetworkBridgeFilter info = (NetworkBridgeFilter)o;
+ info.setNetworkTTL(dataIn.readInt());
+ info.setNetworkBrokerId((org.apache.activemq.command.BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn));
+
+ }
+
+
+ /**
+ * Write the booleans that this object uses to a BooleanStream
+ */
+ public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutputStream dataOut) throws IOException {
+
+ NetworkBridgeFilter info = (NetworkBridgeFilter)o;
+
+ super.looseMarshal(wireFormat, o, dataOut);
+ dataOut.writeInt(info.getNetworkTTL());
+ looseMarshalCachedObject(wireFormat, (DataStructure)info.getNetworkBrokerId(), dataOut);
+
+ }
+}
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/AtomicIntegerMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/CommandMarshaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/ResponseRedirectInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BrokerSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java (original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsQueueCompositeSendReceiveTest.java Tue Mar 21 15:20:55 2006
@@ -61,7 +61,7 @@
protected String getProducerSubject() {
return "FOO.BAR.HUMBUG,FOO.BAR.HUMBUG2";
}
-
+
/**
* Test if all the messages sent are being received.
*
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/LargeStreamletTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/ListContainerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/LoadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/Loader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/MapContainerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/StoreTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java (original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java Tue Mar 21 15:20:55 2006
@@ -1 +1,57 @@
-/**
*
* Copyright 2005-2006 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.
*/
package org.apache.activemq.openwire.v1;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.activemq.openwire.*;
import org.apache.activemq.command.*;
/**
* Test case for the OpenWire marshalling for NetworkBridgeFilter
*
*
* NOTE!: This file is auto generated - do not modify!
* if you need to
make a change, please see the modify the groovy scripts in the
* under src/gram/script and then use maven openwire:generate to regenerate
* this file.
*
* @version $Revision: $
*/
public class NetworkBridgeFilterTest extends DataFileGeneratorTestSupport {
public static NetworkBridgeFilterTest SINGLETON = new NetworkBridgeFilterTest();
public Object createObject() throws Exception {
NetworkBridgeFilter info = new NetworkBridgeFilter();
populateObject(info);
return info;
}
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
NetworkBridgeFilter info = (NetworkBridgeFilter) object;
info.setNetworkTTL(1);
info.setNetworkBrokerId(createBrokerId("NetworkBrokerId:1"));
}
}
\ No newline at end of file
+/**
+ *
+ * Copyright 2005-2006 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.
+ */
+package org.apache.activemq.openwire.v1;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.*;
+import org.apache.activemq.command.*;
+
+
+/**
+ * Test case for the OpenWire marshalling for NetworkBridgeFilter
+ *
+ *
+ * NOTE!: This file is auto generated - do not modify!
+ * if you need to make a change, please see the modify the groovy scripts in the
+ * under src/gram/script and then use maven openwire:generate to regenerate
+ * this file.
+ *
+ * @version $Revision: $
+ */
+public class NetworkBridgeFilterTest extends DataFileGeneratorTestSupport {
+
+
+ public static NetworkBridgeFilterTest SINGLETON = new NetworkBridgeFilterTest();
+
+ public Object createObject() throws Exception {
+ NetworkBridgeFilter info = new NetworkBridgeFilter();
+ populateObject(info);
+ return info;
+ }
+
+
+ protected void populateObject(Object object) throws Exception {
+ super.populateObject(object);
+ NetworkBridgeFilter info = (NetworkBridgeFilter) object;
+ info.setNetworkTTL(1);
+ info.setNetworkBrokerId(createBrokerId("NetworkBrokerId:1"));
+
+ }
+ }
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/NetworkBridgeFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/BrokerException.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/BrokerException.cs?rev=387665&r1=387664&r2=387665&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/BrokerException.cs (original)
+++ incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/BrokerException.cs Tue Mar 21 15:20:55 2006
@@ -1,54 +1,54 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * 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.
- */
-using ActiveMQ.Commands;
-using NMS;
-
-namespace ActiveMQ
-{
-
- /// <summary>
- /// Exception thrown when the broker returns an error
- /// </summary>
- public class BrokerException : NMSException
- {
-
- private BrokerError brokerError;
-
- public BrokerException(BrokerError brokerError) : base(
- brokerError.ExceptionClass + " : " + brokerError.Message)
- {
- this.brokerError = brokerError;
- }
-
- public BrokerError BrokerError
- {
- get {
- return brokerError;
- }
- }
-
- public virtual string JavaStackTrace
- {
- get {
- return brokerError.StackTrace;
- }
- }
-
- }
-}
-
-
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * 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.
+ */
+using ActiveMQ.Commands;
+using NMS;
+
+namespace ActiveMQ
+{
+
+ /// <summary>
+ /// Exception thrown when the broker returns an error
+ /// </summary>
+ public class BrokerException : NMSException
+ {
+
+ private BrokerError brokerError;
+
+ public BrokerException(BrokerError brokerError) : base(
+ brokerError.ExceptionClass + " : " + brokerError.Message)
+ {
+ this.brokerError = brokerError;
+ }
+
+ public BrokerError BrokerError
+ {
+ get {
+ return brokerError;
+ }
+ }
+
+ public virtual string JavaStackTrace
+ {
+ get {
+ return brokerError.StackTrace;
+ }
+ }
+
+ }
+}
+
+
Propchange: incubator/activemq/trunk/activemq-dotnet/src/main/csharp/ActiveMQ/BrokerException.cs
------------------------------------------------------------------------------
svn:eol-style = native