I guess that would work fine. But I am searching for a solution for any
number of application, without the need of changing code because the add or
removal of an application. If anyone thinking about how will the constants
values be different then, they are read from .ini text files, that are
different because they look for each in the context of their own web
application.

   Rodrigo.

>
> Hi,
>
> Maybe something like:
>
>
>      1  public abstract class AbstractConstant
>      2  {
>      3      private final static int APP1 = 1;
>      4      private final static int APP2 = 2;
>
>      5      public static class App1Constant extends
> AbstractConstant {
>      6          public App1Constant() {
>      7              setDBUrl( "some value for App1" );
>      8          }
>      9      }
>     10      public static class App2Constant extends
> AbstractConstant {
>     11          public App2Constant() {
>     12              setDBUrl( "some value for App2" );
>     13          }
>     14      }
>
>     15      private String dbURL = null;
>     16      public void setDBUrl( String s ) {
>     17          this.dbURL = s;
>     18      }
>     19      public String getDBUrl() {
>     20          return this.dbURL;
>     21      }
>     22      public static AbstractConstant Create( int
> i ) {
>     23          AbstractConstant ap = null;
>     24          if( APP1 == i ) {
>     25              ap = new AbstractConstant.App1Constant();
>     26          }
>     27          else if( APP2 == i ) {
>     28              ap = new AbstractConstant.App2Constant();
>     29          }
>     30          return ap;
>     31      }
>     32  }
>
>
>     33  public class App1
>     34  {
>     35      private AbstractConstant abcon =
> AbstractConstant.Create( 1 );
>     36      public App1() {
>     37          System.out.println( "1 dburl: " +
> abcon.getDBUrl() );
>     38      }
>     39      public static void main( String[] arg ) {
>     40          App1 ap = new App1();
>     41      }
>     42  }
>
>
>     43  public class App2
>     44  {
>     45      private AbstractConstant abcon =
> AbstractConstant.Create( 2 );
>     46      public App2() {
>     47          System.out.println( "2 dburl: " +
> abcon.getDBUrl() );
>     48      }
>     49      public static void main( String[] arg ) {
>     50          App2 ap = new App2();
>     51      }
>     52  }
>
>
> ron

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to