Dashboard > CAS User Manual > Home > TicketRegistry > JpaTicketRegistry
Log In   View a printable version of the current page.
JpaTicketRegistry
Added by Scott Battaglia , last edited by Scott Battaglia on Mar 19, 2008  (view change)
Labels: 
(None)


Enabling the JpaTicketRegistry

Overriding the ticketRegistry.xml

If you're not using the Maven2 WAR Overlay process, then you'll need to edit the WEB-INF/spring-configuration/ticketRegistry.xml.

If you are using the Maven2 WAR overlway process, then you'll need to place the "ticketRegistry.xml" file below into the WEB-INF/spring-configuration/ directory:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
       
    <!-- Ticket Registry -->
    <bean id="ticketRegistry" class="org.jasig.cas.ticket.registry.JpaTicketRegistry">
    	<constructor-arg index="0" ref="entityManagerFactory" />
    </bean>
    
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="generateDdl" value="true"/>
				<property name="showSql" value="true" />
			</bean>
		</property>
		<property name="jpaProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
		p:entityManagerFactory-ref="entityManagerFactory" />

	<tx:annotation-driven transaction-manager="transactionManager"/>

	<bean
		id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		p:driverClassName="com.mysql.jdbc.Driver"
		p:url="jdbc:mysql://localhost:3306/test?autoReconnect=true"
		p:password=""
		p:username="" />
	
	<!--Quartz -->
	<!-- TICKET REGISTRY CLEANER -->
	<bean id="ticketRegistryCleaner" class="org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner"
		p:ticketRegistry-ref="ticketRegistry" />
	
	<bean id="jobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
		p:targetObject-ref="ticketRegistryCleaner"
		p:targetMethod="clean" />
	
	<bean id="triggerJobDetailTicketRegistryCleaner" class="org.springframework.scheduling.quartz.SimpleTriggerBean"
		p:jobDetail-ref="jobDetailTicketRegistryCleaner"
		p:startDelay="20000"
		p:repeatInterval="5000000" />

	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref
					local="triggerJobDetailTicketRegistryCleaner" />
			</list>
		</property>
	</bean>
</beans>

Be sure to replace the dataSource information with your own. You may reference other data sources external to this file.

Setting up the Database

If your user has sufficient privileges (do this on a test/dev tier first), on start up, the database tables should be created.

Updating the Maven2 POM

If you are using the Maven2 WAR overlay method, add these to your custom webapp POM. Otherwise add these to the CAS project's cas-server-webapp/pom.xml file:

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-entitymanager</artifactId>
	<version>3.3.1.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-commons-annotations</artifactId>
	<version>3.3.0.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-annotations</artifactId>
	<version>3.3.0.ga</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate</artifactId>
	<version>3.2.4.sp1</version>
	<scope>runtime</scope>
</dependency>

<dependency>
	<groupId>concurrent</groupId>
	<artifactId>concurrent</artifactId>
	<version>1.3.4</version>
	<scope>runtime</scope>
</dependency>

You'll also need a database connection pool (i.e. DataSource). One example is:

<dependency>
   <groupId>commons-dbcp</groupId>
   <artifactId>commons-dbcp</artifactId>
   <version>1.2.2</version>
   <scope>runtime</scope>
</dependency>

Powered by a free Atlassian Confluence Open Source Project License granted to Java Architectures Special Interest Group. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators