Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Grails 2.4.5 and Hibernate 4 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
188 changes: 172 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,176 @@
web-app
target
target-eclipse
build
bin
build.sh
plugin.xml
stacktrace.log
*.tmproj
*.iws
*.zip
##Grails.gitignore-------------------------------------------------------------
# web application files
/web-app/WEB-INF/classes

# default HSQL database files for production mode
/prodDb.*

# general HSQL database files
*Db.properties
*Db.script

# logs
/stacktrace.log
/test/reports
/logs

# project release file
/*.war

# plugin release files
/*.zip
/plugin.xml

# older plugin install locations
/plugins
/web-app/plugins

# "temporary" build files
/target


##Java.gitignore---------------------------------------------------------------
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


##Maven.gitignore--------------------------------------------------------------
target/
**/target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties


##Eclipse.gitignore------------------------------------------------------------
*.pydevproject
.metadata
.gradle
.DS_Store
.classpath
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath

# Eclipse Core
.project
.settings
.idea
*.sha1

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse


##SublimeText.gitignore--------------------------------------------------------
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json


##NetBeans.gitignore-----------------------------------------------------------
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/


##JetBrains.gitignore----------------------------------------------------------
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
78 changes: 57 additions & 21 deletions HibernateHijackerGrailsPlugin.groovy
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
import grails.plugin.hibernatehijacker.hibernate.HibernateEventSubscriptionFactory
import grails.plugin.hibernatehijacker.hibernate.SessionFactoryProxyFactory
import grails.plugin.hibernatehijacker.hibernate.events.HibernateEventListener
import grails.plugin.hibernatehijacker.hibernate.events.HibernateEventPropertyUpdater
import grails.plugin.hibernatehijacker.indexdsl.IndexDslPostProcessor
import grails.plugin.hibernatehijacker.spring.HibernateEventSubscriptionFactory
import grails.plugin.hibernatehijacker.spring.SessionFactoryPostProcessor
import grails.plugin.hibernatehijacker.template.HibernateTemplates

class HibernateHijackerGrailsPlugin {

def version = "0.8.1"

def grailsVersion = "1.3.5 > *"

/* The webflow plugin replaces SpringSessionContext.
* By loading our plugin after webflow (if it's installed) we can detect this
* and create an instance of FlowAwareCurrentSessionContext instead of SpringSessionContext.
*/
def loadAfter = ['webflow']

// the plugin version
def version = "1.0"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.4 > *"
// resources that are excluded from plugin packaging
def pluginExcludes = [
"**/demo/**"
"grails-app/views/error.gsp",
"**/demo/**"
]

def author = "Kim A. Betti"
def authorEmail = "kim.betti@gmail.com"
def title = "Hibernate Hijacker"
def documentation = "http://grails.org/plugin/hibernate-hijacker"
// TODO Fill in these fields
def title = "Hibernate Hijacker" // Headline display name of the plugin
def author = "Sandeep Poonia"
def authorEmail = "sandeep.poonia.90@gmail.com"
def description = '''\
This plugin is a part of the re-engineering efforts going into the Multi-Tenant plugin.
It is very difficult to intercept new Hibernate sessions in a non-intrusive way.
Multiple plugins trying to archive this are likely to step on each others feet.
This plugin publishes intercepted Session instances to a lightweight event broker.
'''

// URL to the plugin's documentation
def documentation = "https://github.com/spoonia/grails-hibernate-hijacker"

// Extra (optional) plugin metadata

// License: one of 'APACHE', 'GPL2', 'GPL3'
def license = "APACHE"
// def developers = [[name: "Joe Bloggs", email: "joe@bloggs.net"]]
def issueManagement = [system: 'GitHub', url: 'https://github.com/multi-tenant/grails-hibernate-hijacker/issues']
def scm = [url: 'https://github.com/multi-tenant/grails-hibernate-hijacker']

def doWithSpring = {
// Details of company behind the plugin (if there is one)
// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]

// Any additional developers beyond the author specified above.
// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]

// Location of the plugin's issue tracker.
def issueManagement = [system: 'GitHub', url: 'https://github.com/spoonia/grails-hibernate-hijacker/issues']

// Online location of the plugin's browseable source code.
def scm = [url: 'https://github.com/spoonia/grails-hibernate-hijacker']

def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
}

def doWithSpring = {
// Responsible for wrapping the real SessionFactory instance
// inside a JDK proxy so we can intercept new sessions.
sessionFactoryProxyFactory(SessionFactoryProxyFactory) {
Expand Down Expand Up @@ -72,4 +85,27 @@ This plugin publishes intercepted Session instances to a lightweight event broke
// before it's persisted to the database.
hibernateEventPropertyUpdater(HibernateEventPropertyUpdater)
}

def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}

def doWithApplicationContext = { ctx ->
// TODO Implement post initialization spring config (optional)
}

def onChange = { event ->
// TODO Implement code that is executed when any artefact that this plugin is
// watching is modified and reloaded. The event contains: event.source,
// event.application, event.manager, event.ctx, and event.plugin.
}

def onConfigChange = { event ->
// TODO Implement code that is executed when the project configuration changes.
// The event is the same as for 'onChange'.
}

def onShutdown = { event ->
// TODO Implement code that is executed when the application shuts down (optional)
}
}
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ The Hibernate Hijacker's Guide to the Galaxy

This plugin is a part of the re-engineering efforts going into the [Multi-Tenant plugin](http://grails.org/plugin/multi-tenant). It is very difficult to intercept new Hibernate sessions in a non-intrusive way. Multiple plugins trying to archive this are likely to step on each other's feet. This plugin publishes intercepted [Session](http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/Session.html) instances to [Hawk Eventing](http://github.com/multi-tenant/grails-hawk-eventing), a lightweight event broker, that multiple plugins can subscribe to.

The documentation is now hosted at [GitHub Pages](http://multi-tenant.github.com/grails-hibernate-hijacker/).
The documentation is now hosted at [GitHub Pages](https://github.com/spoonia/grails-hibernate-hijacker).

Current Issues:
---
* Other plugins will not be able to set configClass in dataSource block. So grails-hibernate-filter plugin might not work.
* Not an easy way to create sessionFactory proxy. As [GrailsHibernateTemplate](org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateTemplate) constructor uses [SessionFactoryImpl](org.hibernate.internal.SessionFactoryImpl) which is a final class instead of the interface. Which makes it difficult to pass a proxy object of SessionFactoryImplementor.
5 changes: 4 additions & 1 deletion application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
app.grails.version=2.0.0
#Grails Metadata file
#Wed Mar 23 07:56:28 IST 2016
app.grails.version=2.4.5
app.name=hibernate-hijacker
70 changes: 48 additions & 22 deletions grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
@@ -1,29 +1,55 @@
grails.project.work.dir = 'target'
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"

grails.project.dependency.resolution = {

inherits 'global'
log 'warn'
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

repositories {
grailsCentral()
}
// configure settings for the test-app JVM, uses the daemon by default
test : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon: true],
// configure settings for the run-app JVM
run : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
// configure settings for the run-war JVM
war : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

plugins {
build ':release:2.2.1', ':rest-client-builder:1.0.3', {
export = false
}
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.27'
}

compile ":hibernate:$grailsVersion", {
export = false
}
plugins {
build(":release:3.1.1", ":rest-client-builder:2.1.1") {
export = false
}

compile ':hawk-eventing:0.5.1', {
excludes 'svn'
}
compile ":hibernate4:4.3.10", {
export = false
}

test ':spock:0.7', {
export = false
}
}
compile ':hawk-eventing:1.0', {
excludes 'svn'
}
}
}
Loading