Author: [email protected]
Date: Wed Nov 16 16:51:42 2011
New Revision: 1726
Log:
Modified:
sandbox/ivol/amdatu-gadget-container/pom.xml
sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/pom.xml
sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/src/main/java/org/amdatu/opensocial/tenant/gadget/service/TenantConfigDAOImpl.java
sandbox/ivol/amdatu-gadget-container/tenant-management-service/pom.xml
sandbox/ivol/amdatu-gadget-container/tenant-management-service/src/main/java/org/amdatu/core/tenant/service/TenantConfigServiceImpl.java
Modified: sandbox/ivol/amdatu-gadget-container/pom.xml
==============================================================================
--- sandbox/ivol/amdatu-gadget-container/pom.xml (original)
+++ sandbox/ivol/amdatu-gadget-container/pom.xml Wed Nov 16 16:51:42 2011
@@ -432,23 +432,64 @@
<module>tenant-management-service</module>
</modules>
- <profiles>
- <profile>
- <!-- Profile that will copy the jar to the configured
amdatu.deploy.directory when
- the deploy profile is activated -->
- <id>deploy</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <defaultGoal>install</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- Plugin configuration for -Pdeploy -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>ant-contrib</groupId>
+ <artifactId>ant-contrib</artifactId>
+ <version>1.0b3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>install</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.compile.classpath" />
+ <available
file="${project.build.directory}/${project.build.finalName}.jar"
property="fileExists" value="true" />
+
+ <if>
+ <isset property="fileExists" />
+ <then>
+ <if>
+ <isset property="amdatu.deploy.directory" />
+ <then>
+ <copy
file="${project.build.directory}/${project.build.finalName}.jar"
tofile="${amdatu.deploy.directory}/${project.artifactId}-${project.version}.jar"
overwrite="true" />
+ </then>
+ <else>
+ <echo message="Property amdatu.deploy.directory not
defined, skipping copy to deploy dir task" />
+ </else>
+ </if>
+ </then>
+ </if>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
Modified: sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/pom.xml
==============================================================================
--- sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/pom.xml
(original)
+++ sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/pom.xml
Wed Nov 16 16:51:42 2011
@@ -102,17 +102,44 @@
<instructions>
<Bundle-Activator>org.amdatu.opensocial.tenant.gadget.osgi.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Embed-Dependency>*;scope=compile</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
- <Export-Package></Export-Package>
- <Import-Package>
+
<Embed-Dependency>*;scope=compile;artifactId=json|mail|org.amdatu.libraries.utilities</Embed-Dependency>
+ <Embed-Transitive>false</Embed-Transitive>
+ <Import-Package>*;resolution:=optional</Import-Package>
+
+ <!--
!sun.security.util,
+ !javax.microedition.io,
+ !org.apache.coyote.*,
+ !org.apache.tomcat.*,
+ !org.apache.tools.ant.*,
+ !org.apache.xalan.*,
+ !org.apache.xml.utils,
+ !org.apache.xpath.*,
*
- </Import-Package>
+ -->
</instructions>
</configuration>
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <!-- Profile that will copy the jar to the configured
amdatu.deploy.directory when
+ the deploy profile is activated -->
+ <id>deploy</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Modified:
sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/src/main/java/org/amdatu/opensocial/tenant/gadget/service/TenantConfigDAOImpl.java
==============================================================================
---
sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/src/main/java/org/amdatu/opensocial/tenant/gadget/service/TenantConfigDAOImpl.java
(original)
+++
sandbox/ivol/amdatu-gadget-container/tenant-management-gadget/src/main/java/org/amdatu/opensocial/tenant/gadget/service/TenantConfigDAOImpl.java
Wed Nov 16 16:51:42 2011
@@ -35,7 +35,7 @@
private volatile ConfigurationAdmin m_configAdmin;
public List<TenantBean> getTenants() throws IOException {
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
List<TenantBean> tenants = new ArrayList<TenantBean>();
int keyId = 1;
@@ -61,7 +61,7 @@
// This results the tenant by the key as the tenant is prefixed in
ConfiguartionAdmin, i.e. 'tenant1'
private TenantBean getTenantByKey(String key) throws IOException {
if (key != null) {
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
String id = properties.get(key + ".id").toString();
String name = properties.get(key + ".name").toString();
@@ -76,7 +76,7 @@
public boolean setTenant(String id, String name, String hostname) throws
IOException {
boolean created = false;
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
String tenantKey = findTenantKey(id);
if (tenantKey == null) {
@@ -92,7 +92,7 @@
}
public boolean deleteTenant(String tenantId) throws IOException {
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
String tenantKey = findTenantKey(tenantId);
if (tenantKey != null) {
@@ -115,6 +115,7 @@
properties.remove("tenant" + lastId + ".name");
properties.remove("tenant" + lastId + ".properties.hostname");
+ config.
config.update(properties);
return true;
}
@@ -122,7 +123,7 @@
}
private String findTenantKey(String tenantId) throws IOException {
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
Enumeration keys = properties.keys();
while (keys.hasMoreElements()) {
@@ -138,7 +139,7 @@
private int findLastTenantKey() throws IOException {
int maxid = 1;
- Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID);
+ Configuration config =
m_configAdmin.getConfiguration(TenantManagementService.PID, null);
Dictionary properties = config.getProperties();
Enumeration keys = properties.keys();
while (keys.hasMoreElements()) {
Modified: sandbox/ivol/amdatu-gadget-container/tenant-management-service/pom.xml
==============================================================================
--- sandbox/ivol/amdatu-gadget-container/tenant-management-service/pom.xml
(original)
+++ sandbox/ivol/amdatu-gadget-container/tenant-management-service/pom.xml
Wed Nov 16 16:51:42 2011
@@ -50,8 +50,26 @@
</instructions>
</configuration>
</plugin>
-
</plugins>
</build>
+ <profiles>
+ <profile>
+ <!-- Profile that will copy the jar to the configured
amdatu.deploy.directory when
+ the deploy profile is activated -->
+ <id>deploy</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Modified:
sandbox/ivol/amdatu-gadget-container/tenant-management-service/src/main/java/org/amdatu/core/tenant/service/TenantConfigServiceImpl.java
==============================================================================
---
sandbox/ivol/amdatu-gadget-container/tenant-management-service/src/main/java/org/amdatu/core/tenant/service/TenantConfigServiceImpl.java
(original)
+++
sandbox/ivol/amdatu-gadget-container/tenant-management-service/src/main/java/org/amdatu/core/tenant/service/TenantConfigServiceImpl.java
Wed Nov 16 16:51:42 2011
@@ -22,7 +22,6 @@
import java.util.List;
import java.util.Map;
-import org.amdatu.core.tenant.Tenant;
import org.amdatu.core.tenant.TenantEntity;
import org.amdatu.core.tenant.TenantException;
import org.amdatu.core.tenant.TenantManagementService;
@@ -63,20 +62,34 @@
m_newTenants.add(getTenant(properties, key));
}
}
-
+
+ if (m_logService != null && m_tenantService != null) {
+ update();
+ }
}
}
- public void start() {
+ public void start() throws TenantException {
+ // When the tenant service is started, read the current tenants from
the tenant management service
+ loadTenantsFromStore();
+ update();
+ }
+
+ private void update() {
try {
update(m_tenants, m_newTenants);
- m_tenants = m_newTenants;
+ loadTenantsFromStore();
}
catch (TenantException e) {
m_logService.log(LogService.LOG_ERROR, "Failed to update
tenants.", e);
}
}
+ private void loadTenantsFromStore() throws TenantException {
+ m_tenants.clear();
+ m_tenants.addAll(m_tenantService.getTenants());
+ }
+
// This method compares the old tenants against the new tenants and
ensures that tenants are
// added, updated or removed only when necessary. For example, if the
configuration file was
// updated but no tenant was effectively changed, this method will do
nothing
@@ -110,6 +123,12 @@
}
}
+ String msg = "Change in Tenant configuration received, applying
modifications:\r\n";
+ msg += " Create tenants: " +
tenantsToCreate + "\r\n";
+ msg += " Update tenants: " +
tenantsToUpdate + "\r\n";
+ msg += " Delete tenants: " +
tenantsToDelete + "\r\n";
+ m_logService.log(LogService.LOG_INFO, msg);
+
// Create new tenants
for (TenantEntity tenant : tenantsToCreate) {
m_tenantService.createTenant(tenant.getId(), tenant.getName(),
tenant.getProperties());
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits