DNA SVN: r1522 - in trunk/dna-graph/src/main/java/org/jboss/dna/graph: request and 1 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2010-01-04 15:11:45 -0500 (Mon, 04 Jan 2010)
New Revision: 1522
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
Log:
DNA-549 Creating A New Property And Changing An Existing Property Should Have Different ChangeRequest Types: The request processor now sets the actual property on the UpdateValuesRequest. This property is used by the NetChangeObserver. Reviewed by Randall H.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -225,12 +225,18 @@
// the new location is a new node event
details.addEventType(ChangeType.NODE_ADDED);
} else if (change instanceof UpdateValuesRequest) {
- // TODO need to know if this is a new property
UpdateValuesRequest updateValuesRequest = (UpdateValuesRequest)change;
if (!updateValuesRequest.addedValues().isEmpty() || !updateValuesRequest.removedValues().isEmpty()) {
- details.addEventType(ChangeType.PROPERTY_CHANGED);
- // TODO need to set property like details.changeProperty(property);
+ assert (updateValuesRequest.getActualProperty() != null);
+
+ if (updateValuesRequest.isNewProperty()) {
+ details.addEventType(ChangeType.PROPERTY_ADDED);
+ details.addProperty(updateValuesRequest.getActualProperty());
+ } else {
+ details.addEventType(ChangeType.PROPERTY_CHANGED);
+ details.changeProperty(updateValuesRequest.getActualProperty());
+ }
} else if (details.getEventTypes().isEmpty()) {
// details was just created for this request and now it is not needed
deleteLocationDetails(workspace, location, detailsByLocationByWorkspace);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -2,6 +2,7 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.Name;
@@ -40,6 +41,7 @@
private List<Object> actualAddedValues;
private List<Object> actualRemovedValues;
private boolean actualCreation;
+ private Property actualProperty;
public UpdateValuesRequest( String workspaceName,
Location on,
@@ -150,15 +152,29 @@
/**
* Record that the property did not exist prior to the processing of this request and was actually created by this request.
- * This method must be called when processing the request, and the actual location must have a {@link Location#getPath() path}
- * .
+ * This method must be called when processing the request, and the actual location must have a {@link Location#getPath() path}.
*
+ * @param property the property being created or updated (may not be <code>null</code>)
* @param created true if the property was created by this request, or false if this request updated an existing property
* @throws IllegalStateException if the request is frozen
+ * @throws IllegalArgumentException if the property is <code>null</code>
*/
- public void setNewProperty( boolean created ) {
+ public void setActualProperty( Property property,
+ boolean created ) {
+ CheckArg.isNotNull(property, "property");
+ checkNotFrozen();
+ this.actualProperty = property;
this.actualCreation = created;
}
+
+ /**
+ * Get the actual node property that was created or updated.
+ *
+ * @return the actual property or <code>null</code> if the actual property was not set
+ */
+ public Property getActualProperty() {
+ return this.actualProperty;
+ }
/**
* Get the actual location of the node that was updated.
@@ -210,7 +226,11 @@
UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, actualLocation != null ? actualLocation : on,
propertyName, addedValues, removedValues);
request.setActualLocation(actualLocation, actualAddedValues, actualRemovedValues);
- request.setNewProperty(actualCreation);
+
+ // don't call request.setActualProperty(Property, boolean) here as the actual property may have not been set
+ request.actualProperty = actualProperty;
+ request.actualCreation = actualCreation;
+
return request;
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-04 19:10:52 UTC (rev 1521)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-04 20:11:45 UTC (rev 1522)
@@ -822,13 +822,13 @@
// Update the current values
SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
process(setProperty);
- request.setNewProperty(setProperty.isNewProperty());
if (setProperty.hasError()) {
request.setError(setProperty.getError());
} else {
- // Set the actual location ...
+ // Set the actual location and property
request.setActualLocation(setProperty.getActualLocationOfNode(), request.addedValues(), actualRemovedValues);
+ request.setActualProperty(newProperty, setProperty.isNewProperty());
}
}
14 years, 4 months
DNA SVN: r1521 - trunk/extensions/dna-search-lucene.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2010-01-04 14:10:52 -0500 (Mon, 04 Jan 2010)
New Revision: 1521
Modified:
trunk/extensions/dna-search-lucene/
Log:
ignoring target directory in extensions/dna-search-lucene
Property changes on: trunk/extensions/dna-search-lucene
___________________________________________________________________
Name: svn:ignore
+ target
14 years, 4 months
DNA SVN: r1520 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache and 6 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-04 10:33:19 -0500 (Mon, 04 Jan 2010)
New Revision: 1520
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/CacheStatistics.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/DefaultPathCachePolicy.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/InMemoryWorkspaceCache.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathCachePolicy.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathRepositoryCache.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/WorkspaceCache.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/package-info.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySourceTest.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractWritablePathWorkspace.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathRepository.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathWorkspace.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorWritableTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataSource.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java
Log:
DNA-615 PathRepository Should Provide Support for Caching
Applied patch that provides a default caching implementation for path-based repositories. The patch has the following salient features:
1. It adds a new base class (AbstractPathRepositorySource) for path repository sources that encapuslates some of the common required properties that have been cut-and-pasted a few times and manages the path repository cache for the source.
2. It adds PathRepositoryCache (a map of workspace names to WorkspaceCaches) and WorkspaceCache (a per-workspace Path to PathNode map).
3. It adds a beefed-up version of CachePolicy (called PathCachePolicy) that is used by the PathRepositoryCache to determine which implementation of WorkspaceCache to use. It is also used by the WorkspaceCache implementation to determine if a particular node should be cached, allowing for custom exclusion policies based on node size, node volatility, etc.
4. It integrates these changes with the FileSystemSource and JDBC Metadata source to demonstrate their efficacy.
It's fairly vanilla stuff, but it's built to be rather customizable. Also, changing the cache policy on the source at run-time is supported, so you're not limited to configuring the cache for a repo at startup.
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySource.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySource.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySource.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,237 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import javax.naming.BinaryRefAddr;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.connector.RepositoryContext;
+import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.path.cache.DefaultPathCachePolicy;
+import org.jboss.dna.graph.connector.path.cache.PathCachePolicy;
+import org.jboss.dna.graph.connector.path.cache.PathRepositoryCache;
+
+/**
+ * Basic implementation of the trivial {@link PathRepositorySource} methods and the {@link org.jboss.dna.graph.connector.path path
+ * repository cache life cycle}.
+ */
+public abstract class AbstractPathRepositorySource implements PathRepositorySource {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The default UUID that is used for root nodes in a store.
+ */
+ public static final String DEFAULT_ROOT_NODE_UUID = "cafebabe-cafe-babe-cafe-babecafebabe";
+
+ /**
+ * The default number of times that a request that failed due to system error should be retried
+ */
+ public static final int DEFAULT_RETRY_LIMIT = 0;
+
+ private static final int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS = 30;
+
+ /**
+ * The default cache policy for this repository source (cache all nodes which remain valid for 30 seconds)
+ */
+ public static final PathCachePolicy DEFAULT_CACHE_POLICY = new DefaultPathCachePolicy(DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS);
+
+ protected int retryLimit = DEFAULT_RETRY_LIMIT;
+ protected String name;
+
+ protected transient RepositoryContext repositoryContext;
+ protected transient UUID rootNodeUuid = UUID.fromString(DEFAULT_ROOT_NODE_UUID);
+ protected transient PathCachePolicy cachePolicy = DEFAULT_CACHE_POLICY;
+
+ private transient PathRepositoryCache repositoryCache = new PathRepositoryCache(cachePolicy);
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.path.PathRepositorySource#areUpdatesAllowed()
+ */
+ public boolean areUpdatesAllowed() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.path.PathRepositorySource#getRepositoryContext()
+ */
+ public RepositoryContext getRepositoryContext() {
+ return repositoryContext;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositorySource#initialize(RepositoryContext)
+ */
+ public void initialize( RepositoryContext context ) throws RepositorySourceException {
+ CheckArg.isNotNull(context, "context");
+ this.repositoryContext = context;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.path.PathRepositorySource#getCachePolicy()
+ */
+ public PathCachePolicy getCachePolicy() {
+ return this.cachePolicy;
+ }
+
+ /**
+ * Sets the cache policy for the repository and replaces the path repository cache with a new path repository cache tied to
+ * the new cache policy
+ *
+ * @param cachePolicy the new cache policy; may not be null
+ */
+ public void setCachePolicy( PathCachePolicy cachePolicy ) {
+ CheckArg.isNotNull(cachePolicy, "cachePolicy");
+
+ PathRepositoryCache oldCache = repositoryCache;
+ this.cachePolicy = cachePolicy;
+ this.repositoryCache = new PathRepositoryCache(cachePolicy);
+
+ oldCache.close();
+ }
+
+ /**
+ * @return rootNodeUuid
+ */
+ public UUID getRootNodeUuid() {
+ return rootNodeUuid;
+ }
+
+ /**
+ * @param rootNodeUuid Sets rootNodeUuid to the specified value.
+ * @throws IllegalArgumentException if the string value cannot be converted to UUID
+ */
+ public void setRootNodeUuid( String rootNodeUuid ) {
+ if (rootNodeUuid != null && rootNodeUuid.trim().length() == 0) rootNodeUuid = DEFAULT_ROOT_NODE_UUID;
+ this.rootNodeUuid = UUID.fromString(rootNodeUuid);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositorySource#close()
+ */
+ public void close() {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositorySource#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the repository source. The name should be unique among loaded repository sources.
+ *
+ * @param name the new name for the repository source; may not be empty
+ */
+ public void setName( String name ) {
+ if (name != null) {
+ name = name.trim();
+ if (name.length() == 0) name = null;
+ }
+
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositorySource#getRetryLimit()
+ */
+ public int getRetryLimit() {
+ return retryLimit;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositorySource#setRetryLimit(int limit)
+ */
+ public void setRetryLimit( int limit ) {
+ this.retryLimit = limit < 0 ? 0 : limit;
+ }
+
+ /**
+ * Extracts the values from the given reference, automatically translating {@link BinaryRefAddr} instances into the
+ * deserialized classes that they represent.
+ *
+ * @param ref the reference from which the values should be extracted
+ * @return a map of value names to values from the reference
+ * @throws IOException if there is an error deserializing a {@code BinaryRefAddr}
+ * @throws ClassNotFoundException if a serialized class cannot be deserialized because its class is not in the classpath
+ */
+ protected Map<String, Object> valuesFrom( Reference ref ) throws IOException, ClassNotFoundException {
+ Map<String, Object> values = new HashMap<String, Object>();
+
+ Enumeration<?> en = ref.getAll();
+ while (en.hasMoreElements()) {
+ RefAddr subref = (RefAddr)en.nextElement();
+ if (subref instanceof StringRefAddr) {
+ String key = subref.getType();
+ Object value = subref.getContent();
+ if (value != null) values.put(key, value.toString());
+ } else if (subref instanceof BinaryRefAddr) {
+ String key = subref.getType();
+ Object value = subref.getContent();
+ if (value instanceof byte[]) {
+ // Deserialize ...
+ ByteArrayInputStream bais = new ByteArrayInputStream((byte[])value);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ value = ois.readObject();
+ values.put(key, value);
+ }
+ }
+ }
+
+ return values;
+ }
+
+ /**
+ * @return the active path repository cache; never null
+ */
+ public PathRepositoryCache getPathRepositoryCache() {
+ return repositoryCache;
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySource.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractWritablePathWorkspace.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractWritablePathWorkspace.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/AbstractWritablePathWorkspace.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.graph.connector.path;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.jboss.dna.graph.ExecutionContext;
@@ -112,6 +113,17 @@
return newCopy;
}
+ public PathNode removeProperties( ExecutionContext context,
+ Path nodePath,
+ Iterable<Name> propertyNames ) {
+ Map<Name, Property> properties = new HashMap<Name, Property>();
+ for (Name propertyName : propertyNames) {
+ properties.put(propertyName, null);
+ }
+
+ return setProperties(context, nodePath, properties);
+ }
+
public QueryResults query( ExecutionContext context,
AccessQueryRequest accessQuery ) {
return null;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/DefaultPathNode.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -8,6 +8,8 @@
import java.util.Set;
import java.util.UUID;
import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.text.NoOpEncoder;
+import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
@@ -21,6 +23,8 @@
@Immutable
public class DefaultPathNode implements PathNode {
+ private final static TextEncoder TO_STRING_ENCODER = new NoOpEncoder();
+
private final Path path;
private final Map<Name, Property> properties;
private final List<Segment> childSegments;
@@ -94,5 +98,12 @@
return null;
}
+ @Override
+ public String toString() {
+ StringBuilder buff = new StringBuilder();
+ buff.append(path.getString(TO_STRING_ENCODER)).append('(').append(properties.keySet()).append(')');
+ return buff.toString();
+ }
+
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepository.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -20,38 +20,21 @@
protected final ConcurrentMap<String, PathWorkspace> workspaces = new ConcurrentHashMap<String, PathWorkspace>();
/**
- * Creates a {@code PathRepository} with the given repository source name, root node UUID, and a default workspace named
- * {@code ""} (the empty string).
+ * Creates a {@code PathRepository} with the given repository source, root node UUID, and a default workspace with the given
+ * name.
*
- * @param sourceName the name of the repository source for use in error and informational messages; may not be null or empty
- * @param rootNodeUuid the UUID that will be used as the root node UUID for each workspace in the repository; may not be null
- * or empty
+ * @param source the path repository source; may not be null
*/
- protected PathRepository( String sourceName,
- UUID rootNodeUuid ) {
- this(sourceName, rootNodeUuid, null);
+ protected PathRepository( PathRepositorySource source ) {
+ CheckArg.isNotNull(source, "source");
+ CheckArg.isNotEmpty(source.getName(), "source.name");
+ CheckArg.isNotNull(source.getRootNodeUuid(), "source.rootNodeUUID");
+ this.rootNodeUuid = source.getRootNodeUuid();
+ this.sourceName = source.getName();
+ this.defaultWorkspaceName = source.getDefaultWorkspaceName() != null ? source.getDefaultWorkspaceName() : "";
}
/**
- * Creates a {@code PathRepository} with the given repository source name, root node UUID, and a default workspace with the
- * given name.
- *
- * @param sourceName the name of the repository source for use in error and informational messages; may not be null or empty
- * @param rootNodeUuid the UUID that will be used as the root node UUID for each workspace in the repository; may not be null
- * or empty
- * @param defaultWorkspaceName the name of the default, auto-created workspace
- */
- protected PathRepository( String sourceName,
- UUID rootNodeUuid,
- String defaultWorkspaceName ) {
- CheckArg.isNotEmpty(sourceName, "sourceName");
- CheckArg.isNotNull(rootNodeUuid, "rootNodeUUID");
- this.rootNodeUuid = rootNodeUuid;
- this.sourceName = sourceName;
- this.defaultWorkspaceName = defaultWorkspaceName != null ? defaultWorkspaceName : "";
- }
-
- /**
* Returns the UUID used by the root nodes in each workspace.
* <p>
* Note that the root nodes themselves are distinct objects in each workspace and a change to the root node of one workspace
@@ -113,6 +96,7 @@
return false;
}
+
PathRequestProcessor createRequestProcessor( ExecutionContext context,
PathRepositorySource source ) {
RepositoryContext repositoryContext = source.getRepositoryContext();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryConnection.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -34,7 +34,7 @@
* {@inheritDoc}
*/
public CachePolicy getDefaultCachePolicy() {
- return source.getDefaultCachePolicy();
+ return source.getCachePolicy();
}
/**
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositorySource.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -1,8 +1,10 @@
package org.jboss.dna.graph.connector.path;
+import java.util.UUID;
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.RepositorySource;
+import org.jboss.dna.graph.connector.path.cache.PathCachePolicy;
/**
* An extension of the {@link RepositorySource} class that provides a {@link CachePolicy cache policy} and a
@@ -28,17 +30,30 @@
void setUpdatesAllowed( boolean updatesAllowed );
/**
- * Returns the {@link CachePolicy cache policy} for the repository source
+ * Returns the {@link PathCachePolicy cache policy} for the repository source
*
- * @return the {@link CachePolicy cache policy} for the repository source
+ * @return the {@link PathCachePolicy cache policy} for the repository source
*/
- CachePolicy getDefaultCachePolicy();
+ PathCachePolicy getCachePolicy();
/**
+ * Get the UUID that is used for the root node of each workspace
+ *
+ * @return the UUID that is used for the root node of each workspace
+ */
+ UUID getRootNodeUuid();
+
+ /**
+ * Get the name of the default workspace.
+ *
+ * @return the name of the workspace that should be used by default; never null
+ */
+ String getDefaultWorkspaceName();
+
+ /**
* Returns the {@link RepositoryContext repository context} for the repository source
*
* @return the {@link RepositoryContext repository context} for the repository source
*/
RepositoryContext getRepositoryContext();
-
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRequestProcessor.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -498,7 +498,7 @@
WritablePathWorkspace newWorkspace = (WritablePathWorkspace)workspace;
// Now set (or remove) the properties to the supplied node ...
- newWorkspace.setProperties(getExecutionContext(), node.getPath(), request.properties().values());
+ newWorkspace.setProperties(getExecutionContext(), node.getPath(), request.properties());
request.setActualLocationOfNode(Location.create(node.getPath(), node.getUuid()));
recordChange(request);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathRepository.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathRepository.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathRepository.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -23,7 +23,6 @@
*/
package org.jboss.dna.graph.connector.path;
-import java.util.UUID;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Path;
@@ -37,17 +36,10 @@
@ThreadSafe
public abstract class WritablePathRepository extends PathRepository {
- public WritablePathRepository( String sourceName,
- UUID rootNodeUuid,
- String defaultWorkspaceName ) {
- super(sourceName, rootNodeUuid, defaultWorkspaceName);
+ public WritablePathRepository( PathRepositorySource source ) {
+ super(source);
}
- public WritablePathRepository( String sourceName,
- UUID rootNodeUuid ) {
- super(sourceName, rootNodeUuid);
- }
-
/**
* Creates a new workspace with the given name containing only a root node.
* <p>
@@ -141,7 +133,7 @@
PathNode root = workspace.getNode(rootPath);
PathNode origRoot = original.getNode(rootPath);
workspace.removeProperties(context, rootPath, root.getProperties().keySet());
- workspace.setProperties(context, rootPath, origRoot.getProperties().values());
+ workspace.setProperties(context, rootPath, origRoot.getProperties());
// Loop over each child and call this method to copy the immediate children (and below).
for (Segment childSegment : origRoot.getChildSegments()) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathWorkspace.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathWorkspace.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/WritablePathWorkspace.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -135,7 +135,7 @@
*/
public PathNode setProperties( ExecutionContext context,
Path nodePath,
- Iterable<Property> properties );
+ Map<Name, Property> properties );
/**
* Removes the properties with the given names
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/CacheStatistics.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/CacheStatistics.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/CacheStatistics.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,53 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+/**
+ * This interface provides access to statistics for an individual workspace cache.
+ */
+public interface CacheStatistics {
+
+ /**
+ * @return the number of times that a node was written to the cache
+ */
+ long getWrites();
+
+ /**
+ * @return the number of times that a node was retrieved from the cache
+ */
+ long getHits();
+
+ /**
+ * @return the number of times that an attempt to retrieve a node from the cache failed because the node was not yet in the
+ * cache.
+ */
+ long getMisses();
+
+ /**
+ * @return the number of times that an attempt to retrieve a node from the cache failed because the node had previously been
+ * placed in the cache, but the time to live for the node in the cache had expired
+ */
+ long getExpirations();
+
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/CacheStatistics.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/DefaultPathCachePolicy.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/DefaultPathCachePolicy.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/DefaultPathCachePolicy.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,63 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.graph.connector.path.PathNode;
+
+/**
+ * Trivial path cache policy implementation that caches all nodes in an in-memory cache.
+ * <p>
+ * As a result, this cache policy may not be safe for use with some large repositories as it does not attempt to limit cache
+ * attempts based on the size of the node or the current size of the cache.
+ * </p>
+ */
+@Immutable
+public class DefaultPathCachePolicy implements PathCachePolicy {
+
+ private static final long serialVersionUID = 1L;
+
+ private final long cacheTimeToLiveInSeconds;
+
+ public DefaultPathCachePolicy( long cacheTimeToLiveInSeconds ) {
+ super();
+ this.cacheTimeToLiveInSeconds = cacheTimeToLiveInSeconds;
+ }
+
+ /**
+ * @return true for all nodes
+ * @see PathCachePolicy#shouldCache(PathNode)
+ */
+ public boolean shouldCache( PathNode node ) {
+ return true;
+ }
+
+ public long getTimeToLive() {
+ return this.cacheTimeToLiveInSeconds;
+ }
+
+ public Class<? extends WorkspaceCache> getCacheClass() {
+ return InMemoryWorkspaceCache.class;
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/DefaultPathCachePolicy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/InMemoryWorkspaceCache.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/InMemoryWorkspaceCache.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/InMemoryWorkspaceCache.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,147 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+import java.lang.ref.SoftReference;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.graph.connector.path.PathNode;
+import org.jboss.dna.graph.property.Path;
+
+/**
+ * Implementation of {@link WorkspaceCache} that stores all nodes in-memory.
+ */
+@ThreadSafe
+public class InMemoryWorkspaceCache implements WorkspaceCache {
+ private final ConcurrentMap<Path, CacheEntry> nodesByPath = new ConcurrentHashMap<Path, CacheEntry>();
+ private PathCachePolicy policy = null;
+ private InMemoryStatistics statistics = new InMemoryStatistics();
+
+ public void initialize( PathCachePolicy policy ) {
+ if (this.policy != null) {
+ throw new IllegalStateException();
+ }
+
+ this.policy = policy;
+ }
+
+ public void clearStatistics() {
+ statistics = new InMemoryStatistics();
+ }
+
+ public CacheStatistics getStatistics() {
+ return this.statistics;
+ }
+
+ public PathNode get( Path path ) {
+ assert path != null;
+
+ CacheEntry entry = nodesByPath.get(path);
+ if (entry == null) {
+ statistics.misses.getAndIncrement();
+ return null;
+ }
+
+ PathNode node = entry.getNode();
+ if (node != null) {
+ statistics.hits.getAndIncrement();
+ return node;
+ }
+
+ nodesByPath.remove(path, entry);
+ statistics.expirations.getAndIncrement();
+ return null;
+ }
+
+ public void set( PathNode node ) {
+ assert node != null;
+
+ if (!policy.shouldCache(node)) return;
+
+ statistics.writes.getAndIncrement();
+ nodesByPath.put(node.getPath(), new CacheEntry(node));
+ }
+
+ public void invalidate( Path path ) {
+ assert path != null;
+
+ for (Iterator<Path> iter = nodesByPath.keySet().iterator(); iter.hasNext();) {
+ Path key = iter.next();
+ if (key.isAtOrBelow(path)) {
+ iter.remove();
+ }
+ }
+ }
+
+ public void close() {
+ assert this.statistics != null : "Attempt to close an already-closed cache";
+
+ this.nodesByPath.clear();
+ this.statistics = null;
+ }
+
+ class CacheEntry {
+ private final SoftReference<PathNode> ref;
+ private final long expiryTime;
+
+ CacheEntry( PathNode node ) {
+ ref = new SoftReference<PathNode>(node);
+ expiryTime = System.currentTimeMillis() + (policy.getTimeToLive() * 1000);
+ }
+
+ PathNode getNode() {
+ if (System.currentTimeMillis() > expiryTime) {
+ return null;
+ }
+
+ return ref.get();
+ }
+ }
+
+ class InMemoryStatistics implements CacheStatistics {
+ private final AtomicLong writes = new AtomicLong(0);
+ private final AtomicLong hits = new AtomicLong(0);
+ private final AtomicLong misses = new AtomicLong(0);
+ private final AtomicLong expirations = new AtomicLong(0);
+
+ public long getWrites() {
+ return writes.get();
+ }
+
+ public long getHits() {
+ return hits.get();
+ }
+
+ public long getMisses() {
+ return misses.get();
+ }
+
+ public long getExpirations() {
+ return expirations.get();
+ }
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/InMemoryWorkspaceCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathCachePolicy.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathCachePolicy.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathCachePolicy.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,49 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connector.path.PathNode;
+
+/**
+ * The {@PathCachePolicy} provides a method for selectively allowing or disallowing nodes to be cached based on
+ * their size, volatility, or any other factor that can be determined for the node.
+ */
+public interface PathCachePolicy extends CachePolicy {
+
+ /**
+ * Indicates whether the node should be cached .
+ *
+ * @param node the node that may or may not be cached; may not be null
+ * @return true if the node should be cached and false if it should not be cached
+ */
+ boolean shouldCache( PathNode node );
+
+ /**
+ * Return the class to be used as the cache implementation
+ *
+ * @return the cache class
+ */
+ Class<? extends WorkspaceCache> getCacheClass();
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathCachePolicy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathRepositoryCache.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathRepositoryCache.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathRepositoryCache.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,86 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import net.jcip.annotations.ThreadSafe;
+
+/**
+ * The repository-source level cache of workspace names to {@link WorkspaceCache workspace caches}.
+ * <p>
+ * This object gets created for each repository whenever the {@link PathCachePolicy cache policy} is set. When the cache policy is
+ * modified, the old {@code PathRepositoryCache} is {@link #close() closed} after the new path repository cache is created.
+ * </p>
+ */
+@ThreadSafe
+public class PathRepositoryCache {
+
+ private final PathCachePolicy policy;
+ private final ConcurrentMap<String, WorkspaceCache> cachesByName = new ConcurrentHashMap<String, WorkspaceCache>();
+
+ public PathRepositoryCache( PathCachePolicy policy ) {
+ this.policy = policy;
+ }
+
+ public void close() {
+ for (WorkspaceCache cache : cachesByName.values()) {
+ cache.close();
+ }
+ }
+
+ /**
+ * Gets the cache for the named workspace, creating a cache if necessary. Subsequent calls to this method with the same
+ * workspace name must return the exact same cache instance.
+ *
+ * @param workspaceName the name of the workspace for which the cache should be returned.
+ * @return the cache instance associated with the workspace; never null
+ * @throws IllegalStateException if no cache exists for this workspace and an instance of the
+ * {@link PathCachePolicy#getCacheClass() cache class from the policy} cannot be created.
+ */
+ public WorkspaceCache getCache( String workspaceName ) {
+ WorkspaceCache cache = cachesByName.get(workspaceName);
+ if (cache != null) return cache;
+
+ cache = newCache();
+ cachesByName.putIfAbsent(workspaceName, cache);
+
+ return cachesByName.get(workspaceName);
+ }
+
+ private final WorkspaceCache newCache() {
+ WorkspaceCache cache = null;
+
+ try {
+ cache = policy.getCacheClass().newInstance();
+ cache.initialize(policy);
+ } catch (IllegalAccessException iae) {
+ throw new IllegalStateException(iae);
+ } catch (InstantiationException ie) {
+ throw new IllegalStateException(ie);
+ }
+ return cache;
+ }
+
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/PathRepositoryCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/WorkspaceCache.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/WorkspaceCache.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/WorkspaceCache.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,91 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path.cache;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.graph.connector.path.PathNode;
+import org.jboss.dna.graph.property.Path;
+
+/**
+ * The basic contract for a workspace-level cache of paths to the nodes stored at that path.
+ * <p>
+ * Implementations must provide a no-argument constructor in order to be instantiated by {@link PathRepositoryCache}. After
+ * instantiation, the {@link #initialize(PathCachePolicy)} method will be called to inject the cache policy into the
+ * implementation.
+ * </p>
+ * <p>
+ * Implementations must be thread-safe.
+ * </p>
+ */
+@ThreadSafe
+public interface WorkspaceCache {
+
+ /**
+ * Injects the cache policy into the cache
+ *
+ * @param policy the active cache policy for the repository source with which this cache is associated
+ * @throws IllegalStateException if this method is called on a cache that has already been initialized.
+ */
+ public void initialize( PathCachePolicy policy );
+
+ /**
+ * Clears all statistics for this cache
+ */
+ public void clearStatistics();
+
+ /**
+ * @return the statistics since the most recent of the cache initialization or the last call to {@link #clearStatistics()};
+ * never null
+ */
+ public CacheStatistics getStatistics();
+
+ /**
+ * Retrieves the cached node with the given path, it it exists and is valid
+ *
+ * @param path the path for the node to be retrieved
+ * @return the cached node with the given path; may be null if no node with that path is cached or a node with that path is
+ * cached but is deemed invalid for implementation-specific reasons
+ */
+ public PathNode get( Path path );
+
+ /**
+ * Attempts to cache the given node. Implementations must call {@link PathCachePolicy#shouldCache(PathNode)} on the policy
+ * from the {@link #initialize(PathCachePolicy)} method to determine if the node should be cached.
+ *
+ * @param node the node that is to be cached; may not be null
+ */
+ public void set( PathNode node );
+
+ /**
+ * Invalidates all nodes in the cache that have the given path or have a path that is an ancestor of the given path
+ *
+ * @param path the root of the branch of nodes that are to be invalidated; may not be null
+ */
+ public void invalidate( Path path );
+
+ /**
+ * Indicates that the cache is no longer in use and should relinquish any resources.
+ */
+ public void close();
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/WorkspaceCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/package-info.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/package-info.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/package-info.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,42 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.
+ */
+/**
+ *
+ * The {@link PathRepositoryCache} class and its supporting classes provide a standard caching mechanism for path-based repositories. Users of any path repository
+ * based on {@link org.jboss.dna.graph.connector.path.AbstractPathRepositorySource} can call {@link org.jboss.dna.graph.connector.path.AbstractPathRepositorySource#setCachePolicy(PathCachePolicy)} to
+ * configure the caching for that repository. This method can be invoked at run-time to modify the cache properties of an in-use repository.
+ * <p>
+ * Each {@code AbstractPathRepositorySource} has a local instance of {@link PathRepositoryCache} that reads the {@code PathCachePolicy} for the source and uses it to create instances of
+ * {@link WorkspaceCache} for each workspace in the repository. When a workspace cache instance is requested for the first time from the {@link PathRepositoryCache#getCache(String)} method,
+ * an instance of the class is created using the no-argument constructor for the class and {@link WorkspaceCache#initialize(PathCachePolicy)} is called with the current cache policy.
+ * </p>
+ * <p>
+ * When {@link org.jboss.dna.graph.connector.path.AbstractPathRepositorySource#setCachePolicy(PathCachePolicy) the cache policy is changed} on the source, the existing {@code PathRepositoryCache}
+ * is {@link PathRepositoryCache#close() closed} and a new path repository cache is created.
+ * </p>
+ *
+ */
+
+package org.jboss.dna.graph.connector.path.cache;
+
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/cache/package-info.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySourceTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySourceTest.java (rev 0)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySourceTest.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -0,0 +1,165 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.graph.connector.path;
+
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
+import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.path.cache.CacheStatistics;
+import org.jboss.dna.graph.connector.path.cache.PathCachePolicy;
+import org.jboss.dna.graph.connector.path.cache.PathRepositoryCache;
+import org.jboss.dna.graph.connector.path.cache.WorkspaceCache;
+import org.jboss.dna.graph.property.Path;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AbstractPathRepositorySourceTest {
+
+ private AbstractPathRepositorySource source;
+
+ @SuppressWarnings( "serial" )
+ @Before
+ public void beforeEach() throws Exception {
+ source = new AbstractPathRepositorySource() {
+
+ public String getDefaultWorkspaceName() {
+ return null;
+ }
+
+ public void setUpdatesAllowed( boolean updatesAllowed ) {
+ }
+
+ public RepositorySourceCapabilities getCapabilities() {
+ return null;
+ }
+
+ public RepositoryConnection getConnection() throws RepositorySourceException {
+ return null;
+ }
+
+ public Reference getReference() throws NamingException {
+ return null;
+ }
+ };
+ }
+
+ @Test
+ public void shouldProvideDefaultCachePolicy() throws Exception {
+ assertThat(source.getCachePolicy(), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldProvideDefaultPathRepositoryCache() throws Exception {
+ assertThat(source.getPathRepositoryCache(), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldMakeNewRepositoryCacheWhenCachePolicyIsChanged() throws Exception {
+ PathCachePolicy policy1 = new MockCachePolicy();
+ source.setCachePolicy(policy1);
+
+ PathRepositoryCache cache1 = source.getPathRepositoryCache();
+ assertThat(cache1, is(notNullValue()));
+
+ PathCachePolicy policy2 = new MockCachePolicy();
+ source.setCachePolicy(policy2);
+
+ assertThat(source.getCachePolicy(), is(policy2));
+ assertThat(source.getCachePolicy(), is(not(policy1)));
+
+ PathRepositoryCache cache2 = source.getPathRepositoryCache();
+ assertThat(cache2, is(notNullValue()));
+ assertThat(cache2, is(not(cache1)));
+ }
+
+ @Test
+ public void shouldCloseOldWorkspaceCacheWhenCachePolicyIsChanged() throws Exception {
+ PathCachePolicy policy1 = new MockCachePolicy();
+ source.setCachePolicy(policy1);
+
+ PathRepositoryCache repositoryCache = source.getPathRepositoryCache();
+ MockWorkspaceCache cache = (MockWorkspaceCache)repositoryCache.getCache("foo");
+ assertThat(cache, is(notNullValue()));
+
+ source.setCachePolicy(new MockCachePolicy());
+
+ assertThat(cache.closed, is(true));
+ }
+
+ @SuppressWarnings( "serial" )
+ class MockCachePolicy implements PathCachePolicy {
+
+ public Class<? extends WorkspaceCache> getCacheClass() {
+ return MockWorkspaceCache.class;
+ }
+
+ public boolean shouldCache( PathNode node ) {
+ return false;
+ }
+
+ public long getTimeToLive() {
+ return 0;
+ }
+
+ }
+
+ public static class MockWorkspaceCache implements WorkspaceCache {
+
+ boolean closed = false;
+ PathCachePolicy policy;
+
+ public void initialize( PathCachePolicy policy ) {
+ this.policy = policy;
+ }
+
+ public void clearStatistics() {
+ }
+
+ public void close() {
+ closed = true;
+ }
+
+ public PathNode get( Path path ) {
+ return null;
+ }
+
+ public CacheStatistics getStatistics() {
+ return null;
+ }
+
+ public void invalidate( Path path ) {
+ }
+
+ public void set( PathNode node ) {
+ }
+
+ }
+}
Property changes on: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/path/AbstractPathRepositorySourceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRepository.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -51,6 +51,7 @@
import org.jboss.dna.graph.connector.path.PathNode;
import org.jboss.dna.graph.connector.path.WritablePathRepository;
import org.jboss.dna.graph.connector.path.WritablePathWorkspace;
+import org.jboss.dna.graph.connector.path.cache.WorkspaceCache;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
import org.jboss.dna.graph.property.Binary;
import org.jboss.dna.graph.property.BinaryFactory;
@@ -80,7 +81,7 @@
private File repositoryRoot;
public FileSystemRepository( FileSystemSource source ) {
- super(source.getName(), source.getRootNodeUuid(), source.getDefaultWorkspaceName());
+ super(source);
this.source = source;
initialize();
@@ -125,6 +126,11 @@
}
}
+
+ public WorkspaceCache getCache( String workspaceName ) {
+ return source.getPathRepositoryCache().getCache(workspaceName);
+ }
+
/**
* Internal method that creates a workspace and adds it to the map of active workspaces without checking to see if
* {@link FileSystemSource#isCreatingWorkspacesAllowed() the source allows creating workspaces}. This is useful when setting
@@ -376,7 +382,18 @@
getName(),
getSourceName()));
}
- return getNode(newPath);
+
+ PathNode node = getNode(newPath);
+
+ List<Segment> newChildren = new ArrayList<Segment>(parentNode.getChildSegments().size() + 1);
+ newChildren.addAll(parentNode.getChildSegments());
+ newChildren.add(node.getPath().getLastSegment());
+
+ WorkspaceCache cache = getCache(getName());
+ cache.set(new DefaultPathNode(parentNode.getPath(), parentNode.getUuid(), parentNode.getProperties(), newChildren));
+ cache.set(node);
+
+ return node;
}
public boolean removeNode( ExecutionContext context,
@@ -411,57 +428,16 @@
return true;
}
- public PathNode removeProperties( ExecutionContext context,
- Path nodePath,
- Iterable<Name> propertyNames ) {
-
- PathNode targetNode = getNode(nodePath);
- if (targetNode == null) return null;
- if (source.getCustomPropertiesFactory() == null) return targetNode;
-
- Property primaryTypeProp = targetNode.getProperty(JcrLexicon.PRIMARY_TYPE);
- Name primaryTypeName = (Name)primaryTypeProp.getFirstValue();
- Map<Name, Property> properties = new HashMap<Name, Property>(targetNode.getProperties());
-
- for (Name propertyName : propertyNames) {
- properties.remove(propertyName);
- }
-
- CustomPropertiesFactory customPropertiesFactory = source.customPropertiesFactory();
- Location location = Location.create(nodePath, targetNode.getUuid());
-
- /*
- * You can't remove any of the protected properties that the repository provides by default, but you could
- * remove custom properties.
- */
- if (JcrNtLexicon.FILE.equals(primaryTypeName)) {
- customPropertiesFactory.recordFileProperties(context, getSourceName(), location, fileFor(nodePath), properties);
- } else if (DnaLexicon.RESOURCE.equals(primaryTypeName)) {
- File file = fileFor(nodePath.getParent());
- customPropertiesFactory.recordResourceProperties(context, getSourceName(), location, file, properties);
- } else {
- File file = fileFor(nodePath);
- customPropertiesFactory.recordDirectoryProperties(context, getSourceName(), location, file, properties);
- }
-
- return getNode(nodePath);
- }
-
public PathNode setProperties( ExecutionContext context,
Path nodePath,
- Iterable<Property> newProperties ) {
+ Map<Name, Property> properties ) {
PathNode targetNode = getNode(nodePath);
if (targetNode == null) return null;
if (source.getCustomPropertiesFactory() == null) return targetNode;
Property primaryTypeProp = targetNode.getProperty(JcrLexicon.PRIMARY_TYPE);
Name primaryTypeName = (Name)primaryTypeProp.getFirstValue();
- Map<Name, Property> properties = new HashMap<Name, Property>(targetNode.getProperties());
- for (Property newProperty : newProperties) {
- properties.put(newProperty.getName(), newProperty);
- }
-
CustomPropertiesFactory customPropertiesFactory = source.customPropertiesFactory();
Location location = Location.create(nodePath, targetNode.getUuid());
@@ -479,7 +455,10 @@
customPropertiesFactory.recordDirectoryProperties(context, getSourceName(), location, file, properties);
}
- return getNode(nodePath);
+ PathNode node = getNode(nodePath);
+ getCache(getName()).set(node);
+
+ return node;
}
@Override
@@ -492,7 +471,11 @@
if (beforeNode != null) {
throw new InvalidRequestException(FileSystemI18n.nodeOrderingNotSupported.text(getSourceName()));
}
- return super.moveNode(context, node, desiredNewName, originalWorkspace, newParent, beforeNode);
+ PathNode movedNode = super.moveNode(context, node, desiredNewName, originalWorkspace, newParent, beforeNode);
+
+ getCache(getName()).invalidate(node.getPath());
+
+ return movedNode;
}
public Path getLowestExistingPath( Path path ) {
@@ -525,6 +508,11 @@
}
public PathNode getNode( Path path ) {
+ WorkspaceCache cache = getCache(getName());
+
+ PathNode node = cache.get(path);
+ if (node != null) return node;
+
Map<Name, Property> properties = new HashMap<Name, Property>();
PropertyFactory factory = context.getPropertyFactory();
@@ -615,9 +603,11 @@
}
properties.put(JcrLexicon.PRIMARY_TYPE, factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FILE));
properties.put(JcrLexicon.CREATED, factory.create(JcrLexicon.CREATED, dateFactory.create(file.lastModified())));
- return new DefaultPathNode(path, null, properties,
+ node = new DefaultPathNode(path, null, properties,
Collections.singletonList(pathFactory.createSegment(JcrLexicon.CONTENT)));
+ cache.set(node);
+ return node;
}
/**
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemSource.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -24,33 +24,26 @@
package org.jboss.dna.connector.filesystem;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import java.util.regex.Pattern;
import javax.naming.BinaryRefAddr;
import javax.naming.Context;
-import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
-import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.CheckArg;
@@ -59,14 +52,12 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.Location;
-import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.path.AbstractPathRepositorySource;
import org.jboss.dna.graph.connector.path.PathRepositoryConnection;
-import org.jboss.dna.graph.connector.path.PathRepositorySource;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Property;
@@ -77,7 +68,7 @@
* workspace. New workspaces can be created, as long as the names represent valid paths to existing directories.
*/
@ThreadSafe
-public class FileSystemSource implements PathRepositorySource, ObjectFactory {
+public class FileSystemSource extends AbstractPathRepositorySource implements ObjectFactory {
/**
* An immutable {@link CustomPropertiesFactory} implementation that is used by default when none is provided. Note that this
@@ -96,8 +87,6 @@
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE = "default";
protected static final String SOURCE_NAME = "sourceName";
- protected static final String CACHE_TIME_TO_LIVE_IN_MILLISECONDS = "cacheTimeToLiveInMilliseconds";
- protected static final String RETRY_LIMIT = "retryLimit";
protected static final String DEFAULT_WORKSPACE = "defaultWorkspace";
protected static final String WORKSPACE_ROOT = "workspaceRootPath";
protected static final String PREDEFINED_WORKSPACE_NAMES = "predefinedWorkspaceNames";
@@ -128,18 +117,12 @@
*/
protected static final boolean SUPPORTS_REFERENCES = false;
- public static final int DEFAULT_RETRY_LIMIT = 0;
- public static final int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS = 60 * 5; // 5 minutes
public static final int DEFAULT_MAX_PATH_LENGTH = 255; // 255 for windows users
public static final String DEFAULT_EXCLUSION_PATTERN = null;
- private volatile String name;
- private volatile int retryLimit = DEFAULT_RETRY_LIMIT;
- private volatile int cacheTimeToLiveInMilliseconds = DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS * 1000;
private volatile String defaultWorkspaceName = DEFAULT_NAME_OF_DEFAULT_WORKSPACE;
private volatile String workspaceRootPath;
private volatile String[] predefinedWorkspaces = new String[] {};
- private volatile UUID rootNodeUuid = UUID.randomUUID();
private volatile int maxPathLength = DEFAULT_MAX_PATH_LENGTH;
private volatile String exclusionPattern = DEFAULT_EXCLUSION_PATTERN;
private volatile RepositorySourceCapabilities capabilities = new RepositorySourceCapabilities(
@@ -148,8 +131,6 @@
SUPPORTS_EVENTS,
DEFAULT_SUPPORTS_CREATING_WORKSPACES,
SUPPORTS_REFERENCES);
- private transient RepositoryContext repositoryContext;
- private transient CachePolicy defaultCachePolicy;
private transient FileSystemRepository repository;
private volatile CustomPropertiesFactory customPropertiesFactory;
@@ -169,28 +150,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositorySource#getName()
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the name for the source
- *
- * @param name the new name for the source
- */
- public synchronized void setName( String name ) {
- if (name != null) {
- name = name.trim();
- if (name.length() == 0) name = null;
- }
- this.name = name;
- }
-
- /**
* Get whether this source supports updates.
*
* @return true if this source supports updates, or false if this source only supports reading content.
@@ -255,25 +214,6 @@
}
/**
- * Get the UUID that is used for the root node of each workspace
- *
- * @return the UUID that is used for the root node of each workspace
- */
- public UUID getRootNodeUuid() {
- return rootNodeUuid;
- }
-
- /**
- * Set the {@code jcr:uuid} property of the root node in each workspace to the given value.
- *
- * @param rootNodeUuid the UUID to use for the root nodes of all workspaces
- */
- public synchronized void setRootNodeUuid( String rootNodeUuid ) {
- CheckArg.isNotNull(rootNodeUuid, "rootNodeUuid");
- this.rootNodeUuid = UUID.fromString(rootNodeUuid);
- }
-
- /**
* Get the maximum path length (in characters) allowed by the underlying file system
*
* @return the maximum path length (in characters) allowed by the underlying file system
@@ -377,6 +317,7 @@
* @return true if this source allows updates by clients, or false if no updates are allowed
* @see #setUpdatesAllowed(boolean)
*/
+ @Override
public boolean areUpdatesAllowed() {
return capabilities.supportsUpdates();
}
@@ -395,45 +336,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositorySource#getRetryLimit()
- */
- public int getRetryLimit() {
- return retryLimit;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositorySource#setRetryLimit(int)
- */
- public synchronized void setRetryLimit( int limit ) {
- this.retryLimit = limit < 0 ? 0 : limit;
- }
-
- /**
- * Get the time in milliseconds that content returned from this source may used while in the cache.
- *
- * @return the time to live, in milliseconds, or 0 if the time to live is not specified by this source
- */
- public int getCacheTimeToLiveInMilliseconds() {
- return cacheTimeToLiveInMilliseconds;
- }
-
- /**
- * Set the time in milliseconds that content returned from this source may used while in the cache.
- *
- * @param cacheTimeToLive the time to live, in milliseconds; 0 if the time to live is not specified by this source; or a
- * negative number for the default value
- */
- public synchronized void setCacheTimeToLiveInMilliseconds( int cacheTimeToLive ) {
- if (cacheTimeToLive < 0) cacheTimeToLive = DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS;
- this.cacheTimeToLiveInMilliseconds = cacheTimeToLive;
- this.defaultCachePolicy = cacheTimeToLiveInMilliseconds > 0 ? new FileSystemCachePolicy(cacheTimeToLiveInMilliseconds) : null;
- }
-
- /**
* Get the factory that is used to create custom properties on "nt:folder", "nt:file", and "nt:resource" nodes.
*
* @return the factory, or null if no custom properties are to be created
@@ -458,23 +360,6 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.connector.RepositorySource#initialize(org.jboss.dna.graph.connector.RepositoryContext)
- */
- public synchronized void initialize( RepositoryContext context ) throws RepositorySourceException {
- this.repositoryContext = context;
- }
-
- public RepositoryContext getRepositoryContext() {
- return this.repositoryContext;
- }
-
- public CachePolicy getDefaultCachePolicy() {
- return defaultCachePolicy;
- }
-
- /**
- * {@inheritDoc}
- *
* @see javax.naming.Referenceable#getReference()
*/
public synchronized Reference getReference() {
@@ -485,8 +370,6 @@
if (getName() != null) {
ref.add(new StringRefAddr(SOURCE_NAME, getName()));
}
- ref.add(new StringRefAddr(CACHE_TIME_TO_LIVE_IN_MILLISECONDS, Integer.toString(getCacheTimeToLiveInMilliseconds())));
- ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getDefaultWorkspaceName()));
ref.add(new StringRefAddr(ALLOW_CREATING_WORKSPACES, Boolean.toString(isCreatingWorkspacesAllowed())));
ref.add(new StringRefAddr(EXCLUSION_PATTERN, exclusionPattern));
@@ -518,30 +401,9 @@
Context nameCtx,
Hashtable<?, ?> environment ) throws Exception {
if (obj instanceof Reference) {
- Map<String, Object> values = new HashMap<String, Object>();
- Reference ref = (Reference)obj;
- Enumeration<?> en = ref.getAll();
- while (en.hasMoreElements()) {
- RefAddr subref = (RefAddr)en.nextElement();
- if (subref instanceof StringRefAddr) {
- String key = subref.getType();
- Object value = subref.getContent();
- if (value != null) values.put(key, value.toString());
- } else if (subref instanceof BinaryRefAddr) {
- String key = subref.getType();
- Object value = subref.getContent();
- if (value instanceof byte[]) {
- // Deserialize ...
- ByteArrayInputStream bais = new ByteArrayInputStream((byte[])value);
- ObjectInputStream ois = new ObjectInputStream(bais);
- value = ois.readObject();
- values.put(key, value);
- }
- }
- }
+ Map<String, Object> values = valuesFrom((Reference)obj);
+
String sourceName = (String)values.get(SOURCE_NAME);
- String cacheTtlInMillis = (String)values.get(CACHE_TIME_TO_LIVE_IN_MILLISECONDS);
- String retryLimit = (String)values.get(RETRY_LIMIT);
String defaultWorkspace = (String)values.get(DEFAULT_WORKSPACE);
String createWorkspaces = (String)values.get(ALLOW_CREATING_WORKSPACES);
String exclusionPattern = (String)values.get(EXCLUSION_PATTERN);
@@ -558,8 +420,6 @@
// Create the source instance ...
FileSystemSource source = new FileSystemSource();
if (sourceName != null) source.setName(sourceName);
- if (cacheTtlInMillis != null) source.setCacheTimeToLiveInMilliseconds(Integer.parseInt(cacheTtlInMillis));
- if (retryLimit != null) source.setRetryLimit(Integer.parseInt(retryLimit));
if (defaultWorkspace != null) source.setDefaultWorkspaceName(defaultWorkspace);
if (createWorkspaces != null) source.setCreatingWorkspacesAllowed(Boolean.parseBoolean(createWorkspaces));
if (workspaceNames != null && workspaceNames.length != 0) source.setPredefinedWorkspaceNames(workspaceNames);
@@ -588,14 +448,6 @@
}
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositorySource#close()
- */
- public synchronized void close() {
- }
-
protected static class StandardPropertiesFactory implements CustomPropertiesFactory {
private static final long serialVersionUID = 1L;
private final Collection<Property> empty = Collections.emptyList();
@@ -719,20 +571,4 @@
}
}
-
- @Immutable
- /*package*/class FileSystemCachePolicy implements CachePolicy {
- private static final long serialVersionUID = 1L;
- private final int ttl;
-
- /*package*/FileSystemCachePolicy( int ttl ) {
- this.ttl = ttl;
- }
-
- public long getTimeToLive() {
- return ttl;
- }
-
- }
-
}
Modified: trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorWritableTest.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorWritableTest.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorWritableTest.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -155,7 +155,6 @@
File newFolder = new File(testWorkspaceRoot, "testFolder");
assertThat(newFolder.exists(), is(true));
assertThat(newFolder.isDirectory(), is(true));
- System.out.println("Created new folder at: " + newFolder.getCanonicalPath());
graph.create("/testFolder/testFile").with(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FILE).orReplace().and();
graph.create("/testFolder/testFile/jcr:content")
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -48,6 +48,7 @@
import org.jboss.dna.graph.connector.path.PathNode;
import org.jboss.dna.graph.connector.path.PathRepository;
import org.jboss.dna.graph.connector.path.PathWorkspace;
+import org.jboss.dna.graph.connector.path.cache.WorkspaceCache;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
@@ -75,7 +76,7 @@
private int databaseMinorVersion;
public JdbcMetadataRepository( JdbcMetadataSource source ) {
- super(source.getName(), source.getRootUuid(), source.getDefaultWorkspaceName());
+ super(source);
this.source = source;
initialize();
}
@@ -122,6 +123,10 @@
}
}
+ public WorkspaceCache getCache( String workspaceName ) {
+ return source.getPathRepositoryCache().getCache(workspaceName);
+ }
+
Connection getConnection() {
try {
return source.getDataSource().getConnection();
@@ -144,9 +149,11 @@
private class JdbcMetadataWorkspace implements PathWorkspace {
private final String name;
+ private final WorkspaceCache cache;
JdbcMetadataWorkspace( String name ) {
this.name = name;
+ cache = getCache(name);
}
public Path getLowestExistingPath( Path path ) {
@@ -176,37 +183,45 @@
public PathNode getNode( Path path ) {
assert path != null;
+ PathNode node = cache.get(path);
+ if (node != null) return node;
+
List<Segment> segments = path.getSegmentsList();
switch (segments.size()) {
case 0:
- return getRoot();
+ node = getRoot();
+ break;
case 1:
- return catalogNodeFor(segments);
+ node = catalogNodeFor(segments);
+ break;
case 2:
- return schemaNodeFor(segments);
+ node = schemaNodeFor(segments);
+ break;
case 3:
if (TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
- return tablesNodeFor(segments);
+ node = tablesNodeFor(segments);
} else if (PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
- return proceduresNodeFor(segments);
+ node = proceduresNodeFor(segments);
}
-
- return null;
+ break;
case 4:
if (TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
- return tableNodeFor(segments);
+ node = tableNodeFor(segments);
} else if (PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
- return procedureNodeFor(segments);
+ node = procedureNodeFor(segments);
}
- return null;
+ break;
case 5:
if (TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
- return columnNodeFor(segments);
+ node = columnNodeFor(segments);
}
- return null;
+ break;
default:
return null;
}
+
+ if (node != null) cache.set(node);
+ return node;
}
private PathNode catalogNodeFor( List<Segment> segments ) throws RepositorySourceException {
@@ -759,7 +774,7 @@
}
public UUID getUuid() {
- return source.getRootUuid();
+ return source.getRootNodeUuid();
}
public Map<Name, Property> getProperties() {
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataSource.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataSource.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataSource.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -24,14 +24,10 @@
package org.jboss.dna.connector.meta.jdbc;
import java.beans.PropertyVetoException;
-import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
-import java.util.UUID;
import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
@@ -40,17 +36,15 @@
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.path.AbstractPathRepositorySource;
import org.jboss.dna.graph.connector.path.PathRepositoryConnection;
-import org.jboss.dna.graph.connector.path.PathRepositorySource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
@ThreadSafe
-public class JdbcMetadataSource implements PathRepositorySource, ObjectFactory {
+public class JdbcMetadataSource extends AbstractPathRepositorySource implements ObjectFactory {
private static final long serialVersionUID = 1L;
@@ -99,11 +93,6 @@
public static final boolean SUPPORTS_CREATING_WORKSPACES = false;
/**
- * The default UUID that is used for root nodes in a store.
- */
- public static final String DEFAULT_ROOT_NODE_UUID = "cafebabe-cafe-babe-cafe-babecafebabe";
-
- /**
* The initial {@link #getDefaultWorkspaceName() name of the default workspace} is "{@value} ", unless otherwise specified.
*/
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE = "default";
@@ -120,8 +109,7 @@
*/
public static final String DEFAULT_NAME_OF_DEFAULT_SCHEMA = "default";
- private static final int DEFAULT_RETRY_LIMIT = 0;
- private static final int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS = 60 * 5; // 5 minutes
+
private static final int DEFAULT_MAXIMUM_CONNECTIONS_IN_POOL = 5;
private static final int DEFAULT_MINIMUM_CONNECTIONS_IN_POOL = 0;
private static final int DEFAULT_MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS = 60 * 10; // 10 minutes
@@ -130,22 +118,18 @@
private static final int DEFAULT_IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS = 60 * 3; // 3 minutes
private static final MetadataCollector DEFAULT_METADATA_COLLECTOR = new JdbcMetadataCollector();
- private volatile String name;
private volatile String dataSourceJndiName;
private volatile String username;
private volatile String password;
private volatile String url;
private volatile String driverClassName;
private volatile String driverClassloaderName;
- private volatile String rootNodeUuid = DEFAULT_ROOT_NODE_UUID;
private volatile int maximumConnectionsInPool = DEFAULT_MAXIMUM_CONNECTIONS_IN_POOL;
private volatile int minimumConnectionsInPool = DEFAULT_MINIMUM_CONNECTIONS_IN_POOL;
private volatile int maximumConnectionIdleTimeInSeconds = DEFAULT_MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS;
private volatile int maximumSizeOfStatementCache = DEFAULT_MAXIMUM_NUMBER_OF_STATEMENTS_TO_CACHE;
private volatile int numberOfConnectionsToAcquireAsNeeded = DEFAULT_NUMBER_OF_CONNECTIONS_TO_ACQUIRE_AS_NEEDED;
private volatile int idleTimeInSecondsBeforeTestingConnections = DEFAULT_IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS;
- private volatile int retryLimit = DEFAULT_RETRY_LIMIT;
- private volatile int cacheTimeToLiveInMilliseconds = DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS * 1000;
private volatile String defaultWorkspace = DEFAULT_NAME_OF_DEFAULT_WORKSPACE;
private volatile String defaultCatalogName = DEFAULT_NAME_OF_DEFAULT_CATALOG;
private volatile String defaultSchemaName = DEFAULT_NAME_OF_DEFAULT_SCHEMA;
@@ -157,52 +141,14 @@
SUPPORTS_CREATING_WORKSPACES,
SUPPORTS_REFERENCES);
private transient DataSource dataSource;
- private transient CachePolicy cachePolicy;
private transient JdbcMetadataRepository repository;
- private transient RepositoryContext repositoryContext;
- private transient UUID rootUuid = UUID.fromString(rootNodeUuid);
private transient MetadataCollector metadataCollector = DEFAULT_METADATA_COLLECTOR;
final JdbcMetadataRepository repository() {
return this.repository;
}
- /**
- * Set the time in milliseconds that content returned from this source may used while in the cache.
- *
- * @param cacheTimeToLive the time to live, in milliseconds; 0 if the time to live is not specified by this source; or a
- * negative number for the default value
- */
- public synchronized void setCacheTimeToLiveInMilliseconds( int cacheTimeToLive ) {
- if (cacheTimeToLive < 0) cacheTimeToLive = DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS;
- this.cacheTimeToLiveInMilliseconds = cacheTimeToLive;
- if (this.cacheTimeToLiveInMilliseconds == 0) {
- this.cachePolicy = null;
- } else {
- final int ttl = this.cacheTimeToLiveInMilliseconds;
- this.cachePolicy = new CachePolicy() {
-
- private static final long serialVersionUID = 1L;
-
- public long getTimeToLive() {
- return ttl;
- }
- };
- }
- }
-
- public long getCacheTimeToLiveInMilliseconds() {
- return this.cacheTimeToLiveInMilliseconds;
- }
-
- public CachePolicy getDefaultCachePolicy() {
- return this.cachePolicy;
- }
-
- public RepositoryContext getRepositoryContext() {
- return this.repositoryContext;
- }
-
+ @Override
public void close() {
if (this.dataSource instanceof ComboPooledDataSource) {
((ComboPooledDataSource)this.dataSource).close();
@@ -299,51 +245,13 @@
return new PathRepositoryConnection(this, repository);
}
- /*
- * (non-Javadoc)
- * @see org.jboss.dna.graph.connector.RepositorySource#getName()
- */
- public String getName() {
- return this.name;
- }
-
- public void setName( String name ) {
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.dna.graph.connector.RepositorySource#getRetryLimit()
- */
- public int getRetryLimit() {
- return this.retryLimit;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.dna.graph.connector.RepositorySource#initialize(org.jboss.dna.graph.connector.RepositoryContext)
- */
- public void initialize( RepositoryContext context ) throws RepositorySourceException {
- this.repositoryContext = context;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.dna.graph.connector.RepositorySource#setRetryLimit(int)
- */
- public void setRetryLimit( int limit ) {
- this.retryLimit = limit;
-
- }
-
public Reference getReference() {
String className = getClass().getName();
String factoryClassName = this.getClass().getName();
Reference ref = new Reference(className, factoryClassName, null);
ref.add(new StringRefAddr(SOURCE_NAME, getName()));
- ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid()));
+ ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid().toString()));
ref.add(new StringRefAddr(DATA_SOURCE_JNDI_NAME, getDataSourceJndiName()));
ref.add(new StringRefAddr(USERNAME, getUsername()));
ref.add(new StringRefAddr(PASSWORD, getPassword()));
@@ -359,7 +267,6 @@
Integer.toString(getNumberOfConnectionsToAcquireAsNeeded())));
ref.add(new StringRefAddr(IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS,
Integer.toString(getIdleTimeInSecondsBeforeTestingConnections())));
- ref.add(new StringRefAddr(CACHE_TIME_TO_LIVE_IN_MILLISECONDS, Long.toString(getCacheTimeToLiveInMilliseconds())));
ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getDefaultWorkspaceName()));
ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
@@ -378,38 +285,28 @@
return null;
}
- Map<String, String> values = new HashMap<String, String>();
- Reference ref = (Reference)obj;
- Enumeration<?> en = ref.getAll();
- while (en.hasMoreElements()) {
- RefAddr subref = (RefAddr)en.nextElement();
- if (subref instanceof StringRefAddr) {
- String key = subref.getType();
- Object value = subref.getContent();
- if (value != null) values.put(key, value.toString());
- }
- }
- String sourceName = values.get(SOURCE_NAME);
- String rootNodeUuid = values.get(ROOT_NODE_UUID);
- String dataSourceJndiName = values.get(DATA_SOURCE_JNDI_NAME);
- String username = values.get(USERNAME);
- String password = values.get(PASSWORD);
- String url = values.get(URL);
- String driverClassName = values.get(DRIVER_CLASS_NAME);
- String driverClassloaderName = values.get(DRIVER_CLASSLOADER_NAME);
- String maxConnectionsInPool = values.get(MAXIMUM_CONNECTIONS_IN_POOL);
- String minConnectionsInPool = values.get(MINIMUM_CONNECTIONS_IN_POOL);
- String maxConnectionIdleTimeInSec = values.get(MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS);
- String maxSizeOfStatementCache = values.get(MAXIMUM_SIZE_OF_STATEMENT_CACHE);
- String acquisitionIncrement = values.get(NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED);
- String idleTimeInSeconds = values.get(IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS);
- String cacheTtlInMillis = values.get(CACHE_TIME_TO_LIVE_IN_MILLISECONDS);
- String retryLimit = values.get(RETRY_LIMIT);
- String defaultWorkspace = values.get(DEFAULT_WORKSPACE);
- String defaultCatalogName = values.get(DEFAULT_CATALOG_NAME);
- String defaultSchemaName = values.get(DEFAULT_SCHEMA_NAME);
- String metadataCollectorClassName = values.get(METADATA_COLLECTOR_CLASS_NAME);
+ Map<String, Object> values = valuesFrom((Reference)obj);
+ String sourceName = (String)values.get(SOURCE_NAME);
+ String rootNodeUuid = (String)values.get(ROOT_NODE_UUID);
+ String dataSourceJndiName = (String)values.get(DATA_SOURCE_JNDI_NAME);
+ String username = (String)values.get(USERNAME);
+ String password = (String)values.get(PASSWORD);
+ String url = (String)values.get(URL);
+ String driverClassName = (String)values.get(DRIVER_CLASS_NAME);
+ String driverClassloaderName = (String)values.get(DRIVER_CLASSLOADER_NAME);
+ String maxConnectionsInPool = (String)values.get(MAXIMUM_CONNECTIONS_IN_POOL);
+ String minConnectionsInPool = (String)values.get(MINIMUM_CONNECTIONS_IN_POOL);
+ String maxConnectionIdleTimeInSec = (String)values.get(MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS);
+ String maxSizeOfStatementCache = (String)values.get(MAXIMUM_SIZE_OF_STATEMENT_CACHE);
+ String acquisitionIncrement = (String)values.get(NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED);
+ String idleTimeInSeconds = (String)values.get(IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS);
+ String retryLimit = (String)values.get(RETRY_LIMIT);
+ String defaultWorkspace = (String)values.get(DEFAULT_WORKSPACE);
+ String defaultCatalogName = (String)values.get(DEFAULT_CATALOG_NAME);
+ String defaultSchemaName = (String)values.get(DEFAULT_SCHEMA_NAME);
+ String metadataCollectorClassName = (String)values.get(METADATA_COLLECTOR_CLASS_NAME);
+
// Create the source instance ...
JdbcMetadataSource source = new JdbcMetadataSource();
if (sourceName != null) source.setName(sourceName);
@@ -426,7 +323,6 @@
if (maxSizeOfStatementCache != null) source.setMaximumSizeOfStatementCache(Integer.parseInt(maxSizeOfStatementCache));
if (acquisitionIncrement != null) source.setNumberOfConnectionsToAcquireAsNeeded(Integer.parseInt(acquisitionIncrement));
if (idleTimeInSeconds != null) source.setIdleTimeInSecondsBeforeTestingConnections(Integer.parseInt(idleTimeInSeconds));
- if (cacheTtlInMillis != null) source.setCacheTimeToLiveInMilliseconds(Integer.parseInt(cacheTtlInMillis));
if (retryLimit != null) source.setRetryLimit(Integer.parseInt(retryLimit));
if (defaultWorkspace != null) source.setDefaultWorkspaceName(defaultWorkspace);
if (defaultCatalogName != null) source.setDefaultCatalogName(defaultCatalogName);
@@ -627,30 +523,6 @@
}
/**
- * @return rootNodeUuid
- */
- public String getRootNodeUuid() {
- return rootNodeUuid;
- }
-
- /**
- * @return rootUuid
- */
- public UUID getRootUuid() {
- return rootUuid;
- }
-
- /**
- * @param rootNodeUuid Sets rootNodeUuid to the specified value.
- * @throws IllegalArgumentException if the string value cannot be converted to UUID
- */
- public void setRootNodeUuid( String rootNodeUuid ) {
- if (rootNodeUuid != null && rootNodeUuid.trim().length() == 0) rootNodeUuid = DEFAULT_ROOT_NODE_UUID;
- this.rootUuid = UUID.fromString(rootNodeUuid);
- this.rootNodeUuid = rootNodeUuid;
- }
-
- /**
* Get the name of the default workspace.
*
* @return the name of the workspace that should be used by default, or null if there is no default workspace
@@ -752,10 +624,6 @@
return metadataCollector;
}
- public boolean areUpdatesAllowed() {
- return false;
- }
-
/**
* In-memory connectors aren't shared and cannot be loaded from external sources if updates are not allowed. Therefore, in
* order to avoid setting up an in-memory connector that is permanently empty (presumably, not a desired outcome), all
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -32,6 +32,7 @@
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Types;
import java.util.Map;
import java.util.Set;
@@ -101,8 +102,12 @@
workspace = repository.getWorkspace(source.getDefaultWorkspaceName());
assertThat(workspace, is(notNullValue()));
+ try {
TestEnvironment.executeDdl(this.source.getDataSource(), "create.ddl", this);
+ } catch (SQLException se) {
+ }
+
DataSource dataSource = source.getDataSource();
Connection conn = dataSource.getConnection();
DatabaseMetaData dmd = conn.getMetaData();
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java 2010-01-04 15:29:24 UTC (rev 1519)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java 2010-01-04 15:33:19 UTC (rev 1520)
@@ -70,9 +70,6 @@
value = properties.getProperty("jpaSource.maximumConnectionIdleTimeInSeconds");
if (isValue(value)) source.setMaximumConnectionIdleTimeInSeconds(Integer.parseInt(value));
- value = properties.getProperty("jpaSource.cacheTimeToLiveInMilliseconds");
- if (isValue(value)) source.setCacheTimeToLiveInMilliseconds(Integer.parseInt(value));
-
value = properties.getProperty("jpaSource.defaultWorkspaceName");
if (isValue(value)) source.setDefaultWorkspaceName(value);
14 years, 4 months
DNA SVN: r1519 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-04 10:29:24 -0500 (Mon, 04 Jan 2010)
New Revision: 1519
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
Log:
DNA-572 FederatedRepositoryConnection Can Freeze When Exception Thrown from RepositoryConnection.execute(...)
Applied patch that corrects one possible source of freezes in the federated connector by ensuring that a FederatedRequest is still submitted if the projection fails.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2010-01-04 15:26:50 UTC (rev 1518)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2010-01-04 15:29:24 UTC (rev 1519)
@@ -311,7 +311,6 @@
public void process( VerifyNodeExistsRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -343,7 +342,6 @@
public void process( ReadNodeRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -414,7 +412,6 @@
public void process( ReadAllChildrenRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.of(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -504,7 +501,6 @@
public void process( ReadAllPropertiesRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -538,7 +534,6 @@
public void process( ReadPropertyRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.on(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -578,15 +573,18 @@
public void process( ReadBranchRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
- FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
- // And process the branch, creating ReadNodeRequests for each placeholder, and ReadBranchRequests for each proxy node...
- if (request.maximumDepth() > 0) {
- processBranch(federatedRequest, projectedNode, workspace, request.maximumDepth());
+ if (projectedNode != null) {
+ FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
+
+ // And process the branch, creating ReadNodeRequests for each placeholder, and ReadBranchRequests for each proxy
+ // node...
+ if (request.maximumDepth() > 0) {
+ processBranch(federatedRequest, projectedNode, workspace, request.maximumDepth());
+ }
}
// Submit the requests for processing ...
@@ -645,10 +643,13 @@
public void process( CreateNodeRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.under(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
// Any non-read request should be submitted to the first ProxyNode ...
PlaceholderNode placeholder = null;
@@ -724,11 +725,15 @@
public void process( RemovePropertyRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.from(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -759,11 +764,15 @@
public void process( UpdatePropertiesRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.on(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -794,11 +803,15 @@
public void process( UpdateValuesRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.on(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -830,11 +843,15 @@
public void process( SetPropertyRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.on(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -865,11 +882,15 @@
public void process( DeleteChildrenRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// A delete should be executed against any ProxyNode that applies ...
FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext(), false);
@@ -892,11 +913,15 @@
public void process( DeleteBranchRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// A delete should be executed against any ProxyNode that applies ...
FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext(), true);
@@ -965,9 +990,15 @@
public void process( CopyBranchRequest request ) {
// Figure out where the 'from' is projected ...
ProjectedNode projectedFromNode = project(request.from(), request.fromWorkspace(), request, false);
- if (projectedFromNode == null) return;
+ if (projectedFromNode == null) {
+ submit(new FederatedRequest(request));
+ return;
+ }
ProjectedNode projectedIntoNode = project(request.into(), request.intoWorkspace(), request, true);
- if (projectedIntoNode == null) return;
+ if (projectedIntoNode == null) {
+ submit(new FederatedRequest(request));
+ return;
+ }
// Limitation: only able to project the copy if the 'from' and 'into' are in the same source & projection ...
while (projectedFromNode != null) {
@@ -1023,9 +1054,15 @@
public void process( CloneBranchRequest request ) {
// Figure out where the 'from' is projected ...
ProjectedNode projectedFromNode = project(request.from(), request.fromWorkspace(), request, false);
- if (projectedFromNode == null) return;
+ if (projectedFromNode == null) {
+ submit(new FederatedRequest(request));
+ return;
+ }
ProjectedNode projectedIntoNode = project(request.into(), request.intoWorkspace(), request, true);
- if (projectedIntoNode == null) return;
+ if (projectedIntoNode == null) {
+ submit(new FederatedRequest(request));
+ return;
+ }
// Limitation: only able to project the copy if the 'from' and 'into' are in the same source & projection ...
while (projectedFromNode != null) {
@@ -1082,7 +1119,10 @@
public void process( MoveBranchRequest request ) {
// Figure out where the 'from' is projected ...
ProjectedNode projectedFromNode = project(request.from(), request.inWorkspace(), request, true);
- if (projectedFromNode == null) return;
+ if (projectedFromNode == null) {
+ submit(new FederatedRequest(request));
+ return;
+ }
ProjectedNode projectedBeforeNode = request.before() != null ? project(request.before(),
request.inWorkspace(),
@@ -1164,11 +1204,15 @@
public void process( RenameNodeRequest request ) {
// Figure out where the 'at' is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -1199,11 +1243,15 @@
public void process( LockBranchRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -1234,11 +1282,15 @@
public void process( UnlockBranchRequest request ) {
// Figure out where this request is projected ...
ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
+ if (projectedNode == null) {
+ submit(federatedRequest);
+ return;
+ }
+
// Any non-read request should be submitted to the first ProxyNode ...
while (projectedNode != null) {
if (projectedNode.isProxy()) {
@@ -1273,7 +1325,6 @@
// Get the root location ...
Location root = Location.create(getExecutionContext().getValueFactories().getPathFactory().createRootPath());
ProjectedNode projectedNode = project(root, workspace.getName(), request, false);
- if (projectedNode == null) return;
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
@@ -1378,5 +1429,4 @@
channel.cancel(mayInterruptIfRunning);
}
}
-
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2010-01-04 15:26:50 UTC (rev 1518)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2010-01-04 15:29:24 UTC (rev 1519)
@@ -204,7 +204,7 @@
@Override
public void process( VerifyNodeExistsRequest request ) {
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.at();
int numMerged = 0;
@@ -258,7 +258,7 @@
Map<Name, Property> properties = request.getPropertiesByName();
Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.at();
int numMerged = 0;
@@ -409,7 +409,7 @@
Path federatedPath = request.of().getPath();
Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.of();
int numMerged = 0;
@@ -506,7 +506,7 @@
public void process( ReadAllPropertiesRequest request ) {
Map<Name, Property> properties = request.getPropertiesByName();
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.at();
int numMerged = 0;
@@ -568,7 +568,7 @@
@Override
public void process( ReadPropertyRequest request ) {
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.on();
int numMerged = 0;
@@ -631,7 +631,7 @@
@Override
public void process( ReadBranchRequest request ) {
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
request.setCachePolicy(getDefaultCachePolicy());
Location actualLocation = request.at();
int numMerged = 0;
@@ -838,8 +838,8 @@
@Override
public void process( CreateNodeRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- Request projectedRequest = projected.getRequest();
+
+ Request projectedRequest = projected == null ? null : projected.getRequest();
// Check the error first ...
if (checkErrorOrCancel(request, projectedRequest)) return;
@@ -866,8 +866,8 @@
@Override
public void process( UpdatePropertiesRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- UpdatePropertiesRequest source = (UpdatePropertiesRequest)projected.getRequest();
+
+ UpdatePropertiesRequest source = projected == null ? null : (UpdatePropertiesRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location sourceLocation = source.getActualLocationOfNode();
request.setActualLocationOfNode(projectToFederated(request.on(), projected.getProjection(), sourceLocation, request));
@@ -882,8 +882,8 @@
@Override
public void process( SetPropertyRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- SetPropertyRequest source = (SetPropertyRequest)projected.getRequest();
+
+ SetPropertyRequest source = projected == null ? null : (SetPropertyRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
// Set the actual location and created flags ...
Location sourceLocation = source.getActualLocationOfNode();
@@ -899,8 +899,8 @@
@Override
public void process( RemovePropertyRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- SetPropertyRequest source = (SetPropertyRequest)projected.getRequest();
+
+ SetPropertyRequest source = projected == null ? null : (SetPropertyRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location sourceLocation = source.getActualLocationOfNode();
request.setActualLocationOfNode(projectToFederated(request.from(), projected.getProjection(), sourceLocation, request));
@@ -914,6 +914,11 @@
@Override
public void process( DeleteBranchRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
+
+ // Do an initial check to make sure that there was no error on the source that prevented projection
+ Request projectedSource = projected == null ? null : projected.getRequest();
+ if (checkErrorOrCancel(request, projectedSource)) return;
+
// Go through the projected requests, and look for the top-most node ...
Location highest = null;
while (projected != null) {
@@ -949,6 +954,11 @@
@Override
public void process( DeleteChildrenRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
+
+ // Do an initial check to make sure that there was no error on the source that prevented projection
+ Request projectedSource = projected == null ? null : projected.getRequest();
+ if (checkErrorOrCancel(request, projectedSource)) return;
+
// Go through the projected requests, and look for the top-most node ...
Location highest = null;
while (projected != null) {
@@ -976,8 +986,8 @@
@Override
public void process( RenameNodeRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- RenameNodeRequest source = (RenameNodeRequest)projected.getRequest();
+
+ RenameNodeRequest source = projected == null ? null : (RenameNodeRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location locationBefore = source.getActualLocationBefore();
Location locationAfter = source.getActualLocationBefore();
@@ -994,8 +1004,8 @@
@Override
public void process( CopyBranchRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- CopyBranchRequest source = (CopyBranchRequest)projected.getRequest();
+
+ CopyBranchRequest source = projected == null ? null : (CopyBranchRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location locationBefore = source.getActualLocationBefore();
Location locationAfter = source.getActualLocationBefore();
@@ -1012,8 +1022,8 @@
@Override
public void process( CloneBranchRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- CloneBranchRequest source = (CloneBranchRequest)projected.getRequest();
+
+ CloneBranchRequest source = projected == null ? null : (CloneBranchRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location locationBefore = source.getActualLocationBefore();
Location locationAfter = source.getActualLocationBefore();
@@ -1037,8 +1047,8 @@
@Override
public void process( MoveBranchRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
- assert !projected.hasNext();
- MoveBranchRequest source = (MoveBranchRequest)projected.getRequest();
+
+ MoveBranchRequest source = projected == null ? null : (MoveBranchRequest)projected.getRequest();
if (checkErrorOrCancel(request, source)) return;
Location locationBefore = source.getActualLocationBefore();
Location locationAfter = source.getActualLocationBefore();
@@ -1057,7 +1067,7 @@
@Override
public void process( VerifyWorkspaceRequest request ) {
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();
- assert projectedRequest != null;
+
Location actualLocation = Location.create(getExecutionContext().getValueFactories().getPathFactory().createRootPath());
while (projectedRequest != null) {
VerifyNodeExistsRequest readFromSource = (VerifyNodeExistsRequest)projectedRequest.getRequest();
14 years, 4 months
DNA SVN: r1518 - in trunk/dna-graph/src/main/java/org/jboss/dna/graph/request: processor and 1 other directory.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-04 10:26:50 -0500 (Mon, 04 Jan 2010)
New Revision: 1518
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
Log:
DNA-549 Creating A New Property And Changing An Existing Property Should Have Different ChangeRequest Types
Applied patch that adds a boolean method (isNewProperty()) that indicates whether a property was created as a result of processing this request. It's a parallel to the same method in SetPropertyRequest.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-02 16:45:32 UTC (rev 1517)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2010-01-04 15:26:50 UTC (rev 1518)
@@ -39,6 +39,7 @@
private Location actualLocation;
private List<Object> actualAddedValues;
private List<Object> actualRemovedValues;
+ private boolean actualCreation;
public UpdateValuesRequest( String workspaceName,
Location on,
@@ -148,6 +149,18 @@
}
/**
+ * Record that the property did not exist prior to the processing of this request and was actually created by this request.
+ * This method must be called when processing the request, and the actual location must have a {@link Location#getPath() path}
+ * .
+ *
+ * @param created true if the property was created by this request, or false if this request updated an existing property
+ * @throws IllegalStateException if the request is frozen
+ */
+ public void setNewProperty( boolean created ) {
+ this.actualCreation = created;
+ }
+
+ /**
* Get the actual location of the node that was updated.
*
* @return the actual location, or null if the actual location was not set
@@ -176,6 +189,15 @@
}
/**
+ * Get whether the {@link #property() property} was created.
+ *
+ * @return true if this request created the property, or false if this request changed an existing property
+ */
+ public boolean isNewProperty() {
+ return actualCreation;
+ }
+
+ /**
* {@inheritDoc}
* <p>
* This method does not clone the results.
@@ -188,6 +210,7 @@
UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, actualLocation != null ? actualLocation : on,
propertyName, addedValues, removedValues);
request.setActualLocation(actualLocation, actualAddedValues, actualRemovedValues);
+ request.setNewProperty(actualCreation);
return request;
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-02 16:45:32 UTC (rev 1517)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2010-01-04 15:26:50 UTC (rev 1518)
@@ -822,6 +822,7 @@
// Update the current values
SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
process(setProperty);
+ request.setNewProperty(setProperty.isNewProperty());
if (setProperty.hasError()) {
request.setError(setProperty.getError());
14 years, 4 months
DNA SVN: r1517 - trunk/docs/examples/gettingstarted/sequencers/src/main/resources.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-02 11:45:32 -0500 (Sat, 02 Jan 2010)
New Revision: 1517
Added:
trunk/docs/examples/gettingstarted/sequencers/src/main/resources/JcrRepository.clazz
Log:
Added missing file for sequencer example
Added: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/JcrRepository.clazz
===================================================================
(Binary files differ)
Property changes on: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/JcrRepository.clazz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 4 months
DNA SVN: r1516 - trunk/docs/examples/gettingstarted/sequencers.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-02 11:30:15 -0500 (Sat, 02 Jan 2010)
New Revision: 1516
Modified:
trunk/docs/examples/gettingstarted/sequencers/pom.xml
Log:
Corrected dependency scope on classfile sequencer to fix a CI break
Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml 2010-01-02 16:19:39 UTC (rev 1515)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml 2010-01-02 16:30:15 UTC (rev 1516)
@@ -32,7 +32,6 @@
<groupId>org.jboss.dna</groupId>
<artifactId>dna-sequencer-classfile</artifactId>
<version>${project.version}</version>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
14 years, 4 months
DNA SVN: r1515 - trunk/docs/examples/gettingstarted.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-02 11:19:39 -0500 (Sat, 02 Jan 2010)
New Revision: 1515
Modified:
trunk/docs/examples/gettingstarted/pom.xml
Log:
Removed repository example temporarily to keep it from hanging the build server
Modified: trunk/docs/examples/gettingstarted/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/pom.xml 2010-01-01 18:26:33 UTC (rev 1514)
+++ trunk/docs/examples/gettingstarted/pom.xml 2010-01-02 16:19:39 UTC (rev 1515)
@@ -10,7 +10,7 @@
<modules>
<module>sequencers</module>
- <module>repositories</module>
+ <!-- module>repositories</module -->
</modules>
<dependencyManagement>
14 years, 4 months
DNA SVN: r1514 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-01 13:26:33 -0500 (Fri, 01 Jan 2010)
New Revision: 1514
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryTransaction.java
Log:
Fixed Javadoc error
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryTransaction.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryTransaction.java 2010-01-01 18:02:31 UTC (rev 1513)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/path/PathRepositoryTransaction.java 2010-01-01 18:26:33 UTC (rev 1514)
@@ -26,7 +26,7 @@
import org.jboss.dna.graph.connector.map.MapRepositoryTransaction;
/**
- * A transaction returned by the {@link PathRepository#startTransaction(boolean)}.
+ * A transaction for a {@link PathRepository}.
*
* @see MapRepositoryTransaction
*/
@@ -37,7 +37,6 @@
* committing the changes, but the transaction is still expected to be closed.
*
* @see #rollback()
- * @see PathRepository#startTransaction(boolean)
*/
void commit();
@@ -46,7 +45,6 @@
* rolling back the changes, but the transaction is still expected to be closed.
*
* @see #commit()
- * @see PathRepository#startTransaction(boolean)
*/
void rollback();
14 years, 4 months
DNA SVN: r1513 - in trunk/extensions/dna-sequencer-classfile: src/main/java/org/jboss/dna/sequencer/classfile and 1 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2010-01-01 13:02:31 -0500 (Fri, 01 Jan 2010)
New Revision: 1513
Modified:
trunk/extensions/dna-sequencer-classfile/
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java
trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java
Log:
DNA-62 Sequence Java class files to extract the class structure with annotations
Fixed 3 spurious @Overrides and added target folder to svn:ignore
Property changes on: trunk/extensions/dna-sequencer-classfile
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java 2010-01-01 17:46:39 UTC (rev 1512)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/ClassFileSequencer.java 2010-01-01 18:02:31 UTC (rev 1513)
@@ -38,7 +38,6 @@
private ClassFileRecorder classFileRecorder = DEFAULT_CLASS_FILE_RECORDER;
- @Override
public void sequence( InputStream stream,
SequencerOutput output,
StreamSequencerContext context ) {
Modified: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java 2010-01-01 17:46:39 UTC (rev 1512)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/DefaultClassFileRecorder.java 2010-01-01 18:02:31 UTC (rev 1513)
@@ -40,7 +40,6 @@
public class DefaultClassFileRecorder implements ClassFileRecorder {
- @Override
public void recordClass( StreamSequencerContext context,
SequencerOutput output,
ClassMetadata classMetadata ) {
Modified: trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java
===================================================================
--- trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java 2010-01-01 17:46:39 UTC (rev 1512)
+++ trunk/extensions/dna-sequencer-classfile/src/main/java/org/jboss/dna/sequencer/classfile/metadata/FieldMetadata.java 2010-01-01 18:02:31 UTC (rev 1513)
@@ -91,7 +91,6 @@
return annotations;
}
- @Override
public int compareTo( FieldMetadata o ) {
if (this.isStatic() && !o.isStatic()) {
return 1;
14 years, 4 months