Re: playing around with helma.servlet.StandaloneServletClient
"Hannes Wallnoefer" <[email protected]> Wed, 2 Apr 2008 15:48:39 +0200
| Newsgroups | gmane.comp.java.helma.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks, Philipp. I committed your patch and closed bug 544. http://helma.org/bugs/show_bug.cgi?id=544 hannes 2008/3/17, Franz Philipp Moser <[email protected]>: > Hi list, > > this weekend I played around with helma and tomcat. First of all it > works nice with some drawbacks. > > * you can't use app.__app__.getAppDir > * you can't use repositories > > These 2 things are really annoying so I tried to overcome them with some > java in helma.servlet.StandaloneServletClient. > > The first things is simple: > in helma/servlet/StandaloneServletClient.java FIND: > {{{ > app = new Application(appName, repositories, dbHome); > }}} > > REPLACE WITH: > {{{ > File appHome = new File(appDir); > app = new Application(appName, null, repositories, appHome, dbHome); > }}} > > So everything is OK with the getAppDir function. Maybe we should ad a > new constructor to the Application class, would be more elegant. > > Second is to copy the code from the ApplicationManager where the > repositories are read from apps.properties. This is double code and > should be solved different! > > add import java.util.* to the imports. > > > IN helma/servlet/StandaloneServletClient.java FIND: > {{{ > public final class StandaloneServletClient extends AbstractServletClient { > private Application app = null; > private String appName; > private String appDir; > private String dbDir; > }}} > > INSERT AFTER: > {{{ > private Repository[] repositories; > }}} > > IN helma/servlet/StandaloneServletClient.java FIND: > {{{ > dbDir = init.getInitParameter("dbdir"); > > if ((dbDir == null) || (dbDir.trim().length() == 0)) { > throw new ServletException("dbdir parameter not specified"); > } > }}} > > INSERT AFTER: > {{{ > Class[] parameters = { String.class }; > ArrayList repositoryList = new ArrayList(); > for (int i = 0; true; i++) { > String repositoryArgs = > init.getInitParameter("repository." + i); > if (repositoryArgs != null) { > // lookup repository implementation > String repositoryImpl = > init.getInitParameter("repository." + i + > ".implementation"); > if (repositoryImpl == null) { > // implementation not set manually, have to guess it > if (repositoryArgs.endsWith(".zip")) { > repositoryImpl = > "helma.framework.repository.ZipRepository"; > } else if > (repositoryArgs.endsWith(".js")) { > repositoryImpl = > "helma.framework.repository.SingleFileRepository"; > } else { > repositoryImpl = > "helma.framework.repository.FileRepository"; > } > } > > try { > Repository newRepository = (Repository) > Class.forName(repositoryImpl) > .getConstructor(parameters) > .newInstance(new Object[] { repositoryArgs }); > repositoryList.add(newRepository); > log("adding repository: " + repositoryArgs); > } catch (Exception ex) { > log("Adding repository " + repositoryArgs + " failed. " > + > "Will not use that repository. Check your initArgs!", > ex); > } > } else { > // we always scan repositories 0-9, beyond that only if > defined > if (i > 9) { > break; > } > } > } > > // add app dir > FileRepository appRep = new FileRepository(appDir); > log("adding repository: " + appDir); > if (!repositoryList.contains(appRep)) { > repositoryList.add(appRep); > } > repositories = new > Repository[repositoryList.size()]; > repositoryList.toArray(repositories); > }}} > > IN helma/servlet/StandaloneServletClient.java REMOVE this > to lines: > {{{ > Repository[] repositories = new Repository[1]; > repositories[0] = new FileRepository(new File(appDir)); > }}} > This is it and you have a full helma with repositories and getAppDir ;) > > Maybe these code snippets go into svn. > > I added the svn diff so the patch can be applied easy. > > Please tell me what you think about these modifications. > > cu Philipp > > > _______________________________________________ > Helma-user mailing list > [email protected] > http://helma.org/mailman/listinfo/helma-user > > >