#46237: preset size of BAOStream BLD200502211900
authordprusa@netbeans.org
Mon, 21 Feb 2005 18:52:37 +0000
changeset 16634e4e7f740ebe
parent 1662 d5e21f0ce6f2
child 1664 79270a45ef2d
#46237: preset size of BAOStream
mdr/src/org/netbeans/mdr/handlers/gen/HandlerGenerator.java
     1.1 --- a/mdr/src/org/netbeans/mdr/handlers/gen/HandlerGenerator.java	Mon Feb 21 14:34:26 2005 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/handlers/gen/HandlerGenerator.java	Mon Feb 21 18:52:37 2005 +0000
     1.3 @@ -51,26 +51,34 @@
     1.4      protected static final String HANDLE_PREFIX = "_handle"; //NOI18N
     1.5      protected static final String CUSTOM_PREFIX = "super_"; //NOI18N
     1.6      
     1.7 +    private static final int PROXY_DEF_LENGTH = 3200;
     1.8 +    private static final int INSTANCE_DEF_LENGTH = 32000;
     1.9 +    
    1.10      /* -------------------------------------------------------------------- */
    1.11      /* -- Static methods (public) ----------------------------------------- */
    1.12      /* -------------------------------------------------------------------- */
    1.13 -
    1.14 +    
    1.15      /**
    1.16       * Generate a handler class given a name, interface and storable object to
    1.17       * be wrapped by a handler object.
    1.18       */
    1.19      public static byte[] generateHandler(final String name, Class ifc, StorableBaseObject storable) {
    1.20          HandlerGenerator gen;
    1.21 +        int def_length;
    1.22          try {
    1.23              if (storable instanceof StorableAssociation) {
    1.24                  gen = new AssociationGenerator(name, ifc, ((StorableAssociation)storable).getAssociationSuperclass(), (StorableAssociation)storable, ((StorableAssociation)storable).getAssociationCustomImpl());
    1.25 +                def_length = PROXY_DEF_LENGTH;
    1.26              } else if (storable instanceof StorableClass) {
    1.27                  gen = new ClassGenerator(name, ifc, ((StorableClass) storable).getClassSuperclass(), (StorableClass)storable, ((StorableClass) storable).getClassCustomImpl());
    1.28 +                def_length = PROXY_DEF_LENGTH;
    1.29              } else if (storable instanceof StorablePackage) {
    1.30                  gen = new PackageGenerator(name, ifc, ((StorablePackage) storable).getPackageSuperclass(), (StorablePackage)storable, ((StorablePackage) storable).getPackageCustomImpl());
    1.31 +                def_length = INSTANCE_DEF_LENGTH;
    1.32              } else if (storable instanceof StorableObject) {
    1.33                  StorableClass proxy = ((StorableObject) storable).getClassProxy();
    1.34                  gen = new InstanceGenerator(name, ifc, proxy.getInstanceSuperclass(), (StorableObject)storable, proxy.getInstanceCustomImpl());
    1.35 +                def_length = INSTANCE_DEF_LENGTH;
    1.36              } else {
    1.37                  throw new InternalError("Unknow dispatcher type."); //NOI18N
    1.38              }
    1.39 @@ -78,7 +86,7 @@
    1.40              throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
    1.41          }
    1.42          
    1.43 -        ByteArrayOutputStream bout = new ByteArrayOutputStream();
    1.44 +        ByteArrayOutputStream bout = new ByteArrayOutputStream(def_length);
    1.45          gen.generateClassFile(bout);
    1.46          return bout.toByteArray();
    1.47      }