com.silverpeas.jcrutil
Class BetterRepositoryFactoryBean

java.lang.Object
  extended by org.springmodules.jcr.RepositoryFactoryBean
      extended by com.silverpeas.jcrutil.BetterRepositoryFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class BetterRepositoryFactoryBean
extends org.springmodules.jcr.RepositoryFactoryBean

FactoryBean for creating a JackRabbit (JCR-170) repository through Spring configuration files. Use this factory bean when you have to manually configure the repository; for retrieving the repository from JNDI use the JndiObjectFactoryBean org.springframework.jndi.JndiObjectFactoryBean. Sample configuration : <bean id="repository" class="BetterRepositoryFactoryBean"> <!-- normal factory beans params --> <property name="configuration" value="classpath:repository.xml" /> <property name="homeDir" value="file:///c:/tmp/jackrabbit" /> <property name="configurationProperties"> <list> <value>classpath:/first.properties</value> <value>classpath:/second.properties</value> </list> </property> </bean>

Author:
Emmanuel Hugonnet
See Also:
org.springframework.jndi.JndiObjectFactoryBean

Field Summary
 
Fields inherited from class org.springmodules.jcr.RepositoryFactoryBean
configuration, log, repository
 
Constructor Summary
BetterRepositoryFactoryBean()
           
 
Method Summary
protected  javax.jcr.Repository createJndiRepository(String jndiName)
           
protected  javax.jcr.Repository createRepository()
           
 void destroy()
          Shutdown method.
protected  String getConfiguration(org.springframework.core.io.Resource config)
          Load a Resource as a String.
 List<String> getConfigurationProperties()
           
 org.springframework.core.io.Resource getHomeDir()
           
 String getJndiName()
           
 org.apache.jackrabbit.core.config.RepositoryConfig getRepositoryConfig()
           
 boolean isUseSystemProperties()
           
protected  Properties loadConfigurationKeys()
          Load all the configuration properties
protected static void prepareContext(InitialContext ic, String jndiName)
           
static String replaceVariables(Properties variables, String value, boolean ignoreMissing)
          Performs variable replacement on the given string value.
protected  void resolveConfigurationResource()
           
 void setConfigurationProperties(List<String> resources)
           
 void setHomeDir(org.springframework.core.io.Resource defaultRepDir)
           
 void setJndiName(String jndiName)
           
 void setRepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig repositoryConfig)
           
 void setUseSystemProperties(boolean useSystemProperties)
           
 void testCleanUp()
           
 
Methods inherited from class org.springmodules.jcr.RepositoryFactoryBean
afterPropertiesSet, getConfiguration, getObject, getObjectType, isSingleton, setConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BetterRepositoryFactoryBean

public BetterRepositoryFactoryBean()
Method Detail

createRepository

protected javax.jcr.Repository createRepository()
                                         throws Exception
Specified by:
createRepository in class org.springmodules.jcr.RepositoryFactoryBean
Throws:
Exception
See Also:
RepositoryFactoryBean.createRepository()

createJndiRepository

protected javax.jcr.Repository createJndiRepository(String jndiName)

prepareContext

protected static void prepareContext(InitialContext ic,
                                     String jndiName)
                              throws NamingException
Throws:
NamingException

resolveConfigurationResource

protected void resolveConfigurationResource()
                                     throws Exception
Specified by:
resolveConfigurationResource in class org.springmodules.jcr.RepositoryFactoryBean
Throws:
Exception
See Also:
RepositoryFactoryBean.resolveConfigurationResource()

replaceVariables

public static String replaceVariables(Properties variables,
                                      String value,
                                      boolean ignoreMissing)
                               throws IllegalArgumentException
Performs variable replacement on the given string value. Each ${...} sequence within the given value is replaced with the value of the named parser variable. If a variable is not found in the properties an IllegalArgumentException is thrown unless ignoreMissing is true. In the later case, the missing variable is not replaced.

Parameters:
variables -
value - the original value
ignoreMissing - if true, missing variables are not replaced.
Returns:
value after variable replacements
Throws:
IllegalArgumentException - if the replacement of a referenced variable is not found

destroy

@PreDestroy
public void destroy()
             throws Exception
Shutdown method.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Overrides:
destroy in class org.springmodules.jcr.RepositoryFactoryBean
Throws:
Exception

testCleanUp

public void testCleanUp()
                 throws IOException
Throws:
IOException

getHomeDir

public org.springframework.core.io.Resource getHomeDir()
Returns:
Returns the defaultRepDir.

setHomeDir

public void setHomeDir(org.springframework.core.io.Resource defaultRepDir)
Parameters:
defaultRepDir - The defaultRepDir to set.

getRepositoryConfig

public org.apache.jackrabbit.core.config.RepositoryConfig getRepositoryConfig()
Returns:
Returns the repositoryConfig.

setRepositoryConfig

public void setRepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig repositoryConfig)
Parameters:
repositoryConfig - The repositoryConfig to set.

getConfigurationProperties

public List<String> getConfigurationProperties()
Returns:
Returns the configuration properties.

setConfigurationProperties

public void setConfigurationProperties(List<String> resources)
Parameters:
resources - The configuration resources to set for the repository.

getJndiName

public String getJndiName()

setJndiName

public void setJndiName(String jndiName)

isUseSystemProperties

public boolean isUseSystemProperties()

setUseSystemProperties

public void setUseSystemProperties(boolean useSystemProperties)

loadConfigurationKeys

protected Properties loadConfigurationKeys()
Load all the configuration properties

Returns:

getConfiguration

protected String getConfiguration(org.springframework.core.io.Resource config)
                           throws IOException
Load a Resource as a String.

Parameters:
config - the resource
Returns:
the String filled with the content of the Resource
Throws:
IOException


Copyright © 2016 Silverpeas. All Rights Reserved.