ozone core API

org.ozoneDB.tools.OPP.srcgen.builder
Class ProxyBuilder

java.lang.Object
  extended byorg.ozoneDB.tools.OPP.srcgen.builder.ProxyBuilder
All Implemented Interfaces:
ClassBuilder

public class ProxyBuilder
extends java.lang.Object
implements ClassBuilder

Builds an ozone Proxy. The code is lifted out of the proxy generator and adapted to the builder director pattern. A lot oof code changes has to do with the absence of reflection dependency in the implementation of the builder director pattern implementation. The proxy builder still depends heavily on reflection, something that could probably be dealt with. The changes we have now is a lot of String lookup functionality for classes. We'd like to support static inner classes as OzoneObjects, but where should the proxy classes be defined? Within the the proxy class of the enclosing class? If so, what if the enclosing class is not OzoneCompatible?

Author:
SMB, Medium.net, Per Nyfelt, Joakim Ohlrogge

Nested Class Summary
 
Nested classes inherited from class org.ozoneDB.tools.OPP.srcgen.ClassBuilder
ClassBuilder.Parameter
 
Field Summary
private  boolean cache
           
private  java.lang.String className
           
private  java.lang.Class implementationClass
           
private  MessageWriter msgWriter
           
private  OutputStreamFactory osFactory
           
private  java.io.PrintWriter out
           
private  java.lang.String postfix
           
private  boolean printStackTrace
           
private  java.lang.String proxyClassName
           
private  java.util.Collection remoteInterfaces
           
private  java.lang.reflect.Method[] sortedMethods
           
 
Constructor Summary
ProxyBuilder(OutputStreamFactory osFactory, java.lang.String postfix, boolean printStackTrace, boolean cache, MessageWriter listener)
           
 
Method Summary
 void beginClass(int modifer, java.lang.String fullName, java.lang.String superClass, java.lang.String[] interfaces)
          Called for each new class.
 void endClass()
          Called at the end of each generated class.
private  java.util.Collection findRemoteInterfaces(java.lang.String[] interfaces)
           
private  java.lang.Class getClassForType(java.lang.String type)
           
private  int getMethodIndex(java.lang.String method, ClassBuilder.Parameter[] parameters)
           
private  java.lang.String[] getTypes(ClassBuilder.Parameter[] parameters)
           
 void init(MessageWriter msgWriter)
          Initializes the builder for each new build.
 void makeConstructor(int modifier, ClassBuilder.Parameter[] parameters, java.lang.String[] exceptions)
          Called for each constructor in the current class
private  void makeCreateMethod(ClassBuilder.Parameter[] parameters, java.lang.String[] exceptions)
           
private  void makeCstr(ClassBuilder.Parameter[] parameters, java.lang.String[] exceptions)
           
private  void makeCtrs()
           
private  void makeGlobalHeader(java.lang.String implementationClass)
           
private  void makeLocalHeader(java.lang.String proxyClassName)
           
 void makeMethod(int modifier, java.lang.String name, ClassBuilder.Parameter[] parameters, java.lang.String returnType, java.lang.String[] exceptions, int lockLevel)
          Called for each method in the current class
private  java.lang.Class[] parametersToClasses(ClassBuilder.Parameter[] parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private java.io.PrintWriter out

osFactory

private OutputStreamFactory osFactory

postfix

private java.lang.String postfix

remoteInterfaces

private java.util.Collection remoteInterfaces

printStackTrace

private boolean printStackTrace

cache

private boolean cache

msgWriter

private MessageWriter msgWriter

className

private java.lang.String className

proxyClassName

private java.lang.String proxyClassName

implementationClass

private java.lang.Class implementationClass

sortedMethods

private java.lang.reflect.Method[] sortedMethods
Constructor Detail

ProxyBuilder

public ProxyBuilder(OutputStreamFactory osFactory,
                    java.lang.String postfix,
                    boolean printStackTrace,
                    boolean cache,
                    MessageWriter listener)
Method Detail

getMethodIndex

private int getMethodIndex(java.lang.String method,
                           ClassBuilder.Parameter[] parameters)
                    throws java.lang.ClassNotFoundException,
                           java.lang.NoSuchMethodException
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

parametersToClasses

private java.lang.Class[] parametersToClasses(ClassBuilder.Parameter[] parameters)
                                       throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getClassForType

private java.lang.Class getClassForType(java.lang.String type)
                                 throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getTypes

private java.lang.String[] getTypes(ClassBuilder.Parameter[] parameters)

makeCtrs

private void makeCtrs()

makeGlobalHeader

private void makeGlobalHeader(java.lang.String implementationClass)

makeLocalHeader

private void makeLocalHeader(java.lang.String proxyClassName)

makeCstr

private void makeCstr(ClassBuilder.Parameter[] parameters,
                      java.lang.String[] exceptions)

makeCreateMethod

private void makeCreateMethod(ClassBuilder.Parameter[] parameters,
                              java.lang.String[] exceptions)

findRemoteInterfaces

private java.util.Collection findRemoteInterfaces(java.lang.String[] interfaces)
                                           throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

init

public void init(MessageWriter msgWriter)
Description copied from interface: ClassBuilder
Initializes the builder for each new build. This method may be called several times during the lifetime of the builder but only once for each build. This method may be used reset any internal state that the builder may have.

Specified by:
init in interface ClassBuilder
Parameters:
msgWriter - The writer the builder should use to report messages.

beginClass

public void beginClass(int modifer,
                       java.lang.String fullName,
                       java.lang.String superClass,
                       java.lang.String[] interfaces)
                throws BuilderException
Description copied from interface: ClassBuilder
Called for each new class. May be called moore than once if the class has inner classes.

Specified by:
beginClass in interface ClassBuilder
Parameters:
modifer - The modifiers for this class
fullName - The full name including package path of this class
superClass - The full name including package pathh for this class
interfaces - The interfaces implemented by this class
Throws:
BuilderException

makeConstructor

public void makeConstructor(int modifier,
                            ClassBuilder.Parameter[] parameters,
                            java.lang.String[] exceptions)
                     throws BuilderException
Description copied from interface: ClassBuilder
Called for each constructor in the current class

Specified by:
makeConstructor in interface ClassBuilder
Parameters:
modifier - The modifier for this constructor
parameters - The parameters for this constructor
exceptions - The exceptions thrown by this constructor
Throws:
BuilderException

makeMethod

public void makeMethod(int modifier,
                       java.lang.String name,
                       ClassBuilder.Parameter[] parameters,
                       java.lang.String returnType,
                       java.lang.String[] exceptions,
                       int lockLevel)
                throws BuilderException
Description copied from interface: ClassBuilder
Called for each method in the current class

Specified by:
makeMethod in interface ClassBuilder
Parameters:
modifier - The modifiers for the method
name - The name of the method
parameters - The parameter list for the method
returnType - The return type of the method, use null for void
exceptions - The exceptions thrown by the method
lockLevel - The lock level for this method
Throws:
BuilderException

endClass

public void endClass()
              throws BuilderException
Description copied from interface: ClassBuilder
Called at the end of each generated class. Must be called once and once only for each beginClass.

Specified by:
endClass in interface ClassBuilder
Throws:
BuilderException

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.