[JBoss Seam] - Re: Seam application with tree on left and editor for select
by christian.bauer@jboss.com
Some code:
package auction.beans;
|
| import org.jboss.seam.annotations.*;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
| import org.jboss.seam.ScopeType;
| import org.hibernate.ejb.HibernateEntityManager;
|
| import javax.ejb.Stateful;
| import javax.ejb.Remove;
| import javax.persistence.EntityManager;
|
| import auction.model.Category;
| import auction.model.Item;
| import auction.dao.CategoryDAO;
| import auction.interceptors.LoggedIn;
|
| import java.util.*;
|
| /**
| * A conversational component for browsing the catalog.
| *
| * When the first variable for "catalog" has to be resolved, this component is
| * instantiated and a conversation begins. All root categories (with no parent)
| * of the catalog are loaded immediately and held during the conversation.
| *
| * When a category is selected, the selected value is passed into the method
| * setSelectedCategory(category) manually, this is the easiest way to get the
| * value of a click from a Trinidad tree JSF component.
| *
| * The item list is loaded when a category is selected and outjected into a
| * data model for display. When a user triggers an action in the data model's
| * table, the selectedItem of this conversation is set.
| *
| * The conversation ends usually by timeout or when it is destroyed
| * with one of Seams UI conversation management switchers/lists.
| *
| * @author Christian Bauer
| */
| @Name("catalog")
| @Scope(ScopeType.CONVERSATION) // Redundant, a SFSB is default in conversation context
|
| @LoggedIn // Wrap LoginInterceptor around every method call
|
| @Stateful
| public class CatalogBean implements Catalog {
|
| // We don't call the EntityManager directly in this bean (except to flush), only the DAOs.
| // But the DAOs are not always called in every method that does data access. For example,
| // when setSelectedCategory() is called, the categoryDAO is injected into this bean,
| // but the persistence context is not set on the categoryDAO (because no method is
| // called on the DAO, we just load a collection on-demand). So the persistence context
| // doesn't join the JTA transaction, which means it doesn't get flushed when
| // setSelectedCategory() returns (no synchronization registered). Short story: The
| // persistence context needs to be injected managed here, so that lazy loading works
| // properly in all methods of this stateful bean.
| @In(value = "caveatEmptorEM", create = true)
| private EntityManager em;
|
| // A stateless (yes, even for them create="true" is required) DAO component injected by Seam
| @In(create = true)
| private CategoryDAO categoryDAO;
|
| // This bean holds the root categories during a conversation
| private List<Category> rootCategories;
|
| // If present, Seam outjects this into the 'currentCategory' CONVERSATION variable
| @In(required = false)
| @Out(required = false, scope = ScopeType.CONVERSATION)
| private Category currentCategory;
|
| // Seam outjects this always to the 'itemList" CONVERSATION variable as a JSF DataModel
| @DataModel
| private List<Item> itemList;
|
| /**
| * Seam calls this when the Catalog bean is instantiated for a particular CONVERSATION.
| * Seam will start a long-running conversation when this method is called.
| */
| @Create
| @Begin(flushMode = FlushModeType.MANUAL)
| public void refreshRootCategories() {
| rootCategories = categoryDAO.findAll(true);
| }
|
| public List<Category> getRootCategories() {
| return rootCategories;
| }
|
| /**
| * Loads the selected category's items into a data model that is then outjected.
| * @param selectedCategory
| */
| public void setSelectedCategory(Category selectedCategory) {
| // Prepare the member variable for outjection
| currentCategory = selectedCategory;
| // Refresh the itemList (wrap the Set in a List, no pre-defined or database sorting)
| itemList = new ArrayList<Item>(currentCategory.getItems());
| }
|
| @Remove @Destroy @End
| public void closeCatalog() {
| // Nothing to do here, Seam will close the managed persistence context when
| // this method returns.
| }
|
| }
|
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:tr="http://myfaces.apache.org/trinidad"
| xmlns:s="http://jboss.com/products/seam/taglib"
| template="template.xhtml">
|
| <ui:define name="screen">Catalog</ui:define>
|
| <ui:define name="sidebar">
|
| <h1>#{messages['AuctionCategories']}:</h1>
|
| <tr:form>
| <!-- Let Trinidad inject the selected category into our conversation component -->
| <!-- Trinidad tree icons are really really ugly (HTML entities), there is no way to change them... -->
| <tr:tree var="cat" value="#{catalogCategoryAdapter.treeModel}">
| <f:facet name="nodeStamp">
| <tr:commandLink text="#{cat.name}" styleClass="nodeText">
| <tr:setActionListener from="#{cat}" to="#{catalog.selectedCategory}"/>
| </tr:commandLink>
| </f:facet>
| </tr:tree>
|
| </tr:form>
|
| </ui:define>
|
| <ui:define name="content">
|
| <!-- Headline -->
| <div class="section">
| <h1>
| <!-- Read the event context variable "currentCategory" that was outjected by our conversation component -->
| <h:outputText value="#{messages['PleaseSelectCategory']}" rendered="#{currentCategory == null}"/>
| <h:outputText value="#{messages['SelectedCategory']}: #{currentCategory.name}" rendered="#{currentCategory != null}"/>
| </h1>
| </div>
|
| <!-- Item table -->
| <div class="section">
| <!-- Read the conversation context variable "itemList", outjected by the catalog conversation component -->
| <h:outputText value="#{messages['NoItemsInCategory']}"
| rendered="#{itemList != null and itemList.rowCount==0}"/>
|
| <h:form>
| <h:dataTable value="#{itemList}" var="itm" rendered="#{itemList.rowCount>0}">
| <h:column>
| <f:facet name="header">#{messages['ItemName']}</f:facet>
| #{itm.name}
| </h:column>
| <h:column>
| <f:facet name="header">#{messages['ItemDescription']}</f:facet>
| #{itm.description}
| </h:column>
| <h:column>
| <f:facet name="header">#{messages['ItemSeller']}</f:facet>
| #{itm.seller.username}
| </h:column>
| <h:column>
| <f:facet name="header">#{messages['Action']}</f:facet>
| <s:link value="#{messages['PlaceBid']}" styleClass="button" action="#{placeBid.selectItem(itm)}"/>
| </h:column>
| </h:dataTable>
| </h:form>
|
| </div>
|
| </ui:define>
|
| </ui:composition>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978857#3978857
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978857
19 years, 8 months
[JCA/JBoss] - Connection in Use Keeps going Up Jboss 4.0.4.GA Jboss 4.0.4c
by kazam
I am running my application on Jboss 4.0.4.GA and Jboss 4.0.4.c and on both of them on the ManagedConnectionPool MBEAN
ConnectionCreatedCount (Keep going up)
ConnectionDestroyedCount (Keep going up )
InUseConnectionCount (Only goes up until managed connection error is thrown and application crashes).
Other Information
----------------------
- Log file:
I see no entry for any connection leak or house keeping message.
I can't see any message related to IDLE REMOVERrunning.
- I am retrieving the connection using getConnection() only, no user/passwd. This was working fine on jboss-4.0.2 but not since then.
- I have two hibernate applications running on this jboss which use same database but are running fine and aren't using JNDI pooling.
Oracle-ds.xml file
-------------------------
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>jdbc/oracle</jndi-name>
| <connection-url>jdbc:oracle:thin:@localhost:1521:proddb</connection-url>
| <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
| <user-name>user</user-name>
| <password>pass</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
| <min-pool-size>20</min-pool-size>
| <max-pool-size>150</max-pool-size>
| <idle-timeout-minutes>1</idle-timeout-minutes>
| <blocking-timeout-millis>7000</blocking-timeout-millis>
| <!-- sql to call when connection is created
| <new-connection-sql>some arbitrary sql</new-connection-sql>
| -->
| <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
| <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
| -->
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
| <metadata>
| <type-mapping>Oracle9i</type-mapping>
| </metadata>
| </local-tx-datasource>
|
| </datasources>
|
Please, any ideas are welcome. I am confused as to why the idle remover is not running and why are the inUseConnections not coming down even when no one is connected to the application for hours.
Thanks,Kazam.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978853#3978853
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978853
19 years, 8 months