Daniel McDade

Greenhorn
+ Follow
since Mar 21, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel McDade

Pat Farrell wrote:I make using the cache transparent to users (aka other developers). Its an engineering decision which objects get cached. I put the cache in the BusinessObject layer, as part of the ORM. This approach is not 100% transparent to the users, for instance, if your Person object is cached, the normal access to an object via its primary key is
Person aper = Person.getFromId(primkey);
instead of the usual
Person aper = new Person(primkey);



Are you tagging your domain model objects with annotations to mark them as 'cacheable' or loading the target objects to cache via a properties/xml file? You mentioned ORM, so I assume you're doing it at the class level with some kind of annotation. We're not using Hibernate (or any ORM solution) so I was planning on loading everything on startup that is needed by the application. Candidate objects would be loaded from the DB via a configuration file. Does this seem reasonable? Should I keep the CacheManager as a static singleton reference? Inside a thread-local wrapper? I'm just throwing darts. Haha.

Our needs are for mostly static, read-only data, so I don't have a requirement to constantly sync-up the cache elements.
12 years ago

Pat Farrell wrote:I'm not sure what you are asking. Generally, you can use someone else's cache implementation, or you can write your own.

I like one that I've implemented, its a WorkingSetCache based on Denning's work on locality and cache efficiency. Open source code at
http://pfarrell.com/java/pdflib.tar.gz

To get good performance, you have to engineer the design of the cache with the production environment. For example, many cache schemes use a LRU (least recently used) which is simple to program, explain and test. It usually works fairly well, but can fail badly in some cases.



Pat, thanks for the feedback, and I apologize for the vague nature of my inquiry. I'm more speaking to how to design my solution, programmatically speaking. In other words, regardless of which library I choose (JBoss Cache, EHCache, OSCache, etc.) how should my application be structured to leverage their API? Should I simply define a CacheManagerUtil that acts as a wrapper for their cache-specific objects (CacheManagers, Caches, Elements, etc.)? Is there a more interface-based approach that could work as an alternative to integrate the cache implementation? Does anyone have an approach that worked for them successfully in the past?

Thanks in advance,
dannymac
12 years ago
I've been researching the various caching options to limit our roundtrip calls to the database. I've kind of taken a liking to JbossCache as a solution, but was hoping some fine folks might suggest a code-based implementation approach for using the library.

Setup: We are currently refactoring a standard web app built on Spring MVC, Tiles, JSP. The site is 'skinned' depending on the logged in user (by state of user). Due to the 'location' dependent nature of the application, there are pieces of the application (header information, label values, dropdown list values, default field values for certain fields, etc.) which change depending upon the location of the user. Again, these could all be different between states (i.e. default may be 0.8 for a field in Texas, but 0.5 for the same field in Florida). Some of this will be accomplished via ResourceBundles defined by state (labels), but the architect has requested we cache much of the static reference data (dropdowns, etc). In addition, there are complex rules about some aspects of the UI. For example, if we choose Value A in a listbox, a new set of values is displayed in another radio group field. These are also identified as candidates for caching up-front on application startup.

The goal of the development effort is to make the application accessible outside of a purely 'web app' context. They're building out components to be used as web service endpoints that will mimic the workflow that is only currently supported by the web app. The end result is an application which can have services requested ad-hoc using standard XML input and output. The web app is the current model and will continue to be supported, but they're implementing a SOA-based approach.

Does anyone have some good design strategies for implementing a caching solution (patterns, abstract vs. interface approach)? This will be in a single JVM, so no replication is needed currently, though a library that could handle that for future use-cases would be nice. I like JBoss Cache/POJO Cache at this point, due to the hierarchical nature of its cache. I can store the default values of fields as such:

root/texas/defaultvals/field1/value
root/florida/defaultvals/field1/value
...
...

That seems to lend some flexibility w/how the data is stored/retrieved.
12 years ago

Joe Ess wrote:Do not do this. ready() does not tell you if the stream has ended, it tells you if a read call will block:



Joe, based on what I saw, the following would be a better approach, correct?


14 years ago

David Newton wrote:A CSV file *is* a text file.



True enough. :=)
14 years ago

Joe Ess wrote:InputStream -> InputStreamReader -> BufferedReader



Joe, so something like the following should work? Thanks for your help.


I've been told users can also upload the data as a .txt file, but I'm thinking this should work under that scenario, too.
14 years ago
I am allowing our users to upload .csv files, but was having a little trouble deciding how to parse the file content. Normally, I'd wrap the .csv file in a BufferedReader and read it line by line, but with a FormFile object, I only have an InputStream to read the file data. I'm going to add each line in the file to a List object to save to a database.

I'm not a big I/O API expert, so does someone have a clean way to read the .csv data using the Struts FormFile object?

Thanks for any help,
D
14 years ago
I've got a textarea that can take html as input, some of which include the special characters mentioned above. Everything works fine until our users try and use ™ and ® (imagine the symbols are hardcoded like #153; and #174;). All the other html tags work fine, except when mixed with those special codes. When the action form is submitted, I use StringEscapeUtils to escape the HTML. This seems to work okay until I try and render the input on another screen by running the string through the unescapeHTML method. Any html hardcoded into the string after one of those codes displays wrong. Does anyone ever parse input w/those codes correctly? If so, did you use some other API, aside from StringEscapeUtils?

Thanks to anyone for help.
14 years ago

Originally posted by Merrill Higginson:

Yes, they are. Struts cleans them out for each new action. That's one of the disadvantages of "action chaining". You will have to come up with some other way of passing messages from one action to another, such as storing them under a different key in the request and then having the second action retrieve them under that key and rewriting them using the saveErrors method.



Would the code to retreive those stored ActionError objects look something like this?

15 years ago
I am storing ActionError objects (under the Globals.ERROR_KEY) in Action1 and then forwarding to Action2 for processing, but I'm then getting an JspException saying the 'error' bean cannot be found in any scope. When Action2 runs, are the error objects in the original request overwritten or erased?

Can someone help me out in diagnosing the issue. This is using Struts 1.1

In my jsp, I'm accessing the collection as follows:



Thanks for any help,
Daniel
15 years ago
I'm retrieving a value from a backend service that is of data type double, but it is returning the value in scientific notation format (1.383739E8, for example).

How can I take that, and convert it to its actual whole value? Is there some sort of formatter? If so, how do I use it? Thanks for any help!

dannymac21
17 years ago