Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1-osgi/activation-1.1-osgi.jar" sourcepath="M2_REPO/javax/activation/activation/1.1-osgi/activation-1.1-osgi-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar" sourcepath="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar" sourcepath="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="var" path="M2_REPO/org/mule/mule-core/3.2.1/mule-core-3.2.1.jar" sourcepath="M2_REPO/org/mule/mule-core/3.2.1/mule-core-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/safehaus/jug/jug/2.0.0/jug-2.0.0-asl.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.2/commons-cli-1.2.jar" sourcepath="M2_REPO/commons-cli/commons-cli/1.2/commons-cli-1.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4.jar" sourcepath="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.3/commons-pool-1.5.3.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.3/commons-pool-1.5.3-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-j2ee-connector_1.5_spec/1.1-osgi/geronimo-j2ee-connector_1.5_spec-1.1-osgi.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-j2ee-connector_1.5_spec/1.1-osgi/geronimo-j2ee-connector_1.5_spec-1.1-osgi-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/asm/asm/3.1/asm-3.1.jar" sourcepath="M2_REPO/asm/asm/3.1/asm-3.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/asm/asm-commons/3.1/asm-commons-3.1.jar"/>
<classpathentry kind="var" path="M2_REPO/asm/asm-tree/3.1/asm-tree-3.1.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.9/junit-4.9.jar" sourcepath="M2_REPO/junit/junit/4.9/junit-4.9-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mule/modules/mule-module-client/3.2.1/mule-module-client-3.2.1.jar" sourcepath="M2_REPO/org/mule/modules/mule-module-client/3.2.1/mule-module-client-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mule/modules/mule-module-spring-config/3.2.1/mule-module-spring-config-3.2.1.jar" sourcepath="M2_REPO/org/mule/modules/mule-module-spring-config/3.2.1/mule-module-spring-config-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mule/modules/mule-module-annotations/3.2.1/mule-module-annotations-3.2.1.jar" sourcepath="M2_REPO/org/mule/modules/mule-module-annotations/3.2.1/mule-module-annotations-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/3.0.3.RELEASE/spring-context-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/3.0.3.RELEASE/spring-context-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/3.0.3.RELEASE/spring-aop-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/3.0.3.RELEASE/spring-aop-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-asm/3.0.3.RELEASE/spring-asm-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-asm/3.0.3.RELEASE/spring-asm-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/3.0.3.RELEASE/spring-beans-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/3.0.3.RELEASE/spring-beans-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/3.0.3.RELEASE/spring-core-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/3.0.3.RELEASE/spring-core-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/3.0.3.RELEASE/spring-expression-3.0.3.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/3.0.3.RELEASE/spring-expression-3.0.3.RELEASE-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1-osgi/dom4j-1.6.1-osgi.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1-osgi/dom4j-1.6.1-osgi-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1.1-osgi/jaxen-1.1.1-osgi.jar"/>
<classpathentry kind="var" path="M2_REPO/jdom/jdom/1.0/jdom-1.0.jar" sourcepath="M2_REPO/jdom/jdom/1.0/jdom-1.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/mule/modules/mule-module-xml/3.2.1/mule-module-xml-3.2.1.jar" sourcepath="M2_REPO/org/mule/modules/mule-module-xml/3.2.1/mule-module-xml-3.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-jxpath/commons-jxpath/1.3-osgi/commons-jxpath-1.3-osgi.jar" sourcepath="M2_REPO/commons-jxpath/commons-jxpath/1.3-osgi/commons-jxpath-1.3-osgi-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2-osgi/xstream-1.2.2-osgi.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2-osgi/xstream-1.2.2-osgi-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O-osgi/xpp3_min-1.1.3.4.O-osgi.jar"/>
<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar" sourcepath="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.0.8/woodstox-core-asl-4.0.8.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.0.8/woodstox-core-asl-4.0.8-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.0.2/stax2-api-3.0.2.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.0.2/stax2-api-3.0.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/net/java/dev/stax-utils/stax-utils/20080702-osgi/stax-utils-20080702-osgi.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/saxon/saxon/8.9.0.4-osgi/saxon-8.9.0.4-osgi.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/saxon/saxon-dom/8.9.0.4-osgi/saxon-dom-8.9.0.4-osgi.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/saxon/saxon-xqj/8.9.0.4/saxon-xqj-8.9.0.4.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.5/jaxb-impl-2.1.5.jar" sourcepath="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.5/jaxb-impl-2.1.5-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.6.0.Final/hibernate-3.6.0.Final.jar"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
14 changes: 14 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mule-transport-hibernate</name>
<comment>Provides support for data object management using the Hibernate object-relational mapping API. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Sat May 19 11:34:39 BST 2012
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Hibernate Transport for Mule 3.1

This transport implements hibernate support for Mule 3.1

## Build Instructions:
To build use Maven execute the below command from the root folder, this will build the mule-transport-hibernate-3.x.x.jar and add it to the transports folder, you can then reference this jar from your mule project.

```
mvn package
```

You can also import the eclipse project to your workspace and reference the project in your mule project java build path for debugging.

## Use Instructions:
To include this transport in your mule flow you need to create...
1. Spring Bean JDBC Data Source
2. Spring Bean Hibernate Session Factory
3. Spring Bean Hibernate Transaction Manager
4. JDBC Connector
5. Hibernate Connector
6. Hibernate Endpoint

## Spring Bean JDBC Data Source
```
<spring:bean id="jdbcDataSource"
name="Bean"
class="org.enhydra.jdbc.standard.StandardDataSource"
destroy-method="shutdown"
doc:name="JDBCDataSourceBean>
<spring:property
name="url"
value="jdbc:sqlserver://localhost:1433;databaseName=TestDB;user=sa;password=cupcake"/>
<spring:property
name="driverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
</spring:bean>
```

## Spring Bean Hibernate Session Factory
```
<spring:bean
id="hibernateSessionFactory"
name="hibernateSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
doc:name="Hibernate Session Factory">
<spring:property name="hibernateProperties">
<spring:props>
<spring:prop key="hibernate.show_sql">true</spring:prop>
<spring:prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</spring:prop>
</spring:props>
</spring:property>
<spring:property name="annotatedClasses">
<spring:list>
<spring:value>Person</spring:value>
</spring:list>
</spring:property>
<spring:property name="configurationClass">
<spring:value>org.hibernate.cfg.AnnotationConfiguration</spring:value>
</spring:property>
<spring:property name="dataSource" ref="jdbcDataSource"/>
</spring:bean>
```

## Spring Bean Hibernate Transaction Manager
```
<spring:bean
id="transactionManager"
name="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
doc:name="Transaction Manager">
<spring:property name="sessionFactory" ref="hibernateSessionFactory"/>
</spring:bean>
```

## JDBC Connector
```
<jdbc:connector
name="jdbcConnector"
dataSource-ref="jdbcDataSource"
validateConnections="false"
transactionPerMessage="true"
queryTimeout="10"
pollingFrequency="5000"
doc:name="Database (JDBC)"/>
```

## Hibernate Connector
```
<hibernate:connector name="hibernateConnector" sessionFactory-ref="hibernateSessionFactory"/>
```

## Hibernate Endpoint -- add to your flow
```
<hibernate:outbound-endpoint change="merge" connector-ref="hibernateConnector"/>
```

## Namespace:
To use the hibernate xml namespace you must import it into your flow add...
```
xmlns:hibernate="http://tabletlive.com/schema/mule/hibernate"
```
to your root node and...
```
http://tabletlive.com/schema/mule/hibernate http://tabletlive.com/schema/mule/hibernate/mule-hibernate.xsd
```
to the root nodes schema location attribute.

