Caching the InitialContext?

Due to the time it takes to get a remote InitialContext in client code, I was considering ways to cache the InitialContext in a static variable. The problem is that according to Java Context is not thread safe. Should I even bother trying to cache the InitialContext. Does NamingManager or some other facility take care of this for me?
Thanks,
Bert

Yes, correct. In our frameworks, we have a configurable cache whose options
are (in the web tier) to cache the context on the request, session (i.e.
user) and application (i.e. global) level, as well as the obviously-bad "no
caching" setting. Request is good for non-thread-safe implementations,
session is good for the scenario you painted, and application is good for WL
if you are using default new InitCtx().
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"Paul taylor" <[email protected]> wrote in message
news:3b5ec5b8$[email protected]..
Yes,but if you create the context with a user & password (i.e a form of
principal) and that user is used within the bean you can run into problems
because if it is a stateless bean another use can pick up the same
reference.
"Cameron Purdy" <[email protected]> wrote in message
news:[email protected]..
Yes, you can cache it. WL's implementation is thread-safe etc.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"Alexander Bunkenburg" <[email protected]> wrote in message
news:3b5d44d0$[email protected]..
new InitialContext() inside EJBs takes some time,
and occurs inside every method.
Can we save that time by caching the InitialContext object?
We could cache it once per instance of EJB,
or even once per application.
Is that advisable, or are there any problems with that?

