Author: rhauch
Date: 2008-06-13 14:25:41 -0400 (Fri, 13 Jun 2008)
New Revision: 288
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/NodeConflictBehavior.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/RecordBranchCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicRecordBranchCommand.java
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java
trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Property.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/MoveBranchCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicMoveBranchCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySource.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicEmptyProperty.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicMultiValueProperty.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicProperty.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPropertyFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicSingleValueProperty.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
Log:
Added array-based methods to PropertyValueFactory, modified several of the commands, and
further implemented the Federation Service components
Modified:
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
---
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/connectors/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -202,7 +202,8 @@
for (Map.Entry<Name, Object> data : dataMap.entrySet()) {
Name propertyName = data.getKey();
Object values = data.getValue();
- theCommand.setProperty(propertyName, values);
+ Property property = env.getPropertyFactory().create(propertyName,
values);
+ theCommand.setProperty(property);
}
}
if (command instanceof SetPropertiesCommand) {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryI18n.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -112,6 +112,7 @@
public static I18n warningSequencingXmlDocument;
public static I18n interruptedWhileConnectingToFederationConfigurationRepository;
+ public static I18n interruptedWhileUsingFederationConfigurationRepository;
public static I18n
interruptedWhileClosingConnectionToFederationConfigurationRepository;
public static I18n unableToCreateConnectionToFederatedRepository;
public static I18n unableToAuthenticateConnectionToFederatedRepository;
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederatedRepositorySource.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -56,20 +56,34 @@
protected static final String RETRY_LIMIT = "retryLimit";
protected static final String FEDERATION_SERVICE_JNDI_NAME =
"fedServiceJndiName";
- private final String repositoryName;
- private final FederationService federationService;
+ private String repositoryName;
+ private FederationService federationService;
private String sourceName;
- private int retryLimit;
+ private int retryLimit = DEFAULT_RETRY_LIMIT;
private String username;
private String credentials;
- protected FederatedRepositorySource( FederationService federationService,
- String repositoryName ) {
+ /**
+ * Create a new instance of the source, which must still be properly initialized with
a
+ * {@link #setRepositoryName(String) repository name} and a reference to the
+ * {@link #setFederationService(FederationService) federation service}.
+ */
+ public FederatedRepositorySource() {
+ }
+
+ /**
+ * Create a new instance of the source with the required repository name and
federation service.
+ *
+ * @param federationService the {@link FederationService}
+ * @param repositoryName the repository name
+ * @throws IllegalArgumentException if the federation service is null or the
repository name is null or blank
+ */
+ public FederatedRepositorySource( FederationService federationService,
+ String repositoryName ) {
ArgCheck.isNotNull(federationService, "federationService");
ArgCheck.isNotNull(repositoryName, "repositoryName");
this.federationService = federationService;
this.repositoryName = repositoryName;
- this.retryLimit = DEFAULT_RETRY_LIMIT;
}
/**
@@ -80,6 +94,14 @@
}
/**
+ * @param federationService Sets federationService to the specified value.
+ */
+ public void setFederationService( FederationService federationService ) {
+ ArgCheck.isNotNull(federationService, "federatedService");
+ this.federationService = federationService;
+ }
+
+ /**
* {@inheritDoc}
*/
public int getRetryLimit() {
@@ -165,6 +187,14 @@
}
/**
+ * @param repositoryName Sets repositoryName to the specified value.
+ */
+ public void setRepositoryName( String repositoryName ) {
+ ArgCheck.isNotEmpty(repositoryName, "repositoryName");
+ this.repositoryName = repositoryName;
+ }
+
+ /**
* {@inheritDoc}
*/
public Reference getReference() {
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/federation/FederationService.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -27,11 +27,15 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.component.ClassLoaderFactory;
+import org.jboss.dna.common.component.StandardClassLoaderFactory;
+import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.services.AbstractServiceAdministrator;
import org.jboss.dna.repository.services.AdministeredService;
import org.jboss.dna.repository.services.ServiceAdministrator;
+import org.jboss.dna.repository.util.ExecutionContext;
import org.jboss.dna.spi.graph.connection.RepositoryConnection;
import org.jboss.dna.spi.graph.connection.RepositorySource;
@@ -80,12 +84,15 @@
/**
* {@inheritDoc}
*/
- public boolean awaitTermination( long timeout, TimeUnit unit ) throws
InterruptedException {
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
return FederationService.this.awaitTermination(timeout, unit);
}
}
+ private final ClassLoaderFactory classLoaderFactory;
+ private final ExecutionContext executionContext;
private final RepositorySource configurationSource;
private final Administrator administrator = new Administrator();
private final ConcurrentMap<String, FederatedRepository> repositories = new
ConcurrentHashMap<String, FederatedRepository>();
@@ -95,12 +102,22 @@
* Create a federation service instance
*
* @param configurationSource the repository source that contains the configuration
for this federation service (including the
- * respositories and the sources used by the federated repositories)
- * @throws IllegalArgumentException if the bootstrap source is null
+ * respositories and the sources used by the federated repositories)
+ * @param executionContext the context in which this service should run
+ * @param classLoaderFactory the class loader factory used to instantiate {@link
RepositorySource} instances; may be null if
+ * this instance should use a default factory that attempts to load classes
first from the
+ * {@link Thread#getContextClassLoader() thread's current context class
loader} and then from the class loader that
+ * loaded this class.
+ * @throws IllegalArgumentException if the bootstrap source is null or the execution
context is null
*/
- public FederationService( RepositorySource configurationSource ) {
+ public FederationService( RepositorySource configurationSource,
+ ExecutionContext executionContext,
+ ClassLoaderFactory classLoaderFactory ) {
ArgCheck.isNotNull(configurationSource, "configurationSource");
+ ArgCheck.isNotNull(executionContext, "executionContext");
this.configurationSource = configurationSource;
+ this.executionContext = executionContext;
+ this.classLoaderFactory = classLoaderFactory != null ? classLoaderFactory : new
StandardClassLoaderFactory();
}
/**
@@ -119,21 +136,136 @@
return this.configurationSource;
}
+ /**
+ * @return executionContext
+ */
+ public ExecutionContext getExecutionContext() {
+ return this.executionContext;
+ }
+
+ /**
+ * @return classLoaderFactory
+ */
+ public ClassLoaderFactory getClassLoaderFactory() {
+ return this.classLoaderFactory;
+ }
+
public String getJndiName() {
// TODO
return null;
}
- protected void startService() {
+ protected synchronized void startService() {
if (this.configurationConnection == null) {
try {
this.configurationConnection = this.configurationSource.getConnection();
} catch (InterruptedException err) {
- throw new
FederationException(RepositoryI18n.interruptedWhileConnectingToFederationConfigurationRepository.text(this.configurationSource.getName()));
+ I18n msg =
RepositoryI18n.interruptedWhileConnectingToFederationConfigurationRepository;
+ throw new FederationException(msg.text(configurationSource.getName()));
}
+ // // Read the configuration and obtain the RepositorySource instances for
each of the
+ // // federated repositories. Each repository configuration is rooted at
+ // // "/dna:repositories/[repositoryName]", and under this node at
"dna:federation"
+ // // is the RepositorySource for the integrated repository, and under the
+ // // "dna:sources/[sourceName]" are the nodes representing the
inital RepositorySource
+ // // instances for each of the sources.
+ // //
+ // // The integrated repository for each federated repository contains the
complete unified
+ // // graph merged from all of the sources. It also contains the
configuration for the federated
+ // // repository at "/dna:system/dna:federation", including under
"dna:sources" a node for each of the current
+ // // sources (e.g.,
"/dna:system/dna:federation/dna:sources/[sourceName]"). If this area of the
+ // // graph does not yet exist, the sources are copied from the
+ // // "/dna:repositories/[repositoryName]/dna:sources" area of the
service's configuration repository.
+ // // However, after that, the federated repository manages its own sources.
+ //
+ // ValueFactories valueFactories = executionContext.getValueFactories();
+ // PathFactory pathFactory = valueFactories.getPathFactory();
+ //
+ // // Get the list of repositories in the configuration, and create a
FederatedRepository for each one ...
+ // try {
+ // Path repositoriesNode = pathFactory.create("dna:repositories");
+ // BasicGetChildrenCommand getRepositories = new
BasicGetChildrenCommand(repositoriesNode);
+ // configurationConnection.execute(executionContext, getRepositories);
+ //
+ // // For each repository ...
+ // for (Path.Segment child : getRepositories.getChildren()) {
+ //
+ // // Get the repository's name ...
+ // final String repositoryName = child.getUnencodedString();
+ // final Path pathToRepository = pathFactory.create(repositoriesNode,
child);
+ //
+ // // Record the initial sources ...
+ // final Path.Segment sourcesSegment =
pathFactory.createSegment("dna:sources");
+ // final Path pathToRepositorySourcesNode =
pathFactory.create(pathToRepository, sourcesSegment);
+ // BasicRecordBranchCommand getSources = new
BasicRecordBranchCommand(pathToRepositorySourcesNode,
+ // NodeConflictBehavior.DO_NOT_REPLACE);
+ //
+ // // Get the source of the integrated repository ...
+ // final Path.Segment integratedRepositorySegment =
pathFactory.createSegment("dna:federatedRepository");
+ // final Path pathToIntegratedRepositoryNode =
pathFactory.create(pathToRepository, integratedRepositorySegment);
+ // BasicGetNodeCommand getSource = new
BasicGetNodeCommand(pathToIntegratedRepositoryNode);
+ // configurationConnection.execute(executionContext, getSource);
+ // RepositorySource integratedRepositorySource =
createRepositorySource(valueFactories,
+ // getSource.getProperties());
+ //
+ // // Copy these to the federated repository ...
+ // RepositoryConnection integratedConnection = integratedReposi
+ // // Look for the
+ // // Read the initial sources ...
+ //
+ // // Get the repository source information for the integrated repository
...
+ //
+ // // Look for existing sources and load them ...
+ //
+ // // Otherwise, read the intial sources from the
+ //
+ // }
+ // } catch (InterruptedException err) {
+ // I18n msg =
RepositoryI18n.interruptedWhileUsingFederationConfigurationRepository;
+ // throw new FederationException(msg.text(configurationSource.getName()));
+ // }
+ // // TODO
}
}
+ // protected RepositorySource createRepositorySource( ValueFactories values,
+ // Iterable<Property> properties ) {
+ // // Put the properties in a map so we can find them by name ...
+ // Map<Name, Property> byName = new HashMap<Name, Property>();
+ // for (Property property : properties) {
+ // byName.put(property.getName(), property);
+ // }
+ //
+ // // Get the concrete class ...
+ // Name classnameName = values.getNameFactory().create("dna:className");
+ // Property classProperty = byName.get(classnameName);
+ // if (classProperty == null) return null;
+ // if (classProperty.isEmpty()) return null;
+ // String className =
values.getStringFactory().create(classProperty.getValues().next());
+ // if (className == null) return null;
+ //
+ // Name classpathName = values.getNameFactory().create("dna:classpath");
+ // Property classpathProperty = byName.get(classpathName);
+ // String[] classpath = null;
+ // if (classpathProperty != null) {
+ // classpath =
values.getStringFactory().create(classpathProperty.getValuesAsArray());
+ // }
+ //
+ // // Load the class and look for the constructors ...
+ // RepositorySource source = null;
+ // try {
+ // ClassLoader loader = getClassLoaderFactory().getClassLoader(classpath);
+ // Class<?> sourceClass = loader.loadClass(className);
+ // source = (RepositorySource)sourceClass.newInstance();
+ // } catch (ClassNotFoundException err) {
+ // return null;
+ // } catch (InstantiationException err) {
+ //
+ // } catch (IllegalAccessException err) {
+ // }
+ // return null;
+ // }
+
/**
* Get the federated repository object with the given name. The resulting repository
will be started and ready to use.
*
@@ -157,12 +289,13 @@
return repository;
}
- protected void shutdownService() {
+ protected synchronized void shutdownService() {
if (this.configurationConnection != null) {
try {
this.configurationConnection.close();
} catch (InterruptedException err) {
- throw new
FederationException(RepositoryI18n.interruptedWhileClosingConnectionToFederationConfigurationRepository.text(this.configurationSource.getName()));
+ throw new FederationException(
+
RepositoryI18n.interruptedWhileClosingConnectionToFederationConfigurationRepository.text(this.configurationSource.getName()));
}
// Now shut down all repositories ...
for (String repositoryName : this.repositories.keySet()) {
@@ -181,7 +314,8 @@
return true;
}
- protected boolean awaitTermination( long timeout, TimeUnit unit ) throws
InterruptedException {
+ protected boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
// Now shut down all repositories ...
for (String repositoryName : this.repositories.keySet()) {
FederatedRepository repository = this.repositories.get(repositoryName);
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -61,6 +61,7 @@
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.repository.util.SessionFactory;
import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PropertyFactory;
import org.jboss.dna.spi.graph.ValueFactories;
/**
@@ -656,6 +657,13 @@
/**
* {@inheritDoc}
*/
+ public PropertyFactory getPropertyFactory() {
+ return this.delegate.getPropertyFactory();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public SessionFactory getSessionFactory() {
return this.factory;
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/ExecutionContext.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -22,36 +22,26 @@
package org.jboss.dna.repository.util;
import javax.jcr.Session;
-import org.jboss.dna.spi.graph.NamespaceRegistry;
-import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.connection.ExecutionEnvironment;
/**
* The context of an execution.
+ *
* @author Randall Hauch
*/
-public interface ExecutionContext {
+public interface ExecutionContext extends ExecutionEnvironment {
/**
- * Get the namespace registry.
- * @return the namespace registry; never null
- */
- NamespaceRegistry getNamespaceRegistry();
-
- /**
- * Get the factories that are to be used to create property values of various types.
- * @return the set of value factories; never null
- */
- ValueFactories getValueFactories();
-
- /**
* Get the session factory, which can be used to obtain sessions temporarily for this
context. Any session obtained from this
* factory should be {@link Session#logout() closed} before the execution finishes.
+ *
* @return the session factory
*/
SessionFactory getSessionFactory();
/**
* Get a set of utilities for working with JCR.
+ *
* @return the tools
*/
JcrTools getTools();
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/SimpleExecutionContext.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -23,7 +23,9 @@
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.PropertyFactory;
import org.jboss.dna.spi.graph.ValueFactories;
+import org.jboss.dna.spi.graph.impl.BasicPropertyFactory;
import org.jboss.dna.spi.graph.impl.StandardValueFactories;
/**
@@ -32,24 +34,31 @@
public class SimpleExecutionContext implements ExecutionContext {
private final JcrTools tools = new JcrTools();
+ private final PropertyFactory propertyFactory;
private final SessionFactory sessionFactory;
private final ValueFactories valueFactories;
private final NamespaceRegistry namespaceRegistry;
- public SimpleExecutionContext( SessionFactory sessionFactory, String
repositoryWorkspaceForNamespaceRegistry ) {
- this(sessionFactory, new JcrNamespaceRegistry(sessionFactory,
repositoryWorkspaceForNamespaceRegistry), null);
+ public SimpleExecutionContext( SessionFactory sessionFactory,
+ String repositoryWorkspaceForNamespaceRegistry ) {
+ this(sessionFactory, new JcrNamespaceRegistry(sessionFactory,
repositoryWorkspaceForNamespaceRegistry), null, null);
}
- public SimpleExecutionContext( SessionFactory sessionFactory, NamespaceRegistry
namespaceRegistry ) {
- this(sessionFactory, namespaceRegistry, null);
+ public SimpleExecutionContext( SessionFactory sessionFactory,
+ NamespaceRegistry namespaceRegistry ) {
+ this(sessionFactory, namespaceRegistry, null, null);
}
- public SimpleExecutionContext( SessionFactory sessionFactory, NamespaceRegistry
namespaceRegistry, ValueFactories valueFactories ) {
+ public SimpleExecutionContext( SessionFactory sessionFactory,
+ NamespaceRegistry namespaceRegistry,
+ ValueFactories valueFactories,
+ PropertyFactory propertyFactory ) {
ArgCheck.isNotNull(sessionFactory, "session factory");
ArgCheck.isNotNull(namespaceRegistry, "namespace registry");
this.sessionFactory = sessionFactory;
this.namespaceRegistry = namespaceRegistry;
this.valueFactories = valueFactories != null ? valueFactories : new
StandardValueFactories(this.namespaceRegistry);
+ this.propertyFactory = propertyFactory != null ? propertyFactory : new
BasicPropertyFactory(this.valueFactories);
}
/**
@@ -69,6 +78,13 @@
/**
* {@inheritDoc}
*/
+ public PropertyFactory getPropertyFactory() {
+ return this.propertyFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public SessionFactory getSessionFactory() {
return this.sessionFactory;
}
Modified:
trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
===================================================================
---
trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-06-13
18:25:41 UTC (rev 288)
@@ -98,8 +98,9 @@
canceledSequencingXmlDocument = Canceled sequencing XML
warningSequencingXmlDocument = A warning was received while sequencing XML: {0}
-interruptedWhileConnectingToFederationConfigurationRepository = Interrupted while
connecting to federation configuration repository for "{0}" repository
-interruptedWhileClosingConnectionToFederationConfigurationRepository = Interrupted while
closing connection to federation configuration repository for "{0}" repository
+interruptedWhileConnectingToFederationConfigurationRepository = Interrupted while
connecting to federation configuration repository "{0}"
+interruptedWhileUsingFederationConfigurationRepository = Interrupted while using
federation configuration repository "{0}"
+interruptedWhileClosingConnectionToFederationConfigurationRepository = Interrupted while
closing connection to federation configuration repository "{0}"
unableToCreateConnectionToFederatedRepository = Unable to create a connection to the
repository "{0}". Check the Federation Service configuration.
unableToAuthenticateConnectionToFederatedRepository = Unable to authenticate
"{1}" for repository "{0}"
repositoryHasBeenShutDown = The "{0}" repository has been shut down and may no
longer be used.
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -81,7 +81,7 @@
}
};
NamespaceRegistry registry = new JcrNamespaceRegistry(sessionFactory,
"doesn't matter");
- this.context = new SimpleExecutionContext(sessionFactory, registry, null);
+ this.context = new SimpleExecutionContext(sessionFactory, registry, null, null);
this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
this.progressMonitor = new
RecordingProgressMonitor(StreamSequencerAdapterTest.class.getName());
final SequencerOutputMap finalOutput = sequencerOutput;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java 2008-06-13 18:16:28 UTC
(rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Path.java 2008-06-13 18:25:41 UTC
(rev 288)
@@ -185,6 +185,15 @@
public boolean isParentReference();
/**
+ * Get the raw string form of the segment using the {@link Path#NO_OP_ENCODER
no-op encoder}. This is equivalent to
+ * calling <code>getString(Path.NO_OP_ENCODER)</code>.
+ *
+ * @return the un-encoded string
+ * @see #getString(TextEncoder)
+ */
+ public String getUnencodedString();
+
+ /**
* Get the string form of the segment. The {@link #DEFAULT_ENCODER default
encoder} is used to encode characters in each
* of the path segments.
*
@@ -208,7 +217,7 @@
* prefix. The {@link #DEFAULT_ENCODER default encoder} is used to encode
characters in each of the path segments.
*
* @param namespaceRegistry the namespace registry that should be used to obtain
the prefix for the
- * {@link Name#getNamespaceUri() namespace URI} in the segment's {@link
#getName() name}
+ * {@link Name#getNamespaceUri() namespace URI} in the segment's
{@link #getName() name}
* @return the encoded string
* @throws IllegalArgumentException if the namespace registry is null
* @see #getString(NamespaceRegistry,TextEncoder)
@@ -220,13 +229,14 @@
* to a prefix and the supplied encoder to encode characters in each of the path
segments.
*
* @param namespaceRegistry the namespace registry that should be used to obtain
the prefix for the
- * {@link Name#getNamespaceUri() namespace URI} in the segment's {@link
#getName() name}
+ * {@link Name#getNamespaceUri() namespace URI} in the segment's
{@link #getName() name}
* @param encoder the encoder to use, or null if the {@link #DEFAULT_ENCODER
default encoder} should be used
* @return the encoded string
* @throws IllegalArgumentException if the namespace registry is null
* @see #getString(NamespaceRegistry)
*/
- public String getString( NamespaceRegistry namespaceRegistry, TextEncoder encoder
);
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder );
}
/**
@@ -417,7 +427,7 @@
* @param beginIndex the beginning index, inclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the <code>beginIndex</code> is
negative or larger than the length of this
- * <code>Path</code> object
+ * <code>Path</code> object
*/
public Path subpath( int beginIndex );
@@ -429,9 +439,11 @@
* @param endIndex the ending index, exclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the <code>beginIndex</code> is
negative, or <code>endIndex</code> is larger
- * than the length of this <code>Path</code> object, or
<code>beginIndex</code> is larger than <code>endIndex</code>.
+ * than the length of this <code>Path</code> object, or
<code>beginIndex</code> is larger than
+ * <code>endIndex</code>.
*/
- public Path subpath( int beginIndex, int endIndex );
+ public Path subpath( int beginIndex,
+ int endIndex );
/**
* {@inheritDoc}
@@ -475,7 +487,7 @@
* The {@link #DEFAULT_ENCODER default encoder} is used to encode characters in each
of the path segments.
*
* @param namespaceRegistry the namespace registry that should be used to obtain the
prefix for the
- * {@link Name#getNamespaceUri() namespace URIs} in the segment {@link
Segment#getName() names}
+ * {@link Name#getNamespaceUri() namespace URIs} in the segment {@link
Segment#getName() names}
* @return the encoded string
* @throws IllegalArgumentException if the namespace registry is null
* @see #getString(NamespaceRegistry,TextEncoder)
@@ -487,12 +499,13 @@
* prefixes and the supplied encoder to encode characters in each of the path
segments.
*
* @param namespaceRegistry the namespace registry that should be used to obtain the
prefix for the
- * {@link Name#getNamespaceUri() namespace URIs} in the segment {@link
Segment#getName() names}
+ * {@link Name#getNamespaceUri() namespace URIs} in the segment {@link
Segment#getName() names}
* @param encoder the encoder to use, or null if the {@link #DEFAULT_ENCODER default
encoder} should be used
* @return the encoded string
* @throws IllegalArgumentException if the namespace registry is null
* @see #getString(NamespaceRegistry)
*/
- public String getString( NamespaceRegistry namespaceRegistry, TextEncoder encoder );
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder );
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PathFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -37,7 +37,7 @@
*
* @return the new path
*/
- Path create();
+ Path createRootPath();
/**
* Create an absolute path with the supplied segment names, in order. If no segments
are provided, the result will be the root
@@ -47,7 +47,7 @@
* @return the new path
* @throws IllegalArgumentException if at least one segment name is provided and if
any of the supplied segment names are null
*/
- Path create( Name... segmentNames );
+ Path createAbsolutePath( Name... segmentNames );
/**
* Create an absolute path with the supplied segments, in order. If no segments are
provided, the result will be the root
@@ -57,7 +57,7 @@
* @return the new path
* @throws IllegalArgumentException if at least one segment is provided and if any of
the supplied segments are null
*/
- Path create( Path.Segment... segments );
+ Path createAbsolutePath( Path.Segment... segments );
/**
* Create an empty relative path (i.e., equivalent to {@link
#createRelativePath(Path.Segment...) createRelativePath}({@link Path#SELF_SEGMENT})).
@@ -95,7 +95,9 @@
* @return the new path
* @throws IllegalArgumentException if the parent path reference or the segment name
is null, or if the index is invalid
*/
- Path create( Path parentPath, Name segmentName, int index );
+ Path create( Path parentPath,
+ Name segmentName,
+ int index );
/**
* Create a path by appending the supplied names to the parent path. If no names are
appended, the parent path is returned.
@@ -104,9 +106,10 @@
* @param segmentNames the names of the segments that are to be appended, in order,
to the parent path
* @return the new path
* @throws IllegalArgumentException if the parent path reference is null, or if at
least one segment name is provided and if
- * any of the supplied segment names are null
+ * any of the supplied segment names are null
*/
- Path create( Path parentPath, Name... segmentNames );
+ Path create( Path parentPath,
+ Name... segmentNames );
/**
* Create a path by appending the supplied names to the parent path. If no names are
appended, the parent path is returned.
@@ -115,9 +118,10 @@
* @param segments the segments that are to be appended, in order, to the parent
path
* @return the new path
* @throws IllegalArgumentException if the parent path reference is null, or if at
least one segment name is provided and if
- * any of the supplied segment names are null
+ * any of the supplied segment names are null
*/
- Path create( Path parentPath, Path.Segment... segments );
+ Path create( Path parentPath,
+ Path.Segment... segments );
/**
* Create a path segment given the supplied segment name. The resulting segment will
have no index.
@@ -125,7 +129,7 @@
* @param segmentName the name of the segment
* @return the segment
* @throws IllegalArgumentException if the segment name reference is
<code>null</code> or the value could not be created
- * from the supplied string
+ * from the supplied string
*/
Path.Segment createSegment( String segmentName );
@@ -136,9 +140,10 @@
* @param decoder the decoder that should be used to decode the qualified name
* @return the segment
* @throws IllegalArgumentException if the segment name reference is
<code>null</code> or the value could not be created
- * from the supplied string
+ * from the supplied string
*/
- Path.Segment createSegment( String segmentName, TextDecoder decoder );
+ Path.Segment createSegment( String segmentName,
+ TextDecoder decoder );
/**
* Create a path segment given the supplied segment name and index.
@@ -148,7 +153,8 @@
* @return the segment
* @throws IllegalArgumentException if the segment name reference is
<code>null</code> or if the index is invalid
*/
- Path.Segment createSegment( String segmentName, int index );
+ Path.Segment createSegment( String segmentName,
+ int index );
/**
* Create a path segment given the supplied segment name. The resulting segment will
have no index.
@@ -167,6 +173,7 @@
* @return the segment
* @throws IllegalArgumentException if the segment name reference is null or if the
index is invalid
*/
- Path.Segment createSegment( Name segmentName, int index );
+ Path.Segment createSegment( Name segmentName,
+ int index );
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Property.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Property.java 2008-06-13 18:16:28
UTC (rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/Property.java 2008-06-13 18:25:41
UTC (rev 288)
@@ -21,8 +21,6 @@
*/
package org.jboss.dna.spi.graph;
-import java.math.BigDecimal;
-import java.net.URI;
import java.util.Iterator;
import net.jcip.annotations.Immutable;
@@ -43,13 +41,6 @@
Name getName();
/**
- * Get the name of the property's definition.
- *
- * @return the property definition's name; never null
- */
- Name getDefinitionName();
-
- /**
* Get the number of actual values in this property. If the property allows {@link
#isMultiple() multiple values}, then this
* method may return a value greater than 1. If the property only allows a {@link
#isSingle() single value}, then this method
* will return either 0 or 1. This method may return 0 regardless of whether the
property allows a
@@ -91,15 +82,7 @@
boolean isEmpty();
/**
- * Get the type for this property.
- *
- * @return the property's type, which is never null
- */
- PropertyType getPropertyType();
-
- /**
- * Obtain the property's values in their natural form, as defined by {@link
#getPropertyType()}. This is equivalent to
- * calling {@link Iterable#iterator() iterator()}.
+ * Obtain the property's values in their natural form. This is equivalent to
calling {@link Iterable#iterator() iterator()}.
* <p>
* A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
* </p>
@@ -114,7 +97,7 @@
Iterator<?> getValues();
/**
- * Obtain the property's values as an array of objects in their natural form, as
defined by {@link #getPropertyType()}.
+ * Obtain the property's values as an array of objects in their natural form.
* <p>
* A valid array is return if the property has {@link #isSingle() single valued} or
{@link #isMultiple() multi-valued}, or a
* null value is returned if the property is {@link #isEmpty() empty}.
@@ -129,181 +112,4 @@
*/
Object[] getValuesAsArray();
- /**
- * Obtain the property's values in their natural form, converting the values to
the supplied {@link PropertyType} if it is
- * different than this property's {@link #getPropertyType() property type}. Note
that it is not always possible to convert
- * between PropertyTypes.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @param type the property type defining the form of the values to be returned; if
null, the
- * {@link #getPropertyType() property's type} is used
- * @return an iterator over the values; never null
- */
- Iterator<?> getValues( PropertyType type );
-
- /**
- * Obtain the property's values as String objects, converting the values if the
{@link #getPropertyType() property type} is
- * not {@link PropertyType#STRING}. Note that it is always possible to convert to a
String value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the String values; never null
- */
- Iterator<String> getStringValues();
-
- /**
- * Obtain the property's values as Binary objects, converting the values if the
{@link #getPropertyType() property type} is
- * not {@link PropertyType#BINARY}. Note that it is always possible to convert to a
{@link Binary} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the {@link Binary} values; never null
- */
- Iterator<Binary> getBinaryValues();
-
- /**
- * Obtain the property's values as longs, converting the values if the {@link
#getPropertyType() property type} is not
- * {@link PropertyType#LONG}. Note that it is not always possible to convert to a
{@link PropertyType#LONG long} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the long values; never null
- */
- Iterator<Long> getLongValues();
-
- /**
- * Obtain the property's values as doubles, converting the values if the {@link
#getPropertyType() property type} is not
- * {@link PropertyType#DOUBLE}. Note that it is not always possible to convert to a
{@link PropertyType#DOUBLE double} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the double values; never null
- */
- Iterator<Double> getDoubleValues();
-
- /**
- * Obtain the property's values as decimal values, converting the values if the
{@link #getPropertyType() property type} is
- * not {@link PropertyType#DECIMAL}. Note that it is not always possible to convert
to a {@link PropertyType#DECIMAL decimal}
- * value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the decimal values; never null
- */
- Iterator<BigDecimal> getDecimalValues();
-
- /**
- * Obtain the property's values as {@link DateTime dates}, converting the values
if the
- * {@link #getPropertyType() property type} is not {@link PropertyType#DATE}. Note
that it is not always possible to convert
- * to a {@link PropertyType#DATE date} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the DateTime values; never null
- */
- Iterator<DateTime> getDateValues();
-
- /**
- * Obtain the property's values as booleans, converting the values if the {@link
#getPropertyType() property type} is not
- * {@link PropertyType#BOOLEAN}. Note that it is not always possible to convert to a
{@link PropertyType#BOOLEAN boolean}
- * value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the Boolean values; never null
- */
- Iterator<Boolean> getBooleanValues();
-
- /**
- * Obtain the property's values as {@link Name names}, converting the values if
the {@link #getPropertyType() property type}
- * is not {@link PropertyType#NAME}. Note that it is not always possible to convert
to a {@link PropertyType#NAME long}
- * value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the Name values; never null
- */
- Iterator<Name> getNameValues();
-
- /**
- * Obtain the property's values as {@link Path paths}, converting the values if
the {@link #getPropertyType() property type}
- * is not {@link PropertyType#PATH}. Note that it is not always possible to convert
to a {@link PropertyType#PATH path}
- * value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the Path values; never null
- */
- Iterator<Path> getPathValues();
-
- /**
- * Obtain the property's values as references, converting the values if the
{@link #getPropertyType() property type} is not
- * {@link PropertyType#REFERENCE}. Note that it is not always possible to convert to
a
- * {@link PropertyType#REFERENCE reference} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the Reference values; never null
- */
- Iterator<Reference> getReferenceValues();
-
- /**
- * Obtain the property's values as {@link URI URIs}, converting the values if the
{@link #getPropertyType() property type} is
- * not {@link PropertyType#URI}. Note that it is not always possible to convert to a
{@link PropertyType#URI URI} value.
- * <p>
- * A valid iterator is returned if the property has {@link #isSingle() single valued}
or {@link #isMultiple() multi-valued}.
- * </p>
- * <p>
- * The resulting iterator is immutable, and all property values are immutable.
- * </p>
- *
- * @return an iterator over the URI values; never null
- */
- Iterator<URI> getUriValues();
-
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -27,11 +27,70 @@
* @author Randall Hauch
*/
public interface PropertyFactory {
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ Object... values );
- Property create( Name name, PropertyType type, Name definitionName, Object... values
);
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ Iterable<?> values );
- Property create( Name name, PropertyType type, Name definitionName, Iterable<?>
values );
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ Iterator<?> values );
- Property create( Name name, PropertyType type, Name definitionName, Iterator<?>
values );
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param desiredType the type that the objects should be converted to; if null, they
will be used as is
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ PropertyType desiredType,
+ Object... values );
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param desiredType the type that the objects should be converted to; if null, they
will be used as is
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ PropertyType desiredType,
+ Iterable<?> values );
+
+ /**
+ * Create a property with the supplied name and values
+ *
+ * @param name the property name; may not be null
+ * @param desiredType the type that the objects should be converted to; if null, they
will be used as is
+ * @param values the values
+ * @return the resulting property
+ */
+ Property create( Name name,
+ PropertyType desiredType,
+ Iterator<?> values );
+
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -228,4 +228,154 @@
*/
T create( Object value ) throws IoException;
+ /**
+ * Create an array of values from an array of string values, using no decoding.
+ *
+ * @param values the values
+ * @return the values, or null if the supplied string is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ * @see #create(String[], TextDecoder)
+ */
+ T[] create( String[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of strings, using the supplied decoder.
+ *
+ * @param values the string values from which the values are to be created
+ * @param decoder the decoder that should be used; if null, the {@link
#DEFAULT_DECODER default decoder} is used
+ * @return the value, or null if the supplied string is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ * @see #create(String)
+ */
+ T[] create( String[] values,
+ TextDecoder decoder ) throws IoException;
+
+ /**
+ * Create an array of values from an array of integers.
+ *
+ * @param values the integers from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( int[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of longs.
+ *
+ * @param values the longs from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( long[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of booleans.
+ *
+ * @param values the booleans from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( boolean[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of booleans.
+ *
+ * @param values the floats from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( float[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of doubles.
+ *
+ * @param values the doubles from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( double[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of decimal values.
+ *
+ * @param values the decimals from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( BigDecimal[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of Calendar instances.
+ *
+ * @param values the Calendar instances from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Calendar[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of dates.
+ *
+ * @param values the dates from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Date[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of names.
+ *
+ * @param values the names from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Name[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of paths.
+ *
+ * @param values the paths from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Path[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of references.
+ *
+ * @param values the references from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Reference[] values ) throws IoException;
+
+ /**
+ * Create an array of values from an array of URIs.
+ *
+ * @param values the URIs from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( URI[] values ) throws IoException;
+
+ /**
+ * Create an array of values from the array of binary content.
+ *
+ * @param values the array of content to be used to create the values
+ * @return the value, or null if the supplied array is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( byte[][] values ) throws IoException;
+
+ /**
+ * Create an array of values from the specified information by determining which
other <code>create</code> method applies
+ * for each object and then delegating to that method. Note that this method will not
consider
+ * {@link #create(InputStream, int)}, {@link #create(Reader, int)} and {@link
#create(String, TextDecoder)}.
+ *
+ * @param values the values
+ * @return the new value, or null if the supplied parameter is null
+ * @throws IoException If an unexpected problem occurs during the conversion.
+ */
+ T[] create( Object[] values ) throws IoException;
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/ActsOnProperties.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -28,12 +28,14 @@
* Aspect interface for any repository command that acts upon or updates properties on a
given node. This aspect also allows for
* the recipient to {@link Cacheable#setCachePolicy(org.jboss.dna.spi.cache.CachePolicy)
update the cache policy} for the updated
* information.
+ *
* @author Randall Hauch
*/
-public interface ActsOnProperties extends ActsOnPath, Cacheable {
+public interface ActsOnProperties extends ActsOnPath {
/**
* Get the properties. Any property with no values will be removed.
+ *
* @return the properties
*/
Iterable<Property> getProperties();
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/CreateNodeCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -22,19 +22,28 @@
package org.jboss.dna.spi.graph.commands;
import java.util.Iterator;
-import org.jboss.dna.spi.cache.Cacheable;
import org.jboss.dna.spi.graph.Property;
/**
* A command to get the children of a single node given its path.
+ *
* @author Randall Hauch
*/
-public interface CreateNodeCommand extends GraphCommand, ActsOnPath, Cacheable,
ActsOnProperties, ActsAsUpdate {
+public interface CreateNodeCommand
+ extends GraphCommand, ActsOnPath, ActsOnProperties, ActsAsUpdate,
Comparable<CreateNodeCommand> {
/**
* Get the properties for this new node. The recipient of the command should {@link
Iterator#remove() remove} any property
* that will not be stored.
+ *
* @return the property iterator; never null, but possibly empty
*/
Iterable<Property> getProperties();
+
+ /**
+ * Get the desired behavior when a node at the target {@link ActsOnPath#getPath()
path} already exists.
+ *
+ * @return the desired behavior; never null
+ */
+ NodeConflictBehavior getConflictBehavior();
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetChildrenCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -41,7 +41,8 @@
* </p>
* <p>
* The caller may supply a custom iterator implementation, which will be called on
this same connection within the same
- * transaction when the node data is processed and consumed.
+ * transaction when the node data is processed and consumed. This is useful, for
example, if the iterator to transparently
+ * page through the information without requiring all children to be pulled into
memory.
* </p>
*
* @param namesOfChildren the iterator over the names of children; may be null if
there are no children
@@ -55,8 +56,9 @@
* The indexes of the same-name siblings will be determined by the order in which
they appear in the iterator.
* </p>
* <p>
- * The caller may supply a custom iterator implementation, which will be called on
this same connection within the same
- * transaction when the node data is processed and consumed.
+ * The caller may supply a custom {@link Iterable} implementation, which will be
called on this same connection within the
+ * same transaction when the node data is processed and consumed. This is useful, for
example, if the iterator to
+ * transparently page through the information without requiring all children to be
pulled into memory.
* </p>
*
* @param namesOfChildren the iterable names of children; may be null if there are no
children
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetPropertiesCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetPropertiesCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GetPropertiesCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -21,9 +21,8 @@
*/
package org.jboss.dna.spi.graph.commands;
-import java.util.Iterator;
import org.jboss.dna.spi.cache.Cacheable;
-import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Property;
/**
* A command to obtain from the source the properties for a single node given its path.
@@ -35,34 +34,9 @@
/**
* Set the values for the named property. Any existing property values, if previously
set, will be overwritten. If there are
* no property vlaues or if all of the property values are null, the property will be
removed.
- * <p>
- * The implementation should be capable of accepting an array, {@link Iterator}, or
{@link Iterable} as a sole single
- * parameter, and properly extracting the values. This is so that callers that have
an {@link Object} reference to an array,
- * Iterator, or Iterable don't need to type check and cast in order to call
{@link #setProperty(Name, Iterable...) the}
- * {@link #setProperty(Name, Iterator...) appropriate} method.
- * </p>
*
- * @param propertyName the name of the property
- * @param values the property values
+ * @param property the property
*/
- void setProperty( Name propertyName, Object... values );
+ void setProperty( Property property );
- /**
- * Set the values for the named property. Any existing property values, if previously
set, will be overwritten. If there are
- * no property vlaues or if all of the property values are null, the property will be
removed.
- *
- * @param propertyName the name of the property
- * @param values the iterable property values
- */
- void setProperty( Name propertyName, Iterable<?> values );
-
- /**
- * Set the values for the named property. Any existing property values, if previously
set, will be overwritten. If there are
- * no property vlaues or if all of the property values are null, the property will be
removed.
- *
- * @param propertyName the name of the property
- * @param values the iterator over the property values
- */
- void setProperty( Name propertyName, Iterator<?> values );
-
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/MoveBranchCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/MoveBranchCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/MoveBranchCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -25,13 +25,22 @@
/**
* Command that moves a branch from one path to another.
+ *
* @author Randall Hauch
*/
public interface MoveBranchCommand extends GraphCommand, ActsOnPath, ActsAsUpdate {
/**
* Get the new path to which the branch is to be moved.
+ *
* @return the new path; never null
*/
Path getNewPath();
+
+ /**
+ * Get the desired behavior when a node at the target {@link ActsOnPath#getPath()
path} already exists.
+ *
+ * @return the desired behavior; never null
+ */
+ NodeConflictBehavior getConflictBehavior();
}
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/NodeConflictBehavior.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/NodeConflictBehavior.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/NodeConflictBehavior.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.dna.spi.graph.commands;
+
+/**
+ * An enumeration used by several commands for the choice of handling duplicate nodes,
such as when a node is to be copied to
+ * another location where a node already exists.
+ *
+ * @author Randall Hauch
+ */
+public enum NodeConflictBehavior {
+
+ DO_NOT_REPLACE,
+ APPEND,
+ REPLACE;
+
+}
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/RecordBranchCommand.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/RecordBranchCommand.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/RecordBranchCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.dna.spi.graph.commands;
+
+import java.util.Iterator;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+
+/**
+ * Command that records the structure of a branch. To process this command, the recipient
should walk the branch rooted at
+ * {@link ActsOnPath#getPath()} and, for each node in the branch, {@link #record(Path,
Iterable)} the node's information. If
+ * {@link #record(Path, Iterable)} returns true, then the children of that node should
also be recorded; if false, then the
+ * recording the children of that node can be ignored.
+ *
+ * @author Randall Hauch
+ */
+public interface RecordBranchCommand extends GraphCommand, ActsOnPath {
+
+ /**
+ * Sets the properties of the supplied node.
+ * <p>
+ * If the supplied path is a relative path, it is assumed to be relative to the
{@link ActsOnPath#getPath() branch root}. If
+ * the supplied path is an absolute path, it must be a {@link
Path#isDecendantOf(Path) decendant} of the
+ * {@link ActsOnPath#getPath() branch root}; if not, this method returns false and
ignores the call.
+ * </p>
+ * <p>
+ * This method should not be called multiple times with the same path. The behavior
for such cases is not defined.
+ * </p>
+ *
+ * @param path the path for the node; may not be null
+ * @param properties the properties for the node; may be null if there are no
properties
+ * @return true if the children of the node should be recorded, or false if this new
node is as deep as the recording should
+ * go
+ */
+ boolean record( Path path,
+ Iterable<Property> properties );
+
+ /**
+ * Sets the properties of the supplied node.
+ * <p>
+ * If the supplied path is a relative path, it is assumed to be relative to the
{@link ActsOnPath#getPath() branch root}. If
+ * the supplied path is an absolute path, it must be a {@link
Path#isDecendantOf(Path) decendant} of the
+ * {@link ActsOnPath#getPath() branch root}; if not, this method returns false and
ignores the call.
+ * </p>
+ * <p>
+ * This method should not be called multiple times with the same path. The behavior
for such cases is not defined.
+ * </p>
+ *
+ * @param path the path for the node; may not be null
+ * @param properties the properties for the node; may be null if there are no
properties
+ * @return true if the children of the node should be recorded, or false if this new
node is as deep as the recording should
+ * go
+ */
+ boolean record( Path path,
+ Iterator<Property> properties );
+
+ /**
+ * Sets the properties of the supplied node.
+ * <p>
+ * If the supplied path is a relative path, it is assumed to be relative to the
{@link ActsOnPath#getPath() branch root}. If
+ * the supplied path is an absolute path, it must be a {@link
Path#isDecendantOf(Path) decendant} of the
+ * {@link ActsOnPath#getPath() branch root}; if not, this method returns false and
ignores the call.
+ * </p>
+ * <p>
+ * This method should not be called multiple times with the same path. The behavior
for such cases is not defined.
+ * </p>
+ *
+ * @param path the path for the node; may not be null
+ * @param properties the properties for the node; may be null if there are no
properties
+ * @return true if the children of the node should be recorded, or false if this new
node is as deep as the recording should
+ * go
+ */
+ boolean record( Path path,
+ Property... properties );
+
+}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicCreateNodeCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -23,10 +23,10 @@
import java.util.List;
import net.jcip.annotations.NotThreadSafe;
-import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.commands.CreateNodeCommand;
+import org.jboss.dna.spi.graph.commands.NodeConflictBehavior;
/**
* @author Randall Hauch
@@ -39,20 +39,23 @@
private static final long serialVersionUID = -5452285887178397354L;
private final Path path;
private final List<Property> properties;
- private CachePolicy cachePolicy;
- private long timeLoaded;
+ private final NodeConflictBehavior conflictBehavior;
/**
* @param path the path to the node; may not be null
* @param properties the properties of the node; may not be null
+ * @param conflictBehavior the desired behavior when a node exists at the
<code>path</code>; may not be null
*/
public BasicCreateNodeCommand( Path path,
- List<Property> properties ) {
+ List<Property> properties,
+ NodeConflictBehavior conflictBehavior ) {
super();
assert path != null;
assert properties != null;
+ assert conflictBehavior != null;
this.properties = properties;
this.path = path;
+ this.conflictBehavior = conflictBehavior;
}
/**
@@ -72,29 +75,36 @@
/**
* {@inheritDoc}
*/
- public CachePolicy getCachePolicy() {
- return cachePolicy;
+ public NodeConflictBehavior getConflictBehavior() {
+ return this.conflictBehavior;
}
/**
* {@inheritDoc}
*/
- public long getTimeLoaded() {
- return timeLoaded;
+ public int compareTo( CreateNodeCommand that ) {
+ if (this == that) return 0;
+ return this.path.compareTo(that.getPath());
}
/**
- * @param timeLoaded Sets timeLoaded to the specified value.
+ * {@inheritDoc}
*/
- public void setTimeLoaded( long timeLoaded ) {
- this.timeLoaded = timeLoaded;
+ @Override
+ public int hashCode() {
+ return path.hashCode();
}
/**
* {@inheritDoc}
*/
- public void setCachePolicy( CachePolicy cachePolicy ) {
- this.cachePolicy = cachePolicy;
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof CreateNodeCommand) {
+ CreateNodeCommand that = (CreateNodeCommand)obj;
+ return this.path.equals(that.getPath());
+ }
+ return false;
}
-
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGetPropertiesCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -22,13 +22,12 @@
package org.jboss.dna.spi.graph.commands.impl;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.commands.GetPropertiesCommand;
/**
@@ -40,7 +39,7 @@
/**
*/
private static final long serialVersionUID = -7816393217506909521L;
- private final Map<Name, List<Object>> propertyValues = new
HashMap<Name, List<Object>>();
+ private final Map<Name, Property> properties = new HashMap<Name,
Property>();
private final Path path;
private CachePolicy cachePolicy;
private long timeLoaded;
@@ -57,31 +56,19 @@
/**
* {@inheritDoc}
*/
- public void setProperty( Name propertyName, Object... values ) {
- setProperty(propertyValues, propertyName, values);
+ public void setProperty( Property property ) {
+ if (property != null) {
+ properties.put(property.getName(), property);
+ }
}
/**
- * {@inheritDoc}
- */
- public void setProperty( Name propertyName, Iterable<?> values ) {
- setProperty(propertyValues, propertyName, values);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setProperty( Name propertyName, Iterator<?> values ) {
- setProperty(propertyValues, propertyName, values);
- }
-
- /**
* Get the property values that were added to the command
*
* @return the map of property name to values
*/
- public Map<Name, List<Object>> getPropertyValues() {
- return this.propertyValues;
+ public Iterable<Property> getProperties() {
+ return this.properties.values();
}
/**
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicMoveBranchCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicMoveBranchCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicMoveBranchCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -24,6 +24,7 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.commands.MoveBranchCommand;
+import org.jboss.dna.spi.graph.commands.NodeConflictBehavior;
/**
* @author Randall Hauch
@@ -33,17 +34,23 @@
private final Path oldPath;
private final Path newPath;
+ private final NodeConflictBehavior conflictBehavior;
/**
* @param oldPath the path to the original; may not be null
* @param newPath the path to the new location; may not be null
+ * @param conflictBehavior the desired behavior when a node exists at the
<code>path</code>; may not be null
*/
- public BasicMoveBranchCommand( Path oldPath, Path newPath ) {
+ public BasicMoveBranchCommand( Path oldPath,
+ Path newPath,
+ NodeConflictBehavior conflictBehavior ) {
super();
assert oldPath != null;
assert newPath != null;
+ assert conflictBehavior != null;
this.oldPath = oldPath;
this.newPath = newPath;
+ this.conflictBehavior = conflictBehavior;
}
/**
@@ -60,4 +67,11 @@
return newPath;
}
+ /**
+ * {@inheritDoc}
+ */
+ public NodeConflictBehavior getConflictBehavior() {
+ return conflictBehavior;
+ }
+
}
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicRecordBranchCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicRecordBranchCommand.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicRecordBranchCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.jboss.dna.spi.graph.commands.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.Property;
+import org.jboss.dna.spi.graph.commands.CreateNodeCommand;
+import org.jboss.dna.spi.graph.commands.NodeConflictBehavior;
+import org.jboss.dna.spi.graph.commands.RecordBranchCommand;
+
+/**
+ * @author Randall Hauch
+ */
+@NotThreadSafe
+public class BasicRecordBranchCommand extends BasicGraphCommand implements
RecordBranchCommand {
+
+ private final int maxDepth;
+ private final Path topOfBranch;
+ private final List<CreateNodeCommand> commands;
+ private final NodeConflictBehavior conflictBehavior;
+
+ /**
+ * @param topOfBranch the top node in the branch that is to be recorded; may not be
null
+ * @param conflictBehavior the desired behavior when a node exists at the
<code>path</code>; may not be null
+ */
+ public BasicRecordBranchCommand( Path topOfBranch,
+ NodeConflictBehavior conflictBehavior ) {
+ this(topOfBranch, conflictBehavior, null, Integer.MAX_VALUE);
+ }
+
+ /**
+ * @param topOfBranch the top node in the branch that is to be recorded; may not be
null
+ * @param conflictBehavior the desired behavior when a node exists at the
<code>path</code>; may not be null
+ * @param commands the list into which the {@link CreateNodeCommand}s should be
place; may be null
+ */
+ public BasicRecordBranchCommand( Path topOfBranch,
+ NodeConflictBehavior conflictBehavior,
+ List<CreateNodeCommand> commands ) {
+ this(topOfBranch, conflictBehavior, commands, Integer.MAX_VALUE);
+ }
+
+ /**
+ * @param topOfBranch the top node in the branch that is to be recorded; may not be
null
+ * @param conflictBehavior the desired behavior when a node exists at the
<code>path</code>; may not be null
+ * @param commands the list into which the {@link CreateNodeCommand}s should be
place; may be null
+ * @param maxDepthOfBranch the maximum depth of the branch that should be recorded,
or {@link Integer#MAX_VALUE} if there is
+ * no limit
+ */
+ public BasicRecordBranchCommand( Path topOfBranch,
+ NodeConflictBehavior conflictBehavior,
+ List<CreateNodeCommand> commands,
+ int maxDepthOfBranch ) {
+ super();
+ assert topOfBranch != null;
+ assert conflictBehavior != null;
+ assert maxDepthOfBranch > 0;
+ this.topOfBranch = topOfBranch;
+ this.maxDepth = maxDepthOfBranch;
+ this.conflictBehavior = conflictBehavior;
+ this.commands = commands != null ? commands : new
LinkedList<CreateNodeCommand>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Path getPath() {
+ return topOfBranch;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean record( Path path,
+ Iterable<Property> properties ) {
+ // Determine the relative path for this node ...
+ if (path.isAbsolute()) {
+ if (!path.isDecendantOf(this.topOfBranch)) return false;
+ path = path.relativeTo(this.topOfBranch);
+ }
+ int numberOfLevelsLeft = maxDepth - path.size();
+ if (numberOfLevelsLeft < 0) return false;
+ List<Property> propertyList = Collections.emptyList();
+ if (properties != null) {
+ if (properties instanceof List) {
+ propertyList = (List<Property>)properties;
+ } else {
+ propertyList = new LinkedList<Property>();
+ for (Property property : properties) {
+ propertyList.add(property);
+ }
+ }
+ }
+ record(new BasicCreateNodeCommand(path, propertyList, this.conflictBehavior));
+ return numberOfLevelsLeft > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean record( Path path,
+ Iterator<Property> properties ) {
+ int numberOfLevelsLeft = maxDepth - path.size();
+ if (numberOfLevelsLeft < 0) return false;
+ List<Property> propertyList = Collections.emptyList();
+ if (properties != null) {
+ propertyList = new LinkedList<Property>();
+ while (properties.hasNext()) {
+ Property property = properties.next();
+ propertyList.add(property);
+ }
+ }
+ record(new BasicCreateNodeCommand(path, propertyList, this.conflictBehavior));
+ return numberOfLevelsLeft > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean record( Path path,
+ Property... properties ) {
+ int numberOfLevelsLeft = maxDepth - path.size();
+ if (numberOfLevelsLeft < 0) return false;
+ List<Property> propertyList = Collections.emptyList();
+ if (properties != null) {
+ propertyList = new ArrayList<Property>(properties.length);
+ for (Property property : properties) {
+ propertyList.add(property);
+ }
+ }
+ record(new BasicCreateNodeCommand(path, propertyList, this.conflictBehavior));
+ return numberOfLevelsLeft > 0;
+ }
+
+ /**
+ * @return maxDepth
+ */
+ public int getMaxDepth() {
+ return this.maxDepth;
+ }
+
+ /**
+ * Method that is called whenver a node is recorded by the recipient of this command.
This implementation simply records it,
+ * but subclasses can override this method to respond immediately.
+ *
+ * @param command the command containing the node information; never null and always
above the
+ * {@link #getMaxDepth() maximum depth}.
+ */
+ protected void record( CreateNodeCommand command ) {
+ commands.add(command);
+ }
+
+ /**
+ * Return the commands to create the nodes, in the order they were recorded.
+ *
+ * @return the mutable list of {@link CreateNodeCommand create node commands}; never
null
+ */
+ public List<CreateNodeCommand> getCreateNodeCommands() {
+ return this.commands;
+ }
+}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicSetPropertiesCommand.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -23,7 +23,6 @@
import java.util.List;
import net.jcip.annotations.NotThreadSafe;
-import org.jboss.dna.spi.cache.CachePolicy;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
import org.jboss.dna.spi.graph.commands.SetPropertiesCommand;
@@ -39,14 +38,13 @@
private static final long serialVersionUID = -2693642411179501304L;
private final Path path;
private final List<Property> properties;
- private CachePolicy cachePolicy;
- private long timeLoaded;
/**
* @param path the path to the node; may not be null
* @param properties the properties of the node; may not be null
*/
- public BasicSetPropertiesCommand( Path path, List<Property> properties ) {
+ public BasicSetPropertiesCommand( Path path,
+ List<Property> properties ) {
super();
assert path != null;
assert properties != null;
@@ -67,33 +65,4 @@
public Iterable<Property> getProperties() {
return properties;
}
-
- /**
- * {@inheritDoc}
- */
- public CachePolicy getCachePolicy() {
- return cachePolicy;
- }
-
- /**
- * {@inheritDoc}
- */
- public long getTimeLoaded() {
- return timeLoaded;
- }
-
- /**
- * @param timeLoaded Sets timeLoaded to the specified value.
- */
- public void setTimeLoaded( long timeLoaded ) {
- this.timeLoaded = timeLoaded;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCachePolicy( CachePolicy cachePolicy ) {
- this.cachePolicy = cachePolicy;
- }
-
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/ExecutionEnvironment.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -46,13 +46,6 @@
NamespaceRegistry getNamespaceRegistry();
/**
- * Return the repository source against which this environment applies.
- *
- * @return the repository source; never null
- */
- RepositorySource getRepositorySource();
-
- /**
* Get the factory for creating {@link Property} objects.
*
* @return the property factory; never null
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySource.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySource.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/connection/RepositorySource.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -33,6 +33,11 @@
* leaving that entirely to the implementation classes.
* </p>
* <p>
+ * Implementations should also provide a no-arg constructor so that it is possible to
easily create instances and initialize using
+ * the standard getters and setters. One example where this is required is when a
RepositorySource instance is recorded in a
+ * repository (e.g., in a configuration area), and needs to be reinstantiated.
+ * </p>
+ * <p>
* Objects that implement this <code>RepositorySource</code> interface are
typically registered with a naming service such as
* Java Naming and Directory Interface<sup><font
size=-3>TM</font></sup> (JNDI). This interface extends both
* {@link Referenceable} and {@link Serializable} so that such objects can be stored in
any JNDI naming context and enable proper
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -30,6 +30,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
@@ -116,4 +117,215 @@
return create(value.toString());
}
+ protected abstract T[] createEmptyArray( int length );
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( BigDecimal[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( boolean[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( byte[][] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Calendar[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Date[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( double[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( float[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( int[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( long[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Name[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Object[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Path[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( Reference[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( String[] values,
+ TextDecoder decoder ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i], decoder);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( String[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T[] create( URI[] values ) throws IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicEmptyProperty.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicEmptyProperty.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicEmptyProperty.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -25,8 +25,6 @@
import java.util.NoSuchElementException;
import net.jcip.annotations.Immutable;
import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.PropertyType;
-import org.jboss.dna.spi.graph.ValueFactories;
/**
* @author Randall Hauch
@@ -36,12 +34,9 @@
/**
* @param name
- * @param type
- * @param definitionName
- * @param valueFactories
*/
- public BasicEmptyProperty( Name name, PropertyType type, Name definitionName,
ValueFactories valueFactories ) {
- super(name, type, definitionName, valueFactories);
+ public BasicEmptyProperty( Name name ) {
+ super(name);
}
/**
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicMultiValueProperty.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicMultiValueProperty.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicMultiValueProperty.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -25,8 +25,6 @@
import java.util.List;
import net.jcip.annotations.Immutable;
import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.PropertyType;
-import org.jboss.dna.spi.graph.ValueFactories;
/**
* @author Randall Hauch
@@ -38,13 +36,11 @@
/**
* @param name
- * @param type
- * @param definitionName
- * @param valueFactories
* @param values
*/
- public BasicMultiValueProperty( Name name, PropertyType type, Name definitionName,
ValueFactories valueFactories, List<Object> values ) {
- super(name, type, definitionName, valueFactories);
+ public BasicMultiValueProperty( Name name,
+ List<Object> values ) {
+ super(name);
this.values = values;
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPathSegment.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -30,6 +30,7 @@
/**
* A basic implementation of {@link Path.Segment}.
+ *
* @author Randall Hauch
*/
@Immutable
@@ -54,7 +55,8 @@
* @param index the segment index
* @throws IllegalArgumentException if the name is null or if the index is invalid
*/
- public BasicPathSegment( Name name, int index ) {
+ public BasicPathSegment( Name name,
+ int index ) {
ArgCheck.isNotNull(name, "name");
ArgCheck.isNotLessThan(index, Path.NO_INDEX, "index");
this.name = name;
@@ -142,6 +144,13 @@
/**
* {@inheritDoc}
*/
+ public String getUnencodedString() {
+ return getString(Path.NO_OP_ENCODER);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getString() {
return getString(Path.DEFAULT_ENCODER);
}
@@ -168,7 +177,8 @@
/**
* {@inheritDoc}
*/
- public String getString( NamespaceRegistry namespaceRegistry, TextEncoder encoder )
{
+ public String getString( NamespaceRegistry namespaceRegistry,
+ TextEncoder encoder ) {
ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
if (encoder == null) encoder = Path.DEFAULT_ENCODER;
String encodedName = this.getName().getString(namespaceRegistry, encoder);
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicProperty.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicProperty.java 2008-06-13
18:16:28 UTC (rev 287)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicProperty.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -21,19 +21,10 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.math.BigDecimal;
-import java.net.URI;
import java.util.Iterator;
import net.jcip.annotations.Immutable;
-import org.jboss.dna.spi.graph.Binary;
-import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Property;
-import org.jboss.dna.spi.graph.PropertyType;
-import org.jboss.dna.spi.graph.Reference;
-import org.jboss.dna.spi.graph.ValueFactories;
-import org.jboss.dna.spi.graph.ValueFactory;
/**
* @author Randall Hauch
@@ -42,21 +33,12 @@
public abstract class BasicProperty implements Property {
private final Name name;
- private final Name definitionName;
- private final PropertyType type;
- private final ValueFactories factories;
/**
* @param name
- * @param type
- * @param definitionName
- * @param valueFactories
*/
- public BasicProperty( Name name, PropertyType type, Name definitionName,
ValueFactories valueFactories ) {
+ public BasicProperty( Name name ) {
this.name = name;
- this.type = type;
- this.definitionName = definitionName;
- this.factories = valueFactories;
}
/**
@@ -69,97 +51,6 @@
/**
* {@inheritDoc}
*/
- public Name getDefinitionName() {
- return definitionName;
- }
-
- /**
- * {@inheritDoc}
- */
- public PropertyType getPropertyType() {
- return type;
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Binary> getBinaryValues() {
- return new ValueIterator<Binary>(factories.getBinaryFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Boolean> getBooleanValues() {
- return new ValueIterator<Boolean>(factories.getBooleanFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<DateTime> getDateValues() {
- return new ValueIterator<DateTime>(factories.getDateFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<BigDecimal> getDecimalValues() {
- return new ValueIterator<BigDecimal>(factories.getDecimalFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Double> getDoubleValues() {
- return new ValueIterator<Double>(factories.getDoubleFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Long> getLongValues() {
- return new ValueIterator<Long>(factories.getLongFactory(), iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Name> getNameValues() {
- return new ValueIterator<Name>(factories.getNameFactory(), iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Path> getPathValues() {
- return new ValueIterator<Path>(factories.getPathFactory(), iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<Reference> getReferenceValues() {
- return new ValueIterator<Reference>(factories.getReferenceFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<String> getStringValues() {
- return new ValueIterator<String>(factories.getStringFactory(),
iterator());
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<URI> getUriValues() {
- return new ValueIterator<URI>(factories.getUriFactory(), iterator());
- }
-
- /**
- * {@inheritDoc}
- */
public Iterator<?> getValues() {
return iterator();
}
@@ -167,39 +58,6 @@
/**
* {@inheritDoc}
*/
- public Iterator<?> getValues( PropertyType type ) {
- switch (type) {
- case BINARY:
- return getBinaryValues();
- case BOOLEAN:
- return getBooleanValues();
- case DATE:
- return getDateValues();
- case DECIMAL:
- return getDecimalValues();
- case DOUBLE:
- return getDoubleValues();
- case LONG:
- return getLongValues();
- case NAME:
- return getNameValues();
- case OBJECT:
- return getValues();
- case PATH:
- return getPathValues();
- case REFERENCE:
- return getReferenceValues();
- case STRING:
- return getStringValues();
- case URI:
- return getUriValues();
- }
- return getValues(); // should never get here ...
- }
-
- /**
- * {@inheritDoc}
- */
public Object[] getValuesAsArray() {
if (size() == 0) return null;
Object[] results = new Object[size()];
@@ -236,7 +94,6 @@
if (obj instanceof Property) {
Property that = (Property)obj;
if (!this.getName().equals(that.getName())) return false;
- if (this.getPropertyType() != that.getPropertyType()) return false;
if (this.size() != that.size()) return false;
Iterator<?> thisIter = iterator();
Iterator<?> thatIter = that.iterator();
@@ -254,40 +111,4 @@
}
return false;
}
-
- protected class ValueIterator<T> implements Iterator<T> {
-
- private final ValueFactory<T> factory;
- private final Iterator<Object> values;
-
- protected ValueIterator( ValueFactory<T> factory, Iterator<Object>
values ) {
- assert factory != null;
- assert values != null;
- this.factory = factory;
- this.values = values;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasNext() {
- return values.hasNext();
- }
-
- /**
- * {@inheritDoc}
- */
- public T next() {
- return factory.create(values.next());
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- }
-
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPropertyFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPropertyFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicPropertyFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -52,44 +52,71 @@
/**
* {@inheritDoc}
*/
- public Property create( Name name, PropertyType type, Name definitionName, Object...
values ) {
+ public Property create( Name name,
+ Iterable<?> values ) {
+ return create(name, PropertyType.OBJECT, values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Property create( Name name,
+ Iterator<?> values ) {
+ return create(name, PropertyType.OBJECT, values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Property create( Name name,
+ Object... values ) {
+ return create(name, PropertyType.OBJECT, values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Property create( Name name,
+ PropertyType desiredType,
+ Object... values ) {
ArgCheck.isNotNull(name, "name");
- ArgCheck.isNotNull(type, "type");
if (values == null || values.length == 0) {
- return new BasicEmptyProperty(name, type, definitionName, this.factories);
+ return new BasicEmptyProperty(name);
}
final int len = values.length;
- final ValueFactory<?> factory = factories.getValueFactory(type);
+ if (desiredType == null) desiredType = PropertyType.OBJECT;
+ final ValueFactory<?> factory = factories.getValueFactory(desiredType);
if (values.length == 1) {
Object value = values[0];
// Check whether the sole value was a collection ...
if (value instanceof Collection) {
// The single value is a collection, so create property with the
collection's contents ...
- return create(name, type, definitionName, (Collection<?>)value);
+ return create(name, (Collection<?>)value);
}
value = factory.create(values[0]);
- return new BasicSingleValueProperty(name, type, definitionName,
this.factories, value);
+ return new BasicSingleValueProperty(name, value);
}
List<Object> valueList = new ArrayList<Object>(len);
for (int i = 0; i != len; ++i) {
Object value = factory.create(values[i]);
valueList.add(value);
}
- return new BasicMultiValueProperty(name, type, definitionName, this.factories,
valueList);
+ return new BasicMultiValueProperty(name, valueList);
}
/**
* {@inheritDoc}
*/
@SuppressWarnings( "unchecked" )
- public Property create( Name name, PropertyType type, Name definitionName,
Iterable<?> values ) {
+ public Property create( Name name,
+ PropertyType desiredType,
+ Iterable<?> values ) {
ArgCheck.isNotNull(name, "name");
- ArgCheck.isNotNull(type, "type");
List<Object> valueList = null;
if (values instanceof Collection) {
Collection<Object> originalValues = (Collection<Object>)values;
if (originalValues.isEmpty()) {
- return new BasicEmptyProperty(name, type, definitionName,
this.factories);
+ return new BasicEmptyProperty(name);
}
valueList = new ArrayList<Object>(originalValues.size());
} else {
@@ -97,39 +124,42 @@
valueList = new ArrayList<Object>();
}
// Copy the values, ensuring that the values are the correct type ...
- final ValueFactory<?> factory = factories.getValueFactory(type);
+ if (desiredType == null) desiredType = PropertyType.OBJECT;
+ final ValueFactory<?> factory = factories.getValueFactory(desiredType);
for (Object value : values) {
valueList.add(factory.create(value));
}
if (valueList.isEmpty()) { // may not have been a collection earlier
- return new BasicEmptyProperty(name, type, definitionName, this.factories);
+ return new BasicEmptyProperty(name);
}
if (valueList.size() == 1) {
- return new BasicSingleValueProperty(name, type, definitionName,
this.factories, valueList.get(0));
+ return new BasicSingleValueProperty(name, valueList.get(0));
}
- return new BasicMultiValueProperty(name, type, definitionName, this.factories,
valueList);
+ return new BasicMultiValueProperty(name, valueList);
}
/**
* {@inheritDoc}
*/
- public Property create( Name name, PropertyType type, Name definitionName,
Iterator<?> values ) {
+ public Property create( Name name,
+ PropertyType desiredType,
+ Iterator<?> values ) {
ArgCheck.isNotNull(name, "name");
- ArgCheck.isNotNull(type, "type");
final List<Object> valueList = new ArrayList<Object>();
- final ValueFactory<?> factory = factories.getValueFactory(type);
+ if (desiredType == null) desiredType = PropertyType.OBJECT;
+ final ValueFactory<?> factory = factories.getValueFactory(desiredType);
while (values.hasNext()) {
Object value = values.next();
value = factory.create(value);
valueList.add(value);
}
if (valueList.isEmpty()) {
- return new BasicEmptyProperty(name, type, definitionName, this.factories);
+ return new BasicEmptyProperty(name);
}
if (valueList.size() == 1) {
- return new BasicSingleValueProperty(name, type, definitionName,
this.factories, valueList.get(0));
+ return new BasicSingleValueProperty(name, valueList.get(0));
}
- return new BasicMultiValueProperty(name, type, definitionName, this.factories,
valueList);
+ return new BasicMultiValueProperty(name, valueList);
}
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicSingleValueProperty.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicSingleValueProperty.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BasicSingleValueProperty.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -25,8 +25,6 @@
import java.util.NoSuchElementException;
import net.jcip.annotations.Immutable;
import org.jboss.dna.spi.graph.Name;
-import org.jboss.dna.spi.graph.PropertyType;
-import org.jboss.dna.spi.graph.ValueFactories;
/**
* @author Randall Hauch
@@ -38,13 +36,11 @@
/**
* @param name
- * @param type
- * @param definitionName
- * @param valueFactories
* @param value
*/
- public BasicSingleValueProperty( Name name, PropertyType type, Name definitionName,
ValueFactories valueFactories, Object value ) {
- super(name, type, definitionName, valueFactories);
+ public BasicSingleValueProperty( Name name,
+ Object value ) {
+ super(name);
this.value = value;
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -199,4 +199,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Boolean[] createEmptyArray( int length ) {
+ return new Boolean[length];
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -195,4 +195,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected BigDecimal[] createEmptyArray( int length ) {
+ return new BigDecimal[length];
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -202,4 +202,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Double[] createEmptyArray( int length ) {
+ return new Double[length];
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -193,8 +193,9 @@
byte[] value = IoUtil.readBytes(stream);
return create(value);
} catch (IOException err) {
- throw new
IoException(SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
-
Binary.class.getSimpleName()), err);
+ throw new IoException(
+
SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
Binary.class.getSimpleName()),
+ err);
}
}
@@ -209,8 +210,15 @@
String value = IoUtil.read(reader);
return create(this.getStringValueFactory().create(value));
} catch (IOException err) {
- throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
-
Binary.class.getSimpleName()), err);
+ throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
Binary.class.getSimpleName()), err);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Binary[] createEmptyArray( int length ) {
+ return new Binary[length];
+ }
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -247,4 +247,12 @@
return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond,
timeZoneId);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected DateTime[] createEmptyArray( int length ) {
+ return new DateTime[length];
+ }
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -196,4 +196,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Long[] createEmptyArray( int length ) {
+ return new Long[length];
+ }
+
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -297,4 +297,12 @@
public NamespaceRegistry getNamespaceRegistry() {
return namespaceRegistry;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Name[] createEmptyArray( int length ) {
+ return new Name[length];
+ }
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -185,4 +185,12 @@
return getBinaryValueFactory().create(reader, approximateLength);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object[] createEmptyArray( int length ) {
+ return new Object[length];
+ }
+
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -95,9 +95,9 @@
* {@inheritDoc}
* </p>
*
- * @see org.jboss.dna.spi.graph.PathFactory#create()
+ * @see org.jboss.dna.spi.graph.PathFactory#createRootPath()
*/
- public Path create() {
+ public Path createRootPath() {
return BasicPath.ROOT;
}
@@ -251,7 +251,7 @@
/**
* {@inheritDoc}
*/
- public Path create( Name... segmentNames ) {
+ public Path createAbsolutePath( Name... segmentNames ) {
if (segmentNames == null || segmentNames.length == 0) return BasicPath.ROOT;
List<Segment> segments = new
ArrayList<Segment>(segmentNames.length);
for (Name segmentName : segmentNames) {
@@ -266,7 +266,7 @@
/**
* {@inheritDoc}
*/
- public Path create( Segment... segments ) {
+ public Path createAbsolutePath( Segment... segments ) {
if (segments == null || segments.length == 0) return BasicPath.ROOT;
List<Segment> segmentsList = new
ArrayList<Segment>(segments.length);
for (Segment segment : segments) {
@@ -494,4 +494,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Path[] createEmptyArray( int length ) {
+ return new Path[length];
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -212,8 +212,9 @@
String.class.getSimpleName(),
value),
err);
} catch (IOException err) {
- throw new
IoException(SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
-
String.class.getSimpleName()), err);
+ throw new IoException(
+
SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
String.class.getSimpleName()),
+ err);
}
}
@@ -226,9 +227,16 @@
try {
return IoUtil.read(reader);
} catch (IOException err) {
- throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
-
String.class.getSimpleName()), err);
+ throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
String.class.getSimpleName()), err);
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String[] createEmptyArray( int length ) {
+ return new String[length];
+ }
+
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -214,4 +214,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected URI[] createEmptyArray( int length ) {
+ return new URI[length];
+ }
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -207,4 +207,12 @@
return create(getStringValueFactory().create(reader, approximateLength));
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Reference[] createEmptyArray( int length ) {
+ return new Reference[length];
+ }
+
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/connection/TimeDelayingRepositorySource.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -44,7 +44,7 @@
/**
*/
private static final long serialVersionUID = -2756725117087437347L;
- private final String identifier;
+ private String name;
private final AtomicInteger retryLimit = new AtomicInteger(0);
private final AtomicInteger connectionsOpenedCount = new AtomicInteger(0);
private final AtomicInteger connectionsClosedCount = new AtomicInteger(0);
@@ -56,17 +56,24 @@
private CachePolicy defaultCachePolicy;
public TimeDelayingRepositorySource( String identifier ) {
- this.identifier = identifier;
+ this.name = identifier;
}
/**
* {@inheritDoc}
*/
public String getName() {
- return this.identifier;
+ return this.name;
}
/**
+ * @param name the identifier
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
* {@inheritDoc}
*/
public int getRetryLimit() {
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-13
18:16:28 UTC (rev 287)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-13
18:25:41 UTC (rev 288)
@@ -126,6 +126,14 @@
int approximateLength ) {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String[] createEmptyArray( int length ) {
+ return new String[length];
+ }
}
private AbstractValueFactory<String> factory;