Hi,
I have tried several days to config two application on Tomcat-Turbine-WebMacro
stucture. I do it this way:
1. in server.xml add two application:
2. create two directory in webapps directory
3. config web.xml of each directory, and config Turbine to use different
TurbineResources.properties file.
4. Config Turbineresouces.properties:
module.package = org.package.one.modules, org.package.two.modules,...
5. in WebMacro.properties config: TemplatePath=/home/one/templates:/home/two/templates
6. copy the one.jar fiel and two.jar file to classpath.
Now I have two applciation installed. I can visit system by:
localhost:8080/one/servlet/Turbine
localhost:8080/two/servlet/Turbine
In fact, I found this is not real two seperated application. I found that turbine will
look for screen class and *.wm file in all the templatepath and classpath.
for example: abc.wm org.package.two.modules.abc belong to applcation two.
I still can access this screen by:
localhost:8080/one/servlet/Turbine/template/abc.wm.
Regards
fanyun
----- Original Message -----
From: "Shamil Yahin" <[EMAIL PROTECTED]>
To: "Turbine" <[EMAIL PROTECTED]>
Sent: Thursday, July 27, 2000 3:09 PM
Subject: Re: Several applications over one Turbine
> Hi,
>
> I have more specified suggestion regarding that problem.
>
> [skipped]
> > Another kind of solution that does not require to bound package names
> > with some conditions can be creating aliases with mappings to the
> > packages in the TurbineResources.properties.
> [skipped]
> > But I think making changes in turbine myself is the last thing I would
> > like to do cause I want to have my application to be separate and
> > independent from turbine framework.
> >
> > So the question is do you have plans to implement some kind of solution
> > in your framework?
>
> I can do it myself. I just worry about if you have different
> vision of that problem you can solve it in different way and I'll need to
> recode my application sources in future.
>
> But if you do not mind to add such kind of solution to Turbine project
> I can implement it. My proposal is the following (we can discuss):
>
> 1) Add additional properties in TurbineResources.properties:
> ---------------------------------------------------------
> # paths according names
> module.package.name = PlugInOne
> module.package.PlugInTwo = org.package.one.modules,...
>
> module.package.name = PlugInTwo
> module.package.PlugInTwo = org.package.two.modules,...
>
> # default path in old property
> module.package = org.company.core.modules, org.apache.turbine.modules
>
> ---------------------------------------------------------
>
> 2) Then for example in ActionLoader we change only
> packages variable and getInstance(name) and getInstance().
>
> It can be something like this:
>
> ---------------------------------------------------------
> // Hashtable instead of vector.
> // It will store keys from module.package.name with corresponding
> // values from module.package.<name>
> // see getInstance() for details
> private Hashtable packages;
>
>
> // new predefined key for default path
> private static String DEFAULT_PATH_KEY = "some.turbine.default.key";
>
>
> // name can be in form 'something.something'
> public Action getInstance (String name) throws Exception
> {
> Action action = null;
> try
> {
> if ( cache() && this.containsKey ( name ) )
> {
> action = ( Action ) this.get ( name );
> }
> else
> {
> // searching class in different paths
> // use prefix as a key in packages hashtable
> // and suffix as a class name
> String prefix = null;
> String suffix = null;
> int pos = name.indexOf('.');
> if ( pos = -1 )
> {
> prefix = DEFAULT_PATH_KEY;
> suffix = name;
> } else {
> prefix = name.substring( 1, pos+1 );
> suffix = name.substring( pos );
> }
>
> if ( prefix==null || suffix==null ){
> prefix = DEFAULT_PATH_KEY;
> suffix = name;
> }
>
> // try to search in specified path
> Vector paths = (Vector) instance.packages.get( key );
> for (int i=0; i<paths.size(); i++)
> {
> // add suffix to the path
> String className = (String)paths.elementAt(i) + ".actions." +
>suffix;
> try
> {
> Class servClass = Class.forName( className );
> action = ( Action ) servClass.newInstance();
> addInstance ( name, action );
> return action;
> }
> catch (ClassNotFoundException cnfe)
> {
> // do this so we loop through all the packages
> }
> catch (ClassCastException cce)
> {
> // do this so we know what class is having problems
> throw new ClassCastException( className );
> }
> }
>
> // Now search in default place but first
> // check this for not searching there twice
> if ( key.equals(DEFAULT_PATH_KEY) == false )
> {
> paths = (Vector) instance.packages.get ( DEFAULT_KEY );
> for (int i=0; i<paths.size(); i++)
> {
>
> String className = (String)paths.elementAt(i) + ".actions."
>+ name;
> try
> {
> Class servClass = Class.forName( className );
> action = ( Action ) servClass.newInstance();
> addInstance ( name, action );
> return action;
> }
> catch (ClassNotFoundException cnfe)
> {
> // do this so we loop through all the packages
> }
> catch (ClassCastException cce)
> {
> // do this so we know what class is having problems
> throw new ClassCastException( className );
> }
> }
> }
> // if we got here the class is really not found
> throw new ClassNotFoundException();
> }
> }
> catch ( ClassNotFoundException e )
> {
> // TODO: need to change error message
> throw new Exception ( "\n\n\tRequested Action not found: " +
> name + "\n" +
> "\tTurbine looked in the following
>modules.packages path: \n\t" +
> instance.packages.toString() + "\n");
> }
> return action;
> }
>
>
> // This method is modified for loading several
> // paths from TurbineResources.properties
> public static ActionLoader getInstance()
> {
> if (instance == null)
> {
> synchronized (ActionLoader.class)
> {
> if (instance == null)
> {
> int size = TurbineResources.getInt("action.cache.size",20);
> instance = new ActionLoader(size);
>
> // loading all modules paths
> Enumeration e =
>TurbineResources.getVector("module.package.name").elements();
>
> while (e.hasMoreElements())
> {
> String moduleName = (String)e.nextElement();
> Vector modulePaths =
>TurbineResources.getVector("module.package." + moduleName);
> instance.packages.put( moduleName, modulePaths );
> }
> // storing default path
> Vector defaultPaths =
>TurbineResources.getVector("module.packages");
> defaultPaths.addElement( GenericLoader.getBasePackage() );
> instance.packages.put( DEFAULT_KEY, defaultPaths );
>
> }
> }
> }
> return instance;
> }
> ---------------------------------------------------------
>
> This modification will not change the old behavior of loader
> with only one module.packages property.
>
> What is your opinion?
>
>
> /Shamil
>
>
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?: [EMAIL PROTECTED]
>
���r��z۫n)ޢyb��(�H��� ��&N�����r��z۫n)ޡ���p��"�h��(�'���a���
0���j�!����o�����4�+-�x��oϮ��zk#�|(�H��� ��&