[EJB 3.0] - Re: Adding EJB3 Stateless EJBs to an EJB2.1 jar ClassCastExc
by MarcusDidiusFalco
Thank you for your interest
| package de.dzbw.dnp.migvis.persistence;
|
| import de.dzbw.dnp.migvis.person.pojo.Bearbeitungverbund;
|
| public interface BearbeitungsverbundDAOI {
| public Bearbeitungverbund getBearbeitungverbund(int bvId);
| }
|
|
| package de.dzbw.dnp.migvis.persistence;
|
| import javax.ejb.Local;
|
| @Local
| public interface BearbeitungsverbundDAOLocal extends BearbeitungsverbundDAOI {
|
| }
|
| package de.dzbw.dnp.migvis.persistence;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface BearbeitungsverbundDAORemote extends BearbeitungsverbundDAOI {
|
| }
|
| package de.dzbw.dnp.migvis.persistence;
|
|
| import java.sql.Connection;
| import java.sql.PreparedStatement;
| import java.sql.ResultSet;
| import java.sql.SQLException;
| import java.util.Date;
|
| import javax.ejb.Stateless;
|
| import org.apache.log4j.Logger;
|
|
| import de.dzbw.dnp.migvis.person.pojo.Bearbeitungverbund;
| import de.dzbw.dnp.migvis.person.pojo.Person;
| import de.dzbw.dnp.migvis.person.pojo.Personengruppenkennzeichen;
| import de.dzbw.dnp.migvis.person.pojo.Stellung;
| import de.dzbw.dnp.migvis.person.pojo.Vorgang;
| import de.dzbw.dnp.migvis.schnittstelle.common.BaseDAO;
|
| @Stateless
| public class BearbeitungsverbundDAO extends BaseDAO implements BearbeitungsverbundDAOLocal, BearbeitungsverbundDAORemote{
|
| private Logger log = Logger.getLogger(this.getClass());
|
| public Bearbeitungverbund getBearbeitungverbund(int bvId) {
| if (log.isDebugEnabled()) {
| log.debug("Entry getBearbeitungverbund(" + bvId + ")");
| }
| Bearbeitungverbund bearbeitungverbund = null;
| Connection connection = getConnection();
| String sql = "Select P.ID, P.VORNAME, P.NAME, P.STELLBE, P.GEBDATUM, v.id, v.pergrp, v.zda FROM PERSON P INNER JOIN VORGANG V ON p.id = v.personid WHERE P.IDBE= ? ORDER BY STELLBE ASC, p.gebdatum, v.pergrp";
| ResultSet resultSet = null;
| try {
| PreparedStatement statement = connection.prepareStatement(sql);
| statement.setInt(1, bvId);
| resultSet = statement.executeQuery();
| if (resultSet != null) {
| bearbeitungverbund = new Bearbeitungverbund(bvId);
| Person person = null;
| while (resultSet.next()) {
| int id = resultSet.getInt(1);
| //Neue Person
| if (! bearbeitungverbund.containsPerson(id)) {
| String vorname = resultSet.getString(2);
| String name = resultSet.getString(3);
| int stellbe = resultSet.getInt(4);
| Stellung stellung = Stellung.getStellungById(stellbe);
| Date geburtsDatum = resultSet.getDate(5);
| person = new Person(id, vorname, name, geburtsDatum, stellung);
| person.addVorgang(getVorgang(resultSet));
| bearbeitungverbund.addPerson(person);
| }
| //Nur neuer Fall der zur aktuellen Person hinzugef????gt wird
| else {
| bearbeitungverbund.getPerson(id).addVorgang(getVorgang(resultSet));
| }
|
| }
| }
| else {
| log.info("Kein Bearbeitungsverbund f????r id " + bvId + " gefunden");
| }
| } catch (SQLException e) {
| log.error(e);
| }
|
|
| return bearbeitungverbund;
| }
|
| private Vorgang getVorgang(ResultSet resultSet) throws SQLException {
| int fallId = resultSet.getInt(6);
| int fall = resultSet.getInt(7);
| Personengruppenkennzeichen personengruppenkennzeichen = Personengruppenkennzeichen.getPersonengruppenkennzeichenById(fall);
| Date zdaDatum = resultSet.getDate(8);
| Vorgang vorgang = new Vorgang(fallId, zdaDatum, personengruppenkennzeichen);
| return vorgang;
| }
|
| }
|
The beans are packaged in a jar.
jboss.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
|
| <jboss>
|
| <security-domain>java:/jaas/MigvisLdapRealm</security-domain>
|
| <enterprise-beans>
|
| <!--
| To add beans that you have deployment descriptor info for, add
| a file to your XDoclet merge directory called jboss-beans.xml that contains
| the <session></session>, <entity></entity> and <message-driven></message-driven>
| markup for those beans.
| -->
|
| <session>
| <ejb-name>dzbw/migvis/Schnittstelle</ejb-name>
| <jndi-name>ejb/dzbw/migvis/Schnittstelle</jndi-name>
| <local-jndi-name>dzbw/migvis/SchnittstelleLocal</local-jndi-name>
|
| <method-attributes>
| </method-attributes>
| </session>
|
| <!--
| write a merge file jboss-webservices.ent for webservice-description
| -->
|
| </enterprise-beans>
|
| <resource-managers>
| </resource-managers>
|
| <!--
| | for container settings, you can merge in jboss-container.xml
| | this can contain <invoker-proxy-bindings/> and <container-configurations/>
| -->
|
| </jboss>
|
ejb-jar.xml:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
|
| <ejb-jar >
|
| <description><![CDATA[No Description.]]></description>
| <display-name>Generated by XDoclet</display-name>
|
| <enterprise-beans>
|
| <!-- Session Beans -->
| <session >
| <description><![CDATA[Die Klasse <code>SchnittstelleBean</code> dient als Fassadenbean.]]></description>
| <display-name>Schnittstelle</display-name>
|
| <ejb-name>dzbw/migvis/Schnittstelle</ejb-name>
|
| <home>de.dzbw.dnp.migvis.schnittstelle.SchnittstelleHome</home>
| <remote>de.dzbw.dnp.migvis.schnittstelle.Schnittstelle</remote>
| <local-home>de.dzbw.dnp.migvis.schnittstelle.SchnittstelleLocalHome</local-home>
| <local>de.dzbw.dnp.migvis.schnittstelle.SchnittstelleLocal</local>
| <ejb-class>de.dzbw.dnp.migvis.schnittstelle.SchnittstelleBean</ejb-class>
| <session-type>Stateless</session-type>
| <transaction-type>Container</transaction-type>
|
| <env-entry>
| <env-entry-name>DataSourceName</env-entry-name>
| <env-entry-type>java.lang.String</env-entry-type>
| <env-entry-value><![CDATA[java:/migvisDS]]></env-entry-value>
| </env-entry>
|
| </session>
|
| <!--
| To add session beans that you have deployment descriptor info for, add
| a file to your XDoclet merge directory called session-beans.xml that contains
| the <session></session> markup for those beans.
| -->
|
| <!-- Entity Beans -->
| <!--
| To add entity beans that you have deployment descriptor info for, add
| a file to your XDoclet merge directory called entity-beans.xml that contains
| the <entity></entity> markup for those beans.
| -->
|
| <!-- Message Driven Beans -->
| <!--
| To add message driven beans that you have deployment descriptor info for, add
| a file to your XDoclet merge directory called message-driven-beans.xml that contains
| the <message-driven></message-driven> markup for those beans.
| -->
|
| </enterprise-beans>
|
| <!-- Relationships -->
|
| <!-- Assembly Descriptor -->
| <!--
| To specify your own assembly descriptor info here, add a file to your
| XDoclet merge directory called assembly-descriptor.xml that contains
| the <assembly-descriptor></assembly-descriptor> markup.
| -->
|
| <assembly-descriptor >
| <!--
| To specify additional security-role elements, add a file in the merge
| directory called ejb-security-roles.xml that contains them.
| -->
|
| <!-- method permissions -->
| <!--
| To specify additional method-permission elements, add a file in the merge
| directory called ejb-method-permissions.ent that contains them.
| -->
| <method-permission >
| <description><![CDATA[description not supported yet by ejbdoclet]]></description>
| <unchecked/>
| <method >
| <description><![CDATA[description not supported yet by ejbdoclet]]></description>
| <ejb-name>dzbw/migvis/Schnittstelle</ejb-name>
| <method-name>*</method-name>
| </method>
| </method-permission>
|
| <!-- transactions -->
| <!--
| To specify additional container-transaction elements, add a file in the merge
| directory called ejb-container-transactions.ent that contains them.
| -->
| <container-transaction >
| <method >
| <ejb-name>dzbw/migvis/Schnittstelle</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>NotSupported</trans-attribute>
| </container-transaction>
|
| <!-- finder transactions -->
|
| <!-- message destinations -->
| <!--
| To specify additional message-destination elements, add a file in the merge
| directory called ejb-message-destinations.ent that contains them.
| -->
|
| <!-- exclude list -->
| <!--
| To specify an exclude-list element, add a file in the merge directory
| called ejb-exclude-list.xml that contains it.
| -->
| </assembly-descriptor>
|
| </ejb-jar>
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4223930#4223930
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4223930
15 years, 9 months
[JBoss Cache: Core Edition] - Re: How to subclass JDBCCacheLoader
by jorgemoralespou_2
"genman" wrote :
| But instead of writing code, one thing you could consider is simply adding a update timestamp column to the cache loader's table, which is populated through a trigger. Then a background process run by your DBA could cull the data as necessary.
|
With the fixes Manick have done, now I can subclass JDBCCacheloader, and introduced a timestamp in:
TimestampedJDBCCacheLoader.populatePreparedStatementForInsert
| TimestampedJDBCCacheLoader.updateNode
|
| and also:
| TimestampedJDBCCacheLoaderConfig.constructCreateTableDDL
| TimestampedJDBCCacheLoaderConfig.constructUpdateNodeSql
| TimestampedJDBCCacheLoaderConfig.constructInsertNodeSql
|
| This modifications add a timestamp column, and set timestamp value in every insert/update in the database and no need to cal the DBA guy to insert a trigger.
|
| We are developing a product, we are a group of 5 developers, with different databases (mysql, oracle) as target for our application, so this solution seems easier for us. No need to know on target database peculiarities.
|
| Probably to do a more complex mapping as you suggest, needs more programming on the JDBCCacheLoader subclass, but sometimes can be useful, as per when the client you deploy the app in, wants, no matter how, to have the dba guy tunning the DB, and wanting to know what goes into the DB. You know they aren`t very eager to rely on blobs.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4223928#4223928
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4223928
15 years, 9 months
[JBossWS] - Getting Soap Header from WebServiceContext's MessageContext
by dhanushgopinath
Hi,
I want to access some SOAP Header values inside the WebService when it is called.
(I know I can use server side handlers fro this, but I do not want to use it as I want the header values for some application inside the web service)
So I use the injection using WebServiceContext, and then get the SOAPMessageCotnext by
SOAPMessageContext soapMsgContext = (SOAPMessageContext) context.getMessageContext();
And then I get the SoapMessage and Soap Header
| SOAPEnvelope envelope = soapMessageContext.getMessage().getSOAPPart()
| .getEnvelope();
|
| SOAPHeader soapHeader = envelope.getHeader();
| // Extract All header elements.
| Iterator headerElements = soapHeader.extractAllHeaderElements();
The Iterator headerElements, doesnt have any values in it.
Why is this happening? Doesn't the WebServiceContext return the SoapHeaders.
I checked the rest of the SOAP Message and Soap Body is having only the body elements, it doesn't have any values.
Please let me know in case anyone of u faced the same problems
Thanks
Dhanush
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4223896#4223896
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4223896
15 years, 9 months