Author: jverhaeg(a)redhat.com
Date: 2008-10-24 14:08:17 -0400 (Fri, 24 Oct 2008)
New Revision: 581
Added:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerContext.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerOutput.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/util/GraphImporter.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlSequencer.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerOutput.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/xml/XmlSequencerTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
Log:
DNA-185: Modified SequencerContext and all implementation to extend ExecutionContext.
Also removed related deprecated getNamespaceRegistry() and getFactories() methods in
SequencerOutput.
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerContext.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerContext.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerContext.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -22,26 +22,17 @@
package org.jboss.dna.graph.sequencers;
import java.util.Set;
-import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.properties.Name;
-import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.Property;
-import org.jboss.dna.graph.properties.ValueFactories;
/**
* @author John Verhaeg
*/
-public interface SequencerContext {
+public interface SequencerContext extends ExecutionContext {
/**
- * Get the factories that can be used to create {@link Path paths} and other property
values.
- *
- * @return the collection of factories; never <code>null</code>.
- */
- ValueFactories getFactories();
-
- /**
* Return the path of the input node containing the content being sequenced.
*
* @return input node's path.
@@ -69,34 +60,4 @@
* @return the MIME-type
*/
String getMimeType();
-
- /**
- * Convenience method to get the namespace registry used by the {@link
ValueFactories#getNameFactory() name value factory}.
- *
- * @return the namespace registry; never <code>null</code>.
- */
- NamespaceRegistry getNamespaceRegistry();
-
- /**
- * Return a logger associated with this context. This logger records only those
activities within the context and provide a
- * way to capture the context-specific activities. All log messages are also sent to
the system logger, so classes that log
- * via this mechanism should <i>not</i> also {@link
Logger#getLogger(Class) obtain a system logger}.
- *
- * @param clazz the class that is doing the logging
- * @return the logger, named after <code>clazz</code>; never null
- * @see #getLogger(String)
- */
- Logger getLogger( Class<?> clazz );
-
- /**
- * Return a logger associated with this context. This logger records only those
activities within the context and provide a
- * way to capture the context-specific activities. All log messages are also sent to
the system logger, so classes that log
- * via this mechanism should <i>not</i> also {@link
Logger#getLogger(Class) obtain a system logger}.
- *
- * @param name the name for the logger
- * @return the logger, named after <code>clazz</code>; never null
- * @see #getLogger(Class)
- */
- Logger getLogger( String name );
-
}
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerOutput.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerOutput.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencers/SequencerOutput.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -22,9 +22,7 @@
package org.jboss.dna.graph.sequencers;
import org.jboss.dna.graph.properties.Name;
-import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
-import org.jboss.dna.graph.properties.ValueFactories;
/**
* Interface for sequencers to use to generate their output.
@@ -35,33 +33,15 @@
public interface SequencerOutput {
/**
- * Get the factories that can be used to create {@link Path paths} and other property
values.
- *
- * @return the collection of factories; never null
- * @deprecated Replaced by {@link SequencerContext#getFactories()}.
- */
- @Deprecated
- ValueFactories getFactories();
-
- /**
- * Convenience method to get the namespace registry used by the {@link
ValueFactories#getNameFactory() name value factory}.
- *
- * @return the namespace registry; never <code>null</code>
- * @deprecated Replaced by {@link SequencerContext#getNamespaceRegistry()}.
- */
- @Deprecated
- NamespaceRegistry getNamespaceRegistry();
-
- /**
* Set the supplied property on the supplied node.
* <p>
- * The {@link #getFactories() value factories} should be used to create paths, names,
and values. These factories can be used
- * to create new values or convert values from one property type to another. (Note
that each of the factories have methods
- * that create values from all of the property types.)
+ * The {@link SequencerContext#getValueFactories() value factories} should be used to
create paths, names, and values. These
+ * factories can be used to create new values or convert values from one property
type to another. (Note that each of the
+ * factories have methods that create values from all of the property types.)
* </p>
* <p>
* This method is provided as a convenience, but it identical to creating a {@link
Path} and {@link Name} using the
- * {@link #getFactories() factories} and calling {@link #setProperty(Path, Name,
Object...)}.
+ * {@link SequencerContext#getValueFactories() factories} and calling {@link
#setProperty(Path, Name, Object...)}.
* </p>
*
* @param nodePath the path to the node containing the property; may not be null
@@ -76,7 +56,7 @@
* Set the supplied reference on the supplied node.
* <p>
* This method is provided as a convenience, but it identical to creating a {@link
Path} and {@link Name} using the
- * {@link #getFactories() factories} and calling {@link #setProperty(Path, Name,
Object...)}.
+ * {@link SequencerContext#getValueFactories() factories} and calling {@link
#setProperty(Path, Name, Object...)}.
* </p>
*
* @param nodePath the path to the node containing the property; may not be null
@@ -91,9 +71,9 @@
/**
* Set the supplied property on the supplied node.
* <p>
- * The {@link #getFactories() value factories} should be used to create paths, names,
and values. These factories can be used
- * to create new values or convert values from one property type to another. (Note
that each of the factories have methods
- * that create values from all of the property types.)
+ * The {@link SequencerContext#getValueFactories() value factories} should be used to
create paths, names, and values. These
+ * factories can be used to create new values or convert values from one property
type to another. (Note that each of the
+ * factories have methods that create values from all of the property types.)
* </p>
*
* @param nodePath the path to the node containing the property; may not be null
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/util/GraphImporter.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/util/GraphImporter.java 2008-10-24
18:04:46 UTC (rev 580)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/util/GraphImporter.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -25,9 +25,12 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
+import java.security.AccessControlContext;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.SimpleProgressMonitor;
@@ -59,6 +62,7 @@
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class GraphImporter {
@@ -208,27 +212,13 @@
this.primaryTypeName = this.nameFactory.create("jcr:primaryType");
}
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.sequencers.SequencerOutput#getFactories()
- */
- public ValueFactories getFactories() {
+ private ValueFactories getFactories() {
return getContext().getValueFactories();
}
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencers.SequencerOutput#getNamespaceRegistry()
- */
- public NamespaceRegistry getNamespaceRegistry() {
- return getContext().getNamespaceRegistry();
- }
-
- /**
- * {@inheritDoc}
- *
* @see
org.jboss.dna.graph.sequencers.SequencerOutput#setProperty(java.lang.String,
java.lang.String, java.lang.Object[])
*/
public void setProperty( String nodePath,
@@ -321,15 +311,24 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencers.SequencerContext#getFactories()
+ * @see org.jboss.dna.graph.ExecutionContext#getAccessControlContext()
*/
- public ValueFactories getFactories() {
- return getContext().getValueFactories();
+ public AccessControlContext getAccessControlContext() {
+ return getContext().getAccessControlContext();
}
/**
* {@inheritDoc}
*
+ * @see
org.jboss.dna.common.component.ClassLoaderFactory#getClassLoader(java.lang.String[])
+ */
+ public ClassLoader getClassLoader( String... classpath ) {
+ return getContext().getClassLoader(classpath);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.sequencers.SequencerContext#getInputPath()
*/
public Path getInputPath() {
@@ -378,6 +377,15 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.ExecutionContext#getLoginContext()
+ */
+ public LoginContext getLoginContext() {
+ return getContext().getLoginContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.sequencers.SequencerContext#getMimeType()
*/
public String getMimeType() {
@@ -393,6 +401,32 @@
return getContext().getNamespaceRegistry();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getPropertyFactory()
+ */
+ public PropertyFactory getPropertyFactory() {
+ return getContext().getPropertyFactory();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return getContext().getSubject();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getValueFactories()
+ */
+ public ValueFactories getValueFactories() {
+ return getContext().getValueFactories();
+ }
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlSequencer.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlSequencer.java 2008-10-24
18:04:46 UTC (rev 580)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/xml/XmlSequencer.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -160,9 +160,9 @@
this.context = context;
this.monitor = monitor;
// Initialize path to a an empty path relative to the SequencerOutput's
target path.
- path = context.getFactories().getPathFactory().createRelativePath();
+ path = context.getValueFactories().getPathFactory().createRelativePath();
// Cache name factory since it is frequently used
- nameFactory = context.getFactories().getNameFactory();
+ nameFactory = context.getValueFactories().getNameFactory();
}
/**
@@ -560,7 +560,7 @@
indexedNames.add(indexedName);
// Add element name and the appropriate index to the path.
// Per the JCR spec, the index must be relative to same-name sibling nodes
- path = context.getFactories().getPathFactory().create(path, name,
indexedNames.size());
+ path = context.getValueFactories().getPathFactory().create(path, name,
indexedNames.size());
path = path.getNormalizedPath();
// Add the indexed name map to the stack and set the current map to the new
element's map
nameToIndexedNamesMapStack.addFirst(nameToIndexedNamesMap);
Added:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerContext.java
===================================================================
---
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerContext.java
(rev 0)
+++
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerContext.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.graph.sequencers;
+
+import java.security.AccessControlContext;
+import java.util.Set;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.DnaLexicon;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NamespaceRegistry;
+import org.jboss.dna.graph.properties.Path;
+import org.jboss.dna.graph.properties.Property;
+import org.jboss.dna.graph.properties.PropertyFactory;
+import org.jboss.dna.graph.properties.ValueFactories;
+import org.jboss.dna.graph.properties.basic.BasicNamespaceRegistry;
+import org.jboss.dna.graph.properties.basic.StandardValueFactories;
+
+/**
+ * @author jverhaeg
+ */
+@Immutable
+public class MockSequencerContext implements SequencerContext {
+
+ private final ValueFactories factories;
+ private final NamespaceRegistry registry = new BasicNamespaceRegistry();
+
+ public MockSequencerContext() {
+ registry.register("jcr", "http://www.jcp.org/jcr/1.0");
+ registry.register("mix", "http://www.jcp.org/jcr/mix/1.0");
+ registry.register("nt", "http://www.jcp.org/jcr/nt/1.0");
+ registry.register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
+ registry.register("dnadtd",
"http://www.jboss.org/dna/dtd/1.0");
+ registry.register("dnaxml",
"http://www.jboss.org/dna/xml/1.0");
+ factories = new StandardValueFactories(registry);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.component.ClassLoaderFactory#getClassLoader(java.lang.String[])
+ */
+ public ClassLoader getClassLoader( String... classpath ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getInputPath()
+ */
+ public Path getInputPath() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getInputProperties()
+ */
+ public Set<Property> getInputProperties() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.graph.sequencers.SequencerContext#getInputProperty(org.jboss.dna.graph.properties.Name)
+ */
+ public Property getInputProperty( Name name ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getMimeType()
+ */
+ public String getMimeType() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getAccessControlContext()
+ */
+ public AccessControlContext getAccessControlContext() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getLogger(java.lang.Class)
+ */
+ public Logger getLogger( Class<?> clazz ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getLogger(java.lang.String)
+ */
+ public Logger getLogger( String name ) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getLoginContext()
+ */
+ public LoginContext getLoginContext() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getNamespaceRegistry()
+ */
+ public NamespaceRegistry getNamespaceRegistry() {
+ return registry;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getPropertyFactory()
+ */
+ public PropertyFactory getPropertyFactory() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getSubject()
+ */
+ public Subject getSubject() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getValueFactories()
+ */
+ public ValueFactories getValueFactories() {
+ return factories;
+ }
+}
Property changes on:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerOutput.java
===================================================================
---
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerOutput.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencers/MockSequencerOutput.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -24,15 +24,9 @@
import java.util.HashMap;
import java.util.Map;
import net.jcip.annotations.NotThreadSafe;
-import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.properties.Name;
-import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.PathFactory;
-import org.jboss.dna.graph.properties.ValueFactories;
-import org.jboss.dna.graph.properties.basic.BasicNamespaceRegistry;
-import org.jboss.dna.graph.properties.basic.StandardValueFactories;
-import org.jboss.dna.graph.sequencers.SequencerOutput;
/**
* @author Randall Hauch
@@ -42,43 +36,16 @@
public class MockSequencerOutput implements SequencerOutput {
private final Map<Path, Object[]> properties;
- private final ValueFactories factories;
+ private final SequencerContext context;
- /**
- */
- public MockSequencerOutput() {
+ public MockSequencerOutput( SequencerContext context ) {
+ this.context = context;
this.properties = new HashMap<Path, Object[]>();
- NamespaceRegistry registry = new BasicNamespaceRegistry();
- registry.register("jcr", "http://www.jcp.org/jcr/1.0");
- registry.register("mix", "http://www.jcp.org/jcr/mix/1.0");
- registry.register("nt", "http://www.jcp.org/jcr/nt/1.0");
- registry.register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
- registry.register("dnadtd",
"http://www.jboss.org/dna/dtd/1.0");
- registry.register("dnaxml",
"http://www.jboss.org/dna/xml/1.0");
- factories = new StandardValueFactories(registry);
}
/**
* {@inheritDoc}
*/
- public ValueFactories getFactories() {
- return this.factories;
- }
-
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.jboss.dna.graph.sequencers.SequencerOutput#getNamespaceRegistry()
- */
- public NamespaceRegistry getNamespaceRegistry() {
- return factories.getNameFactory().getNamespaceRegistry();
- }
-
- /**
- * {@inheritDoc}
- */
public void setProperty( Path nodePath,
Name propertyName,
Object... values ) {
@@ -96,8 +63,8 @@
public void setProperty( String nodePath,
String propertyName,
Object... values ) {
- Path path = this.factories.getPathFactory().create(nodePath);
- Name name = this.factories.getNameFactory().create(propertyName);
+ Path path = context.getValueFactories().getPathFactory().create(nodePath);
+ Name name = context.getValueFactories().getNameFactory().create(propertyName);
setProperty(path, name, values);
}
@@ -107,9 +74,9 @@
public void setReference( String nodePath,
String propertyName,
String... paths ) {
- PathFactory pathFactory = this.factories.getPathFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
Path path = pathFactory.create(nodePath);
- Name name = this.factories.getNameFactory().create(propertyName);
+ Name name = context.getValueFactories().getNameFactory().create(propertyName);
Object[] values = null;
if (paths != null && paths.length != 0) {
values = new Path[paths.length];
@@ -139,14 +106,14 @@
protected Path createKey( String nodePath,
String propertyName ) {
- Path path = this.factories.getPathFactory().create(nodePath);
- Name name = this.factories.getNameFactory().create(propertyName);
+ Path path = context.getValueFactories().getPathFactory().create(nodePath);
+ Name name = context.getValueFactories().getNameFactory().create(propertyName);
return createKey(path, name);
}
protected Path createKey( Path nodePath,
Name propertyName ) {
- return this.factories.getPathFactory().create(nodePath, propertyName);
+ return context.getValueFactories().getPathFactory().create(nodePath,
propertyName);
}
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/xml/XmlSequencerTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/xml/XmlSequencerTest.java 2008-10-24
18:04:46 UTC (rev 580)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/xml/XmlSequencerTest.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -25,7 +25,6 @@
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -33,13 +32,12 @@
import org.jboss.dna.common.monitor.SimpleProgressMonitor;
import org.jboss.dna.graph.properties.Name;
import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.sequencers.MockSequencerContext;
import org.jboss.dna.graph.sequencers.MockSequencerOutput;
import org.jboss.dna.graph.sequencers.SequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* @author John Verhaeg
@@ -70,14 +68,13 @@
private URL xml3;
private URL xml4;
private URL xsd;
- @Mock
private SequencerContext context;
@Before
public void beforeEach() {
- MockitoAnnotations.initMocks(this);
sequencer = new XmlSequencer();
- output = new MockSequencerOutput();
+ context = new MockSequencerContext();
+ output = new MockSequencerOutput(context);
monitor = new SimpleProgressMonitor("Test activity");
xml1 =
this.getClass().getClassLoader().getResource("jackrabbitInMemoryTestRepositoryConfig.xml");
assertThat(xml1, is(notNullValue()));
@@ -89,8 +86,6 @@
assertThat(xml4, is(notNullValue()));
xsd =
this.getClass().getClassLoader().getResource("Descriptor.1.0.xsd");
assertThat(xsd, is(notNullValue()));
- stub(context.getFactories()).toReturn(output.getFactories());
- stub(context.getNamespaceRegistry()).toReturn(output.getNamespaceRegistry());
}
@After
@@ -215,7 +210,7 @@
String property,
String expectedName ) {
Name name = verify(nodePath, property, Name.class);
- assertThat(name,
is(output.getFactories().getNameFactory().create(expectedName)));
+ assertThat(name,
is(context.getValueFactories().getNameFactory().create(expectedName)));
}
private void verifyString( String nodePath,
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.security.AccessControlContext;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -31,6 +32,8 @@
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.Logger;
@@ -38,6 +41,7 @@
import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.Property;
+import org.jboss.dna.graph.properties.PropertyFactory;
import org.jboss.dna.graph.properties.ValueFactories;
import org.jboss.dna.graph.sequencers.SequencerContext;
import org.jboss.dna.graph.sequencers.StreamSequencer;
@@ -135,8 +139,26 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getAccessControlContext()
*/
- public ValueFactories getFactories() {
+ public AccessControlContext getAccessControlContext() {
+ return context.getAccessControlContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.common.component.ClassLoaderFactory#getClassLoader(java.lang.String[])
+ */
+ public ClassLoader getClassLoader( String... classpath ) {
+ return context.getClassLoader(classpath);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ValueFactories getValueFactories() {
return factories;
}
@@ -206,7 +228,34 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getLogger(java.lang.Class)
*/
+ public Logger getLogger( Class<?> clazz ) {
+ return context.getLogger(clazz);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.sequencers.SequencerContext#getLogger(java.lang.String)
+ */
+ public Logger getLogger( String name ) {
+ return context.getLogger(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.ExecutionContext#getLoginContext()
+ */
+ public LoginContext getLoginContext() {
+ return context.getLoginContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public NamespaceRegistry getNamespaceRegistry() {
return factories.getNameFactory().getNamespaceRegistry();
}
@@ -214,18 +263,18 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencers.SequencerContext#getLogger(java.lang.Class)
+ * @see org.jboss.dna.graph.ExecutionContext#getPropertyFactory()
*/
- public Logger getLogger( Class<?> clazz ) {
- return context.getLogger(clazz);
+ public PropertyFactory getPropertyFactory() {
+ return context.getPropertyFactory();
}
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencers.SequencerContext#getLogger(java.lang.String)
+ * @see org.jboss.dna.graph.ExecutionContext#getSubject()
*/
- public Logger getLogger( String name ) {
- return context.getLogger(name);
+ public Subject getSubject() {
+ return context.getSubject();
}
}
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -34,340 +34,326 @@
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.graph.properties.Name;
import org.jboss.dna.graph.properties.NameFactory;
-import org.jboss.dna.graph.properties.NamespaceRegistry;
import org.jboss.dna.graph.properties.Path;
import org.jboss.dna.graph.properties.PathFactory;
import org.jboss.dna.graph.properties.ValueFactories;
import org.jboss.dna.graph.sequencers.SequencerOutput;
/**
- * A basic {@link SequencerOutput} that records all information in-memory and which
organizes the properties by
- * {@link Path node paths} and provides access to the nodes in a natural path-order.
- *
+ * A basic {@link SequencerOutput} that records all information in-memory and which
organizes the properties by {@link Path node
+ * paths} and provides access to the nodes in a natural path-order.
+ *
* @author Randall Hauch
+ * @author John Verhaeg
*/
@NotThreadSafe
public class SequencerOutputMap implements SequencerOutput,
Iterable<SequencerOutputMap.Entry> {
- private static final String JCR_NAME_PROPERTY_NAME = "jcr:name";
+ private static final String JCR_NAME_PROPERTY_NAME = "jcr:name";
- private final Map<Path, List<PropertyValue>> data;
- private transient boolean valuesSorted = true;
- private final ValueFactories factories;
- private final Name jcrName;
+ private final Map<Path, List<PropertyValue>> data;
+ private transient boolean valuesSorted = true;
+ private final ValueFactories factories;
+ private final Name jcrName;
- public SequencerOutputMap( ValueFactories factories ) {
- CheckArg.isNotNull(factories, "factories");
- this.data = new HashMap<Path, List<PropertyValue>>();
- this.factories = factories;
- this.jcrName = this.factories.getNameFactory().create(JCR_NAME_PROPERTY_NAME);
- }
+ public SequencerOutputMap( ValueFactories factories ) {
+ CheckArg.isNotNull(factories, "factories");
+ this.data = new HashMap<Path, List<PropertyValue>>();
+ this.factories = factories;
+ this.jcrName = this.factories.getNameFactory().create(JCR_NAME_PROPERTY_NAME);
+ }
- /**
- * {@inheritDoc}
- */
- public ValueFactories getFactories() {
- return this.factories;
- }
+ ValueFactories getFactories() {
+ return this.factories;
+ }
- /**
- * <p>
- * {@inheritDoc}
- * </p>
- *
- * @see org.jboss.dna.graph.sequencers.SequencerOutput#getNamespaceRegistry()
- */
- public NamespaceRegistry getNamespaceRegistry() {
- return factories.getNameFactory().getNamespaceRegistry();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void setProperty( Path nodePath,
+ Name propertyName,
+ Object... values ) {
+ CheckArg.isNotNull(nodePath, "nodePath");
+ CheckArg.isNotNull(propertyName, "property");
+ // Ignore the "jcr:name" property, as that's handled by the path
...
+ if (this.jcrName.equals(propertyName)) return;
- /**
- * {@inheritDoc}
- */
- public void setProperty( Path nodePath,
- Name propertyName,
- Object... values ) {
- CheckArg.isNotNull(nodePath, "nodePath");
- CheckArg.isNotNull(propertyName, "property");
- // Ignore the "jcr:name" property, as that's handled by the path ...
- if (this.jcrName.equals(propertyName)) return;
+ // Find or create the entry for this node ...
+ List<PropertyValue> properties = this.data.get(nodePath);
+ if (properties == null) {
+ if (values == null || values.length == 0) return; // do nothing
+ properties = new ArrayList<PropertyValue>();
+ this.data.put(nodePath, properties);
+ }
+ if (values == null || values.length == 0) {
+ properties.remove(new PropertyValue(propertyName, null));
+ } else {
+ Object propValue = values.length == 1 ? values[0] : values;
+ PropertyValue value = new PropertyValue(propertyName, propValue);
+ properties.add(value);
+ valuesSorted = false;
+ }
+ }
- // Find or create the entry for this node ...
- List<PropertyValue> properties = this.data.get(nodePath);
- if (properties == null) {
- if (values == null || values.length == 0) return; // do nothing
- properties = new ArrayList<PropertyValue>();
- this.data.put(nodePath, properties);
- }
- if (values == null || values.length == 0) {
- properties.remove(new PropertyValue(propertyName, null));
- } else {
- Object propValue = values.length == 1 ? values[0] : values;
- PropertyValue value = new PropertyValue(propertyName, propValue);
- properties.add(value);
- valuesSorted = false;
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void setProperty( String nodePath,
+ String property,
+ Object... values ) {
+ CheckArg.isNotEmpty(nodePath, "nodePath");
+ CheckArg.isNotEmpty(property, "property");
+ Path path = this.factories.getPathFactory().create(nodePath);
+ Name propertyName = this.factories.getNameFactory().create(property);
+ setProperty(path, propertyName, values);
+ }
- /**
- * {@inheritDoc}
- */
- public void setProperty( String nodePath,
- String property,
- Object... values ) {
- CheckArg.isNotEmpty(nodePath, "nodePath");
- CheckArg.isNotEmpty(property, "property");
- Path path = this.factories.getPathFactory().create(nodePath);
- Name propertyName = this.factories.getNameFactory().create(property);
- setProperty(path, propertyName, values);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void setReference( String nodePath,
+ String propertyName,
+ String... paths ) {
+ PathFactory pathFactory = this.factories.getPathFactory();
+ Path path = pathFactory.create(nodePath);
+ Name name = this.factories.getNameFactory().create(propertyName);
+ Object[] values = null;
+ if (paths != null && paths.length != 0) {
+ values = new Path[paths.length];
+ for (int i = 0, len = paths.length; i != len; ++i) {
+ String pathValue = paths[i];
+ values[i] = pathFactory.create(pathValue);
+ }
+ }
+ setProperty(path, name, values);
+ }
- /**
- * {@inheritDoc}
- */
- public void setReference( String nodePath,
- String propertyName,
- String... paths ) {
- PathFactory pathFactory = this.factories.getPathFactory();
- Path path = pathFactory.create(nodePath);
- Name name = this.factories.getNameFactory().create(propertyName);
- Object[] values = null;
- if (paths != null && paths.length != 0) {
- values = new Path[paths.length];
- for (int i = 0, len = paths.length; i != len; ++i) {
- String pathValue = paths[i];
- values[i] = pathFactory.create(pathValue);
- }
- }
- setProperty(path, name, values);
- }
+ /**
+ * Return the number of node entries in this map.
+ *
+ * @return the number of entries
+ */
+ public int size() {
+ return this.data.size();
+ }
- /**
- * Return the number of node entries in this map.
- *
- * @return the number of entries
- */
- public int size() {
- return this.data.size();
- }
+ /**
+ * Return whether there are no entries
+ *
+ * @return true if this container is empty, or false otherwise
+ */
+ public boolean isEmpty() {
+ return this.data.isEmpty();
+ }
- /**
- * Return whether there are no entries
- *
- * @return true if this container is empty, or false otherwise
- */
- public boolean isEmpty() {
- return this.data.isEmpty();
- }
+ protected List<PropertyValue> removeProperties( Path nodePath ) {
+ return this.data.remove(nodePath);
+ }
- protected List<PropertyValue> removeProperties( Path nodePath ) {
- return this.data.remove(nodePath);
- }
+ /**
+ * Get the properties for the node given by the supplied path.
+ *
+ * @param nodePath the path to the node
+ * @return the property values, or null if there are none
+ */
+ protected List<PropertyValue> getProperties( Path nodePath ) {
+ return data.get(nodePath);
+ }
- /**
- * Get the properties for the node given by the supplied path.
- *
- * @param nodePath the path to the node
- * @return the property values, or null if there are none
- */
- protected List<PropertyValue> getProperties( Path nodePath ) {
- return data.get(nodePath);
- }
+ /**
+ * Return the entries in this output in an order with shorter paths first.
+ * <p>
+ * {@inheritDoc}
+ */
+ public Iterator<Entry> iterator() {
+ LinkedList<Path> paths = new LinkedList<Path>(data.keySet());
+ Collections.sort(paths);
+ sortValues();
+ return new EntryIterator(paths.iterator());
+ }
- /**
- * Return the entries in this output in an order with shorter paths first.
- * <p>
- * {@inheritDoc}
- */
- public Iterator<Entry> iterator() {
- LinkedList<Path> paths = new LinkedList<Path>(data.keySet());
- Collections.sort(paths);
- sortValues();
- return new EntryIterator(paths.iterator());
- }
+ protected void sortValues() {
+ if (!valuesSorted) {
+ for (List<PropertyValue> values : this.data.values()) {
+ if (values.size() > 1) Collections.sort(values);
+ }
+ valuesSorted = true;
+ }
+ }
- protected void sortValues() {
- if (!valuesSorted) {
- for (List<PropertyValue> values : this.data.values()) {
- if (values.size() > 1) Collections.sort(values);
- }
- valuesSorted = true;
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return StringUtil.readableString(this.data);
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return StringUtil.readableString(this.data);
- }
+ /**
+ * A property name and value pair. PropertyValue instances have a natural order where
the <code>jcr:primaryType</code> is
+ * first, followed by all other properties in ascending lexicographical order
according to the {@link #getName() name}.
+ *
+ * @author Randall Hauch
+ */
+ @Immutable
+ public class PropertyValue implements Comparable<PropertyValue> {
- /**
- * A property name and value pair. PropertyValue instances have a natural order where
the <code>jcr:primaryType</code> is
- * first, followed by all other properties in ascending lexicographical order according
to the {@link #getName() name}.
- *
- * @author Randall Hauch
- */
- @Immutable
- public class PropertyValue implements Comparable<PropertyValue> {
+ private final Name name;
+ private final Object value;
- private final Name name;
- private final Object value;
+ protected PropertyValue( Name propertyName,
+ Object value ) {
+ this.name = propertyName;
+ this.value = value;
+ }
- protected PropertyValue( Name propertyName,
- Object value ) {
- this.name = propertyName;
- this.value = value;
- }
+ /**
+ * Get the property name.
+ *
+ * @return the property name; never null
+ */
+ public Name getName() {
+ return this.name;
+ }
- /**
- * Get the property name.
- *
- * @return the property name; never null
- */
- public Name getName() {
- return this.name;
- }
+ /**
+ * Get the property value, which is either a single value or an array of values.
+ *
+ * @return the property value
+ */
+ public Object getValue() {
+ return this.value;
+ }
- /**
- * Get the property value, which is either a single value or an array of values.
- *
- * @return the property value
- */
- public Object getValue() {
- return this.value;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo( PropertyValue that ) {
+ if (this == that) return 0;
+ if (this.name.equals(NameFactory.JCR_PRIMARY_TYPE)) return -1;
+ if (that.name.equals(NameFactory.JCR_PRIMARY_TYPE)) return 1;
+ return this.name.compareTo(that.name);
+ }
- /**
- * {@inheritDoc}
- */
- public int compareTo( PropertyValue that ) {
- if (this == that) return 0;
- if (this.name.equals(NameFactory.JCR_PRIMARY_TYPE)) return -1;
- if (that.name.equals(NameFactory.JCR_PRIMARY_TYPE)) return 1;
- return this.name.compareTo(that.name);
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return this.name.hashCode();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.name.hashCode();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof PropertyValue) {
+ PropertyValue that = (PropertyValue)obj;
+ if (!this.getName().equals(that.getName())) return false;
+ return true;
+ }
+ return false;
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals( Object obj ) {
- if (obj == this) return true;
- if (obj instanceof PropertyValue) {
- PropertyValue that = (PropertyValue)obj;
- if (!this.getName().equals(that.getName())) return false;
- return true;
- }
- return false;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "[" + this.name + "=" +
StringUtil.readableString(value) + "]";
+ }
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "[" + this.name + "=" + StringUtil.readableString(value) +
"]";
- }
- }
+ /**
+ * An entry in a SequencerOutputMap, which contains the path of the node and the
{@link #getPropertyValues() property values}
+ * on the node.
+ *
+ * @author Randall Hauch
+ */
+ @Immutable
+ public class Entry {
- /**
- * An entry in a SequencerOutputMap, which contains the path of the node and the {@link
#getPropertyValues() property values}
- * on the node.
- *
- * @author Randall Hauch
- */
- @Immutable
- public class Entry {
+ private final Path path;
+ private final Name primaryType;
+ private final List<PropertyValue> properties;
- private final Path path;
- private final Name primaryType;
- private final List<PropertyValue> properties;
+ protected Entry( Path path,
+ List<PropertyValue> properties ) {
+ assert path != null;
+ assert properties != null;
+ this.path = path;
+ this.properties = properties;
+ if (this.properties.size() > 0 &&
this.properties.get(0).getName().equals("jcr:primaryType")) {
+ PropertyValue primaryTypeProperty = this.properties.remove(0);
+ this.primaryType =
getFactories().getNameFactory().create(primaryTypeProperty.getValue());
+ } else {
+ this.primaryType = null;
+ }
+ }
- protected Entry( Path path,
- List<PropertyValue> properties ) {
- assert path != null;
- assert properties != null;
- this.path = path;
- this.properties = properties;
- if (this.properties.size() > 0 &&
this.properties.get(0).getName().equals("jcr:primaryType")) {
- PropertyValue primaryTypeProperty = this.properties.remove(0);
- this.primaryType =
getFactories().getNameFactory().create(primaryTypeProperty.getValue());
- } else {
- this.primaryType = null;
- }
- }
+ /**
+ * @return path
+ */
+ public Path getPath() {
+ return this.path;
+ }
- /**
- * @return path
- */
- public Path getPath() {
- return this.path;
- }
+ /**
+ * Get the primary type specified for this node, or null if the type was not
specified
+ *
+ * @return the primary type, or null
+ */
+ public Name getPrimaryTypeValue() {
+ return this.primaryType;
+ }
- /**
- * Get the primary type specified for this node, or null if the type was not specified
- *
- * @return the primary type, or null
- */
- public Name getPrimaryTypeValue() {
- return this.primaryType;
- }
+ /**
+ * Get the property values, which may be empty
+ *
+ * @return value
+ */
+ public List<PropertyValue> getPropertyValues() {
+ return getProperties(path);
+ }
+ }
- /**
- * Get the property values, which may be empty
- *
- * @return value
- */
- public List<PropertyValue> getPropertyValues() {
- return getProperties(path);
- }
- }
+ protected class EntryIterator implements Iterator<Entry> {
- protected class EntryIterator implements Iterator<Entry> {
+ private Path last;
+ private final Iterator<Path> iter;
- private Path last;
- private final Iterator<Path> iter;
+ protected EntryIterator( Iterator<Path> iter ) {
+ this.iter = iter;
+ }
- protected EntryIterator( Iterator<Path> iter ) {
- this.iter = iter;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
- /**
- * {@inheritDoc}
- */
- public boolean hasNext() {
- return iter.hasNext();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Entry next() {
+ this.last = iter.next();
+ return new Entry(last, getProperties(last));
+ }
- /**
- * {@inheritDoc}
- */
- public Entry next() {
- this.last = iter.next();
- return new Entry(last, getProperties(last));
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void remove() {
+ if (last == null) throw new IllegalStateException();
+ try {
+ removeProperties(last);
+ } finally {
+ last = null;
+ }
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public void remove() {
- if (last == null) throw new IllegalStateException();
- try {
- removeProperties(last);
- } finally {
- last = null;
- }
- }
- }
-
}
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/SequencerNodeContextTest.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -132,7 +132,7 @@
public void shouldProvideValueFactories() throws Exception {
Node input = tools.findOrCreateNode(session, "/a/b/c");
SequencerNodeContext sequencerContext = new SequencerNodeContext(input,
sequencedProperty, execContext);
- assertThat(sequencerContext.getFactories(), notNullValue());
+ assertThat(sequencerContext.getValueFactories(), notNullValue());
}
@Test
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -45,18 +45,19 @@
import org.jboss.dna.graph.sequencers.SequencerOutput;
import org.jboss.dna.graph.sequencers.StreamSequencer;
import org.jboss.dna.repository.observation.NodeChange;
+import org.jboss.dna.repository.util.BasicJcrExecutionContext;
import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.JcrNamespaceRegistry;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.BasicJcrExecutionContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class StreamSequencerAdapterTest extends AbstractJcrRepositoryTest {
@@ -90,8 +91,8 @@
this.streamSequencer = new StreamSequencer() {
/**
- * This method always copies the {@link
StreamSequencerAdapterTest#sequencerOutput} data into the output {@inheritDoc},
- * and does nothing else with any of the other parameters.
+ * This method always copies the {@link
StreamSequencerAdapterTest#sequencerOutput} data into the output {@inheritDoc}
+ * , and does nothing else with any of the other parameters.
*/
public void sequence( InputStream stream,
SequencerOutput output,
@@ -370,7 +371,7 @@
@Test
public void shouldSequencerOutputProvideAccessToNamespaceRegistry() {
- assertThat(sequencerOutput.getNamespaceRegistry(), notNullValue());
+ assertThat(context.getNamespaceRegistry(), notNullValue());
}
@Test
Modified:
trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
===================================================================
---
trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -46,11 +46,10 @@
* <li><strong>image:bitsPerPixel</strong> - optional integer property
for the number of bits per pixel</li>
* <li><strong>image:progressive</strong> - optional boolean property
specifying whether the image is stored in a progressive
* (i.e., interlaced) form</li>
- * <li><strong>image:numberOfImages</strong> - optional integer
property for the number of images stored in the file; defaults
- * to 1</li>
+ * <li><strong>image:numberOfImages</strong> - optional integer
property for the number of images stored in the file; defaults to
+ * 1</li>
* <li><strong>image:physicalWidthDpi</strong> - optional integer
property for the physical width of the image in dots per inch</li>
- * <li><strong>image:physicalHeightDpi</strong> - optional integer
property for the physical height of the image in dots per
- * inch</li>
+ * <li><strong>image:physicalHeightDpi</strong> - optional integer
property for the physical height of the image in dots per inch</li>
* <li><strong>image:physicalWidthInches</strong> - optional double
property for the physical width of the image in inches</li>
* <li><strong>image:physicalHeightInches</strong> - optional double
property for the physical height of the image in inches</li>
* </ul>
@@ -65,6 +64,7 @@
* </p>
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ImageMetadataSequencer implements StreamSequencer {
@@ -109,8 +109,8 @@
// Generate the output graph if we found useful metadata ...
if (metadata != null) {
- NameFactory nameFactory = context.getFactories().getNameFactory();
- PathFactory pathFactory = context.getFactories().getPathFactory();
+ NameFactory nameFactory = context.getValueFactories().getNameFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
Path metadataNode = pathFactory.create(METADATA_NODE);
// Place the image metadata into the output map ...
Modified:
trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
---
trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -25,22 +25,21 @@
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.SimpleProgressMonitor;
+import org.jboss.dna.graph.sequencers.MockSequencerContext;
import org.jboss.dna.graph.sequencers.MockSequencerOutput;
import org.jboss.dna.graph.sequencers.SequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class ImageMetadataSequencerTest {
@@ -52,21 +51,19 @@
private URL cautionJpg;
private URL cautionPict;
private URL cautionPng;
- @Mock
private SequencerContext context;
@Before
public void beforeEach() {
- MockitoAnnotations.initMocks(this);
sequencer = new ImageMetadataSequencer();
- output = new MockSequencerOutput();
- output.getNamespaceRegistry().register("image",
"http://jboss.org/dna/images/1.0");
+ context = new MockSequencerContext();
+ context.getNamespaceRegistry().register("image",
"http://jboss.org/dna/images/1.0");
+ output = new MockSequencerOutput(context);
progress = new SimpleProgressMonitor("Test activity");
cautionGif =
this.getClass().getClassLoader().getResource("caution.gif");
cautionJpg =
this.getClass().getClassLoader().getResource("caution.jpg");
cautionPict =
this.getClass().getClassLoader().getResource("caution.pict");
cautionPng =
this.getClass().getClassLoader().getResource("caution.png");
- stub(context.getFactories()).toReturn(output.getFactories());
}
@After
Modified:
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
===================================================================
---
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -167,6 +167,7 @@
* </p>
*
* @author Serge Pagop
+ * @author John Verhaeg
*/
public class JavaMetadataSequencer implements JavaSourceCndDefinition, StreamSequencer {
@@ -184,8 +185,8 @@
progressMonitor.beginTask(10, JavaMetadataI18n.sequencerTaskName);
JavaMetadata javaMetadata = null;
- NameFactory nameFactory = context.getFactories().getNameFactory();
- PathFactory pathFactory = context.getFactories().getPathFactory();
+ NameFactory nameFactory = context.getValueFactories().getNameFactory();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
try {
javaMetadata = JavaMetadata.instance(stream, JavaMetadataUtil.length(stream),
null, progressMonitor.createSubtask(10));
@@ -699,9 +700,13 @@
methodReturnPrimitiveType.getType());
}
- if(methodReturnType instanceof SimpleTypeFieldMetadata) {
- SimpleTypeFieldMetadata simpleTypeFieldMetadata =
(SimpleTypeFieldMetadata) methodReturnType;
-
SimpleTypeMetadataSequencer.sequenceMethodReturnType(output,nameFactory,pathFactory,simpleTypeFieldMetadata,methodRootPath);
+ if (methodReturnType instanceof SimpleTypeFieldMetadata) {
+ SimpleTypeFieldMetadata simpleTypeFieldMetadata =
(SimpleTypeFieldMetadata)methodReturnType;
+
SimpleTypeMetadataSequencer.sequenceMethodReturnType(output,
+
nameFactory,
+
pathFactory,
+
simpleTypeFieldMetadata,
+
methodRootPath);
}
// TODO method return reference type
Modified:
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
===================================================================
---
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2008-10-24
18:04:46 UTC (rev 580)
+++
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2008-10-24
18:08:17 UTC (rev 581)
@@ -24,7 +24,6 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -32,16 +31,16 @@
import java.io.InputStream;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.SimpleProgressMonitor;
+import org.jboss.dna.graph.sequencers.MockSequencerContext;
import org.jboss.dna.graph.sequencers.MockSequencerOutput;
import org.jboss.dna.graph.sequencers.SequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* @author Serge Pagop
+ * @author John Verhaeg
*/
public class JavaMetadataSequencerTest {
private JavaMetadataSequencer sequencer;
@@ -49,18 +48,16 @@
private MockSequencerOutput output;
private ProgressMonitor progress;
private File source;
- @Mock
private SequencerContext context;
@Before
public void beforeEach() {
- MockitoAnnotations.initMocks(this);
+ context = new MockSequencerContext();
+ context.getNamespaceRegistry().register("java",
"http://jboss.org/dna/java/1.0");
sequencer = new JavaMetadataSequencer();
- output = new MockSequencerOutput();
- output.getNamespaceRegistry().register("java",
"http://jboss.org/dna/java/1.0");
+ output = new MockSequencerOutput(context);
this.progress = new SimpleProgressMonitor("Test java monitor
activity");
source = new
File("src/test/workspace/projectX/src/org/acme/MySource.java");
- stub(context.getFactories()).toReturn(output.getFactories());
}
@After
@@ -93,7 +90,9 @@
// TODO (find a solution to get the annotation of a package). Java Sequencer does
not yet support sequencing of
// package-info.java with package annotations
- //
assertThat(output.getPropertyValues("java:compilationUnit/java:package/java:packageDeclaration/java:annotation/java:annotationDeclaration/java:annotationType/java:markerAnnotation[1]",
+ // assertThat(output.getPropertyValues(
+ //
"java:compilationUnit/java:package/java:packageDeclaration/java:annotation/java:annotationDeclaration/java:annotationType/java:markerAnnotation[1]"
+ // ,
// "java:typeName"),
// is(new Object[] {"org.acme.annotation.MyPackageAnnotation"}));
@@ -299,8 +298,8 @@
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[5]/java:parameter/java:formalParameter[2]/java:type/java:arrayType/java:arrayTypeVariable/java:variable",
"java:variableName"),
is(new Object[] {"ia"}));
-
- // public Object doSomething3() method
+
+ // public Object doSomething3() method
assertThat(output.getPropertyValues("java:compilationUnit/java:unitType/java:classDeclaration/java:normalClass/java:normalClassDeclaration/java:method/java:methodDeclaration[6]/java:modifier/java:modifierDeclaration[1]",
"java:modifierName"),
is(new Object[] {"public"}));