Hi Raybao, It's basically 2 lines:
CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance(); ccm.configure(configurationProps); ..where configurationProps is a Properties object which you have built. Take a look at the JavaDocs for the project here: http://jakarta.apache.org/jcs/apidocs/index.html Usually you'll only deal with the JCS class, but for more advanced usage (like this) browsing the APIs in other JCS packages is a good place to start. Good luck & Best regards, Niall On Wed, 2008-10-15 at 12:17 -0700, Raybao wrote: > Thanks, Nial, but where can I find a source code example on exactly how to > do it? Or can you tell which class I just look at to start? > > > Niall Gallagher wrote: > > > > Hi Ray, > > > > You can configure JCS programmatically. However once an instance of JCS > > is running, you can't reconfigure it on the fly. > > > > So your application will need to decide at startup and depending on its > > environment how it wants to configure JCS. It can then configure JCS > > programmatically by building a Properties object containing the same > > settings that you would include in an appropriate ccf file. > > > > For example if your application doesn't need a certain region to be > > configured when (say) your deployment team sets a certain system > > property, then your code which builds the Properties object can omit the > > relevant region. > > > > Niall > > > > On Tue, 2008-09-30 at 09:59 -0700, Raybao wrote: > > > >> I'm trying to add JCS into one of my current project. Here are what I > >> have > >> done so far. > >> I have created several Regions, and defined them into cache.ccf. Some > >> regions I assigned auxiliary.lateral to them, since they need be Sync.ed > >> between two servers. Some regions have no need to be Sync.ed since they > >> are > >> "Constants" and values never change after loaded. > >> I have tested it, and it works fine. > >> Now I have a question, we have a systemConfig.properties file to define > >> configuration options system wide, > >> I added a new option "UseCacheRegion", which will be followed by a list > >> of > >> region names, separated by comma, then in our application, we have one > >> Cache > >> layer on the top of DAO objects, everytime an object is called from > >> upper > >> modules, the first thing we check is region which this object belongs > >> is > >> "enabled" or not in the systemConifg.preoperties, if it's not enabled, > >> we > >> will skip the Cache layer. > >> This works fine except one issue, For those regions with > >> auxiliary.lateral > >> configured in chace.ccf, > >> even they are never called from our java codes, they are always started > >> looking for the remote server by the JCS initalization process. > >> The whole idea is that since we have a separate team other than out > >> development team to do the deployment job, the deployment team is able > >> to > >> update systemConfig.properties file to enable/disable certain region, but > >> we > >> don't want them to mess up with the cache.ccf. Once a region is > >> disabled, > >> then we don't want JCS to do anything with them. > >> I think I should be able to use JCS API to configure this programmly(be > >> able to remove those regions from JCS config, if they are disabled in our > >> systemConfig.properties). > >> > >> Thanks. > >> Ray > > > > > > >