Re: [OJB-developers] Ojbgen code generator
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-05-31 11:49:12
|
Hi Hoang, Hoang, Hai wrote: > I've some code that read the repository.xml Reading a repository.xml is done by ojb.broker.metadata.RepositoryPersistor. I see no reason to duplicate this functionality. If your code uses the RepositoryPersistor, OK! If not please refactor it to use the RepositoryPersistor. > and generate java code That's interesting. You are generating code from a ojb.broker.metadata.DescriptorRepository or directly from the parsed repository.xml file? If you are generating from DescriptorRepository you solution could be the step towards the OJB code genartor stuff! Are you using a special library for code generation, or do you generate Java code manually? I'd prefer using an existing opensource library! > for the > following pattern from previous project (ATG) and now I want to port over to > OJB and donate it to the ojb community. > thanks! > For example, if I have a class descriptor and these are classes will be > generated: > > User (interface) > UserImpl (class) > UserManager (interface) > UserManagerImpl (class) > IMO there should be some kind of template mechanism to allow user-defined generation schemes. Generating those for classes may be perfect for your environment. But others would like different schemes. In my company we use: User (interface) UserBaseImpl implements User (abtract class, only getters and setters are implemented) UserImpl extends UserBaseImpl (all other methods are implemented here) UserHome (factory class) We should not force OJB use to use a specific generation scheme. > 1. I would like to know, which class parses the repository.xml for > information purposes only (without validation), so I can use the information > in the repository to generate code. Have a look at ojb.broker.metadata.RepositoryPersistor. This guy builds up the DescriptorRepository from a repository.xml (and in the near future from a repository.jdo) file. BUT:it uses validation! (I don't understand why you do not to use XML validation???) > > 2. Can we possibly add a > <interface.name>com.xyz.Permission</interface.name> tag to the class > descriptor along with <class.name>com.xyz.PermissionImpl</class.name>? > There is already a mechanism to define interface based extends in the repository. For example there is an extent declaration for "InterfaceArticle" in our junit testsuite repository_junit.xml declaring all implementations of this IF. This could also be used to get your required information The DescriptorRepository is meant for object/relational mapping information. Metainformation related to codegeneration patterns should be kept in a separate place. The best way (as mentioned above) would be to provide a template mechanism to allow maximum flexibility. > 3. Can I reuse the metadata package to store the parsed information from > the repository.xml without required runtime classes? for example, if I have > a <class.name>com.xyz.PermissionImpl</class.name> in one of my class > descriptor and the file is not yet genereated, will this causes me problem? > Oops, you got me! This is an aspect I did not think about before! In fact the current DescriptorRepository relies on existing persistent classes. There are several places where the XmlRepositoryHandler tries a Class.forName(...), which will cause a lot of exceptions in the case you are describing. The same holds true for attribute fields (or getter/setter methods if you are using bean access). But it should not be too difficult to change this. A ClassDescriptor should be marked with a special tag saying "this class could not be found and should be generated". cheers, Thomas > Thank you, > > Hai > > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's Conference > August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > |