taylor 2004/11/07 10:44:44 Modified: components/capability/src/test/org/apache/jetspeed/capabilities TestCapability.java components/capability project.xml components/capability/src/java/org/apache/jetspeed/capabilities/impl JetspeedCapabilities.java Added: components/capability/src/java/META-INF test-spring.xml capabilities-ojb.xml Removed: components/capability/src/java/META-INF ojb_repository.xml Log: - convert Capabilities component to Spring DAO - remove all references to assembly to PersistentStore component Revision Changes Path 1.2 +10 -18 jakarta-jetspeed-2/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java Index: TestCapability.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestCapability.java 28 May 2004 18:49:14 -0000 1.1 +++ TestCapability.java 7 Nov 2004 18:44:44 -0000 1.2 @@ -21,8 +21,7 @@ import junit.framework.Test; import junit.framework.TestSuite; -import org.apache.jetspeed.capabilities.impl.JetspeedCapabilities; -import org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase; +import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase; /** * Test Capability Service @@ -30,21 +29,10 @@ * @author <a href="[EMAIL PROTECTED]">Roger Ruttimann</a> * @version $Id$ */ -public class TestCapability extends PersistenceSupportedTestCase +public class TestCapability extends DatasourceEnabledSpringTestCase { private Capabilities capabilities = null; - - /** - * Defines the testcase name for JUnit. - * - * @param name the testcase's name. - */ - public TestCapability(String name) - { - super(name); - } - - + /** * Start the tests. * @@ -59,8 +47,7 @@ protected void setUp() throws Exception { super.setUp(); - - capabilities = new JetspeedCapabilities(persistenceStore); + this.capabilities = (Capabilities) ctx.getBean("capabilities"); } public static Test suite() @@ -150,4 +137,9 @@ } } + protected String[] getConfigurations() + { + return new String[] {"/META-INF/test-spring.xml"}; + } + } 1.11 +8 -7 jakarta-jetspeed-2/components/capability/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/capability/project.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- project.xml 13 Oct 2004 20:01:45 -0000 1.10 +++ project.xml 7 Nov 2004 18:44:44 -0000 1.11 @@ -43,6 +43,14 @@ &db-ojb-deps; + <dependency> + <id>jetspeed-cm</id> + <groupId>jetspeed2</groupId> + <version>2.0-a1-dev</version> + <properties> + <war.bundle>true</war.bundle> + </properties> + </dependency> <dependency> <id>jetspeed2:jetspeed-commons</id> <version>2.0-a1-dev</version> @@ -52,10 +60,6 @@ <version>2.0-a1-dev</version> </dependency> <dependency> - <id>jetspeed2:jetspeed-persistence</id> - <version>2.0-a1-dev</version> - </dependency> - <dependency> <id>jetspeed2:jetspeed-registry</id> <version>2.0-a1-dev</version> </dependency> @@ -146,9 +150,6 @@ <sourceDirectory>src/java</sourceDirectory> <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory> <unitTest> - <excludes> - <exclude>**/TestCapability.java </exclude > - </excludes> <resources> <resource> <directory>${basedir}/src/test</directory> 1.2 +24 -22 jakarta-jetspeed-2/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java Index: JetspeedCapabilities.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JetspeedCapabilities.java 28 May 2004 18:49:15 -0000 1.1 +++ JetspeedCapabilities.java 7 Nov 2004 18:44:44 -0000 1.2 @@ -29,8 +29,10 @@ import org.apache.jetspeed.capabilities.Client; import org.apache.jetspeed.capabilities.MediaType; import org.apache.jetspeed.capabilities.MimeType; -import org.apache.jetspeed.components.persistence.store.Filter; -import org.apache.jetspeed.components.persistence.store.PersistenceStore; +import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport; +import org.apache.ojb.broker.query.Criteria; +import org.apache.ojb.broker.query.QueryByCriteria; +import org.apache.ojb.broker.query.QueryFactory; /** * Jetspeed Capabilities @@ -39,7 +41,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Roger Ruttimann</a> * @version $Id$ */ -public class JetspeedCapabilities implements Capabilities +public class JetspeedCapabilities extends InitablePersistenceBrokerDaoSupport implements Capabilities { private String originalAlias; @@ -59,11 +61,10 @@ private Class capabilityClass = CapabilityImpl.class; private Class mimeTypeClass = MimeTypeImpl.class; private Class mediaTypeClass = MediaTypeImpl.class; - private PersistenceStore persistenceStore; - public JetspeedCapabilities(PersistenceStore persistenceStore) + public JetspeedCapabilities(String repositoryPath) { - this.persistenceStore = persistenceStore; + super(repositoryPath); } /** @@ -79,9 +80,9 @@ * @param persistenceStore The persistence persistenceStore * @param properties Properties for this component described above */ - public JetspeedCapabilities(PersistenceStore persistenceStore, Properties properties) + public JetspeedCapabilities(String repositoryPath, Properties properties) { - this(persistenceStore); + super(repositoryPath); initModelClasses(properties); } @@ -294,7 +295,8 @@ if (null == clients) { - this.clients = persistenceStore.getExtent(ClientImpl.class); + this.clients = getPersistenceBrokerTemplate().getCollectionByQuery( + QueryFactory.newQuery(clientClass, new Criteria())); } return this.clients.iterator(); @@ -307,7 +309,7 @@ { //Find the MediaType by matching the Mimetype - Filter filter = persistenceStore.newFilter(); + Criteria filter = new Criteria(); Vector temp = new Vector(); // Add Mimetypes to map and create query @@ -326,8 +328,8 @@ if (temp.size() > 0) { filter.addIn("mimetypes.name", temp); - Object query = persistenceStore.newQuery(mediaTypeClass, filter); - co = persistenceStore.getCollectionByQuery(query); + QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter); + co = getPersistenceBrokerTemplate().getCollectionByQuery(query); } if (co == null || co.isEmpty()) @@ -353,12 +355,11 @@ * @see org.apache.jetspeed.capabilities.CapabilityService#getMediaType(java.lang.String) */ public MediaType getMediaType(String mediaType) - { - - Filter filter = persistenceStore.newFilter(); + { + Criteria filter = new Criteria(); filter.addEqualTo("name", mediaType); - Object query = persistenceStore.newQuery(mediaTypeClass, filter); - return (MediaType) persistenceStore.getObjectByQuery(query); + QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter); + return (MediaType) getPersistenceBrokerTemplate().getObjectByQuery(query); } /** @@ -369,12 +370,13 @@ public MediaType getMediaTypeForMimeType(String mimeTypeName) { //Find the MediaType by matching the Mimetype + + Criteria filter = new Criteria(); + filter.addEqualTo("mimetypes.name", mimeTypeName); + QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter); + Collection mediaTypeCollection = getPersistenceBrokerTemplate().getCollectionByQuery(query); - Filter filter = persistenceStore.newFilter(); - filter.addEqualTo("mimetypes.name", mimeTypeName); - Object query = persistenceStore.newQuery(mediaTypeClass, filter); - Collection mediaTypeCollection = persistenceStore.getCollectionByQuery(query); Iterator mtIterator = mediaTypeCollection.iterator(); if (mtIterator.hasNext()) { 1.1 jakarta-jetspeed-2/components/capability/src/java/META-INF/test-spring.xml Index: test-spring.xml =================================================================== <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for PortletRegistry using Apache OJB. --> <beans> <!-- Transaction manager for a single OJB PersistenceBroker (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.ojb.PersistenceBrokerTransactionManager"/> <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) --> <!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> --> <!-- - A parent bean definition which is a base definition for transaction proxies. - It is markes as abstract, since it is never supposed to be instantiated itself. - We set shared transaction attributes here, following our naming patterns. - The attributes can still be overridden in child bean definitions. --> <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- Capabilities DAO--> <bean id="capabilitiesImpl" class="org.apache.jetspeed.capabilities.impl.JetspeedCapabilities" init-method="init"> <constructor-arg> <value>META-INF/capabilities-ojb.xml</value> </constructor-arg> </bean> <!-- Capabilities --> <bean id="org.apache.jetspeed.capabilities.Capabilities" name="capabilities" parent="baseTransactionProxy" > <property name="proxyInterfaces"> <value>org.apache.jetspeed.capabilities.Capabilities</value> </property> <property name="target"> <ref bean="capabilitiesImpl"/> </property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_SUPPORTS</prop> </props> </property> </bean> </beans> 1.1 jakarta-jetspeed-2/components/capability/src/java/META-INF/capabilities-ojb.xml Index: capabilities-ojb.xml =================================================================== <!-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- - C A P A B I L I T Y M A P P I N G --> <descriptor-repository version="1.0"> <!-- - M E D I A T Y P E --> <class-descriptor class="org.apache.jetspeed.capabilities.impl.MediaTypeImpl" table="MEDIA_TYPE" > <field-descriptor name="mediatypeId" column="MEDIATYPE_ID" jdbc-type="INTEGER" primarykey="true" autoincrement="true" /> <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR" /> <field-descriptor name="characterSet" column="CHARACTER_SET" jdbc-type="VARCHAR" /> <field-descriptor name="title" column="TITLE" jdbc-type="VARCHAR" /> <field-descriptor name="description" column="DESCRIPTION" jdbc-type="VARCHAR" /> <collection-descriptor name="capabilities" element-class-ref="org.apache.jetspeed.capabilities.impl.CapabilityImpl" auto-retrieve="true" indirection-table="CLIENT_TO_CAPABILITY" > <fk-pointing-to-this-class column="CLIENT_ID"/> <fk-pointing-to-element-class column="CAPABILITY_ID"/> </collection-descriptor> <collection-descriptor name="mimetypes" element-class-ref="org.apache.jetspeed.capabilities.impl.MimeTypeImpl" auto-retrieve="true" indirection-table="MEDIATYPE_TO_MIMETYPE" > <fk-pointing-to-this-class column="MEDIATYPE_ID"/> <fk-pointing-to-element-class column="MIMETYPE_ID"/> </collection-descriptor> </class-descriptor> <!-- - C L I E N T --> <class-descriptor class="org.apache.jetspeed.capabilities.impl.ClientImpl" table="CLIENT" > <field-descriptor name="clientId" column="CLIENT_ID" jdbc-type="INTEGER" primarykey="true" autoincrement="true" /> <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR" /> <field-descriptor name="userAgentPattern" column="USER_AGENT_PATTERN" jdbc-type="VARCHAR" /> <field-descriptor name="manufacturer" column="MANUFACTURER" jdbc-type="VARCHAR" /> <field-descriptor name="model" column="MODEL" jdbc-type="VARCHAR" /> <field-descriptor name="version" column="VERSION" jdbc-type="VARCHAR" /> <field-descriptor name="preferredMimeTypeId" column="PREFERRED_MIMETYPE_ID" jdbc-type="INTEGER" /> <collection-descriptor name="capabilities" element-class-ref="org.apache.jetspeed.capabilities.impl.CapabilityImpl" indirection-table="CLIENT_TO_CAPABILITY" > <fk-pointing-to-this-class column="CLIENT_ID"/> <fk-pointing-to-element-class column="CAPABILITY_ID"/> </collection-descriptor> <collection-descriptor name="mimetypes" element-class-ref="org.apache.jetspeed.capabilities.impl.MimeTypeImpl" auto-retrieve="true" indirection-table="CLIENT_TO_MIMETYPE" > <fk-pointing-to-this-class column="CLIENT_ID"/> <fk-pointing-to-element-class column="MIMETYPE_ID"/> </collection-descriptor> </class-descriptor> <!-- - M I M E T Y P E --> <class-descriptor class="org.apache.jetspeed.capabilities.impl.MimeTypeImpl" table="MIMETYPE" > <field-descriptor name="mimeTypeId" column="MIMETYPE_ID" jdbc-type="INTEGER" primarykey="true" autoincrement="true" /> <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR" /> </class-descriptor> <!-- - C A P A B I L I T Y --> <class-descriptor class="org.apache.jetspeed.capabilities.impl.CapabilityImpl" table="CAPABILITY" > <field-descriptor name="capabilityId" column="CAPABILITY_ID" jdbc-type="INTEGER" primarykey="true" autoincrement="true" /> <field-descriptor name="name" column="CAPABILITY" jdbc-type="VARCHAR" /> </class-descriptor> </descriptor-repository>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]