|
Right Java tools for J2EE, Web Service, Grid and more |
| |Home | Products | Documents | Downloads | Purchase | Support | Company | Partners | Contact | |
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.acelet.opensource.globalEnvironment.GlobalProperties
public class GlobalProperties
The GlobalEnvironment is a set of classes providing
persistent key - value pairs across different application and components.
GlobalEnvironment is a global version of
java.util.Properties and java.util.Hashtable. Properties and Hashtable
are valid within one single Java VM.
GlobalEnvironment is valid across
the whole network in distributed computing environment.
------------------
|GlobalEnvironment |
EJB <-------------->| |<----->Java application
JSP <-------------->| ---------- |
Servlet <---------->| | | |
Grid computing <--->| |(Database)|<----->C++ application
Helper class <----->| | |<----->Other application
| ---------- |
------------------
There are following classes in this family:
This family is thread safe.
This is a database application. The transaction behavior is subject to database isolation level and other setting.
GlobalProperties is a global version of
java.util.Properties. The data type of key - value
pair is String - String.
GlobalHashtable is a global version of
java.util.Hashtable. The data type of key - value
pair is Object - Object.
GlobalObject fills the gap between
GlobalProperties and GlobalHashtable.
The data type of key - value pair is String - Object.
GlobalDouble is for real numbers.
GlobalLong is for integer type of numbers.
The methods increase in both GlobalDouble and GlobalLong
provide a thread friendly functionality on
top of thread safe behavior: a thread will not overwrite changes from
other threads. For example, you have an attribute "totalSale".
The current value is 10.00. Now you sold something for 2.00 and your
coworker sold something for 5.00 at the same time. If you do:
read totalSale and get the value 10.00
write totalSale as 10.00 + 2.00
and your coworker does similaly. Than the result will be either
12.00 or 15.00, not 17.00.
increase, do not read, do not write, but:
increase by 2.00
and your coworker does similaly. The result will be 17.00,
reguardless of who gets the transaction first.
GlobalEnvironment has most of applicable methods from
java.util.Properties and java.util.Hashtable.
The method signatures are similar, but with a
java.sql.Connection as the first parameter.
Please see java.util.Propertes and
java.util.Hashtable for method descriptions.
GlobalEnvironment is designed to be vender and platform neutral.
GlobalEnvironment is designed for J2EE (Java 2 Enterprise Edition) and
EJB (Enterprise Java Beans). In J2EE/EJB world there is no standard way
to set a global environment to share objects across JSP,
Servlet and EJB. GlobalEnvironment solves this problem.
GlobalEnvironment can be use outside of J2EE/EJB as well.
Note: Transaction issue: There is no COMMIT or ROLLBACK inside GlobalEnvironment library. We assume that EJB container will take care of it, or you have to explicitly take care of it.
If you want to modify GlobalEnvironment (by calling method clear, put...)
and want your modification be a part of a transaction, you should
assign Connection parameter using the same instance with other
class/method calls within the same transaction to ensure the
integraty of the transaction. Or you have to do it in two phase commit.
If you want to modify GlobalEnvironment (by calling method clear, put...)
and do NOT want your modification be a part of a transaction,
you should not do so within another transaction.
Use a different Connection may or may not be good enough.
Some J2EE/EJB vendors are "transaction smart". If you
modify GlobalEnvironment using a different instance of Connection,
but with the same database, the server may treat it the same
as if you used the same instance of Connection.
So your modification will be subject of COMMIT and ROLLBACK within the
transaction. If you want your modification to be independent, do not
modify it within other transactions.
Note: The objects in GlobalHashtable and
GlobalObject must be serializable. That is: those objects
must implement java.io.Serializable. This is the only
requirement.
Note: Some databases have limitations on
the size of primary keys. This affect GlobalHashtable.
You can modify the size of theKey on globalHashtable to
make a compromise between fast access and the size limitation for your keys.
See SQL script files included in this package for details.
Note: the key must be unique.
Note: The key of java.util.Properties is case
sensitive String. GlobalProperties and GlobalObject assume that
the SELECT statement on underlying database is case
sensitive.
Requirements: SQL database. Please see enclosed script files for setup required tables with some databases.
Contributors:
GlobalDouble,
GlobalHashtable,
GlobalLong,
GlobalObject,
Serialized Form| Field Summary | |
|---|---|
java.lang.String |
VERSION
|
| Constructor Summary | |
|---|---|
GlobalProperties()
|
|
GlobalProperties(int queryTimeout)
|
|
| Method Summary | |
|---|---|
static void |
clear(java.sql.Connection connection)
|
static boolean |
contains(java.sql.Connection connection,
java.lang.String value)
|
static boolean |
containsKey(java.sql.Connection connection,
java.lang.String key)
|
static boolean |
containsValue(java.sql.Connection connection,
java.lang.String value)
|
static java.util.Enumeration |
elements(java.sql.Connection connection)
|
static java.lang.String |
get(java.sql.Connection connection,
java.lang.String key)
|
static java.lang.String |
getProperty(java.sql.Connection connection,
java.lang.String key)
|
static java.lang.String |
getProperty(java.sql.Connection connection,
java.lang.String key,
java.lang.String defaultValue)
|
static boolean |
isEmpty(java.sql.Connection connection)
|
static java.util.Enumeration |
keys(java.sql.Connection connection)
|
static void |
main(java.lang.String[] args)
|
static java.util.Enumeration |
propertyNames(java.sql.Connection connection)
|
static java.lang.String |
put(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
|
static java.lang.String |
remove(java.sql.Connection connection,
java.lang.String key)
|
static java.lang.Object |
remove(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
|
static java.lang.String |
setProperty(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
|
static int |
size(java.sql.Connection connection)
|
static java.util.Collection |
values(java.sql.Connection connection)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String VERSION
| Constructor Detail |
|---|
public GlobalProperties()
public GlobalProperties(int queryTimeout)
| Method Detail |
|---|
public static void clear(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static boolean contains(java.sql.Connection connection,
java.lang.String value)
throws java.lang.Exception
java.lang.Exception
public static boolean containsKey(java.sql.Connection connection,
java.lang.String key)
throws java.lang.Exception
java.lang.Exception
public static boolean containsValue(java.sql.Connection connection,
java.lang.String value)
throws java.lang.Exception
java.lang.Exception
public static java.util.Enumeration elements(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String get(java.sql.Connection connection,
java.lang.String key)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String getProperty(java.sql.Connection connection,
java.lang.String key)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String getProperty(java.sql.Connection connection,
java.lang.String key,
java.lang.String defaultValue)
throws java.lang.Exception
java.lang.Exception
public static boolean isEmpty(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static java.util.Enumeration keys(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static java.util.Enumeration propertyNames(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String put(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String remove(java.sql.Connection connection,
java.lang.String key)
throws java.lang.Exception
java.lang.Exception
public static java.lang.Object remove(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String setProperty(java.sql.Connection connection,
java.lang.String key,
java.lang.String value)
throws java.lang.Exception
java.lang.Exception
public static int size(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static java.util.Collection values(java.sql.Connection connection)
throws java.lang.Exception
java.lang.Exception
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
Copyright Acelet Corporation. 2000-2008. All rights reserved. | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||