The above example uses a JDBC connection for Microsoft SQL Server however you can change your datasource to any JDBC driver you choose.
Another thing to note is the property
```
<spring:property name="annotatedClasses">
<spring:list>
<spring:value>Person</spring:value>
</spring:list>
</spring:property>
```
on the session factory, this is the list of the classes you would like to persist with Hibernate, you can use a plain hibernate config instead of this, please see the Spring configuration guide for hibernate for further info [http://static.springsource.org/spring/docs/2.5.x/reference/orm.html](http://static.springsource.org/spring/docs/2.5.x/reference/orm.html).
2 changes: 1 addition & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>2.1-SNAPSHOT</modelVersion>
<groupId>org.mule.transports</groupId>
<properties>
<muleVersion>2.2.1</muleVersion>
<muleVersion>3.2.1</muleVersion>
</properties>
<version>2.2.0</version>
<artifactId>mule-transport-hibernate</artifactId>
Expand Down
19 changes: 8 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
<name>Hibernate Transport</name>
<description>Provides support for data object management using the Hibernate object-relational mapping API.</description>
<packaging>jar</packaging>
<properties>
<muleVersion>2.2.1</muleVersion>
<version>3.2.1</version>
<properties>
<muleVersion>3.2.1</muleVersion>
<shortId>HIBERNATE</shortId>
<domainName>hibernate</domainName>
</properties>
<version>2.2.1-SNAPSHOT</version>
<issueManagement>
<system>Jira</system>
<url>http://mule.mulesource.org/jira/browse/${shortId}</url>
</issueManagement>
<!--
<scm>
<connection>scm:svn:http://svn.muleforge.org/hibernate/</connection>
<developerConnection>scm:svn:https://svn.muleforge.org/hibernate/</developerConnection>
<url>http://svn.hibernate.muleforge.org/</url>
</scm>
-->
<ciManagement>
<system>Bamboo</system>
<url>http://bamboo.muleforge.org/browse/${shortId}</url>
Expand Down Expand Up @@ -86,7 +88,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>1.5</targetJdk>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -161,19 +163,14 @@
<version>${muleVersion}</version>
<scope>provided</scope>
</dependency>
<!-- dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>${muleVersion}</version>
<scope>test</scope>
</dependency -->
<!-- Hibernate Transport specific Dependencies -->
<!-- Mule (full or rar) ships with 3.2.2.ga. You'd better replace it with a newer version -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.2.ga</version>
<version>3.6.0.Final</version>
<scope>provided</scope>
</dependency>

</dependencies>
</project>
16 changes: 12 additions & 4 deletions src/main/java/org/mule/transport/hibernate/HibernateConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.mule.api.MuleContext;
import org.mule.api.MuleException;
import org.mule.api.construct.FlowConstruct;
import org.mule.api.endpoint.InboundEndpoint;
import org.mule.api.lifecycle.InitialisationException;
import org.mule.api.service.Service;
Expand All @@ -19,6 +21,11 @@

public class HibernateConnector extends AbstractConnector {

public HibernateConnector(MuleContext context) {
super(context);
// TODO Auto-generated constructor stub
}

public static final String HIBERNATE_PROTOCOL = "hibernate";

private SessionFactory sessionFactory;
Expand Down Expand Up @@ -93,11 +100,12 @@ public void delete(Session session, Object payload) {
public void setSessionDelete(HibernateSessionDelete sessionDelete) {
this.sessionDelete = sessionDelete;
}

@Override
protected MessageReceiver createReceiver(Service service, InboundEndpoint endpoint) throws Exception {
return getServiceDescriptor().createMessageReceiver(this, service, endpoint, createReceiverParameters(endpoint));
}
protected MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint) throws Exception {

return getServiceDescriptor().createMessageReceiver(this, flowConstruct, endpoint);
}

private Object[] createReceiverParameters(InboundEndpoint endpoint) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ protected MuleMessage doSend(MuleEvent event) throws Exception {
protected void doDispatch(MuleEvent event) throws Exception {
if (logger.isDebugEnabled())
logger.debug("Dispatch event: " + event);

String writeStmt = event.getEndpoint().getEndpointURI().getAddress();


//String writeStmt = event.getEndpoint().getEndpointURI().getAddress();
String writeStmt = endpoint.getEndpointURI().getAddress();

Object payload = event.transformMessage();

Transaction tx = TransactionCoordination.getInstance().getTransaction();
Expand Down
Loading