Z Sugiarto

Ranch Hand
+ Follow
since Jan 09, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Z Sugiarto

Hi all,

I would illustrate what I am trying to do with an informal pseudo-code




In other words: is there such a class that does what FooStructure is doing? holding the content of a ResultSet in a structure that we can apply normal SQL operations against?

I know that some people would say, well why don't you put the select distinct column1 in the initial query in the first place. THIS IS NOT THE POINT (pardon the caps). The point is, I am looking for a SQL-aware data structure that is ResultSet-friendly... (before I go and reinvent one..)

... anyone?
@bear
ah, pardon me. I think of <load-on-startup> and I think about servlet (web.xml) but you are correct, this is more slanted towards struts than pure servlet. Thanks for moving this into the appropriate section

So, Anyone?
15 years ago
ah, pardon me. I got misguided by the notion of <start-on-load> but you are correct, this is more slanted towards struts than pure servlet.

Anyone?
15 years ago
All,

I remember doing this back in the days, but I can't seem to find a good and quick reference on the best way to do this. So here I am posting in the ranch forum.

I'm writing a web app using Struts2. What I needed is a way to call one of the Struts2 action when the web application is started.

I tried to find ways to bind a Struts2 action into the <servlet><load-on-startup /> declared in web.xml, but I can't seem to find a straightforward way to do it?

if you have better ways or a different suggestion, pleaselet me know. I am open for approach & ideas. Thanks!

Regards,
Zen.
15 years ago

Jeanne Boyarsky wrote:

Zenikko Sugiarto wrote:Is there away to tell Eclipse to run the test cases one by one?
Or, is there a way to enforce this behavior so that my test cases is not IDE-dependent?


You could write an Ant script and fork it so each test gets it's own JVM. Or you could null out the singleton between tests so there aren't side effects.



Hi,

Yeah I can write ant or shell script to fork out each test case but I won't be able to see it from the nice GUI JUNIT runner within Eclipse. I want to see the green / red bar!

I ended up modifying the test case to not use the singleton method. I have the classes intended to be singleton instantiated using its constructor on the @beforeClass of each relevant test case. So essentially it becomes a static class for that particular test case.

I was hoping that there's a way to do it in Eclipse. i.e telling Eclipse to run all test classes on separate process / JVM, because really you don't want any dependency between one class to another.

Ideally singleton should exist only for the duration of one test case. I wasn't expecting Eclipse to run all test case under the same process/JVM.

Anyway, problem fixed the hard way, I've got it all under control now - thanks for the reply!

rodolfo de wrote:I click right button mouse and try to export my Tomcat project into Eclipse
but there is no .war option.

This .war file is important as long as I want to deploy my first web application on EATJ webhost.



I would suggest creating your own ant build.xml file and using the ant war task.
http://ant.apache.org/manual/CoreTasks/war.html

Generally, I would create a directory where I would assemble all the directory and files needed. This allows you to have a different file structure between development and deployment. An example of a development file structure of a web application could be as follow:



A build file can then be written to build (assemble) the above into a deployment structure, like so



After the deployment file structure is assembled (using ant) I can then archive it using the ant war task and generate something like. At this point I can also copy the change note, version, readme, and include it within the .war

project root/build/current --> projectName-version-date.war

Which can then be deployed using various ways - the easiest of which is to just copy it into an app server's deployment directory.

All,

I have a problem which I found in eclipse, but not in Netbeans. I hope you can help me find a workaround for this.

I have a lot of test cases that requires a singleton the created for the duration of each test case. When I run the test case on its own, it is fine.

Problem is, in Netbeans each test case is executed as a unit. Therefore the singleton instance is not shared from one test case to another - which I reckon is the correct behavior.

However, in Eclipse the test case fails because the singleton implementation is shared between one test case and another.

Is there away to tell Eclipse to run the test cases one by one?
Or, is there a way to enforce this behavior so that my test cases is not IDE-dependent?

Thanks for any help.
Gaston,

Yeah quite, but this is the implication of using OR mapping and distributed EJBs. OR mapping offers you the convenience, but if you don't partition your services correctly (meaning: to fit your functional and capacity need) you will have to embrace the performance overhead implication.

Example of the sort of partitioning you can do to introduce more flexibility could be like:

Data Model:
one product can belong to many categories. class available: Product, Category. The POJO implemented have a list of Category inside Product class.

Session bean partition:


Usage:


Same concept, just partitioning the service beans to do more atomic operation to allow you more control over what you want to fetch.

Of course, this is a very simplistic example, you can also overcome repetitious callback to remote session beans by implementing caching in the CLIENT end.
Hey,

I'll try to be brief. your problem is caused by LAZY LOADING. Please do a google search on Lazy Loading on hibernate / JPA.