Similar Messages

  • How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap?

    How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class? These are the keys,values: TreeMap The data I'd like to Cache is (date from the file, time of the file, current time).
    import java.io.*;
    public class CacheData {
      public static void main(String[] args) throws IOException {
      String target_dir = "C:\\Files";
      String output = "C:\\Files\output.txt";
      File dir = new File(target_dir);
      File[] files = dir.listFiles();
      // open the Printwriter before your loop
      PrintWriter outputStream = new PrintWriter(output);
      for (File textfiles : files) {
      if (textfiles.isFile() && textfiles.getName().endsWith(".txt")) {
      BufferedReader inputStream = null;
      // close the outputstream after the loop
      outputStream.close();
      try {
      inputStream = new BufferedReader(new FileReader(textfiles));
      String line;
      while ((line = inputStream.readLine()) != null) {
      System.out.println(line);
      // Write Content
      outputStream.println(line);
      } finally {
      if (inputStream != null) {
      inputStream.close();

    How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class?
    I don't understand your question.
    If you don't know how to use TreeMap why do you think a TreeMap is the correct solution for what you want to do?
    If you are just asking how to use TreeMap then there are PLENTY of tutorials on the internet and the Java API provides the methods that area available.
    TreeMap (Java Platform SE 7 )
    Are you sure you want a map and not a tree instead?
    https://docs.oracle.com/javase/tutorial/uiswing/components/tree.html

  • Is there a way to prevent AnyConnect from caching the username of the last person who connected to the VPN?

    Is there a way to prevent AnyConnect from caching the username of the last  person who connected to the VPN?

    This can be done via specifying the "RestrictPreferenceCaching" parameter as described in the Anyconnect Admin Guide here:
    By design, AnyConnect does not cache sensitive information to disk. Enabling this parameter extends this policy to any type of user information stored in the AnyConnect preferences.
    •Credentials—The user name and second user name are not cached.
    •Thumbprints—The client and server certificate thumbprints are not cached.
    •CredentialsAndThumbprints—Certificate thumbprints and user names are not cached.
    •All—No automatic preferences are cached.
    •false—All preferences are written to disk (default—behavior consistent with AnyConnect 2.3 and earlier).

  • SOA Suite Business Rules: Error caching the Decision Services metadata

    hi ofm users
    im currentntly trying
    SOA Suite 11.1.1.1.0
    on Oracle XE
    on Windows XP Pro
    what im trying is a simple use case of business rule component,
    my service is getWorkStatusByDay, that i implement using
    business rules component using decision table.
    my rule model is (conceptually):
    Day{
         String id;
         String code;//mon,tue,wed,...,sat,sun
    WorkStatus{
         String id;
         String code;//holiday, work
    WorkStatus getWorkStatusByDay(Day):
    is rule service that decides WorkStatus code by Day code,
    eg:
    if Day.code=mon,tue,wed,...,fri then we got WorkStatus.code=work
    if Day.code=sat,sun then we got WorkStatus.code=holiday
    i've successfully created the composite project, using
    rule component, mediator, and exposed it as a webservice
    compiled and deployed ok.
    but when i try to run the service using soapUI WS tester,
    i'm getting error in the console, see stacktrace below.
    im able to reproduce the error by deploying the project
    to another computer with a same spec as above.
    So is there any solution to this ? how to fix this issue,
    as this is a very basic sample scenario.
    Any information will be appreciated,
    as im looking forward to evaluating Oracle Business for a client project :)
    [2010-08-11T14:07:14.593+07:00] [soa_server1] [ERROR] [] [oracle.soa.services.rules] [tid: [ACTIVE].ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IdVyLm30nnWFLzmJOA1CO^J500000D,0] [WEBSERVICE_PORT.name: getWorkStatusByDayPT_pt] [APP: soa-infra] [composite_name: TestRule] [component_name: mapWorkStatusByDay] [component_instance_id: c984b23f-0370-478b-99e1-83b651e2e35c] [J2EE_MODULE.name: fabric] [WEBSERVICE.name: getWorkStatusByDay] [J2EE_APP.name: soa-infra] [composite_instance_id: 40001] <.> Error caching the Decision Services metadata.[[
    Error caching the decision services metadata for path default/TestRule!1.0*91126208-425e-4d35-bca3-d2585ec941ea/mapWorkStatusByDay.
    Check the underlying exception and correct the error. This is most likely due to a rule modeling isssue. Validate the rule dictionary in rule designer and fix any errors and warnings. If the error persists, contact Oracle Support Services.
    ORABPEL-36109
    Error caching the Decision Services metadata.
    Error caching the decision services metadata for path default/TestRule!1.0*91126208-425e-4d35-bca3-d2585ec941ea/mapWorkStatusByDay.
    Check the underlying exception and correct the error. This is most likely due to a rule modeling isssue. Validate the rule dictionary in rule designer and fix any errors and warnings. If the error persists, contact Oracle Support Services.
         at oracle.bpel.services.rules.impl.DecisionServiceCache.cacheDecisionServiceMetadata(DecisionServiceCache.java:1211)
         at oracle.bpel.services.rules.impl.DecisionServiceCache.prepare(DecisionServiceCache.java:359)
         at oracle.bpel.services.rules.impl.DecisionServiceImpl.preProcess(DecisionServiceImpl.java:1164)
         at oracle.bpel.services.rules.fabric.BusinessRulesServiceEngine.request(BusinessRulesServiceEngine.java:570)
         at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139)
         at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:179)
         at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:144)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: oracle.rules.rl.exceptions.ParseException: encountered 'rule' when expecting one of:
    <XML_IDENTIFIER> ...<IDENTIFIER> ...
    at line 10 column 49 in main
         at oracle.rules.rl.exceptions.ExceptionFactory.createParseException(ExceptionFactory.java:577)
         at oracle.rules.rl.analyze.RulesetParser.generateParseException(RulesetParser.java:25)
         at oracle.rules.rl.parse.RLParser.jj_consume_token(RLParser.java:5430)
         at oracle.rules.rl.parse.RLParser.Symbol(RLParser.java:697)
         at oracle.rules.rl.parse.RLParser.Qname(RLParser.java:672)
         at oracle.rules.rl.parse.RLParser.ClassName(RLParser.java:795)
         at oracle.rules.rl.parse.RLParser.Type(RLParser.java:729)
         at oracle.rules.rl.parse.RLParser.Parameter(RLParser.java:886)
         at oracle.rules.rl.parse.RLParser.Parameters(RLParser.java:860)
         at oracle.rules.rl.parse.RLParser.Function(RLParser.java:1005)
    [2010-08-11T14:07:14.718+07:00] [soa_server1] [ERROR] [] [oracle.soa.services.rules] [tid: [ACTIVE].ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IdVyLm30nnWFLzmJOA1CO^J500000D,0] [WEBSERVICE_PORT.name: getWorkStatusByDayPT_pt] [APP: soa-infra] [composite_name: TestRule] [component_name: mapWorkStatusByDay] [component_instance_id: c984b23f-0370-478b-99e1-83b651e2e35c] [J2EE_MODULE.name: fabric] [WEBSERVICE.name: getWorkStatusByDay] [J2EE_APP.name: soa-infra] [composite_instance_id: 40001] <.> [[
    oracle.fabric.common.BusinessFaultException
         at oracle.bpel.services.rules.impl.DecisionServiceCache.cacheDecisionServiceMetadata(DecisionServiceCache.java:1211)
         at oracle.bpel.services.rules.impl.DecisionServiceCache.prepare(DecisionServiceCache.java:359)
         at oracle.bpel.services.rules.impl.DecisionServiceImpl.preProcess(DecisionServiceImpl.java:1164)
         at oracle.bpel.services.rules.fabric.BusinessRulesServiceEngine.request(BusinessRulesServiceEngine.java:570)
         at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139)
         at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:179)
         at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:144)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
    -----

    hi ofm users
    im currentntly trying
    SOA Suite 11.1.1.1.0
    on Oracle XE
    on Windows XP Pro
    what im trying is a simple use case of business rule component,
    my service is getWorkStatusByDay, that i implement using
    business rules component using decision table.
    my rule model is (conceptually):
    Day{
         String id;
         String code;//mon,tue,wed,...,sat,sun
    WorkStatus{
         String id;
         String code;//holiday, work
    WorkStatus getWorkStatusByDay(Day):
    is rule service that decides WorkStatus code by Day code,
    eg:
    if Day.code=mon,tue,wed,...,fri then we got WorkStatus.code=work
    if Day.code=sat,sun then we got WorkStatus.code=holiday
    i've successfully created the composite project, using
    rule component, mediator, and exposed it as a webservice
    compiled and deployed ok.
    but when i try to run the service using soapUI WS tester,
    i'm getting error in the console, see stacktrace below.
    im able to reproduce the error by deploying the project
    to another computer with a same spec as above.
    So is there any solution to this ? how to fix this issue,
    as this is a very basic sample scenario.
    Any information will be appreciated,
    as im looking forward to evaluating Oracle Business for a client project :)
    [2010-08-11T14:07:14.593+07:00] [soa_server1] [ERROR] [] [oracle.soa.services.rules] [tid: [ACTIVE].ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IdVyLm30nnWFLzmJOA1CO^J500000D,0] [WEBSERVICE_PORT.name: getWorkStatusByDayPT_pt] [APP: soa-infra] [composite_name: TestRule] [component_name: mapWorkStatusByDay] [component_instance_id: c984b23f-0370-478b-99e1-83b651e2e35c] [J2EE_MODULE.name: fabric] [WEBSERVICE.name: getWorkStatusByDay] [J2EE_APP.name: soa-infra] [composite_instance_id: 40001] <.> Error caching the Decision Services metadata.[[
    Error caching the decision services metadata for path default/TestRule!1.0*91126208-425e-4d35-bca3-d2585ec941ea/mapWorkStatusByDay.
    Check the underlying exception and correct the error. This is most likely due to a rule modeling isssue. Validate the rule dictionary in rule designer and fix any errors and warnings. If the error persists, contact Oracle Support Services.
    ORABPEL-36109
    Error caching the Decision Services metadata.
    Error caching the decision services metadata for path default/TestRule!1.0*91126208-425e-4d35-bca3-d2585ec941ea/mapWorkStatusByDay.
    Check the underlying exception and correct the error. This is most likely due to a rule modeling isssue. Validate the rule dictionary in rule designer and fix any errors and warnings. If the error persists, contact Oracle Support Services.
         at oracle.bpel.services.rules.impl.DecisionServiceCache.cacheDecisionServiceMetadata(DecisionServiceCache.java:1211)
         at oracle.bpel.services.rules.impl.DecisionServiceCache.prepare(DecisionServiceCache.java:359)
         at oracle.bpel.services.rules.impl.DecisionServiceImpl.preProcess(DecisionServiceImpl.java:1164)
         at oracle.bpel.services.rules.fabric.BusinessRulesServiceEngine.request(BusinessRulesServiceEngine.java:570)
         at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139)
         at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:179)
         at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:144)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: oracle.rules.rl.exceptions.ParseException: encountered 'rule' when expecting one of:
    <XML_IDENTIFIER> ...<IDENTIFIER> ...
    at line 10 column 49 in main
         at oracle.rules.rl.exceptions.ExceptionFactory.createParseException(ExceptionFactory.java:577)
         at oracle.rules.rl.analyze.RulesetParser.generateParseException(RulesetParser.java:25)
         at oracle.rules.rl.parse.RLParser.jj_consume_token(RLParser.java:5430)
         at oracle.rules.rl.parse.RLParser.Symbol(RLParser.java:697)
         at oracle.rules.rl.parse.RLParser.Qname(RLParser.java:672)
         at oracle.rules.rl.parse.RLParser.ClassName(RLParser.java:795)
         at oracle.rules.rl.parse.RLParser.Type(RLParser.java:729)
         at oracle.rules.rl.parse.RLParser.Parameter(RLParser.java:886)
         at oracle.rules.rl.parse.RLParser.Parameters(RLParser.java:860)
         at oracle.rules.rl.parse.RLParser.Function(RLParser.java:1005)
    [2010-08-11T14:07:14.718+07:00] [soa_server1] [ERROR] [] [oracle.soa.services.rules] [tid: [ACTIVE].ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 0000IdVyLm30nnWFLzmJOA1CO^J500000D,0] [WEBSERVICE_PORT.name: getWorkStatusByDayPT_pt] [APP: soa-infra] [composite_name: TestRule] [component_name: mapWorkStatusByDay] [component_instance_id: c984b23f-0370-478b-99e1-83b651e2e35c] [J2EE_MODULE.name: fabric] [WEBSERVICE.name: getWorkStatusByDay] [J2EE_APP.name: soa-infra] [composite_instance_id: 40001] <.> [[
    oracle.fabric.common.BusinessFaultException
         at oracle.bpel.services.rules.impl.DecisionServiceCache.cacheDecisionServiceMetadata(DecisionServiceCache.java:1211)
         at oracle.bpel.services.rules.impl.DecisionServiceCache.prepare(DecisionServiceCache.java:359)
         at oracle.bpel.services.rules.impl.DecisionServiceImpl.preProcess(DecisionServiceImpl.java:1164)
         at oracle.bpel.services.rules.fabric.BusinessRulesServiceEngine.request(BusinessRulesServiceEngine.java:570)
         at oracle.integration.platform.blocks.mesh.SynchronousMessageHandler.doRequest(SynchronousMessageHandler.java:139)
         at oracle.integration.platform.blocks.mesh.MessageRouter.request(MessageRouter.java:179)
         at oracle.integration.platform.blocks.mesh.MeshImpl.request(MeshImpl.java:144)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
    -----

  • Client automatically cache the data got from cache server?

    Hi expert,
    I have 2 questions about the client local cache. Would you please help to give me some suggestion?
    1. Will client automatically locally cache the data got from cache server the first time and automatically update the data in local cache when getting the same data from cache server again? I go through the API reference but cannot find any API to query the data currently cached in the local cache.
    2. If client will automatically cache the data got from cache server. Is there any way for a client to get the data event that happens to its local cache, such as entry created in local cache, entry deleted from local cache and entry updated in local cache? In my opinion, when getting an entry from cache server the first time, the MapListener's entry create event should be triggered. When getting the same entry again, the entry update event should be triggered.
    However, I have tried a client with replicated cache, a client with partitioned cache, an extend client with remote cache and a client with local cache(front cache part of near cache), the client (the NamedCache object has been set the MapListener) cannot get any event notification after getting data from cache server. By the way, my listener is OK since when putting data the entry create event and entry update event will be triggered.
    Your suggestion is very appreciated. :)

    Hi
    If I were you I would read this http://download.oracle.com/docs/cd/E14526_01/coh.350/e14510/toc.htm
    and particularly the section about Near Caching here http://download.oracle.com/docs/cd/E14526_01/coh.350/e14510/nearcache.htm#CDEFEAJG
    which is what you are asking about in your question.
    Near Caching is how Coherence stores data in the locally - which is the answetr to your first question. How Near Caching works is explained in the documentation.
    Events, which you ask about in your second question are explained here http://download.oracle.com/docs/cd/E14526_01/coh.350/e14510/delivereventsjava.htm#CBBIIEFA
    It might be that ContinuousQueryCache is closer to what you want. This is explained here http://download.oracle.com/docs/cd/E14526_01/coh.350/e14510/queryabledatafabric.htm#sthref38 A ContinuousQueryCache is like having a sub-set of the underlying cache on the local client which you can then listen to etc...
    JK

  • Getting the InitialContext in an application client

    I have an application client deployed in my application. When I run the client like this:
    java -jar reconcile-client/reconcile-client.jar
    It is failing with this exception when trying to look up anything through the InitialContext object:
    Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
            at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
            at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at aoc.arkansas.ReconcileClient.main(ReconcileClient.java:26)Is there another way I should be running the client? According to this link I shouldn't have to supply any information to the constructor of the InitialContext object. http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi011.htm

    You missed the part where it says you have to use "oracle.j2ee.naming.ApplicationClientInitialContextFactory" and that you should see "Configuring an Oracle Initial Context Factory" (http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi011.htm#CIACBCHB). Follow that link and you'll find you have to pass in a map with the "java.naming.factory.initial" property set to that factory, and with the "java.naming.provider.url" property set up to point to the OC4J server.

  • Does the Browser cach the jnlp-file?

    I have a problem, I think with the browser's caching. As I modify the *.jnlp-File, the old version is loaded, not the new one!
    Or is the old version cached by the webStart-Caching-Mechanism?
    To update the jnlp-file, sometimes it is helpful to clear the Clients webStart cache.
    Is that correct?
    regards,
    ulli

    The browser does in fact cache the jnlp and it can be a real problem. If there is no expiration on the JNLP then the browser may load it from cache instead of going to your web server on the next access. This means you may have modified your JNLP on the server for a new release, but users can start your application WITHOUT GETTING THE LATEST JNLP!
    You can solve this problem by serving the JNLP file from your own servlet (or other HTTP serving technique) and setting the expire header. Setting it to 0 does the right thing.
    Do NOT however, set "Pragma", "no-cache". no-cache stops the browser from writing the JNLP to the file system...this in turn causes a problem when Web Start tries to find the jnlp file after the browser starts Web Start....the jnlp file is not there.
    Note that the JnlpDowloadServlet provided by Sun in the Web Start developers kit does NOT expire the JNLP file...you must fix this code yourself if you want it to work correcly. Sun was supposed to make this source code available but I can't find it anywhere. We used a de-compiler to de-compile the code, fix it and re-jar it.

  • Can we cache the remote object?

    hi,
    can we cache the remote object?
    is this right way of doing?
    please suggest me
    regards
    crr

    Yes, caching EJBHome, EJBObject, and Remote business references is fine. They can also
    be portably stored in an HttpSession. However, when caching in the web tier you must still
    be careful to prevent concurrent access to the same stateful session bean. The fact that
    remote references to stateful session beans can be cached does not guarantee they can
    be accessed by more than one client at a time.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • LCES server caches the custom component classes

    I found that sometime during the (patching) deploy/undeploy install/uninstall phase of custom component LCES start 'caching the custom component or its helper classes' and any changes made to them does not get reflected.
    But after the server restarted every thing work as expected.
    i.e. If server is restarted the latest changes to component deployed previously to server restart get reflected.
    Pl. help.
    Any one had simillar issue?
    Thanks
    Yog

    Hi Paul,
    I have tried both of these frequently (many times)
    1) Component > STOP > PATCH > START
    2) Component > STOP > UNINSTALL > INSTALL > START
    but no effect after some point when server keeps the cache. (it works some time but not all the time I thought 2nd approach should always work)
    But if I restart the server it seems to show the expected result always.
    Does any Adobe teche knows how to gaurrentee 100% that chnges will reflect after new version of the component is installed without restart of the server.
    Also I seen some inside the service impl at the begining of the service method code store the classloader:
    ClassLoader originalClassloader = Thread.currentThread().getContextClassLoader();
    and restore it at the end of service method:
    if (originalClassloader != null) {
    Thread.currentThread().setContextClassLoader(originalClassloader);
    How does this affect?
    and also if one component depends on another how does that affect?
    Thanks
    Yog

  • How to cache the objects MANUALLY?

    hello
    some o-r mapping tools can cache the objects that have been queried,then next time these objects are required,it don't need to access the database again,it can also monitor the database updating.
    i wonder how i can implement such "cache" function MANUALLY? because i DON'T want to use ANY o-r mapping tools. i only use the jdbc to query database,then generate the object.
    who can give me some clue?? or articles? or sample codes??
    thank you!!!!!

    no you don't understand me,what i want to know is the
    mechanism of the cache,and how to implement it myself
    without using the o-r mapping tools.
    the dao pattern can encapsulate the database
    access,but it can NOT cache the object .First you need to define how the caching occurs.
    - Can the data in the database change without going through your code?
    - Are there multiple copies of your app running at the same time. If yes then what happens if one is updated?
    - How many of these can there be and what impact will this have on memory?
    - etc.
    You also need to identify the 'identity' of an object.
    A simple strategy....
    - Some layer requests an object using the 'identity'.
    - The database layer code looks in a hash for the 'identity'. If it finds it it returns it.
    - If it doesn't find it it uses a DAO to load it, then puts it in the hash, then returns it.

  • Does coherence cache the value from the cache?

    Hi, I have the question about if the coherence caches the value from the cache? I believe it does from my test, just want to get the confirmation.
    I like to use an example to describe my question. For example:
    If (key1, value1) are in the cache1, (value1 is an object),
    for the first time, if cache1.get(key1), coherence will deserialize value1 and return. But if in the same JVM, when cache1.get(key1) is invoked again, coherence will return value1, which I believe is cached by coherence in the current JVM, and return; instead of deserializing and return it. Is that right?
    I am asking this question because I found a problem in our project when use coherence. As the above example, if I use value1 = cache1.get(key1), and in our project, value1 object has a set method to change one of its internal attributes, and this method was indeed invoked after value1 get from cache1. Then in another class, value2 = cache1.get(key1) is called again, and I found out that value2's attribute will have the modified value, even cache1.put(key1, value1) is never invoked in the first place.
    Of course, this kind of behavior matches the java.util.Map. But coherence cache is a cluster/distributed environment. In the above example, if on another data node, value3 = cache1.get(key1) will get the original attribute value in value3, since the deserialize object will always get the original value, unless the new value is put in explicitly by cache1.put(key1, value1).
    In this case, should cache1.get(key1) always return a clone object make more sense?
    Thanks

    You observation is correct. More specifically for cache topologies which include an in-process cache Coherence may return the same object reference for repeated get requests on the same key. I say "may" because for any variety of reasons we may also have to retrieve a fresh copy from a remote cache server. When possible we will return existing objects for performance reasons avoiding costly things like network hops, and de-serialization. Any modifications made to an object returned from the cache will not be made automatically available to other cluster members. Additionally if these modifications are made concurrently with another thread performing a cache.put() on the same value could result in a corrupt cached value if your serialization methods are not thread-safe. Best practice dictates that unless you are sure that you are using a cache topology which does not include an in-process cache that you treat the values returned from the cache as immutable, and instead deep clone() it before making any modifications.
    The distributed-scheme and remote-scheme are the only types of caches which do not include in-process caching, and thus always return "mutation safe" values. The most common in-process cache topology is near-scheme, but others include replicated-scheme, optimistic-scheme, local-scheme, and the programatically created ContinuousQueryCache.
    thanks,
    mark

  • Should we Use cache seeding iBots to pre-cache the reports ?

    Hi Everyone,
    We have requirement from client to improve the performance of some reports.We have a very old RPD and it is really huge so we don't want to do much on database side for performance tuning.
    Will it be a good idea to use cache seeding iBots to pre-cache the reports ?
    Most of the reports which are having performance issue are having some 5-6 columns and one key column is having some 30+ choices in column selector.So for each column selector view we will have to create a ibot which will again be a huge task.Can you pls guide how to approach this?
    Thanks in advance !
    Aarti Chawla

    hi Aarti,
    Will it be a good idea to use cache seeding iBots to pre-cache the reports ?http://www.artofbi.com/index.php/2010/03/obiee-ibots-obi-caching-strategy-with-seeding-cache/
    30+choices in column selector will definitely have performance issues..bcz each and every time the report is going to refresh .have u enabled the cache some what better .Whats the issue of using existing report by enabling the cache seeding in ibots?
    Thanks,
    Saichand.v

  • Why is the application caching the old jar file

    Hi all
    I have an application that is caching the old jar file.
    even when i reboot.
    when the application starts up it appears to pick up the old jar file.
    any idea on how i can let it pick up the new jar file ?
    stev

    I'm pretty sure that it is just this one .jar file.
    You see I changed a Servlet class in the jar file and messed up the application.
    Now I'm putting back the old jar file and guess what
    it's somehow hanging on to this old servlet class. and showing the same error. What is unique is that I did the same thing on another PC a server edition and it let go of the old Servlet with no problem
    but on my PC a professional edition it is hanging onto that old Servlet even though I deleted every instance of it on the PC , shut down the PC and restart the app. I even deleted the old jar file from the recycle bin. the jar file has a very distinct name so i can easily search for it and
    This app uses tomcat as well - not that that's related.
    I have had this problem happen to me before at home with applet. I would change something and it would just hang on to it forever.
    Anybody has any idea how to go into the registry or some other place and get rid of this servlet class or jar file ?
    stev

  • Which cache the Formula Engine will use in this case?

    Say that a MDX query contains:
    ❶a calculated measure defined in the targeted cube, ❷and another
    WITH MEMBER.
    Which cache the Formula Engine will use in this case:
    ❶Query,
    ❷Global, or
    ❸both (query & global)? and why? .... illustrate as possible please.

    Thanks Elvis ... but
    ❶ doesn't your reply, especially this part:
    ...But if we use WITH MEMBER keyword to define a calculated measure, it's the Storage Engine cache and not the Formula Engine cache....
    contradict with Microsoft's white
    paper: SQL
    Server 2008 R2 Analysis Services Performance Guide? ... check the figure below please:
    this is in page 36, where they are talking about the Formula Engine (or Query Processor, as they sometimes refer to it) types of cache. note the highlighted, they are saying that using the "WITH keyword within a query" forces the use of the "Query
    Context" which is one of the formula engine cache (as they said).
    Actually I've asked the main question because of this part of the same 36 page:
    I wanted to know
    ❷ what will happen to the calculated measures (those defined in the cube) if combined with another calculated members defined using the WITH keyword, in the same query? are they going to be recalculated even if they are already
    exist in the global cache?

  • Can I cache the Remote object

    I am using Stateless session bean. Can I cache the reference of the remote objects to this bean ?
    I read that some containers support the fearture of pre creating the EJB objects in the pool , during startup
    using some custom configuration ( like connection pool ). How is this performed ?`

    I am using Stateless session bean. Can I cache the
    reference of the remote objects to this bean ?No, but you can cache the HomeHandle of the Home interface references - that saves you the overhead of JNDI lookups, which are far more "expensive" time-wise than calling the create method to get the Remote implemenation.
    I read that some containers support the fearture of
    pre creating the EJB objects in the pool , during
    startup using some custom configuration ( like connection pool
    ). How is this performed ?Ask your vendor - it's vendor-specific.

Maybe you are looking for