You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2001/05/22 15:41:24 UTC

cvs commit: xml-axis/java/src/org/apache/axis/server AxisServer.java

rubys       01/05/22 06:41:23

  Modified:    java/src/org/apache/axis/encoding TypeMappingRegistry.java
               java/src/org/apache/axis/server AxisServer.java
  Log:
  Make TypeMappingRegistry self managing (like the other registries)
  
  Revision  Changes    Path
  1.10      +57 -25    xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
  
  Index: TypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TypeMappingRegistry.java	2001/05/21 19:36:18	1.9
  +++ TypeMappingRegistry.java	2001/05/22 13:41:16	1.10
  @@ -72,6 +72,29 @@
    */
   public class TypeMappingRegistry implements Serializer { 
   
  +    // default location for save/load
  +    private String fileName = null;
  +
  +    /**
  +     * Constructor for persistent registries
  +     */
  +    public TypeMappingRegistry(String fileName) {
  +        this();
  +        this.fileName = fileName;
  +    }
  +
  +    /**
  +     * Default constructor (transient registry)
  +     */
  +    public TypeMappingRegistry() {}
  +
  +    /**
  +     * Init (ie. load settings...)
  +     */
  +    public void init() {
  +        // load();
  +    }
  +
       class SerializerDescriptor implements Serializable {
           QName typeQName;
           Serializer serializer;
  @@ -112,6 +135,7 @@
                                 Serializer serializer) {
           if (s == null) s = new Hashtable();
           s.put(_class, new SerializerDescriptor(qName, serializer));
  +        save();
       }
       
       public void addDeserializerFactory(QName qname,
  @@ -119,6 +143,7 @@
                                          DeserializerFactory deserializerFactory) {
           if (d == null) d= new Hashtable();
           d.put(qname, new DeserializerDescriptor(_class, deserializerFactory));
  +        save();
       }
   
       public Serializer getSerializer(Class _class) {
  @@ -160,10 +185,12 @@
       
       public void removeSerializer(Class _class) {
           if (s != null) s.remove(_class);
  +        save();
       }
       
       public void removeDeserializer(QName qname) {
           if (d != null) d.remove(qname);
  +        save();
       }
       
       public boolean hasSerializer(Class _class) {
  @@ -178,33 +205,38 @@
           return false;
       }
       
  -    public void save(OutputStream out) throws Exception {
  -        Hashtable reg = new Hashtable();
  -        reg.put("SERIALIZERS", s);
  -        reg.put("DESERIALIZERS", d);
  -        ObjectOutputStream oos = new ObjectOutputStream(out);
  -        oos.writeObject(reg);
  -        oos.close();
  -    }
  -    
  -    public void load(InputStream in) throws Exception {
  -        ObjectInputStream ois = new ObjectInputStream(in);
  -        Hashtable reg = (Hashtable)ois.readObject();
  -        s = (Hashtable)reg.get("SERIALIZERS");
  -        d = (Hashtable)reg.get("DESERIALIZERS");
  -        ois.close();
  -    }
  -    
  -    public void save(String filename) throws Exception {
  -        FileOutputStream fos = new FileOutputStream(filename);
  -        save(fos);
  -    }
  -    
  -    public void load(String filename) throws Exception {
  -        FileInputStream fis = new FileInputStream(filename);
  -        load(fis);
  +    public void save() {
  +        if (fileName == null) return;
  +
  +        try {
  +            FileOutputStream out = new FileOutputStream(fileName);
  +            Hashtable reg = new Hashtable();
  +            if (s!=null) reg.put("SERIALIZERS", s);
  +            if (d!=null) reg.put("DESERIALIZERS", d);
  +            ObjectOutputStream oos = new ObjectOutputStream(out);
  +            oos.writeObject(reg);
  +            oos.close();
  +        } catch (Exception e) {
  +            e.printStackTrace( System.err );
  +        }
       }
  +    
  +    private void load() {
  +        if (fileName == null) return;
   
  +        try {
  +            FileInputStream in = new FileInputStream(fileName);
  +            ObjectInputStream ois = new ObjectInputStream(in);
  +            Hashtable reg = (Hashtable)ois.readObject();
  +            s = (Hashtable)reg.get("SERIALIZERS");
  +            d = (Hashtable)reg.get("DESERIALIZERS");
  +            ois.close();
  +        } catch (FileNotFoundException fnfe) {
  +        } catch (Exception e) {
  +            e.printStackTrace( System.err );
  +        }
  +    }
  +    
       public Attributes setTypeAttribute(Attributes attributes, QName type,
                                          SerializationContext context)
       {
  
  
  
  1.9       +1 -7      xml-axis/java/src/org/apache/axis/server/AxisServer.java
  
  Index: AxisServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AxisServer.java	2001/05/22 05:25:35	1.8
  +++ AxisServer.java	2001/05/22 13:41:20	1.9
  @@ -110,13 +110,7 @@
           addOption( Constants.SERVICE_REGISTRY, sr );
   
           // Load the registry of deployed types
  -        TypeMappingRegistry tmr = new TypeMappingRegistry();
  -        try {
  -            tmr.load("typemap-supp.reg");
  -        } catch (Exception e) {
  -            // ignore FileNotFoundException
  -            // what to do about the rest?
  -        }
  +        TypeMappingRegistry tmr = new TypeMappingRegistry("typemap-supp.reg");
           tmr.setParent(new SOAPTypeMappingRegistry());
           addOption( Constants.TYPEMAP_REGISTRY, tmr );