[JBoss Seam] - SwingWorker and the Event Dispatcher Thread
by SmokingAPipe
One of the main reason incorrectly-written Swing apps are bad is that people do work on the event disptach thread (EDT). They'll have some event handler which loads and parses the file right within the event dispatcher itself. If the file can load and parse in 0.05 seconds, fine, but if it takes 0.5 seconds or 1 second or longer, you have a frozen GUI during that time and people start repeating all those things they say about Swing. Anyone who is a real Swing developer moves all that work over to a thread, often one that is written with the friendly SwingWorker class, that lets us do the work and then do more stuff on the EDT (where GUI draws are safe) after the work is done.
The exact same problem comes up in Web applications. You get a request from the user to do a batch update. Wrong: do the batch update within the session bean or servlet that is called during the request. It may not look wrong because during testing, when your table has only 100 rows in it, but when it has 100,000,000 rows on the live system, the response to the browser will time out.
What's the JBoss / Seam equivalent of a SwingWorker in this case? Should I create an MDB and queue up the job on it? That seems obvious. It would be cool if there were something as small and light-weight as the SwingWorker though, espeically if it could send "I'm working on it" updates back to the GUI.
This seems to be one of the areas of web app building that isn't built out yet or properly understood by a lot of developers, the way SwingWorker is built out for Swing developers. Or else I've totally missed it in the tutorials I've read. I am a newbie to Seam and JBoss so that's very possible.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024919#4024919
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024919
19Â years, 1Â month
[Microcontainer] - Re: Evaluating IOC Containers
by alesj
No, you need this piece of xml code to integrate aop aspects with pojo instantiation - order matters (add dependency if needed).
This is a small example I've done for Seam, and it works.
| <!-- Seam + MC AOP -->
|
| <bean name="SeamAspectManager" class="org.jboss.aop.AspectManager">
| <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
| </bean>
|
| <beanfactory name="SeamAdvice" class="org.jboss.seam.ioc.microcontainer.SeamIntroduction"/>
|
| <bean name="SeamAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
| <property name="advice"><inject bean="SeamAdvice"/></property>
| <property name="manager"><inject bean="SeamAspectManager"/></property>
| </bean>
|
| <bean name="SeamIntroduction" class="org.jboss.aop.microcontainer.beans.IntroductionBinding">
| <property name="classes">@org.jboss.seam.annotations.Name</property>
| <property name="interfaces">
| <list elementClass="java.lang.String">
| <value>org.jboss.kernel.spi.dependency.KernelControllerContextAware</value>
| </list>
| </property>
| <property name="manager"><inject bean="SeamAspectManager"/></property>
| </bean>
|
| <bean name="SeamBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
| <property name="pointcut">execution(* $instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))</property>
| <property name="aspect"><inject bean="SeamAspect" property="definition"/></property>
| <property name="manager"><inject bean="SeamAspectManager"/></property>
| </bean>
| /code]
|
| It intercepts all MC beans that have Seam's @Name annotation.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024918#4024918
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024918
19Â years, 1Â month
[JBoss Seam] - Re: Error when deploying to Tomcat
by mlh496
Unfortunately, for reasons I won't list, I need to deploy to Tomcat. :-(
What I find frustrating is I was able to deploy the Seam examples to Tomcat with no problem. I have been comparing my config files with those from the Booking and DVD examples, and so far I cannot find a difference that would explain my apps error messages.
I know there are 2 directions here: either take a simple example that successfully deploys to Tomcat and grow from that. What I did was use the Seam command line tool to generate an app and to generate the entities from an existing database. I've been working to modify the auto-generated app to deploy on Tomcat. 2 days later, much frustration and no luck... But I'm stubborn, so I'm going to work some more on it. If I find how to get it to work, I'll pass along my lessons learned.
-Michael
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024917#4024917
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024917
19Â years, 1Â month
[Beginners Corner] - CachedConnectionManager is closing connection for me - why?
by xhemjl
Hi all,
I have sucessfully deployed data source for DB2.
I have also created DB2ConnectionFactory class:
public final class DB2ConnectionFactory {
| private static Connection connection;
| static {
| try {
| connection = CachingServiceLocator.getInstance().getDataSource("java:/DataWeaverDS").getConnection();
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
| public static Connection getConnection() {
| return connection;
| }
| }
well - it works i can connect to DB2 from my servlet but
after the response is sent to browser i recieve this message:
17:57:22,265 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@50a11a
| java.lang.Throwable: STACKTRACE
| at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:417)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
next WWW request fails because of already closed connection:
18:14:41,312 ERROR [STDERR] java.sql.SQLException: Connection handle has been closed and is unusable
| 18:14:41,312 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:537)
| 18:14:41,312 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:524)
| 1
|
my DS looks like this:
<?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>DataWeaverDS</jndi-name>
| <connection-url>jdbc:db2://localhost:50000/Test1:retrieveMessagesFromServerOnGetMessage=true;</connection-url>
| <driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
| <user-name>****</user-name>
| <password>****</password>
| <min-pool-size>5</min-pool-size>
| <max-pool-size>20</max-pool-size>
| <idle-timeout-minutes>5</idle-timeout-minutes>
| </local-tx-datasource>
| </datasources>
is my data source definition missing something or is it my Java code?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024914#4024914
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024914
19Â years, 1Â month