Pretty much, you need to either do:

OPTION A: EASY WAY OUT
---
1. in the session bean that returns "Area" (ServiceArea)
2. just before you return the Area object
3. call areaObject.getAreaFunction()

Step 3 will load the AreaFunction object. By the time the object is returned, the AreaFunction is also included (it is now initialised).


OPTION B: THE NORMAL WAY OUT
---
Have a read on LAZY LOADING on Hibernate and JPA. If you can turn off lazy loading between Area and AreaFunction, this will solve the problem too.
what kind of object are you trying to retrieve from this EJB?

Tell us more about the object you are trying to get from the first EJB that you have managed to retrieve.

My guess is that, this 2nd object you are trying to retrieve is still not fetched yet and you are trying to access it. Did you use JPA with lazy loading for this 2nd object?

Please provide more info if possible:
- classes involved
- your design (what is it you are trying to do)
- code of the invoking class
- exception stack

Give us the real deal, not just some vague description of your problem. With that we can only provide you with some vague answer too.
2 points I want to mention wrt the agile process:

1. agile doesn't mean that you can do anything you want, change anything anytime, and leave things undocumented. This is not agile, this is AD-HOC.

2. an agile process is just a different style of development process. But it is still a process. Someone STILL need to monitor, control, and administers it. The word 'agile' indicates that there is a level of freedom and liberty in there, but just like DEMOCRACY, when not enough control and understanding is in place, it falls into ANARCHY.

So in my opinion, the key in incorporating agile is:

1. Control it firmly. Define the rules and regulations.

2. Make sure that everyone understand exactly how the process works, what can and can't be done and ENFORCE it.

This sounds very simple, but the fact it there's a lot of orgs that tries to adopt agile thinking that agile means less overheads. Well, things don't just take care of themselves, someone somewhere needs to ensure that the development are progressing in a controlled manner, someone somewhere need to ensure that everyone is playing by the rules and things are traceable.

Probably this mistakes is not very visible on smaller project, because admit it, on smaller project it doesn't matter whether you are organized or not, following any process or not, you put a good developer in and he will be able to find his way through (after a lot of frustation...)

But try not having a firm structure of control and tracing in place on a big project. The difference will become obvious as the scale of the problem grows.
I'm looking for the same thing now.

It seems that Java does not have one, nor there is an open source project for one.

Such a shame. JTable is a pure display, whereas DataGrid contains the functionality to bind result into the table display. So ideally, there would be one component called JDataGrid.

JDataGrid = Jtable with all the 'good stuff' pre configured, that is able to read a ResultSet and render it properly with the ability to sort, paginate, and so on.

It's a very rich and useful component, one of the stuff I'm dearly missing in .NET.

It got me thinking about it too, if such a component was around, wouldn't applets be more widespread today?
16 years ago
Couldn't find one.

I'm writing a swing application using Jython on eclipse, took me about 20 minute to get used to it. It's very easy.

I'll probably write one once I am finished with my apps - it's an application to process my online banking statements. I'm sick of having to copy paste the csv files into excel every month. But it's pretty much

1. get eclipse + pydev
2. configure pydev, add jython path etc
3. in your jython code:



After that, you can just do...



and the good ol java suggestion pops up. You don't get all the nice feature of the java editor like ctrl+shift+o (manage imports). Also due to its weak typing nature, ctrl+space on a class doesn't automatically give you a list of your private attributes.

My advice is, get used to it. It's PyDev, not JavaDev.

So in 15-20 minutes, downloading Jython, googling around, mucking around, etc I ended up with a very simple Jython-Swing skeleton code like this:



Not my most elegant code, but hey it's a start, and I do plan to refine it over time.
[ September 03, 2008: Message edited by: Zenikko Sugiarto ]
16 years ago
[Edit: name calling is not allowed. Please be nice.]
[ August 30, 2008: Message edited by: Bear Bibeault ]
16 years ago
"why the hassle of having a layer of session beans if I can just use those entity beans directly?"

having more layers (if designed correctly) will make the system to be more 'expandable': - better maintainability, better support for future modification and so on.

Think of the design as a foundation for growth, so if the foundational design and implementation is good, it can evolve quite far in the future.

But if the system will not have such a need in the future, and only used by very few people (i.e not 'enterprise' in any significant way) then you probably don't have to worry that much into having such elaborate foundation structure in your system.

However in such a scenario, you should probably evaluate as to whether or not you REALLY want to choose EJB to build your solution.

If you wanted to access your 'persistance-aware' objects directly from the client, there's stuff like Hibernate or Toplink that you can use too...

[ August 30, 2008: Message edited by: Zenikko Sugiarto ]
[ August 30, 2008: Message edited by: Zenikko Sugiarto ]