Skip to content

Instantly share code, notes, and snippets.

@ascandroli
Created April 1, 2012 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ascandroli/2274287 to your computer and use it in GitHub Desktop.
Save ascandroli/2274287 to your computer and use it in GitHub Desktop.
@CommitAfter not working in RESTEasy
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+><project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n\n\t<modelVersion>4.0.0</modelVersion>\n\t<groupId>org.amneris</groupId>\n\t<artifactId>petstore</artifactId>\n\t<packaging>war</packaging>\n\t<version>0.1.0-SNAPSHOT</version>\n\t<name>petstore - My Tynamo project</name>\n\t<url>http://tynamo.org/</url>\n\n\t<properties>\n\t\t<tynamo-version>0.3.0-SNAPSHOT</tynamo-version>\n\t\t<tapestry.app-package>org.amneris.petstore</tapestry.app-package>\n\t\t<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n\t</properties>\n\n\t<scm>\n\t\t<connection>scm:git:git://github.com/ascandroli/petstore.git</connection> <!-- Read-Only access -->\n\t\t<url>https://github.com/ascandroli/petstore</url>\n\t\t<developerConnection>scm:git:git@github.com:ascandroli/petstore.git</developerConnection> <!-- Read+Write access -->\n\t</scm>\n\n\t<prerequisites>\n\t\t<maven>3.0.3</maven>\n\t</prerequisites>\n\n\t<build>\n\t\t<finalName>petstore</finalName>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>2.3.2</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<source>1.6</source>\n\t\t\t\t\t<target>1.6</target>\n\t\t\t\t\t<optimize>true</optimize>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\n\t\t\t<!-- Run the application using \"mvn jetty:run\" -->\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.mortbay.jetty</groupId>\n\t\t\t\t<artifactId>jetty-maven-plugin</artifactId>\n\t\t\t\t<version>7.6.0.v20120127</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<systemProperties>\n\t\t\t\t\t\t<systemProperty>\n\t\t\t\t\t\t\t<name>tapestry.compress-whitespace</name>\n\t\t\t\t\t\t\t<value>false</value>\n\t\t\t\t\t\t</systemProperty>\n\t\t\t\t\t\t<systemProperty>\n\t\t\t\t\t\t\t<name>tapestry.production-mode</name>\n\t\t\t\t\t\t\t<value>false</value>\n\t\t\t\t\t\t</systemProperty>\n\t\t\t\t\t\t<systemProperty>\n\t\t\t\t\t\t\t<name>javax.xml.stream.XMLInputFactory</name>\n\t\t\t\t\t\t\t<value>com.ctc.wstx.stax.WstxInputFactory</value>\n\t\t\t\t\t\t</systemProperty>\n\t\t\t\t\t</systemProperties>\n<!--\n\t\t\t\t\t<systemPropertiesFile>target/classes/jetty.system.properties</systemPropertiesFile>\n-->\n\t\t\t\t\t<webAppConfig>\n\t\t\t\t\t\t<contextPath>/${project.build.finalName}</contextPath>\n\t\t\t\t\t</webAppConfig>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\n\t\t\t<!-- This changes the WAR file packaging so that what would normally go into WEB-INF/classes\n\t\t\t\t is instead packaged as WEB-INF/lib/petstore.jar. This is necessary for Tapestry\n\t\t\t\t to be able to search for page and component classes at startup. Only\n\t\t\t\t certain application servers require this configuration, please see the documentation\n\t\t\t\t at the Tapestry 5 project page (http://tapestry.apache.org/tapestry5/).\n\t\t\t -->\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-war-plugin</artifactId>\n\t\t\t\t<version>2.1.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<archiveClasses>true</archiveClasses>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\n\t\t\t<!-- This gets the plugin to clean up the cobertura.ser file left in the root directory. -->\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t<artifactId>cobertura-maven-plugin</artifactId>\n\t\t\t\t<version>2.5.1</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>clean</id>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>clean</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\n\t\t\t<!-- Provides build number and timestamp -->\n<!--\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t<artifactId>buildnumber-maven-plugin</artifactId>\n\t\t\t\t<version>1.0-beta-4</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<phase>process-resources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>create</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n-->\n\t\t</plugins>\n\t</build>\n\n\t<reporting>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-project-info-reports-plugin</artifactId>\n\t\t\t\t<version>2.4</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<dependencyDetailsEnabled>false</dependencyDetailsEnabled>\n\t\t\t\t\t<dependencyLocationsEnabled>false</dependencyLocationsEnabled>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t<artifactId>cobertura-maven-plugin</artifactId>\n\t\t\t\t<version>2.5.1</version>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-surefire-plugin</artifactId>\n\t\t\t\t<version>2.7.2</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<systemPropertyVariables>\n\t\t\t\t\t\t<tapestry.execution-mode>Qa</tapestry.execution-mode>\n\t\t\t\t\t</systemPropertyVariables>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</reporting>\n\n\t<dependencies>\n\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-model-hibernate</artifactId>\n\t\t\t<version>${tynamo-version}</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-model-test</artifactId>\n\t\t\t<version>${tynamo-version}</version>\n\t\t\t<scope>test</scope>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-resteasy</artifactId>\n\t\t\t<version>0.3.0</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.jboss.resteasy</groupId>\n\t\t\t<artifactId>resteasy-jettison-provider</artifactId>\n\t\t\t<version>2.3.0.GA</version>\n\t\t</dependency>\n\n\t\t<!--Add for the security-->\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-security</artifactId>\n\t\t\t<version>0.4.2</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-routing</artifactId>\n\t\t\t<version>0.0.2</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.tynamo</groupId>\n\t\t\t<artifactId>tapestry-exceptionpage</artifactId>\n\t\t\t<version>0.1.1</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>com.h2database</groupId>\n\t\t\t<artifactId>h2</artifactId>\n\t\t\t<version>1.2.125</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>mysql</groupId>\n\t\t\t<artifactId>mysql-connector-java</artifactId>\n\t\t\t<version>5.1.17</version>\n\t\t</dependency>\n\n\t\t<dependency>\n\t\t\t<groupId>org.hibernate</groupId>\n\t\t\t<artifactId>hibernate-c3p0</artifactId>\n\t\t\t<version>3.6.0.Final</version>\n\t\t</dependency>\n\n\t\t<!-- Provided by the servlet container, but sometimes referenced in the application code. -->\n\t\t<dependency>\n\t\t\t<groupId>javax.servlet</groupId>\n\t\t\t<artifactId>servlet-api</artifactId>\n\t\t\t<version>2.5</version>\n\t\t\t<scope>provided</scope>\n\t\t</dependency>\n\n\t\t<!-- Provide dependency to the Tapestry javadoc taglet which replaces the Maven component report -->\n\t\t<dependency>\n\t\t\t<groupId>org.apache.tapestry</groupId>\n\t\t\t<artifactId>tapestry-javadoc</artifactId>\n\t\t\t<version>5.3.1</version>\n\t\t\t<scope>provided</scope>\n\t\t</dependency>\n\n\t</dependencies>\n\n\t<!--\n\tIMPORTANT NOTE:\n\n\tConfiguring repositories is against Maven best practices. If you have\n\ta repository manager in use, remove this section and configure your\n\trepository manager to proxy these repositories instead.\n\t-->\n\t<repositories>\n\t\t<!-- Don't use snapshots unless absolutely necessary -->\n\t\t<repository>\n\t\t\t<id>codehaus-nexus-snapshots</id>\n\t\t\t<name>Codehaus Nexus Snapshots</name>\n\t\t\t<url>https://nexus.codehaus.org/content/groups/snapshots-group/</url>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>true</enabled>\n\t\t\t</snapshots>\n\t\t\t<releases>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</releases>\n\t\t</repository>\n\n\t\t<repository>\n\t\t\t<id>repository.jboss.org</id>\n\t\t\t<url>https://repository.jboss.org/nexus/content/repositories/releases</url>\n\t\t\t<releases>\n\t\t\t\t<enabled>true</enabled>\n\t\t\t</releases>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</snapshots>\n\t\t</repository>\n\n\t\t<!--\n\t\t\tlittle hack to disable java.net repositories because they are not working\n\t\t\tand they corrupt your local repo.\n\t\t-->\n\t\t<repository>\n\t\t\t<id>maven-repository.dev.java.net</id>\n\t\t\t<url>https://maven-repository.dev.java.net/nonav/repository</url>\n\t\t\t<releases>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</releases>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</snapshots>\n\t\t</repository>\n\t\t<repository>\n\t\t\t<id>java.net</id>\n\t\t\t<url>https://maven-repository.dev.java.net/nonav/repository</url>\n\t\t\t<releases>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</releases>\n\t\t\t<snapshots>\n\t\t\t\t<enabled>false</enabled>\n\t\t\t</snapshots>\n\t\t</repository>\n\n\t</repositories>\n\n\t<profiles>\n\t\t<profile>\n\t\t\t<id>commons</id>\n\t\t\t<build>\n\n\t\t\t\t<resources>\n\t\t\t\t\t<resource>\n\t\t\t\t\t\t<directory>src/main/resources</directory>\n\t\t\t\t\t</resource>\n\t\t\t\t\t<resource>\n\t\t\t\t\t\t<directory>src/profiles/commons/resources</directory>\n\t\t\t\t\t\t<filtering>true</filtering>\n\t\t\t\t\t</resource>\n\t\t\t\t\t<resource>\n\t\t\t\t\t\t<directory>src/profiles/${deploy.profile}/resources</directory>\n\t\t\t\t\t\t<filtering>true</filtering>\n\t\t\t\t\t</resource>\n\t\t\t\t</resources>\n\n\t\t\t\t<plugins>\n\t\t\t\t\t<plugin>\n\t\t\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t\t\t<artifactId>maven-war-plugin</artifactId>\n\t\t\t\t\t\t<version>2.1-alpha-2</version>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<archive>\n\t\t\t\t\t\t\t\t<manifest>\n\t\t\t\t\t\t\t\t\t<addDefaultImplementationEntries>true</addDefaultImplementationEntries>\n\t\t\t\t\t\t\t\t</manifest>\n\t\t\t\t\t\t\t\t<manifestEntries>\n\t\t\t\t\t\t\t\t\t<Implementation-Build>${buildNumber}</Implementation-Build>\n\t\t\t\t\t\t\t\t</manifestEntries>\n\t\t\t\t\t\t\t</archive>\n\t\t\t\t\t\t\t<webResources>\n\t\t\t\t\t\t\t\t<!-- cuidado con el orden, el orden de los factores afecta al resultado final -->\n\t\t\t\t\t\t\t\t<!-- a diferencia del \"resources\" los webResources se procesand e abajo a arriba -->\n\t\t\t\t\t\t\t\t<resource>\n\t\t\t\t\t\t\t\t\t<directory>src/profiles/${deploy.profile}/webapp</directory>\n\t\t\t\t\t\t\t\t\t<filtering>true</filtering>\n\t\t\t\t\t\t\t\t</resource>\n\t\t\t\t\t\t\t\t<resource>\n\t\t\t\t\t\t\t\t\t<directory>src/profiles/commons/webapp</directory>\n\t\t\t\t\t\t\t\t\t<filtering>true</filtering>\n\t\t\t\t\t\t\t\t</resource>\n\t\t\t\t\t\t\t</webResources>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</plugin>\n\t\t\t\t</plugins>\n\t\t\t</build>\n\n\t\t\t<properties>\n\t\t\t\t<hibernate.show_sql>true</hibernate.show_sql>\n\t\t\t\t<hibernate.format_sql>true</hibernate.format_sql>\n\t\t\t</properties>\n\n\t\t</profile>\n\n\n\t\t<profile>\n\t\t\t<id>dev.local</id>\n\n\t\t\t<properties>\n\t\t\t\t<deploy.profile>development</deploy.profile>\n\n\t\t\t\t<!-- Google-API Key for localhost -->\n\t\t\t\t<!--\n\t\t\t\t\t<ck.google.key>ABQIAAAABaUqD8Xx-kA5BiG_UZLiBhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTtdAZsgth3rHsqJVoqWZyBNQnQPw</ck.google.key>\n\t\t\t\t-->\n\n\t\t\t\t<!-- Local database properties -->\n\t\t\t\t<hibernate.connection.url.host>localhost</hibernate.connection.url.host>\n\t\t\t\t<hibernate.connection.url.databasename>petstore_dev</hibernate.connection.url.databasename>\n\t\t\t\t<hibernate.connection.username>petstore_admin</hibernate.connection.username>\n\t\t\t\t<hibernate.connection.password>petstore_4dm1n</hibernate.connection.password>\n\t\t\t\t<hibernate.show_sql>true</hibernate.show_sql>\n\t\t\t\t<hibernate.format_sql>true</hibernate.format_sql>\n\n\t\t\t\t<tapestry.production-mode>false</tapestry.production-mode>\n\t\t\t\t<tapestry.compress-whitespace>false</tapestry.compress-whitespace>\n\n\t\t\t</properties>\n\t\t</profile>\n\n\n\t\t<profile>\n\t\t\t<id>[YOURDOMAIN].com</id>\n\n\t\t\t<properties>\n\t\t\t\t<deploy.profile>production</deploy.profile>\n\n\t\t\t\t<!-- Google-API Key for [YOURDOMAIN].com -->\n<!--\n\t\t\t\t<ck.google.key>ABQIAAAABaUqD8Xx-kA5BiG_UZLiBhTfbvvK_7wN5rmfk0_m2BYm7INm6RRxMZysq26CjEdwhqU68TWKr9xczA</ck.google.key>\n-->\n\n\t\t\t\t<!-- Local database properties -->\n\t\t\t\t<hibernate.connection.url.host>localhost</hibernate.connection.url.host>\n\t\t\t\t<hibernate.connection.url.databasename>petstore</hibernate.connection.url.databasename>\n\t\t\t\t<hibernate.connection.username>petstore_admin</hibernate.connection.username>\n\t\t\t\t<hibernate.connection.password>petstore_4dm1n</hibernate.connection.password>\n\t\t\t\t<hibernate.show_sql>false</hibernate.show_sql>\n\t\t\t\t<hibernate.format_sql>false</hibernate.format_sql>\n\n\t\t\t\t<tapestry.production-mode>true</tapestry.production-mode>\n\t\t\t\t<tapestry.compress-whitespace>true</tapestry.compress-whitespace>\n\t\t\t</properties>\n\t\t</profile>\n\n\t</profiles>\n\n</project>\n
===================================================================
--- pom.xml (revision a5688fafc90db6531c692f404c6afc676cb9af5a)
+++ pom.xml (revision )
@@ -169,7 +169,7 @@
<dependency>
<groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jettison-provider</artifactId>
+ <artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.0.GA</version>
</dependency>
Index: src/main/java/org/amneris/petstore/services/AppModule.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>package org.amneris.petstore.services;\n\nimport org.apache.shiro.realm.Realm;\nimport org.apache.tapestry5.hibernate.HibernateSymbols;\nimport org.apache.tapestry5.ioc.Configuration;\nimport org.apache.tapestry5.ioc.MappedConfiguration;\nimport org.apache.tapestry5.ioc.ServiceBinder;\nimport org.apache.tapestry5.ioc.annotations.Contribute;\nimport org.apache.tapestry5.services.BeanBlockContribution;\nimport org.apache.tapestry5.services.BeanBlockSource;\nimport org.apache.tapestry5.services.DisplayBlockContribution;\nimport org.tynamo.PageType;\nimport org.tynamo.builder.Builder;\nimport org.tynamo.security.SecuritySymbols;\nimport org.tynamo.security.services.SecurityFilterChainFactory;\nimport org.tynamo.security.services.impl.SecurityFilterChain;\nimport org.tynamo.shiro.extension.realm.text.ExtendedPropertiesRealm;\n\nimport java.io.IOException;\nimport java.util.Properties;\n\n/**\n * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to configure and extend\n * Tynamo, or to place your own service definitions.\n */\npublic class AppModule\n{\n\n\tpublic static void bind(ServiceBinder binder)\n\t{\n\t\t// Make bind() calls on the binder object to define most IoC services.\n\t\t// Use service builder methods (example below) when the implementation\n\t\t// is provided inline, or requires more initialization than simply\n\t\t// invoking the constructor.\n\n\t}\n\n\tpublic static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)\n\t{\n\t\tloadApplicationDefaultsFromProperties(\"/applicationdefaults.properties\", configuration);\n\n\t\t// Tynamo's tapestry-security (Shiro) module configuration\n\t\tconfiguration.add(SecuritySymbols.LOGIN_URL, \"/signin\");\n\t\tconfiguration.add(SecuritySymbols.UNAUTHORIZED_URL, \"/unauthorized\");\n\t\tconfiguration.add(SecuritySymbols.SUCCESS_URL, \"/home\");\n\n\t\tconfiguration.add(HibernateSymbols.EARLY_START_UP, \"false\");\n\t}\n\n\tpublic static void contributeWebSecurityManager(Configuration<Realm> configuration) \n\t{\n\t\tconfiguration.add(new ExtendedPropertiesRealm(\"classpath:shiro-users.properties\"));\n\t}\n\n\n\tpublic static void contributeSecurityConfiguration(Configuration<SecurityFilterChain> configuration,\n\t SecurityFilterChainFactory factory)\n\t{\n\t\tconfiguration.add(factory.createChain(\"/signin\").add(factory.anon()).build());\n\t\tconfiguration.add(factory.createChain(\"/\").add(factory.roles(), \"admin\").build());\n\t\tconfiguration.add(factory.createChain(\"/edit/**\").add(factory.perms(), \"*:update\").build());\n\t\tconfiguration.add(factory.createChain(\"/show/**\").add(factory.perms(), \"*:select\").build());\n\t\tconfiguration.add(factory.createChain(\"/add/**\").add(factory.perms(), \"*:insert\").build());\n\t\tconfiguration.add(factory.createChain(\"/list/**\").add(factory.perms(), \"*:select\").build());\n\t}\n\t/**\n\t * By default tapestry-hibernate will scan\n\t * InternalConstants.TAPESTRY_APP_PACKAGE_PARAM + \".entities\" (witch is equal to \"org.amneris.petstore.petstore.entities\")\n\t * for annotated entity classes.\n\t *\n\t * Contributes the package \"org.amneris.petstore.petstore.model\" to the configuration, so that it will be\n\t * scanned for annotated entity classes.\n\t */\n\tpublic static void contributeHibernateEntityPackageManager(Configuration<String> configuration)\n\t{\n//\t\tIf you want to scan other packages add them here:\n//\t\tconfiguration.add(\"org.amneris.petstore.petstore.model\");\n\t}\n\n\t/**\n\t * Contributes Builders to the BuilderDirector's builders map.\n\t * Check GOF's <a href=\"http://en.wikipedia.org/wiki/Builder_pattern\">Builder pattern</a>\n\t */\n\tpublic static void contributeBuilderDirector(MappedConfiguration<Class, Builder> configuration)\n\t{\n//\t\tconfiguration.add(org.tynamo.examples.recipe.model.Recipe.class, new RecipeBuilder());\n\t}\n\n/*\n\t@Startup\n\tpublic static void init(Logger logger, MigrationManager migrationManager)\n\t{\n\t\tlogger.info(\"Starting up...\");\n//\t\tmigrationManager.migrate();\n\t}\n*/\n\n\t/**\n\t * Contribution to the BeanBlockSource service to tell the BeanEditForm\n\t * component about the editors.\n\t */\n\t@Contribute(BeanBlockSource.class)\n\tpublic static void addCustomBlocks(Configuration<BeanBlockContribution> configuration)\n\t{\n\t\tconfiguration.add(new DisplayBlockContribution(\"boolean\", \"blocks/DisplayBlocks\", \"check\"));\n\t}\n\n\tprivate static void loadApplicationDefaultsFromProperties(String properties, MappedConfiguration<String, String> contributions)\n\t{\n\t\tProperties prop = new Properties();\n\n\t\ttry\n\t\t{\n\t\t\tprop.load(AppModule.class.getResource(properties).openStream());\n\t\t} catch (IOException ioe)\n\t\t{\n\t\t\tthrow new RuntimeException(\"Unable to load \" + properties, ioe);\n\t\t}\n\n\t\tfor (Object key : prop.keySet())\n\t\t{\n\t\t\tString value = prop.getProperty(key.toString());\n\t\t\tcontributions.add(key.toString(), value);\n\t\t}\n\t}\n\n}\n
===================================================================
--- src/main/java/org/amneris/petstore/services/AppModule.java (revision a5688fafc90db6531c692f404c6afc676cb9af5a)
+++ src/main/java/org/amneris/petstore/services/AppModule.java (revision )
@@ -1,11 +1,15 @@
package org.amneris.petstore.services;
+import org.amneris.petstore.api.MyDomainObjectResource;
import org.apache.shiro.realm.Realm;
import org.apache.tapestry5.hibernate.HibernateSymbols;
+import org.apache.tapestry5.hibernate.HibernateTransactionAdvisor;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.MethodAdviceReceiver;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.annotations.Match;
import org.apache.tapestry5.services.BeanBlockContribution;
import org.apache.tapestry5.services.BeanBlockSource;
import org.apache.tapestry5.services.DisplayBlockContribution;
@@ -32,7 +36,7 @@
// Use service builder methods (example below) when the implementation
// is provided inline, or requires more initialization than simply
// invoking the constructor.
-
+ binder.bind(MyDomainObjectResource.class);
}
public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
@@ -103,6 +107,21 @@
public static void addCustomBlocks(Configuration<BeanBlockContribution> configuration)
{
configuration.add(new DisplayBlockContribution("boolean", "blocks/DisplayBlocks", "check"));
+ }
+
+ /**
+ * Contributions to the RESTeasy main Application, insert all your RESTeasy singletons services here.
+ */
+ @Contribute(javax.ws.rs.core.Application.class)
+ public static void configureRestResources(Configuration<Object> singletons, MyDomainObjectResource myDomainObjectResource)
+ {
+ singletons.add(myDomainObjectResource);
+ }
+
+ @Match("*Resource")
+ public static void adviseTransactions(HibernateTransactionAdvisor advisor, MethodAdviceReceiver receiver)
+ {
+ advisor.addTransactionCommitAdvice(receiver);
}
private static void loadApplicationDefaultsFromProperties(String properties, MappedConfiguration<String, String> contributions)
Index: src/main/java/org/amneris/petstore/rest/MyDomainObjectResource.java
===================================================================
--- src/main/java/org/amneris/petstore/rest/MyDomainObjectResource.java (revision a5688fafc90db6531c692f404c6afc676cb9af5a)
+++ src/main/java/org/amneris/petstore/api/MyDomainObjectResourceImpl.java (revision )
@@ -1,41 +1,37 @@
-package org.amneris.petstore.rest;
+package org.amneris.petstore.api;
import org.amneris.petstore.entities.MyDomainObject;
import org.tynamo.services.PersistenceService;
-import javax.ws.rs.*;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.util.List;
-@Path("/mydomainobject")
-public class MyDomainObjectResource
+public class MyDomainObjectResourceImpl implements MyDomainObjectResource
{
private PersistenceService persistenceService;
- public MyDomainObjectResource(PersistenceService persistenceService) {
+ public MyDomainObjectResourceImpl(PersistenceService persistenceService)
+ {
this.persistenceService = persistenceService;
}
- @GET
- @Produces("application/json")
+ @Override
public List<MyDomainObject> getAllDomains()
{
return (persistenceService.getInstances(MyDomainObject.class));
}
- @POST
- @Consumes("application/json")
+ @Override
public Response post(MyDomainObject domainObject)
{
persistenceService.save(domainObject);
return Response.ok().build();
}
- @GET
- @Path("{id}")
- @Produces("application/json")
- public MyDomainObject getDomainObject(@PathParam("id") Long id)
+ @Override
+ public MyDomainObject getDomainObject(Long id)
{
MyDomainObject domainObject = persistenceService.getInstance(MyDomainObject.class, id);
if (domainObject == null)
Index: src/test/java/org/amneris/petstore/rest/MyDomainObjectResourceTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/test/java/org/amneris/petstore/rest/MyDomainObjectResourceTest.java (revision )
+++ src/test/java/org/amneris/petstore/rest/MyDomainObjectResourceTest.java (revision )
@@ -0,0 +1,43 @@
+package org.amneris.petstore.rest;
+
+import org.amneris.petstore.api.MyDomainObjectResource;
+import org.amneris.petstore.entities.MyDomainObject;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.tynamo.test.AbstractContainerTest;
+
+import javax.ws.rs.core.Response;
+
+public class MyDomainObjectResourceTest extends AbstractContainerTest
+{
+
+ private final static Logger logger = LoggerFactory.getLogger(MyDomainObjectResourceTest.class);
+
+ @Test
+ public void post() throws Exception
+ {
+ RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
+
+ MyDomainObjectResource resource = ProxyFactory.create(MyDomainObjectResource.class, BASEURI + "/rest");
+
+ MyDomainObject dummy = new MyDomainObject();
+ dummy.setName("dummy");
+
+ ClientResponse response = (ClientResponse) resource.post(dummy);
+
+ Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ response.releaseConnection();
+
+ MyDomainObject actual = resource.getDomainObject(1l);
+
+ Assert.assertEquals(actual.getName(), dummy.getName());
+
+ }
+
+}
Index: src/main/java/org/amneris/petstore/api/MyDomainObjectResource.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/org/amneris/petstore/api/MyDomainObjectResource.java (revision )
+++ src/main/java/org/amneris/petstore/api/MyDomainObjectResource.java (revision )
@@ -0,0 +1,26 @@
+package org.amneris.petstore.api;
+
+import org.amneris.petstore.entities.MyDomainObject;
+import org.apache.tapestry5.hibernate.annotations.CommitAfter;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+@Path("/mydomainobject")
+public interface MyDomainObjectResource
+{
+ @GET
+ @Produces("application/json")
+ List<MyDomainObject> getAllDomains();
+
+ @POST
+ @Consumes("application/json")
+ @CommitAfter
+ Response post(MyDomainObject domainObject);
+
+ @GET
+ @Path("{id}")
+ @Produces("application/json")
+ MyDomainObject getDomainObject(@PathParam("id") Long id);
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment