hi,
something like:
1 import java.util.*;
2 public abstract class AbstractConstant
3 {
4 public final static int APP1 = 1;
5 public final static int APP2 = 2;
6 private final static String cdb =
"currentDB";
7 private final static String DBURL =
"dbURL";
8 public static class App1Constant extends
AbstractConstant {
9 public App1Constant() {
10 super();
11 setDBUrl( rb.getString( DBURL + currentDB
+ APP1 ) );
12 }
13 }
14 public static class App2Constant extends
AbstractConstant {
15 public App2Constant() {
16 super();
17 setDBUrl( rb.getString( DBURL + currentDB
+ APP2 ) );
18 }
19 }
20 private String dbURL = null;
21 private String rbString = "ac";
22 protected ResourceBundle rb = null;
23 protected String currentDB = null;
24 public AbstractConstant() {
25 rb = ResourceBundle.getBundle( rbString );
26 currentDB = rb.getString( cdb );
27 }
28 public void setDBUrl( String s ) {
29 this.dbURL = s;
30 }
31 public String getDBUrl() {
32 return this.dbURL;
33 }
34 public static AbstractConstant Create( int
i ) {
35 AbstractConstant ap = null;
36 if( APP1 == i ) {
37 ap = new AbstractConstant.App1Constant();
38 }
39 else if( APP2 == i ) {
40 ap = new AbstractConstant.App2Constant();
41 }
42 return ap;
43 }
44 }
45 public class App1
46 {
47 private AbstractConstant abcon =
AbstractConstant.Create( AbstractConstant.APP1 );
48 public App1() {
49 System.out.println( "1 dburl: " +
abcon.getDBUrl() );
50 }
51 public static void main( String[] arg ) {
52 App1 ap = new App1();
53 }
54 }
55 public class App2
56 {
57 private AbstractConstant abcon =
AbstractConstant.Create( AbstractConstant.APP2 );
58 public App2() {
59 System.out.println( "2 dburl: " +
abcon.getDBUrl() );
60 }
61 public static void main( String[] arg ) {
62 App2 ap = new App2();
63 }
64 }
65 currentDB=oracle
66 dbURLpostgres1=something1
67 dbURLpostgres2=something2
68 dbURLoracle1=somethingElse1
69 dbURLoracle2=somethingElse2
ron
--- Rodrigo Gevaerd <[EMAIL PROTECTED]> wrote:
> 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
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
===========================================================================
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