Skip to content

Commit

Permalink
multi-tenant#41 Remove Custom Spring Scope
Browse files Browse the repository at this point in the history
Bump version to 0.9.0 (since functionality is being removed)
Also Removed documentation
Add simple test for CurrentTenantAware beans
  • Loading branch information
sronderos committed Mar 16, 2015
1 parent 385950f commit d9fed71
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 340 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ stacktrace.log
.classpath
.project
.settings
.idea
/.idea
*.iml
*.ipr
.grails
/out
4 changes: 2 additions & 2 deletions MultiTenantSingleDbGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory
class MultiTenantSingleDbGrailsPlugin {
private Logger log = LoggerFactory.getLogger('grails.plugin.multiTenant.MultiTenantSingleDbPlugin')

def version = "0.8.3"
def version = "0.9.0-SNAPSHOT"
def grailsVersion = "1.3.5 > *"

def loadAfter = [
Expand All @@ -28,7 +28,7 @@ class MultiTenantSingleDbGrailsPlugin {

def license = "APACHE"
def developers = [
[ name: "Steve Ronderos", email: "steve.ronderos@gmail.com" ]
[ name: "Steve Ronderos", email: "steve@ronderos.com" ]
]
def issueManagement = [ system: "github", url: "https://github.com/multi-tenant/grails-multi-tenant-single-db/issues" ]
def scm = [ url: "https://github.com/multi-tenant/grails-multi-tenant-single-db" ]
Expand Down
1 change: 0 additions & 1 deletion grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ log4j = {
}

multiTenant {
perTenantBeans = [ "demoService" ]
tenantClass = demo.DemoTenant
}

Expand Down
5 changes: 5 additions & 0 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import demo.DemoStore

beans = {
demoStore(DemoStore)
}
15 changes: 0 additions & 15 deletions grails-app/services/demo/AnotherDemoService.groovy

This file was deleted.

13 changes: 0 additions & 13 deletions grails-app/services/demo/DemoService.groovy

This file was deleted.

29 changes: 0 additions & 29 deletions src/docs/guide/2.5. Tenant scoped beans.gdoc

This file was deleted.

4 changes: 4 additions & 0 deletions src/docs/guide/6. Changelog.gdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
h3. v0.9.0

* Removed Tenant Scope

h3. v0.8.3 April 18th 2013

* Configurable Filter Position
Expand Down
17 changes: 17 additions & 0 deletions src/groovy/demo/DemoStore.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package demo

import grails.plugin.multitenant.core.CurrentTenant
import grails.plugin.multitenant.core.CurrentTenantAware

/**
* @author Steve Ronderos
*/
class DemoStore implements CurrentTenantAware {

CurrentTenant currentTenant

@Override
void setCurrentTenant(CurrentTenant currentTenant) {
this.currentTenant = currentTenant
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import grails.plugin.multitenant.core.Tenant
import grails.plugin.multitenant.core.exception.TenantException
import grails.plugin.multitenant.core.impl.CurrentTenantThreadLocal
import grails.plugin.multitenant.core.servlet.CurrentTenantServletFilter
import grails.plugin.multitenant.core.spring.ConfiguredTenantScopedBeanProcessor
import grails.plugin.multitenant.core.spring.CurrentTenantAwarePostProcessor
import grails.plugin.multitenant.core.spring.TenantScope
import grails.plugin.multitenant.singledb.hibernate.TenantHibernateEventListener
import grails.plugin.multitenant.singledb.hibernate.TenantHibernateEventProxy
import grails.plugin.multitenant.singledb.hibernate.TenantHibernateFilterConfigurator
Expand All @@ -17,7 +15,6 @@ import grails.plugin.multitenant.singledb.hibernate.TenantHibernateFilterEnabler
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.CustomScopeConfigurer
import org.springframework.context.ApplicationContext
import org.springframework.orm.hibernate3.FilterDefinitionFactoryBean

Expand Down Expand Up @@ -49,21 +46,6 @@ class MtSingleDbPluginSupport {
currentTenant = ref("currentTenant")
}

// A custom Spring scope for beans.
tenantScope(TenantScope) {
currentTenant = ref("currentTenant")
}

// Set per-tenant beans up in the custom tenant scope
configuredTenantBeanProcessor(ConfiguredTenantScopedBeanProcessor) {
perTenantBeans = multiTenantConfig?.perTenantBeans ?: []
}

// Responsible for registering the custom 'tenant' scope with Spring.
tenantScopeConfigurer(CustomScopeConfigurer) {
scopes = [ tenant: ref("tenantScope") ]
}

// Definition of the Hibernate filter making sure that
// each tenant only sees and touches its own data.
multiTenantHibernateFilter(FilterDefinitionFactoryBean) {
Expand Down

This file was deleted.

102 changes: 0 additions & 102 deletions src/java/grails/plugin/multitenant/core/spring/TenantScope.java

This file was deleted.

17 changes: 17 additions & 0 deletions test/integration/demo/CurrentTenantAwareSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package demo

import grails.plugin.spock.IntegrationSpec

/**
* @author Steve Ronderos
*/
class CurrentTenantAwareSpec extends IntegrationSpec {

def demoStore

def "current tenant is injected into the service"() {
expect:
demoStore != null
demoStore.currentTenant != null
}
}
Loading

0 comments on commit d9fed71

Please sign in to comment.