Sven Anderson

Ranch Hand
+ Follow
since Apr 14, 2004
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 Sven Anderson

Hi,

We're currently writing a webapp using Spring MVC which is going to run on Tomcat 6 and Apache httpd. Given that Spring is providing us with HTTP RequestMapping functionality made me think using Apache's mod_rewrite module is unnecessary. Are there any good reasons (architectural/security reasons etc) for keeping rewrite functionality in Apache? Note, that our rewrite requirements so far are quite basic. I'm not sure and don't think Spring caters for the more complex forms of rewrite. It would be interesting to get other peoples opinion on this.

Thanks
S
14 years ago
Hi,

I'm currently using a static builder to create my bean objects. Now, I'm in a situation where I need to extend some of these objects. This is when I'm running into problems using the builder pattern with static builders since I can't subclass the static Builder builder() method. I'm wondering how I can still use the builder pattern when I extends these object.

Currently my code looks like this.


Hi,

I've started using CASTOR to map xml to objects and vice versa. Now I've got the following question.
Is it possible to create mappings for beans that are using a static Builders (see example below)? I briefly looked into using custom field handlers but I'm not sure this is the right way to do it.

Thanks for you help

S



Hi,

I'm interested to know if anyone have used or can make suggestions on available java learning platforms/services that exist out there. Within our company we're currently looking at available online services where our employees can further develop their skills in particular areas of system development. We're interested in systems which facilitate ways for us to track a persons progress within a specific disipline. We have briefly been looking at http://www.javablackbelt.com which seem to provide much of what we're looking for. I'm wondering if there are other products/services out there that offers similar solutions to java blackbelt.

Thanks

S
15 years ago
Hi,

Quite often we end up in situations where we need to test objects using instanceof and then cast the object into the type we're after.
From what I know this is not a prefered solution and is a result of poor design.
For example, we have an interface called MyTypeIF and two concrete implementation classes for this interface.
MyTypeAImpl has some class specific methods and MyTypeBImpl also have additional methods which
MyTypeAImpl hasn't got. Quite often we end up casting the MyTypeIF object into a MyTypeAImpl or a MyTypeBImpl in order
to be able to get access to specific methods on that particular class. I would be keen to not having to cast and test objects using instanceof. I feel
that the problem is related to our OO design but I'm not sure how to get around this. Could the use of generics (sorry but I'm not yet up to date with generics) help me getting around the hassle of using instanceof and casting?
Or would this only be a way of getting around the real problem which is rather related to the actual design?

Thanks
S
Hi,

I'm looking at ways of marshalling our java domain model into xml. I've been playing around with JAXB for a little while which does what we want. However, since all our java beans are immutable objects this doesn't work very well with JAXB (as far as I know). Are there any other technologies out there that can take our immutable java beans and easily turn them into XML?

Thanks
S
Hi,

I'm trying to make use of XmlJavaTypeAdapter in JAXB(2.0.3) but I can't figure out why I'm getting the following exception





The problem is that I'm not able to return an Array of type domain.DummyType when I marshall the object. However, only returning a DummyType object works fine. I've also tried to return a List, Collection etc. but I'm getting exceptions thrown for all java types. Seems that the context is only aware of the objects I've defined in my jaxb.index file.



This is the lines of code that does the marshalling


Many thanks
Sven
Hi,

I'm looking at options in running our standalone RMI application within a servlet container since we're planning to build support for http. I'm currently testing our app on Tomcat 5.5 and my question is if Tomcat by default actually dispatch incoming RMI calls to different threads. Looking at the server stats in Tomcat manager it doesn't seem to be the case in terms of active number of threads etc.

My second question is if there are servlet containers out there that has support for RMI connectivity and can dispatch incoming requests.

Thanks
S
15 years ago
Thanks for a well explained answer,

You raised a very interesting point about using several thread pools in order to prioritise task executions.In my case I'm planning to take advantage of threadings for the following components in my app.

* A dispatcher which serves incoming client requests.
* ServiceA which will concurrently go and fetch data from 10 datasources
* ServiceB which will fetch data based on n number of results returned from a query


I been given the advice to not create threadpools that are greater than the number of server processors (I think this was also mentioned in the book Java Concurrency in Practice). Given I've only got an 8 core server. I guess I need to configure the threadpools wisely. I'm not really sure about the different factors to consider when configuring the different pool sizes. Obviously I want to dedicate as many threads as possible to the dispatcher but on the other hand I would also like to give ServiceA or B as many threads as possible. To me it sound a little bit like I'm moving the possible bottlenecks between the dispatcher and the Service classes.
Hi,

I'm a bit puzzled about some of the concepts around threading and in particular design decisions around using ExecutorService classes.

I'm currently implementing a multi-threaded apps using JDK1.5 and Spring. I have build a Service class which will do a number of IO intense (DB and Web service) operations in order to create a composite object which I return to the user. My first attempt was to create and instantiate an ExecutorService object for each method invocation on this service class (see example1) and then perform a shutdown at the end of the method. Thinking about it, since there will be at least 1 call per second to this service class. To me it sounds like plenty of overhead having to create an ExecutorService and then tear it down for each request. Wouldn't it be better to create an ExecutorService threadpool at application startup (wired in Spring xml) and inject this executorService into each service class that needs threading support? Then the threadpool will only be created once and all the threads in the pool will be shared across the various Service classes that needs threading support. In this case, when do I perform a shutdown? Only during restart of the application? Also, having threads waiting for incoming request, is this what I want, or would I be better of closing the pool and reopen it again?

Bit confused here

Thanks
Sven

Example 1:


Example 2:
Hi,

Just to let you know that I managed to do a mvn cargo eploy from a different machine. This machine is running maven 2.0.8, jdk1.5.0_13 and this computer sits on the same subnet as the tomcat server. It would be interesting to know if other people have experienced similar problems and how you solved them. According to our sys admins we don't have any firewalls etc between these machines so networking shouldn't be an issue.
15 years ago
Hi,

I'm not sure if this is a networking/tomcat problem or a configuration problem with CARGO and my maven2 pom file.

When I try to deploy to a remote Tomcat instance (currently running) I get an IOException stating

Error writing request body to server
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.che
ckError(HttpURLConnection.java:2524)
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.wri
te(HttpURLConnection.java:2507)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65
)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.pipe(Tomca
tManager.java:601)


The war file I'm deploying is about 17MB. Deploying using the Tomcat manager is working fine. Can someone point me in the right direction whether it's a problems with the CARGO config or if the problem might be somewhere else. I'm using maven 2.09, JDK-1.6.0_06 and Tomcat 5.5

<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<!-- <version>1.0-alpha-6</version> -->

<configuration>
<container>
<containerId>tomcat5x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.tomcat.manager.url>
http://server1:8080/manager
</cargo.tomcat.manager.url>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
</properties>
</configuration>

<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>net.xzy</groupId>
<artifactId>myapp</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
15 years ago
Thanks for your replies guys!

If I was to implement an ExecutorCompletionService class for the example above. Would I gain anything in terms of performance by doing this? Or is it simply a matter of writing neater code.

THanks
S
Hi,

I've got the following question about using the ExecutorService.

With the following code snippet. Can I make the assumption that all threads have completed once I get to
populate the List? Or could it be a case where a thread is still running once I start adding elements to the list?

I'm a bit confused here

Thanks
S


Hi,

I'm having a few question about configurating ehcache for distributed cache replication.

I'm currently configurating cache replication (ehcache 1.4.1) between two servers using manual peer discovery over RMI(see config below).

I'm a bit confused about the output of the log files from the two servers in the following scenario:


step1: ServerA: User adds and object to cache. ServerB writes the following output to its log
DEBUG [net.sf.ehcache.distribution.RMICachePeer] - Remote put received. Element is: [ key = 1234, value=net.xzy.AnonymousCookieEntry@83c3cbfe, version=1221936368875, hitCount=0, CreationTime = 1221936356123, LastAccessTime = 0 ]

step2: ServerA: User request the object from step1 which is now in the cache (performing an element.getValue()). ServerB writes the following output to its log
DEBUG [net.sf.ehcache.distribution.RMICachePeer] - Remote remove received for key: 1234

step3: ServerA: User request the same object from step1 and get it from cache. ServerB now output the following.
DEBUG [net.sf.ehcache.store.MemoryStore] - net.xzy.ANONYMOUS_USER_CACHECache: Cannot remove entry as key 1234 was not found


I don't understand why ServerB in step2 performs a "Remote remove received". Is this the reason it can't find the cache key in step3? My understanding is that both servers should keep the cache objects in sync.

ehcache.xml
<code>
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,rmiUrls=//${app.system.cache.peer}:40001/net.xzy.ANONYMOUS_USER_CACHE"/>

<cache name="net.xzy.ANONYMOUS_USER_CACHE"
maxElementsInMemory="10000" eternal="true" overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
>
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>

<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40001,socketTimeoutMillis=2000"/>
</code>


Thanks
S
15 years ago