Author: jeff.yuchang
Date: 2009-06-18 05:12:32 -0400 (Thu, 18 Jun 2009)
New Revision: 617
Added:
idm/trunk/example/auth/src/main/resources/jboss.idm.cfg.xml
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java
Removed:
idm/trunk/example/auth/src/main/resources/jboss-idm.xml
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMServiceMBean.java
idm/trunk/integration/jboss5/src/main/resources/idm-service-assembly.xml
idm/trunk/integration/jboss5/src/main/resources/jboss.idm.cfg.xml
idm/trunk/integration/jboss5/src/main/resources/jboss.idm.hibernate.cfg.xml
Modified:
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml
idm/trunk/integration/deployer/pom.xml
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMDeployer.java
idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml
idm/trunk/integration/jboss5/pom.xml
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMService.java
idm/trunk/integration/jboss5/src/main/resources/META-INF/idm-service-jboss-beans.xml
Log:
* Refactor the IDMService, now the IDMDeployer uses the IDMService to start the service.
* Rename the config file in the example/auth.
* Update the auth example config file accordingly.
Modified:
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml
===================================================================
---
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml 2009-06-18
09:12:32 UTC (rev 617)
@@ -8,16 +8,13 @@
<bean name="idm.example.auth.IDMService"
class="org.jboss.identity.idm.integration.jboss5.IDMService">
<constructor>
- <parameter>jboss-idm.xml</parameter>
- <parameter><inject bean="JMXKernel"
property="mbeanServer"/></parameter>
+ <parameter>jboss.idm.cfg.xml</parameter>
</constructor>
<property name="doChecking">true</property>
<property name="setupLocation">setup.txt</property>
<property
name="idmSessionFactoryJNDI">java:/IdentitySessionFactory</property>
<property
name="hibernateSessionFactoryRegistryName">hibernateSessionFactory</property>
- <property
name="hibernateConfigLocation">jboss.idm.hibernate.cfg.xml</property>
-
-
+ <property
name="hibernateConfigLocation">jboss.idm.hibernate.cfg.xml</property>
<depends>TransactionManager</depends>
</bean>
Deleted: idm/trunk/example/auth/src/main/resources/jboss-idm.xml
===================================================================
--- idm/trunk/example/auth/src/main/resources/jboss-idm.xml 2009-06-17 16:57:41 UTC (rev
616)
+++ idm/trunk/example/auth/src/main/resources/jboss-idm.xml 2009-06-18 09:12:32 UTC (rev
617)
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha
identity-config.xsd">
- <realms>
- <realm>
- <id>realm://JBossIdentity</id>
- <repository-id-ref>JBoss_Identity_Repository</repository-id-ref>
- <identity-type-mappings>
- <user-mapping>USER</user-mapping>
- </identity-type-mappings>
- </realm>
- </realms>
- <repositories>
- <repository>
- <id>JBoss_Identity_Repository</id>
-
<class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
- <external-config/>
-
<default-identity-store-id>Identity_DB_Store</default-identity-store-id>
-
<default-attribute-store-id>Identity_DB_Store</default-attribute-store-id>
- </repository>
- </repositories>
- <stores>
- <attribute-stores/>
- <identity-stores>
- <identity-store>
- <id>Identity_DB_Store</id>
-
<class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
- <external-config/>
- <supported-relationship-types>
-
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
- <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
- </supported-relationship-types>
- <supported-identity-object-types>
- <identity-object-type>
- <name>USER</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials>
- <credential-type>PASSWORD</credential-type>
- </credentials>
- <attributes/>
- <options/>
- </identity-object-type>
- <identity-object-type>
- <name>ORGANIZATION</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials/>
- <attributes/>
- <options/>
- </identity-object-type>
- <identity-object-type>
- <name>GROUP</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials/>
- <attributes/>
- <options/>
- </identity-object-type>
- </supported-identity-object-types>
- <options>
- <!--<option>-->
- <!--<name>hibernateConfiguration</name>-->
-
<!--<value>jboss.idm.hibernate.cfg.xml</value>-->
- <!--</option>-->
- <option>
- <name>hibernateSessionFactoryRegistryName</name>
- <value>hibernateSessionFactory</value>
- </option>
- <option>
- <name>populateRelationshipTypes</name>
- <value>true</value>
- </option>
- <option>
- <name>populateIdentityObjectTypes</name>
- <value>true</value>
- </option>
- <option>
- <name>allowNotDefinedAttributes</name>
- <value>true</value>
- </option>
- <option>
- <name>isRealmAware</name>
- <value>true</value>
- </option>
- </options>
- </identity-store>
- </identity-stores>
- </stores>
-</jboss-identity>
Added: idm/trunk/example/auth/src/main/resources/jboss.idm.cfg.xml
===================================================================
--- idm/trunk/example/auth/src/main/resources/jboss.idm.cfg.xml
(rev 0)
+++ idm/trunk/example/auth/src/main/resources/jboss.idm.cfg.xml 2009-06-18 09:12:32 UTC
(rev 617)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha
identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm://JBossIdentity</id>
+ <repository-id-ref>JBoss_Identity_Repository</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>JBoss_Identity_Repository</id>
+
<class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
+ <external-config/>
+
<default-identity-store-id>Identity_DB_Store</default-identity-store-id>
+
<default-attribute-store-id>Identity_DB_Store</default-attribute-store-id>
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>Identity_DB_Store</id>
+
<class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+
<identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+
<identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>GROUP</name>
+ <relationships>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+
<identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+
<identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <!--<option>-->
+ <!--<name>hibernateConfiguration</name>-->
+
<!--<value>jboss.idm.hibernate.cfg.xml</value>-->
+ <!--</option>-->
+ <option>
+ <name>hibernateSessionFactoryRegistryName</name>
+ <value>hibernateSessionFactory</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
Modified: idm/trunk/integration/deployer/pom.xml
===================================================================
--- idm/trunk/integration/deployer/pom.xml 2009-06-17 16:57:41 UTC (rev 616)
+++ idm/trunk/integration/deployer/pom.xml 2009-06-18 09:12:32 UTC (rev 617)
@@ -39,6 +39,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.identity.idm.integration</groupId>
+ <artifactId>idm-jboss5</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>bsh</groupId>
<artifactId>bsh</artifactId>
<version>1.3.0</version>
Deleted:
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java
===================================================================
---
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -1,251 +0,0 @@
-/**
- *
- */
-package org.jboss.identity.idm.integration.jboss5;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.transaction.TransactionManager;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.tool.hbm2ddl.SchemaUpdate;
-import org.jboss.identity.idm.common.transaction.TransactionManagerProvider;
-import org.jboss.identity.idm.common.transaction.Transactions;
-import org.jboss.identity.idm.impl.helper.SecurityActions;
-import org.jboss.identity.idm.integration.jboss5.jaxb2.HibernateInitializerType;
-
-import bsh.EvalError;
-import bsh.Interpreter;
-
-/**
- *
- * Using the Hibernate built-in SchemaExport.
- *
- * @author Jeff Yu
- * @author Boleslaw Dawidowicz
- * @author Julien Viet
- *
- */
-public class HibernatePopulator {
-
- private static Logger logger = Logger.getLogger(HibernatePopulator.class.getName());
-
- /** doCheck result - schema ok */
- private static final int RESULT_NONE = 0;
-
- /** doCheck result - schema need updates */
- private static final int RESULT_UPDATE = 1;
-
- /** doCheck result - schema not exist */
- private static final int RESULT_CREATE = 2;
-
- private HibernateInitializerType type;
-
- private Configuration config;
-
- private SessionFactory sessionFactory;
-
- public HibernatePopulator(HibernateInitializerType type, Configuration config) {
- this.type = type;
- this.config = config;
- }
-
-
- public void populateSchema() {
- sessionFactory = config.buildSessionFactory();
-
- if (type.isDoChecking())
- {
- //check the schema
- int check = doCheck();
- switch (check)
- {
- case RESULT_NONE:
- break;
- case RESULT_UPDATE:
- updateSchema();
- break;
- case RESULT_CREATE:
- createSchema();
- createContent();
-
- break;
- }
- } else {
- createSchema();
- }
-
- sessionFactory.close();
- }
-
-
- private int doCheck()
- {
- Session session = null;
- int numOfChecks = 0;
- int bad = 0;
- try
- {
- session = sessionFactory.openSession();
- Collection<ClassMetadata> values =
sessionFactory.getAllClassMetadata().values();
- numOfChecks = values.size();
- for (Iterator<ClassMetadata> i = values.iterator(); i.hasNext();)
- {
- ClassMetadata cmd = (ClassMetadata)i.next();
- Query query = session.createQuery("from " + cmd.getEntityName());
- query.setFirstResult(0);
- query.setMaxResults(0);
- try
- {
- query.list();
- }
- catch (SQLGrammarException e)
- {
- // We consider that exception means that the schema does not exist
- bad++;
- }
- }
- }
- finally
- {
- sessionFactory.close();
- }
- // There was no sql grammar exception - schema is ok!
- if (bad == 0)
- {
- logger.fine("The schema was checked as valid");
- //do nothing
- return RESULT_NONE;
- }
- // There is no existing valid schema;
- else if (bad == numOfChecks)
- {
- logger.fine("The schema was checked as not exists");
- // Totaly invalid schema
- return RESULT_CREATE;
- }
- // Schema is partialy corrupted
- else if (bad < numOfChecks)
- {
- // Schema needs updates;
- logger.fine("The schema was checked as need updates");
- return RESULT_UPDATE;
- }
-
- // If here something gone wrong...
- logger.fine("The schema was checked as need to be created");
- return RESULT_CREATE;
- }
-
- private void createSchema()
- {
- logger.fine("Creating database schema");
- SchemaExport export = new SchemaExport(config);
- export.create(false, true);
- }
-
- private void destroySchema()
- {
- logger.fine("Destroying database schema");
- SchemaExport export = new SchemaExport(config);
- export.drop(false, true);
- }
-
- private void updateSchema()
- {
- logger.fine("Updating database schema");
- SchemaUpdate update = new SchemaUpdate(config);
- update.execute(false, true);
- }
-
-
- private void createContent()
- {
-
- if (type.getSetupLocation() != null) {
- URL setupResource =
SecurityActions.getContextClassLoader().getResource(type.getSetupLocation()) ;
- if ( setupResource != null ) {
- try
- {
- logger.info("Creating database content");
- final String script = getString(setupResource.openStream());
-
- // Create an interpreter and configures it
- final Interpreter interpreter = new Interpreter();
-
interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
- interpreter.setOut(System.out);
- interpreter.set("SessionFactory", sessionFactory);
-
- TransactionManager tm =
TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
- Transactions.required(tm, new Transactions.Runnable()
- {
- public Object run() throws Exception
- {
- interpreter.eval(script);
- return null;
- }
- });
- }
- catch (EvalError e)
- {
- logger.info("Error in the bsh script: " + e);
- }
- catch (IllegalStateException e)
- {
- logger.info("Cannot load setup script: " + e);
- }
- catch (Exception e)
- {
- logger.info("Error in bsh script execution: " + e);
- }
- }
- }
- }
-
-
- private String getString(InputStream in) {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
- byte[] buffer = new byte[512];
- while (true)
- {
- int i = in.read(buffer);
- if (i == 0)
- {
- continue;
- }
- if (i == -1)
- {
- break;
- }
- out.write(buffer, 0, i);
- }
- return out.toString("UTF-8");
- } catch (IOException e) {
- logger.log(Level.SEVERE, "error in converting inputstream into
string", e);
- return null;
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- logger.log(Level.SEVERE, "error in closing inputstream", e);
- }
- }
- }
- }
-
-}
Modified:
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMDeployer.java
===================================================================
---
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMDeployer.java 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMDeployer.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -3,39 +3,13 @@
*/
package org.jboss.identity.idm.integration.jboss5;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
import javax.transaction.TransactionManager;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.DialectFactory;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
-import org.jboss.identity.idm.common.exception.IdentityException;
-import org.jboss.identity.idm.common.transaction.Transactions;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.idm.integration.jboss5.jaxb2.HibernateDeployerType;
-import org.jboss.identity.idm.integration.jboss5.jaxb2.HibernateInitializerType;
+import org.jboss.identity.idm.integration.jboss5.jaxb2.InitializerType;
import org.jboss.identity.idm.integration.jboss5.jaxb2.JbossIDMDeployerType;
-import org.jboss.identity.idm.integration.jboss5.jaxb2.SqlInitializerType;
-import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
/**
@@ -43,24 +17,16 @@
* Deploy the JBoss identity Management:
*
* 1. Start the IdentitySessionFactory.
- * 2. Register it into the JNDI.
+ * 2. bind it into the JNDI.
*
* @author Jeff Yu
*
*/
public class IDMDeployer extends AbstractSimpleVFSRealDeployer<IDMMetadata> {
-
- private static final Logger logger = Logger.getLogger(IDMDeployer.class.getName());
- private static final String HIBERNATE_CONFIGFILE = "hibernateConfiguration";
-
- private IdentitySessionFactory idSF;
-
- private SessionFactory hibernateSF;
-
private TransactionManager transactionManager;
- private IdentityConfiguration identityConfiguration;
+ private IDMService service;
public IDMDeployer() {
super(IDMMetadata.class);
@@ -69,171 +35,48 @@
@Override
public void deploy(VFSDeploymentUnit deploymentUnit, IDMMetadata metadata) throws
DeploymentException {
JbossIDMDeployerType config = metadata.getDeploperType();
-
- try {
- InputStream is =
deploymentUnit.getClassLoader().getResourceAsStream(config.getIdmConfigFile());
- IdentityConfigurationMetaData identityMetadata =
JAXB2IdentityConfiguration.createConfigurationMetaData(is);
- identityConfiguration = new IdentityConfigurationImpl().configure(identityMetadata);
-
- if (config.getHibernateDeployer() != null) {
- deployHibernateConfigurationFile(config, identityConfiguration);
- }
-
- if (config.getInitializers() != null) {
- initializeDB(config, identityMetadata, identityConfiguration);
- }
-
- try {
- Transactions.required(transactionManager, new Transactions.Runnable()
- {
- public Object run() throws Exception
- {
- idSF = identityConfiguration.buildIdentitySessionFactory();
- return null;
- }
- });
- } catch (Exception e) {
- throw new Exception("Cannot create IdentitySessionFactory", e);
- }
-
- InitialContext context = new InitialContext();
- context.bind(config.getJNDIName(), idSF);
- logger.info("Started [" + metadata.getDeployerFileName() + "] IDM
SessionFactory at JNDI [" + config.getJNDIName() + "]");
-
- } catch (Exception e) {
- throw new DeploymentException(e);
+ service = new IDMService(config.getIdmConfigFile());
+ if (transactionManager != null) {
+ service.setTransactionManager(transactionManager);
}
+ if (config.getJNDIName() != null) {
+ service.setIdmSessionFactoryJNDI(config.getJNDIName());
+ }
+ if (config.getHibernateDeployer() != null) {
+ service.setHibernateConfigLocation(config.getHibernateDeployer().getHibernateConfiguration());
+ service.setHibernateSessionFactoryJNDIName(config.getHibernateDeployer().getHibernateSessionFactoryJNDIName());
+ service.setHibernateSessionFactoryRegistryName(config.getHibernateDeployer().getHibernateSessionFactoryRegistryName());
+ }
- }
-
- private void initializeDB(JbossIDMDeployerType config, IdentityConfigurationMetaData
identityMetadata,
- final IdentityConfiguration identityConfiguration) throws Exception {
- logger.fine("starting to populate the schema into db");
-
- String datasource = config.getInitializers().getDatasource();
- checkTargetDB(config.getInitializers().getDatasource());
-
- HibernateInitializerType hibernateInitializer =
config.getInitializers().getHibernateInitializer();
- SqlInitializerType sqlInitializer = config.getInitializers().getSqlInitializer();
-
- if (hibernateInitializer != null) {
- String hibernateConfigFile =
config.getHibernateDeployer().getHibernateConfiguration();
- if (hibernateConfigFile == null) {
- for (IdentityStoreConfigurationMetaData store : identityMetadata.getIdentityStores())
{
- hibernateConfigFile = store.getOptionSingleValue(HIBERNATE_CONFIGFILE);
- }
+ if (config.getInitializers() != null) {
+ InitializerType initializers = config.getInitializers();
+ if (initializers.getDatasource() != null) {
+ service.setDatasource(initializers.getDatasource());
}
- if (hibernateConfigFile == null) {
- throw new Exception ("Couldn't find the hibernate configuration
file");
+ if (initializers.getSqlInitializer() != null) {
+ service.setSQLScript(initializers.getSqlInitializer().getSqlFile());
+ service.setExitSQL(initializers.getSqlInitializer().getExitSQL());
}
- Configuration configuration = new
AnnotationConfiguration().configure(hibernateConfigFile);
- logger.fine("starting to populate the schema from file [" +
hibernateConfigFile + "]");
- HibernatePopulator hibernatePopulator = new HibernatePopulator(hibernateInitializer,
configuration);
- hibernatePopulator.populateSchema();
-
- }else if (sqlInitializer != null) {
- logger.fine("starting to populate the schema from script file [" +
sqlInitializer.getSqlFile() + "]");
- SQLPopulator sqlPopulator = new SQLPopulator(datasource, sqlInitializer.getSqlFile(),
sqlInitializer.getExitSQL());
- sqlPopulator.populateSchema();
+ if (initializers.getHibernateInitializer() != null) {
+ service.setSetupLocation(initializers.getHibernateInitializer().getSetupLocation());
+ service.setDoChecking(initializers.getHibernateInitializer().isDoChecking());
+ }
}
- }
-
- private void deployHibernateConfigurationFile(JbossIDMDeployerType config,
- final IdentityConfiguration identityConfiguration) throws NamingException,
IdentityException {
- HibernateDeployerType hibernateConfig = config.getHibernateDeployer();
- hibernateSF = new AnnotationConfiguration().
- configure(hibernateConfig.getHibernateConfiguration()).buildSessionFactory();
- if (hibernateConfig.getHibernateSessionFactoryJNDIName() != null) {
- InitialContext context = new InitialContext();
- context.bind(hibernateConfig.getHibernateSessionFactoryJNDIName(), hibernateSF);
- logger.fine("Registered the Hibernate Session Factory in JNDI of " +
hibernateConfig.getHibernateSessionFactoryJNDIName());
- }
- if (hibernateConfig.getHibernateSessionFactoryRegistryName() != null) {
- identityConfiguration.getIdentityConfigurationRegistry().register(hibernateSF,
hibernateConfig.getHibernateSessionFactoryRegistryName());
- logger.fine("Registered the Hibernate Session Factory in Identity Registration of
" + hibernateConfig.getHibernateSessionFactoryRegistryName());
- }
- }
-
-
- @Override
- public void undeploy(VFSDeploymentUnit deploymentUnit, IDMMetadata metadata) {
- if (idSF != null) {
- idSF.close();
- }
try {
- InitialContext context = new InitialContext();
- context.unbind(metadata.getDeploperType().getJNDIName());
-
- if (metadata.getDeploperType().getHibernateDeployer() != null) {
-
- if (hibernateSF != null) {
- hibernateSF.close();
- }
-
- HibernateDeployerType hibernateDeployer =
metadata.getDeploperType().getHibernateDeployer();
- if (hibernateDeployer.getHibernateSessionFactoryJNDIName() != null) {
- context.unbind(hibernateDeployer.getHibernateSessionFactoryJNDIName());
- }
- if (hibernateDeployer.getHibernateSessionFactoryRegistryName() != null) {
- identityConfiguration.getIdentityConfigurationRegistry().unregister(hibernateDeployer.getHibernateSessionFactoryRegistryName());
- }
- }
+ service.start();
} catch (Exception e) {
- logger.severe(e.getMessage());
- throw new RuntimeException(e);
+ throw new DeploymentException("error in starting the service", e);
}
- logger.info("Stopped [" + metadata.getDeployerFileName() + "] IDM
SessionFactory at JNDI [" + metadata.getDeploperType().getJNDIName() +
"]");
-
}
- private void checkTargetDB(String datasource) {
-
- Connection conn = null;
- Dialect dialectName = null;
- try
- {
- DataSource ds = (DataSource)new InitialContext().lookup(datasource);
- conn = ds.getConnection();
- DatabaseMetaData meta = conn.getMetaData();
- String databaseName = meta.getDatabaseProductName();
- int databaseMajorVersion = getDatabaseMajorVersion(meta);
- dialectName = DialectFactory.determineDialect(databaseName,
databaseMajorVersion);
- logger.fine("Detected dialect " + dialectName + ", database is
(" + databaseName + "," + databaseMajorVersion + ")");
- } catch (Exception e) {
- logger.warning(e.getMessage());
- }
- finally
- {
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "error in closing the connection", e);
- }
- }
- }
+ @Override
+ public void undeploy(VFSDeploymentUnit deploymentUnit, IDMMetadata metadata) {
+ service.destroy();
}
-
- private int getDatabaseMajorVersion(DatabaseMetaData meta)
- {
- try
- {
- Method gdbmvMethod =
DatabaseMetaData.class.getMethod("getDatabaseMajorVersion", (Class[])null);
- return ((Integer)gdbmvMethod.invoke(meta, (Object[])null)).intValue();
- }
- catch (NoSuchMethodException nsme)
- {
- return 0;
- }
- catch (Throwable t)
- {
- logger.fine("could not get database version from JDBC metadata");
- return 0;
- }
- }
+
public TransactionManager getTransactionManager() {
return transactionManager;
Deleted:
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java
===================================================================
---
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -1,127 +0,0 @@
-/**
- *
- */
-package org.jboss.identity.idm.integration.jboss5;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-
-/**
- *
- * It uses datasource to populate the sqlscript file into target database.
- *
- * @author Jeff Yu
- *
- */
-public class SQLPopulator {
-
- private static Logger logger = Logger.getLogger(SQLPopulator.class.getName());
-
- private String SQLScript;
-
- private String exitSQL;
-
- private String datasource;
-
- public SQLPopulator(String datasource, String SQLScript, String exitSQL) {
- this.SQLScript = SQLScript;
- this.exitSQL = exitSQL;
- this.datasource = datasource;
- }
-
- public void populateSchema() throws Exception {
- DataSource ds = (DataSource)new InitialContext().lookup(datasource);
- Connection conn = ds.getConnection();
- boolean load = false;
-
- Statement st = conn.createStatement();
- ResultSet rs = null;
- try
- {
- rs = st.executeQuery(exitSQL.trim());
- rs.close();
- }
- catch (SQLException e)
- {
- load = true;
- }
- st.close();
- if (!load)
- {
- logger.info(datasource + " datasource is already initialized");
- return;
- }
-
- logger.info("Initializing " + datasource + " from listed sql
files");
-
- String[] list = SQLScript.split(",");
- for (String sql : list)
- {
- executeSql(sql.trim(), conn);
- }
- }
-
- private void executeSql(String resource, Connection conn)
- {
- URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
- try {
- String sql = new String(readStream(url.openStream()) , "UTF-8");
- sql = sql.replaceAll("(?m)^--([^\n]+)?$", ""); // Remove all
commented lines
- final String[] statements ;
- statements = sql.split(";");
-
- for (String statement : statements)
- {
- if ((statement == null) || ("".equals(statement.trim()))) {
- } else {
- Statement sqlStatement = conn.createStatement();
- try
- {
- sqlStatement.executeUpdate(statement);
- } catch (Exception e) {
- logger.log(Level.WARNING, "Exception in executing :" + statement,
e);
- }
- finally
- {
- sqlStatement.close();
- }
- }
- }
- } catch (Exception e) {
- logger.log(Level.WARNING, "Exception in populating :" + resource, e);
- }
- }
-
-
- private byte[] readStream(InputStream stream) {
- if(stream == null) {
- throw new IllegalArgumentException("null 'stream' arg passed in method
call.");
- }
-
- ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
- byte[] buffer = new byte[256];
- int readCount = 0;
-
- try {
- while((readCount = stream.read(buffer)) != -1) {
- outBuffer.write(buffer, 0, readCount);
- }
- } catch (IOException e) {
- throw new IllegalStateException("Error reading stream.", e);
- }
-
- return outBuffer.toByteArray();
- }
-
-}
Modified: idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml
===================================================================
--- idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml 2009-06-17
16:57:41 UTC (rev 616)
+++ idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml 2009-06-18
09:12:32 UTC (rev 617)
@@ -21,6 +21,7 @@
<outputDirectory>/</outputDirectory>
<includes>
<include>org.jboss.identity.idm.integration:idm-jboss5-deployer</include>
+
<include>org.jboss.identity.idm.integration:idm-jboss5</include>
<include>org.jboss.identity.idm:idm-ldap</include>
<include>org.jboss.identity.idm:idm-hibernate</include>
<include>org.jboss.identity.idm:idm-core</include>
Modified: idm/trunk/integration/jboss5/pom.xml
===================================================================
--- idm/trunk/integration/jboss5/pom.xml 2009-06-17 16:57:41 UTC (rev 616)
+++ idm/trunk/integration/jboss5/pom.xml 2009-06-18 09:12:32 UTC (rev 617)
@@ -16,10 +16,6 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
- <properties>
- <jboss.version>5.0.0.GA</jboss.version>
- </properties>
-
<dependencies>
<dependency>
@@ -37,74 +33,7 @@
<artifactId>idm-ldap</artifactId>
<version>${version}</version>
</dependency>
- <!--<dependency>-->
- <!--<groupId>org.jboss.identity.idm</groupId>-->
- <!--<artifactId>idm-cache</artifactId>-->
- <!--<version>${version}</version>-->
- <!--</dependency>-->
<dependency>
- <groupId>org.jboss.portal.common</groupId>
- <artifactId>common-common</artifactId>
- <version>1.2.3</version>
- <exclusions>
- <exclusion>
- <groupId>apache-log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-j2ee</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>jboss-jmx</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant-junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-core-uberjar</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant-nodeps</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant-launcher</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
-
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-system-jmx</artifactId>
- <version>${jboss.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>bsh</groupId>
<artifactId>bsh</artifactId>
<version>1.3.0</version>
@@ -137,24 +66,6 @@
</excludes>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <finalName>idm-service.sar</finalName>
- <appendAssemblyId>true</appendAssemblyId>
- <descriptors>
-
<descriptor>src/main/resources/idm-service-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
Added:
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java
===================================================================
---
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java
(rev 0)
+++
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/HibernatePopulator.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -0,0 +1,253 @@
+/**
+ *
+ */
+package org.jboss.identity.idm.integration.jboss5;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.transaction.TransactionManager;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.exception.SQLGrammarException;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.jboss.identity.idm.common.transaction.TransactionManagerProvider;
+import org.jboss.identity.idm.common.transaction.Transactions;
+import org.jboss.identity.idm.impl.helper.SecurityActions;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+
+/**
+ *
+ * Using the Hibernate built-in SchemaExport.
+ *
+ * @author Jeff Yu
+ * @author Boleslaw Dawidowicz
+ * @author Julien Viet
+ *
+ */
+public class HibernatePopulator {
+
+ private static Logger logger = Logger.getLogger(HibernatePopulator.class.getName());
+
+ /** doCheck result - schema ok */
+ private static final int RESULT_NONE = 0;
+
+ /** doCheck result - schema need updates */
+ private static final int RESULT_UPDATE = 1;
+
+ /** doCheck result - schema not exist */
+ private static final int RESULT_CREATE = 2;
+
+ private boolean doChecking;
+
+ private String setupLocation;
+
+ private Configuration config;
+
+ private SessionFactory sessionFactory;
+
+ public HibernatePopulator(boolean doChecking, String setupLocation, Configuration
config) {
+ this.doChecking = doChecking;
+ this.setupLocation = setupLocation;
+ this.config = config;
+ }
+
+
+ public void populateSchema() {
+ sessionFactory = config.buildSessionFactory();
+
+ if (doChecking)
+ {
+ //check the schema
+ int check = doCheck();
+ switch (check)
+ {
+ case RESULT_NONE:
+ break;
+ case RESULT_UPDATE:
+ updateSchema();
+ break;
+ case RESULT_CREATE:
+ createSchema();
+ createContent();
+
+ break;
+ }
+ } else {
+ createSchema();
+ }
+
+ sessionFactory.close();
+ }
+
+
+ private int doCheck()
+ {
+ Session session = null;
+ int numOfChecks = 0;
+ int bad = 0;
+ try
+ {
+ session = sessionFactory.openSession();
+ Collection<ClassMetadata> values =
sessionFactory.getAllClassMetadata().values();
+ numOfChecks = values.size();
+ for (Iterator<ClassMetadata> i = values.iterator(); i.hasNext();)
+ {
+ ClassMetadata cmd = (ClassMetadata)i.next();
+ Query query = session.createQuery("from " + cmd.getEntityName());
+ query.setFirstResult(0);
+ query.setMaxResults(0);
+ try
+ {
+ query.list();
+ }
+ catch (SQLGrammarException e)
+ {
+ // We consider that exception means that the schema does not exist
+ bad++;
+ }
+ }
+ }
+ finally
+ {
+ sessionFactory.close();
+ }
+ // There was no sql grammar exception - schema is ok!
+ if (bad == 0)
+ {
+ logger.fine("The schema was checked as valid");
+ //do nothing
+ return RESULT_NONE;
+ }
+ // There is no existing valid schema;
+ else if (bad == numOfChecks)
+ {
+ logger.fine("The schema was checked as not exists");
+ // Totaly invalid schema
+ return RESULT_CREATE;
+ }
+ // Schema is partialy corrupted
+ else if (bad < numOfChecks)
+ {
+ // Schema needs updates;
+ logger.fine("The schema was checked as need updates");
+ return RESULT_UPDATE;
+ }
+
+ // If here something gone wrong...
+ logger.fine("The schema was checked as need to be created");
+ return RESULT_CREATE;
+ }
+
+ private void createSchema()
+ {
+ logger.fine("Creating database schema");
+ SchemaExport export = new SchemaExport(config);
+ export.create(false, true);
+ }
+
+ private void destroySchema()
+ {
+ logger.fine("Destroying database schema");
+ SchemaExport export = new SchemaExport(config);
+ export.drop(false, true);
+ }
+
+ private void updateSchema()
+ {
+ logger.fine("Updating database schema");
+ SchemaUpdate update = new SchemaUpdate(config);
+ update.execute(false, true);
+ }
+
+
+ private void createContent()
+ {
+
+ if (setupLocation != null) {
+ URL setupResource = SecurityActions.getContextClassLoader().getResource(setupLocation)
;
+ if ( setupResource != null ) {
+ try
+ {
+ logger.info("Creating database content");
+ final String script = getString(setupResource.openStream());
+
+ // Create an interpreter and configures it
+ final Interpreter interpreter = new Interpreter();
+
interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
+ interpreter.setOut(System.out);
+ interpreter.set("SessionFactory", sessionFactory);
+
+ TransactionManager tm =
TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ Transactions.required(tm, new Transactions.Runnable()
+ {
+ public Object run() throws Exception
+ {
+ interpreter.eval(script);
+ return null;
+ }
+ });
+ }
+ catch (EvalError e)
+ {
+ logger.info("Error in the bsh script: " + e);
+ }
+ catch (IllegalStateException e)
+ {
+ logger.info("Cannot load setup script: " + e);
+ }
+ catch (Exception e)
+ {
+ logger.info("Error in bsh script execution: " + e);
+ }
+ }
+ }
+ }
+
+
+ private String getString(InputStream in) {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
+ byte[] buffer = new byte[512];
+ while (true)
+ {
+ int i = in.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ out.write(buffer, 0, i);
+ }
+ return out.toString("UTF-8");
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "error in converting inputstream into
string", e);
+ return null;
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "error in closing inputstream", e);
+ }
+ }
+ }
+ }
+
+}
Modified:
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMService.java
===================================================================
---
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMService.java 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMService.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -3,54 +3,34 @@
*/
package org.jboss.identity.idm.integration.jboss5;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.Method;
-import java.net.URL;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.management.MBeanServer;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import javax.transaction.TransactionManager;
-import org.hibernate.Query;
-import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DialectFactory;
-import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
import org.jboss.identity.idm.common.exception.IdentityException;
import org.jboss.identity.idm.common.transaction.TransactionManagerProvider;
import org.jboss.identity.idm.common.transaction.Transactions;
import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.net.URLTools;
-import org.jboss.portal.common.util.CLResourceLoader;
-import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
-import bsh.EvalError;
-import bsh.Interpreter;
-
/**
* Start the {@link IdentitySessionFactory}, and register it in the JNDI.
*
@@ -59,21 +39,14 @@
* @author Julien Viet
*/
-public class IDMService implements IDMServiceMBean {
+public class IDMService {
public final static String DEFAULT_JNDI = "java:/IdentitySessionFactory";
+ private static final String HIBERNATE_CONFIGFILE = "hibernateConfiguration";
+
private static Logger logger = Logger.getLogger(IDMService.class.getName());
- /** doCheck result - schema ok */
- private static final int RESULT_NONE = 0;
-
- /** doCheck result - schema need updates */
- private static final int RESULT_UPDATE = 1;
-
- /** doCheck result - schema not exist */
- private static final int RESULT_CREATE = 2;
-
/** Hibernate config - if specified will be used to create SessionFactory*/
private String hibernateConfigLocation;
@@ -106,19 +79,16 @@
private String datasource;
- private String objectName;
+ private IdentityConfiguration identityConfiguration;
- private MBeanServer mbeanServer;
+ private TransactionManager transactionManager;
/** The hibernate configuration object. */
protected Configuration config;
- public IDMService(String idmConfigFile, MBeanServer mbeanServer) {
+ public IDMService(String idmConfigFile) {
this.idmConfigFile = idmConfigFile;
- this.mbeanServer = mbeanServer;
- this.idmSessionFactoryJNDI = DEFAULT_JNDI;
- this.objectName = IDMServiceMBean.defaultObjectName;
}
public String getIdmConfigFile() {
@@ -190,35 +160,58 @@
{
this.hibernateSessionFactoryJNDIName = hibernateSessionFactoryJNDIName;
}
-
-
- public String getObjectName() {
- return objectName;
- }
- public void setObjectName(String objectName) {
- this.objectName = objectName;
+ public TransactionManager getTransactionManager() {
+ return transactionManager;
}
- public void start() throws Exception {
- logger.info("Starting the JBoss Identity Management Service");
- if (needToInitializeDBFromScript()) {
- initializeDBFromScript();
+ public void setTransactionManager(TransactionManager transactionManager) {
+ this.transactionManager = transactionManager;
+ }
+
+public void start() throws Exception {
+
+ logger.info("Starting the JBoss Identity Management Service");
+
+ InitialContext context = new InitialContext();
+ IdentityConfigurationMetaData metadata =
JAXB2IdentityConfiguration.createConfigurationMetaData(idmConfigFile);
+ identityConfiguration = new IdentityConfigurationImpl().configure(metadata);
+
+ if (hibernateConfigLocation != null ) {
+ deployHibernateSessionFactory(context);
+ }
+
+ if (datasource != null) {
+ checkTargetDB(datasource);
+ }
+
+ if (needToInitializeDBFromScript()) {
+ SQLPopulator sqlPopulator = new SQLPopulator(datasource, SQLScript, exitSQL);
+ sqlPopulator.populateSchema();
}
- InitialContext context = new InitialContext();
-
- final IdentityConfiguration identityConfiguration = new
IdentityConfigurationImpl().configure(getIdmConfigFile());
-
- // If hibernate config is present than create SessionFactory manually and register
it into identity config
- if (hibernateConfigLocation != null)
+ if (doChecking == true)
{
- initializeDBFromHibernateConfiguration(context, identityConfiguration);
+ if (hibernateConfigLocation == null) {
+ for (IdentityStoreConfigurationMetaData store : metadata.getIdentityStores()) {
+ hibernateConfigLocation = store.getOptionSingleValue(HIBERNATE_CONFIGFILE);
+ }
+ }
+ if (hibernateConfigLocation == null) {
+ throw new Exception ("Couldn't find the hibernate configuration
file");
+ }
+ Configuration configuration = new
AnnotationConfiguration().configure(hibernateConfigLocation);
+ logger.fine("starting to populate the schema from file [" +
hibernateConfigLocation + "]");
+ HibernatePopulator hibernatePopulator = new HibernatePopulator(doChecking,
setupLocation, configuration);
+ hibernatePopulator.populateSchema();
}
try {
- TransactionManager tm =
TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
- Transactions.required(tm, new Transactions.Runnable()
+ if (transactionManager == null) {
+ transactionManager =
TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
+ }
+
+ Transactions.required(transactionManager, new Transactions.Runnable()
{
public Object run() throws Exception
{
@@ -232,81 +225,32 @@
}
context.bind(getIdmSessionFactoryJNDI(), identitySessionFactory);
- mbeanServer.registerMBean(this, ObjectNameFactory.create(getObjectName()));
logger.info("Started the JBoss Identity Management Service");
}
+ private void deployHibernateSessionFactory(InitialContext context)
+ throws NamingException, IdentityException {
+ hibernateSessionFactory = new
AnnotationConfiguration().configure(hibernateConfigLocation).buildSessionFactory();
+ if (hibernateSessionFactoryJNDIName != null) {
+ context.bind(hibernateSessionFactoryJNDIName, hibernateSessionFactory);
+ logger.info("Bind the Hibernate Session Factory in JNDI of " +
hibernateSessionFactoryJNDIName);
+ }
+ if (hibernateSessionFactoryRegistryName != null) {
+
identityConfiguration.getIdentityConfigurationRegistry().register(hibernateSessionFactory,
hibernateSessionFactoryRegistryName);
+ logger.info("Registered the Hibernate Session Factory in Identity Registration
of " + hibernateSessionFactoryRegistryName);
+ }
+ }
- private void initializeDBFromHibernateConfiguration(InitialContext context,
- final IdentityConfiguration identityConfiguration) throws Exception,
IdentityException {
-
- int check = RESULT_NONE;
- URL configURL =
Thread.currentThread().getContextClassLoader().getResource(hibernateConfigLocation);
- if (configURL == null)
- {
- throw new Exception("The config " + hibernateConfigLocation + " does
not exist");
- }
-
- if (!URLTools.exists(configURL))
- {
- throw new Exception("The config " + configURL + " does not
exist");
- }
-
- config = new AnnotationConfiguration().configure(configURL);
-
- createHibernateSessionFactory();
-
- if (getHibernateSessionFactoryJNDIName() != null)
- {
- try
- {
- context.bind(getHibernateSessionFactoryJNDIName(), hibernateSessionFactory);
- }
- catch (NamingException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings |
File Templates.
- }
- }
-
- if (getHibernateSessionFactoryRegistryName() != null)
- {
- identityConfiguration.getIdentityConfigurationRegistry().
- register(hibernateSessionFactory, getHibernateSessionFactoryRegistryName());
- }
-
- if (doChecking)
- {
- //check the schema
- check = doCheck();
- switch (check)
- {
- case RESULT_NONE:
- break;
- case RESULT_UPDATE:
- updateSchema();
- break;
- case RESULT_CREATE:
- createSchema();
- createContent();
-
- break;
- }
- }
-}
-
-
-
- public void stop() throws Exception {
- logger.info("Stopping the JBoss Identity Management Service");
- }
-
- public void destroy() throws Exception {
-
- InitialContext context = new InitialContext();
-
+ public void destroy() {
+
+ logger.info("Stopping the JBoss Identity Management Service");
+
+ InitialContext context = null;
try
{
+ context = new InitialContext();
+
if (identitySessionFactory != null)
{
identitySessionFactory.close();
@@ -318,8 +262,7 @@
}
catch (Exception e)
{
- logger.severe(e.getMessage());
- e.printStackTrace();
+ logger.log(Level.SEVERE, "error in closing identitySessionFactory",
e);
}
if (hibernateSessionFactory != null)
@@ -329,19 +272,16 @@
if (getHibernateSessionFactoryJNDIName() != null)
{
context.unbind(getHibernateSessionFactoryJNDIName());
-
}
hibernateSessionFactory.close();
}
catch (Exception e)
{
- logger.severe(e.getMessage());
- e.printStackTrace();
+ logger.log(Level.SEVERE, "error in closing hibernateSessionFactory",
e);
}
}
- mbeanServer.unregisterMBean(ObjectNameFactory.create(getObjectName()));
logger.info("Stopped the JBoss Identity Management Service");
}
@@ -372,301 +312,7 @@
}
return false;
}
-
-
- private void initializeDBFromScript() throws Exception {
- DataSource ds = (DataSource)new InitialContext().lookup(datasource);
- Connection conn = ds.getConnection();
- boolean load = false;
- Statement st = conn.createStatement();
- ResultSet rs = null;
- try
- {
- rs = st.executeQuery(exitSQL.trim());
- rs.close();
- }
- catch (SQLException e)
- {
- load = true;
- }
- st.close();
- if (!load)
- {
- logger.info(datasource + " datasource is already initialized");
- return;
- }
-
- logger.info("Initializing " + datasource + " from listed sql
files");
-
- String[] list = SQLScript.split(",");
- for (String sql : list)
- {
- executeSql(sql.trim(), conn);
- }
-
- }
-
- private void executeSql(String resource, Connection conn) throws Exception
- {
- URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
- String sql = new String(readStream(url.openStream()) , "UTF-8");
- sql = sql.replaceAll("(?m)^SessionFactory --([^\n]+)?$", ""); //
Remove all commented lines
- final String[] statements ;
- statements = sql.split(";");
-
- for (String statement : statements)
- {
- if ((statement == null) || ("".equals(statement.trim()))) {
- } else {
- Statement sqlStatement = conn.createStatement();
- try
- {
- sqlStatement.executeUpdate(statement);
- }
- finally
- {
- sqlStatement.close();
- }
- }
- }
- }
-
-
- private byte[] readStream(InputStream stream) {
- if(stream == null) {
- throw new IllegalArgumentException("null 'stream' arg passed in method
call.");
- }
-
- ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
- byte[] buffer = new byte[256];
- int readCount = 0;
-
- try {
- while((readCount = stream.read(buffer)) != -1) {
- outBuffer.write(buffer, 0, readCount);
- }
- } catch (IOException e) {
- throw new IllegalStateException("Error reading stream.", e);
- }
-
- return outBuffer.toByteArray();
- }
-
-
- private void createHibernateSessionFactory() throws Exception
- {
-
- // Force transaction manager lookup class and JTA env
-// setPropertyIfAbsent("transaction.auto_close_session",
"true");
-// setPropertyIfAbsent("transaction.flush_before_completion",
"true");
-// setPropertyIfAbsent("hibernate.transaction.flush_before_completion",
"true");
-// setPropertyIfAbsent("hibernate.transaction.factory_class",
"org.hibernate.transaction.JTATransactionFactory");
-// setPropertyIfAbsent("hibernate.transaction.manager_lookup_class",
"org.hibernate.transaction.JBossTransactionManagerLookup");
-
- // Set JNDI name if present and absent
- if (getHibernateSessionFactoryJNDIName() != null)
- {
- setPropertyIfAbsent("hibernate.session_factory_name",
getHibernateSessionFactoryJNDIName());
- }
-
- // Detect the dialect if necessary
- String dialectName = config.getProperty(Environment.DIALECT);
- if (dialectName == null)
- {
- String dataSourceJNDI = config.getProperty(Environment.DATASOURCE);
- logger.fine("Detecting dialect with datasource " + dataSourceJNDI +
" ...");
- DataSource ds = (DataSource)new InitialContext().lookup(dataSourceJNDI);
- Connection conn = null;
- try
- {
- conn = ds.getConnection();
- DatabaseMetaData meta = conn.getMetaData();
- String databaseName = meta.getDatabaseProductName();
- int databaseMajorVersion = getDatabaseMajorVersion(meta);
- dialectName = DialectFactory.determineDialect(databaseName,
databaseMajorVersion).getClass().getName();
- config.setProperty(Environment.DIALECT, dialectName);
- logger.fine("Detected dialect " + dialectName + ", database is
(" + databaseName + "," + databaseMajorVersion + ")");
- }
- finally
- {
- IOTools.safeClose(conn);
- }
- }
- logger.fine("Using dialect " + dialectName);
- if ("org.hibernate.dialect.HSQLDialect".equals(dialectName))
- {
- logger.info("You are using the file based HSQL database, this is not
recommended on a production environment and will not work properly on a clustered
environment.");
- }
-
- hibernateSessionFactory = config.buildSessionFactory();
-
-
-
- }
-
-
-
- private void setPropertyIfAbsent(String name, String value)
- {
- if (config.getProperty(name) == null)
- {
- config.setProperty(name, value);
- }
- }
-
- private int doCheck()
- {
- Session session = null;
- int numOfChecks = 0;
- int bad = 0;
- try
- {
- session = hibernateSessionFactory.openSession();
- Collection values = hibernateSessionFactory.getAllClassMetadata().values();
- numOfChecks = values.size();
- for (Iterator i = values.iterator(); i.hasNext();)
- {
- ClassMetadata cmd = (ClassMetadata)i.next();
- Query query = session.createQuery("from " + cmd.getEntityName());
- query.setFirstResult(0);
- query.setMaxResults(0);
- try
- {
- query.list();
- }
- catch (SQLGrammarException e)
- {
- // We consider that exception means that the schema does not exist
- bad++;
- }
- }
- }
- finally
- {
- IOTools.safeClose(session);
- }
- // There was no sql grammar exception - schema is ok!
- if (bad == 0)
- {
- logger.fine("The schema was checked as valid");
- //do nothing
- return RESULT_NONE;
- }
- // There is no existing valid schema;
- else if (bad == numOfChecks)
- {
- logger.fine("The schema was checked as not exists");
- // Totaly invalid schema
- return RESULT_CREATE;
- }
- // Schema is partialy corrupted
- else if (bad < numOfChecks)
- {
- // Schema needs updates;
- logger.fine("The schema was checked as need updates");
- return RESULT_UPDATE;
- }
-
- // If here something gone wrong...
- logger.fine("The schema was checked as need to be created");
- return RESULT_CREATE;
- }
-
-
- private void createSchema()
- {
- logger.fine("Creating database schema");
- try
- {
- SchemaExport export = new SchemaExport(config);
- export.create(false, true);
- }
- catch (Exception e)
- {
- logger.log(Level.SEVERE, "Cannot create schema:" , e);
- }
- }
-
- private void destroySchema()
- {
- logger.fine("Destroying database schema");
- try
- {
- SchemaExport export = new SchemaExport(config);
- export.drop(false, true);
- }
- catch (Exception e)
- {
- logger.log(Level.SEVERE, "Cannot destroy schema:", e);
- }
- }
-
- private void createContent()
- {
-
- LoaderResource setupResource = null;
-
- //
- if (setupLocation != null && setupResource == null)
- {
- setupResource = new CLResourceLoader().getResource(setupLocation);
- }
-
- if (setupResource != null)
- {
- if (setupResource.exists())
- {
- try
- {
- logger.info("Creating database content");
- final String script = setupResource.asString("UTF-8");
-
- // Create an interpreter and configures it
- final Interpreter interpreter = new Interpreter();
-
interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
- interpreter.setOut(System.out);
- interpreter.set("SessionFactory", hibernateSessionFactory);
-
- TransactionManager tm =
TransactionManagerProvider.JBOSS_PROVIDER.getTransactionManager();
- Transactions.required(tm, new Transactions.Runnable()
- {
- public Object run() throws Exception
- {
- interpreter.eval(script);
- return null;
- }
- });
- }
- catch (EvalError e)
- {
- logger.log(Level.SEVERE, "Error in the bsh script:", e);
- }
- catch (IllegalStateException e)
- {
- logger.log(Level.SEVERE, "Error in the bsh script:", e);
- }
- catch (Exception e)
- {
- logger.log(Level.SEVERE, "Error in the bsh script:", e);
- }
- }
- else
- {
- logger.info("There is a setup URL but the not valid " +
setupResource);
- }
- }
- }
-
-
- private void updateSchema()
- {
- logger.info("Updating database schema");
- SchemaUpdate update = new SchemaUpdate(config);
- update.execute(false, true);
- }
-
-
private int getDatabaseMajorVersion(DatabaseMetaData meta)
{
try
@@ -684,5 +330,34 @@
return 0;
}
}
+
+
+ private void checkTargetDB(String datasource) {
+
+ Connection conn = null;
+ Dialect dialectName = null;
+ try
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(datasource);
+ conn = ds.getConnection();
+ DatabaseMetaData meta = conn.getMetaData();
+ String databaseName = meta.getDatabaseProductName();
+ int databaseMajorVersion = getDatabaseMajorVersion(meta);
+ dialectName = DialectFactory.determineDialect(databaseName,
databaseMajorVersion);
+ logger.fine("Detected dialect " + dialectName + ", database is
(" + databaseName + "," + databaseMajorVersion + ")");
+ } catch (Exception e) {
+ logger.warning(e.getMessage());
+ }
+ finally
+ {
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ logger.log(Level.SEVERE, "error in closing the connection", e);
+ }
+ }
+ }
+ }
}
Deleted:
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMServiceMBean.java
===================================================================
---
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMServiceMBean.java 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/IDMServiceMBean.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -1,40 +0,0 @@
-/**
- *
- */
-package org.jboss.identity.idm.integration.jboss5;
-
-
-
-
-/**
- *
- * Interface for exposing JMX operations.
- *
- * @author Jeff Yu
- *
- */
-public interface IDMServiceMBean {
-
- String defaultObjectName = "org.jboss.identity.idm:service=IDMService";
-
- String getIdmConfigFile() ;
-
- String getIdmSessionFactoryJNDI();
-
- String getDatasource();
-
- String getSQLScript();
-
- String getExitSQL();
-
- String getObjectName();
-
- String getSetupLocation();
-
- boolean isDoChecking();
-
- String getHibernateConfigLocation();
-
- String getHibernateSessionFactoryRegistryName();
-
-}
Added:
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java
===================================================================
---
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java
(rev 0)
+++
idm/trunk/integration/jboss5/src/main/java/org/jboss/identity/idm/integration/jboss5/SQLPopulator.java 2009-06-18
09:12:32 UTC (rev 617)
@@ -0,0 +1,127 @@
+/**
+ *
+ */
+package org.jboss.identity.idm.integration.jboss5;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+/**
+ *
+ * It uses datasource to populate the sqlscript file into target database.
+ *
+ * @author Jeff Yu
+ *
+ */
+public class SQLPopulator {
+
+ private static Logger logger = Logger.getLogger(SQLPopulator.class.getName());
+
+ private String SQLScript;
+
+ private String exitSQL;
+
+ private String datasource;
+
+ public SQLPopulator(String datasource, String SQLScript, String exitSQL) {
+ this.SQLScript = SQLScript;
+ this.exitSQL = exitSQL;
+ this.datasource = datasource;
+ }
+
+ public void populateSchema() throws Exception {
+ DataSource ds = (DataSource)new InitialContext().lookup(datasource);
+ Connection conn = ds.getConnection();
+ boolean load = false;
+
+ Statement st = conn.createStatement();
+ ResultSet rs = null;
+ try
+ {
+ rs = st.executeQuery(exitSQL.trim());
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ load = true;
+ }
+ st.close();
+ if (!load)
+ {
+ logger.info(datasource + " datasource is already initialized");
+ return;
+ }
+
+ logger.info("Initializing " + datasource + " from listed sql
files");
+
+ String[] list = SQLScript.split(",");
+ for (String sql : list)
+ {
+ executeSql(sql.trim(), conn);
+ }
+ }
+
+ private void executeSql(String resource, Connection conn)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+ try {
+ String sql = new String(readStream(url.openStream()) , "UTF-8");
+ sql = sql.replaceAll("(?m)^--([^\n]+)?$", ""); // Remove all
commented lines
+ final String[] statements ;
+ statements = sql.split(";");
+
+ for (String statement : statements)
+ {
+ if ((statement == null) || ("".equals(statement.trim()))) {
+ } else {
+ Statement sqlStatement = conn.createStatement();
+ try
+ {
+ sqlStatement.executeUpdate(statement);
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception in executing :" + statement,
e);
+ }
+ finally
+ {
+ sqlStatement.close();
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING, "Exception in populating :" + resource, e);
+ }
+ }
+
+
+ private byte[] readStream(InputStream stream) {
+ if(stream == null) {
+ throw new IllegalArgumentException("null 'stream' arg passed in method
call.");
+ }
+
+ ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+ byte[] buffer = new byte[256];
+ int readCount = 0;
+
+ try {
+ while((readCount = stream.read(buffer)) != -1) {
+ outBuffer.write(buffer, 0, readCount);
+ }
+ } catch (IOException e) {
+ throw new IllegalStateException("Error reading stream.", e);
+ }
+
+ return outBuffer.toByteArray();
+ }
+
+}
Modified:
idm/trunk/integration/jboss5/src/main/resources/META-INF/idm-service-jboss-beans.xml
===================================================================
---
idm/trunk/integration/jboss5/src/main/resources/META-INF/idm-service-jboss-beans.xml 2009-06-17
16:57:41 UTC (rev 616)
+++
idm/trunk/integration/jboss5/src/main/resources/META-INF/idm-service-jboss-beans.xml 2009-06-18
09:12:32 UTC (rev 617)
@@ -9,7 +9,6 @@
class="org.jboss.identity.idm.integration.jboss5.IDMService">
<constructor>
<parameter>jboss.idm.cfg.xml</parameter>
- <parameter><inject bean="JMXKernel"
property="mbeanServer"/></parameter>
</constructor>
<property
name="idmSessionFactoryJNDI">java:/IdentitySessionFactory</property>
<property
name="SQLScript">idm-sql/jboss.idm.hsql.create.sql</property>
Deleted: idm/trunk/integration/jboss5/src/main/resources/idm-service-assembly.xml
===================================================================
--- idm/trunk/integration/jboss5/src/main/resources/idm-service-assembly.xml 2009-06-17
16:57:41 UTC (rev 616)
+++ idm/trunk/integration/jboss5/src/main/resources/idm-service-assembly.xml 2009-06-18
09:12:32 UTC (rev 617)
@@ -1,36 +0,0 @@
-<assembly
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/assembly-1.1.0-SNAPSHOT.xsd">
- <id>config</id>
- <formats>
- <format>zip</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>${project.build.outputDirectory}</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>META-INF/*.xml</include>
- <include>jboss.idm.cfg.xml</include>
- <include>jboss.idm.hibernate.cfg.xml</include>
- </includes>
- </fileSet>
- </fileSets>
-
- <dependencySets>
- <dependencySet>
- <outputDirectory>/</outputDirectory>
- <includes>
-
<include>org.jboss.identity.idm.integration:idm-jboss5</include>
- <include>org.jboss.identity.idm:idm-cache</include>
- <include>org.jboss.identity.idm:idm-ldap</include>
- <include>org.jboss.identity.idm:idm-hibernate</include>
- <include>org.jboss.identity.idm:idm-core</include>
- <include>org.jboss.identity.idm:idm-api</include>
- <include>org.jboss.identity.idm:idm-common</include>
- <include>org.jboss.identity.idm:idm-spi</include>
- </includes>
- </dependencySet>
- </dependencySets>
-
-</assembly>
Deleted: idm/trunk/integration/jboss5/src/main/resources/jboss.idm.cfg.xml
===================================================================
--- idm/trunk/integration/jboss5/src/main/resources/jboss.idm.cfg.xml 2009-06-17 16:57:41
UTC (rev 616)
+++ idm/trunk/integration/jboss5/src/main/resources/jboss.idm.cfg.xml 2009-06-18 09:12:32
UTC (rev 617)
@@ -1,139 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_alpha"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha
identity-config.xsd">
- <realms>
- <realm>
- <id>realm://JBossIdentity</id>
- <repository-id-ref>JBoss_Identity_Repository</repository-id-ref>
- <identity-type-mappings>
- <user-mapping>USER</user-mapping>
- </identity-type-mappings>
- </realm>
- </realms>
- <repositories>
- <repository>
- <id>JBoss_Identity_Repository</id>
-
<class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
- <external-config/>
-
<default-identity-store-id>Identity_DB_Store</default-identity-store-id>
-
<default-attribute-store-id>Identity_DB_Store</default-attribute-store-id>
- </repository>
- </repositories>
- <stores>
- <attribute-stores/>
- <identity-stores>
- <identity-store>
- <id>Identity_DB_Store</id>
-
<class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
- <external-config/>
- <supported-relationship-types>
-
<relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
- <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
- </supported-relationship-types>
- <supported-identity-object-types>
- <identity-object-type>
- <name>USER</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials>
- <credential-type>PASSWORD</credential-type>
- </credentials>
- <attributes/>
- <options/>
- </identity-object-type>
- <identity-object-type>
- <name>ORGANIZATION</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials/>
- <attributes/>
- <options/>
- </identity-object-type>
- <identity-object-type>
- <name>GROUP</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials/>
- <attributes/>
- <options/>
- </identity-object-type>
- <identity-object-type>
- <name>unit</name>
- <relationships>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>USER</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>GROUP</identity-object-type-ref>
- </relationship>
- <relationship>
-
<relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
-
<identity-object-type-ref>unit</identity-object-type-ref>
- </relationship>
- </relationships>
- <credentials/>
- <attributes/>
- <options/>
- </identity-object-type>
- </supported-identity-object-types>
- <options>
- <option>
- <name>hibernateConfiguration</name>
- <value>jboss.idm.hibernate.cfg.xml</value>
- </option>
- <option>
- <name>populateRelationshipTypes</name>
- <value>true</value>
- </option>
- <option>
- <name>populateIdentityObjectTypes</name>
- <value>true</value>
- </option>
- <option>
- <name>allowNotDefinedAttributes</name>
- <value>true</value>
- </option>
- <option>
- <name>isRealmAware</name>
- <value>true</value>
- </option>
- </options>
- </identity-store>
- </identity-stores>
- </stores>
-</jboss-identity>
Deleted: idm/trunk/integration/jboss5/src/main/resources/jboss.idm.hibernate.cfg.xml
===================================================================
--- idm/trunk/integration/jboss5/src/main/resources/jboss.idm.hibernate.cfg.xml 2009-06-17
16:57:41 UTC (rev 616)
+++ idm/trunk/integration/jboss5/src/main/resources/jboss.idm.hibernate.cfg.xml 2009-06-18
09:12:32 UTC (rev 617)
@@ -1,62 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
- ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
- <session-factory>
-
- <property name="show_sql">false</property>
- <property
name="cache.use_second_level_cache">true</property>
- <property name="cache.use_query_cache">false</property>
-
- <property
name="current_session_context_class">thread</property>
-
- <!--<property
name="connection.datasource"></property>-->
-
- <property
name="hibernate.connection.url">jdbc:hsqldb:mem:jbossidm</property>
- <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
- <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
- <property
name="hibernate.hbm2ddl.auto">create-drop</property>
- <property
name="hibernate.connection.username">sa</property>
- <property name="hibernate.connection.password"></property>
-
- <!-- Mapping classes -->
- <!-- all nessesary mappings are added programatically to the configuration
-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateRealm"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType"/>-->
- <!--<mapping
class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName"/>-->
-
- </session-factory>
-</hibernate-configuration>
\ No newline at end of file