Merged AVMService into the rest of Alfresco. It all comes up in

the same ApplicationContext. Some adjustments to tests needed,
but everything is passing.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3414 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-26 13:47:40 +00:00
parent f7d9d83036
commit 6692c7a979
12 changed files with 401 additions and 10 deletions

View File

@@ -24,6 +24,7 @@
<import resource="classpath:alfresco/import-export-context.xml" /> <import resource="classpath:alfresco/import-export-context.xml" />
<import resource="classpath:alfresco/bootstrap-context.xml" /> <import resource="classpath:alfresco/bootstrap-context.xml" />
<import resource="classpath:alfresco/jcr-api-context.xml" /> <import resource="classpath:alfresco/jcr-api-context.xml" />
<import resource="classpath:alfresco/avm-services-context.xml" />
<import resource="classpath*:alfresco/patch/*-context.xml" /> <import resource="classpath*:alfresco/patch/*-context.xml" />
<import resource="classpath*:alfresco/domain/*-context.xml" /> <import resource="classpath*:alfresco/domain/*-context.xml" />

View File

@@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ID Issuers. -->
<bean id="nodeIssuer" class="org.alfresco.repo.avm.Issuer"
depends-on="retryingTransaction,avmContext" init-method="init">
<property name="name">
<value>node</value>
</property>
<property name="retryingTransaction">
<ref bean="retryingTransaction"/>
</property>
</bean>
<bean id="contentIssuer" class="org.alfresco.repo.avm.Issuer"
depends-on="retryingTransaction,avmContext" init-method="init">
<property name="name">
<value>content</value>
</property>
<property name="retryingTransaction">
<ref bean="retryingTransaction"/>
</property>
</bean>
<bean id="layerIssuer" class="org.alfresco.repo.avm.Issuer"
depends-on="retryingTransaction,avmContext" init-method="init">
<property name="name">
<value>layer</value>
</property>
<property name="retryingTransaction">
<ref bean="retryingTransaction"/>
</property>
</bean>
<!-- DAOs for persistent data types -->
<!-- Issuers are not actual entities. More like pseudo entities. -->
<bean id="issuerDAO" class="org.alfresco.repo.avm.IssuerDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="nodeDAO" class="org.alfresco.repo.avm.AVMNodeDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmStoreDAO" class="org.alfresco.repo.avm.AVMStoreDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="versionRootDAO" class="org.alfresco.repo.avm.VersionRootDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="fileContentDAO" class="org.alfresco.repo.avm.FileContentDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="childEntryDAO" class="org.alfresco.repo.avm.ChildEntryDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="historyLinkDAO" class="org.alfresco.repo.avm.HistoryLinkDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="mergeLinkDAO" class="org.alfresco.repo.avm.MergeLinkDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="deletedChildDAO" class="org.alfresco.repo.avm.DeletedChildDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="newInAVMStoreDAO" class="org.alfresco.repo.avm.NewInAVMStoreDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmNodePropertyDAO" class="org.alfresco.repo.avm.AVMNodePropertyDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmStorePropertyDAO" class="org.alfresco.repo.avm.AVMStorePropertyDAOHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
<property name="issuerDAO">
<ref bean="issuerDAO"/>
</property>
<property name="nodeDAO">
<ref bean="nodeDAO"/>
</property>
<property name="avmStoreDAO">
<ref bean="avmStoreDAO"/>
</property>
<property name="versionRootDAO">
<ref bean="versionRootDAO"/>
</property>
<property name="fileContentDAO">
<ref bean="fileContentDAO"/>
</property>
<property name="childEntryDAO">
<ref bean="childEntryDAO"/>
</property>
<property name="historyLinkDAO">
<ref bean="historyLinkDAO"/>
</property>
<property name="mergeLinkDAO">
<ref bean="mergeLinkDAO"/>
</property>
<property name="deletedChildDAO">
<ref bean="deletedChildDAO"/>
</property>
<property name="newInAVMStoreDAO">
<ref bean="newInAVMStoreDAO"/>
</property>
<property name="avmNodePropertyDAO">
<ref bean="avmNodePropertyDAO"/>
</property>
<property name="avmStorePropertyDAO">
<ref bean="avmStorePropertyDAO"/>
</property>
</bean>
<!-- A read only DefaultTransactionDefinition -->
<bean id="readTransactionDefinition"
class="org.springframework.transaction.support.DefaultTransactionDefinition">
<property name="propagationBehaviorName">
<value>PROPAGATION_REQUIRED</value>
</property>
<property name="readOnly">
<value>true</value>
</property>
</bean>
<!-- A write DefaultTransactionDefinition -->
<bean id="writeTransactionDefinition"
class="org.springframework.transaction.support.DefaultTransactionDefinition">
<property name="propagationBehaviorName">
<value>PROPAGATION_REQUIRED</value>
</property>
<property name="readOnly">
<value>false</value>
</property>
</bean>
<!-- The Retrying Transaction Helper. -->
<bean id="retryingTransaction"
class="org.alfresco.repo.avm.HibernateRetryingTransactionHelper">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="readTransactionDefinition">
<ref bean="readTransactionDefinition"/>
</property>
<property name="writeTransactionDefinition">
<ref bean="writeTransactionDefinition"/>
</property>
</bean>
<bean id="orphanReaper" class="org.alfresco.repo.avm.OrphanReaper"
init-method="init" destroy-method="shutDown" depends-on="AVMService">
<property name="inactiveBaseSleep">
<value>4000</value>
</property>
<property name="activeBaseSleep">
<value>1000</value>
</property>
<property name="batchSize">
<value>50</value>
</property>
<property name="retryingTransaction">
<ref bean="retryingTransaction"/>
</property>
</bean>
<bean id="avmRepository" class="org.alfresco.repo.avm.AVMRepository"
init-method="init">
<property name="storage">
<value>${avm.storage}</value>
</property>
<property name="nodeIssuer">
<ref bean="nodeIssuer"/>
</property>
<property name="contentIssuer">
<ref bean="contentIssuer"/>
</property>
<property name="layerIssuer">
<ref bean="layerIssuer"/>
</property>
</bean>
</beans>

View File

@@ -4,6 +4,7 @@
<beans> <beans>
<!-- Use substitution values in this config. --> <!-- Use substitution values in this config. -->
<!--
<bean id="configurationProperties" <bean id="configurationProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations"> <property name="locations">
@@ -12,7 +13,7 @@
</list> </list>
</property> </property>
</bean> </bean>
-->
<import resource="file:config/alfresco/avm-base-context.xml"/> <import resource="file:config/alfresco/application-context.xml"/>
</beans> </beans>

View File

@@ -41,6 +41,7 @@
<value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/AppliedPatch.hbm.xml</value>
<value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value> <value>org/alfresco/repo/domain/hibernate/Permission.hbm.xml</value>
<value>org/alfresco/repo/avm/hibernate/AVM.hbm.xml</value>
</list> </list>
</property> </property>
<property name="hibernateProperties" ref="hibernateConfigProperties" /> <property name="hibernateProperties" ref="hibernateConfigProperties" />

View File

@@ -935,4 +935,21 @@
</property> </property>
</bean> </bean>
<!-- The AVMService -->
<bean id="AVMService" class="org.alfresco.repo.avm.AVMServiceImpl" init-method="init">
<property name="storage">
<value>${avm.storage}</value>
</property>
<property name="initialize">
<value>${avm.initialize}</value>
</property>
<property name="retryingTransaction">
<ref bean="retryingTransaction"/>
</property>
<property name="avmRepository">
<ref bean="avmRepository"/>
</property>
</bean>
</beans> </beans>

View File

@@ -108,4 +108,7 @@ system.people_container.childname=sys:people
user.name.caseSensitive=false user.name.caseSensitive=false
# AVM Specific properties.
avm.storage=build/test-results/storage
avm.initialize=true

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.repo.avm;
/**
* Utility class with static methods to convert between
* a NodeRef style id string and an ordinary AVM path.
* @author britt
*/
public class AVMPathConverter
{
/**
* Converts to a string to stuff into a NodeRef. Version = 3
* of main:/snot/efluvium/biggle would be converted into
* 3/main/snot/efluvium/biggle
* @param version The version id.
* @param avmPath The full AVM path.
* @return A mangled string appropriate for stuffing into a NodeRef.
*/
public static String toNodeRefStyle(int version, String avmPath)
{
String [] pathParts = avmPath.split(":");
if (pathParts.length != 2)
{
throw new AVMException("Malformed path.");
}
return version + "/" + pathParts[0] + pathParts[1];
}
/**
* Convert from a NodeRef packed form to a version number
* and standard AVM path.
* @param nrID The NodeRef packed for of an AVM path.
* @return The version number and the standard AVM path.
*/
public static Object[] toAVMStyle(String nrID)
{
Object [] result = new Object[2];
String [] pathParts = nrID.split("/");
result[0] = new Integer(pathParts[0]);
StringBuilder builder = new StringBuilder();
builder.append(pathParts[1]);
builder.append(':');
for (int i = 2; i < pathParts.length; i++)
{
builder.append('/');
builder.append(pathParts[i]);
}
if (pathParts.length == 2)
{
builder.append('/');
}
result[1] = builder.toString();
return result;
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.repo.avm;
import junit.framework.TestCase;
/**
* Test of AVMPathConverter.
* @author britt
*/
public class AVMPathConverterTest extends TestCase
{
/**
* Test conversions.
*/
public void testConversions()
{
try
{
String start = "main:/";
String nrRep = AVMPathConverter.toNodeRefStyle(-1, start);
assertEquals("-1/main/", nrRep);
Object[] back = AVMPathConverter.toAVMStyle(nrRep);
assertEquals(((Integer)back[0]).intValue(), -1);
assertEquals((String)back[1], "main:/");
start = "main:/foo/bar/baz";
nrRep = AVMPathConverter.toNodeRefStyle(2, start);
assertEquals("2/main/foo/bar/baz", nrRep);
back = AVMPathConverter.toAVMStyle(nrRep);
assertEquals(((Integer)back[0]).intValue(), 2);
assertEquals((String)back[1], "main:/foo/bar/baz");
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
}

View File

@@ -85,8 +85,15 @@ class AVMServiceImpl implements AVMService
{ {
if (fInitialize) if (fInitialize)
{ {
createAVMStore("main"); try
fgLogger.info("Created new main AVMStore"); {
createAVMStore("main");
fgLogger.info("Created new main AVMStore");
}
catch (AVMExistsException e)
{
fgLogger.info("AVMStore main already exists");
}
} }
} }

View File

@@ -19,7 +19,9 @@ package org.alfresco.repo.avm;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@@ -59,9 +61,8 @@ public class AVMServiceTestBase extends TestCase
@Override @Override
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
// HibernateHelper.GetSessionFactory().getStatistics().setStatisticsEnabled(true);
fContext = new FileSystemXmlApplicationContext("config/alfresco/avm-test-context.xml"); fContext = new FileSystemXmlApplicationContext("config/alfresco/avm-test-context.xml");
fService = (AVMService)fContext.getBean("avmService"); fService = (AVMService)fContext.getBean("AVMService");
fReaper = (OrphanReaper)fContext.getBean("orphanReaper"); fReaper = (OrphanReaper)fContext.getBean("orphanReaper");
fStartTime = System.currentTimeMillis(); fStartTime = System.currentTimeMillis();
} }
@@ -74,10 +75,15 @@ public class AVMServiceTestBase extends TestCase
{ {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
System.out.println("Timing: " + (now - fStartTime) + "ms"); System.out.println("Timing: " + (now - fStartTime) + "ms");
// Statistics stats = HibernateHelper.GetSessionFactory().getStatistics(); List<AVMStoreDescriptor> descriptors = fService.getAVMStores();
// stats.logSummary(); for (AVMStoreDescriptor desc : descriptors)
// stats.clear(); {
fService.purgeAVMStore(desc.getName());
}
fContext.close(); fContext.close();
File alfData = new File("alf_data");
File target = new File("alf_data" + now);
alfData.renameTo(target);
} }
/** /**

View File

@@ -85,7 +85,7 @@ class Issuer
} }
else else
{ {
fNext = doit.value; fNext = doit.value + 1;
} }
} }

View File

@@ -30,6 +30,7 @@ public final class StoreRef implements EntityRef, Serializable
private static final long serialVersionUID = 3905808565129394486L; private static final long serialVersionUID = 3905808565129394486L;
public static final String PROTOCOL_WORKSPACE = "workspace"; public static final String PROTOCOL_WORKSPACE = "workspace";
public static final String PROTOCOL_AVM = "avm";
public static final String URI_FILLER = "://"; public static final String URI_FILLER = "://";