Hi,
my suggestion would be:
Write a class that implements ApplicationTool interface (i.e. write a
Pull service object with the scope Global
compile it and place in under
$TOMCAT_HOME/common/classes
or $TOMCAT_HOME/common/lib if you make a jar.
restart tomcat.
I've read from the tomcat documentation that
$TOMCAT4_HOME/common/classes path got added to all deployed webapps.
in the TurbineResource.properties files of both applications
register this class as a pull service with the scope Global
under the same name.
in the init() method call the getPool() method
write a a singleton class that instantiates just one instance of your
Global Pull object, an example is provided below.
as the class is registered as a pulls global pool service
it's public methods/members will be available in your .vm templates
Regards,
Slava
Here is an example of my BookPool singleton class
######################################
import java.sql.*;
/** A Singleton Class to load exactly one ConnectionPool object
*
*/
public class BookPool extends ConnectionPool
{
private static BookPool pool = null;
private static int vendorName;
private static String host = "localhost";
private static String dbName = "mydb";
private static String username = "me";
private static String password = "mypass";
private static int initialConnections = 5;
private static int maxConnections = 25;
private static boolean waitIfBusy = true;
//constructor
private BookPool(String vendorName,
String host, String dbName,
String username, String password,
int initialConnections, int maxConnections)
throws Exception
{
super(vendorName,
host, dbName,
username, password,
initialConnections,
maxConnections,
waitIfBusy);
}
public static BookPool getPool(String vendorName,
String host, String dbName,
String username, String password,
int initialConnections, int maxConnections)
{
if (pool == null)
{
try
{
pool = new BookPool(vendorName,
host, dbName,
username, password,
initialConnections, maxConnections);
}
catch (Exception e)
{
System.out.println("BookPool:" + e);
pool = null;
}
}
return pool;
}
}
#############################################################
On Wed, 2002-06-05 at 18:06, Edmund Urbani wrote:
>
> Hi!
>
> I wrote a similar question to the Tomcat-Users list, but then I thought,
> maybe there's a Turbine-way to solve this:
>
> I'm working on 2 Turbine webapps, that are both running on the same host
> (in the same Tomcat 4.0.1). Those 2 webapps would need to access a
> common object in memory - really the same instance and not just the same
> class. The way I understand Tomcat those 2 applications run in
> completely independent contexts... so, is there a way for them to "see"
> one another and have references to the same objects? Would Turbine
> somehow support this (a service I do not know yet?)?
>
> Edmund
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>