/** * Create a new execution context that mirrors this context but that uses the supplied {@link PropertyFactory * factory}. * * @param propertyFactory the new propertyfactory implementation, or null if the default implementation should be used * @return the execution context that is identical with this execution context, but which uses the supplied property * factory implementation; never null */ public ExecutionContext with( PropertyFactory propertyFactory ) { return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), propertyFactory, getMimeTypeDetector(), getTextExtractor(), getClassLoaderFactory(), getData(), getProcessId()); }
/** * Create a new execution context that mirrors this context but that uses the supplied namespace registry. The resulting * context's {@link #getValueFactories() value factories} and {@link #getPropertyFactory() property factory} all make use of * the new namespace registry. * * @param namespaceRegistry the new namespace registry implementation, or null if the default implementation should be used * @return the execution context that is identical with this execution context, but which uses the supplied registry; never * null */ public ExecutionContext with( NamespaceRegistry namespaceRegistry ) { // Don't supply the value factories or property factories, since they'll have to be recreated // to reference the supplied namespace registry ... return new ExecutionContext(getSecurityContext(), namespaceRegistry, null, getPropertyFactory(), getMimeTypeDetector(), getTextExtractor(), getClassLoaderFactory(), getData(), getProcessId()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.ExecutionContext#with(org.modeshape.graph.property.NamespaceRegistry) */ @Override public TextExtractorContext with( NamespaceRegistry namespaceRegistry ) { return new TextExtractorContext(super.with(namespaceRegistry), inputPath, inputProperties, mimeType, problems); }
/** * Create an instance of an execution context that uses the {@link AccessController#getContext() current JAAS calling context} * , with default implementations for all other components (including default namespaces in the * {@link #getNamespaceRegistry() namespace registry}. */ @SuppressWarnings( "synthetic-access" ) public ExecutionContext() { this(new NullSecurityContext(), null, null, null, null, null, null, null, null); initializeDefaultNamespaces(this.getNamespaceRegistry()); assert securityContext != null; }
@Before public void beforeEach() { this.context = new ExecutionContext(); this.factories = this.context.getValueFactories(); }
@Before public void beforeEach() { context = new ExecutionContext(); context.getNamespaceRegistry().register("ex", "http://www.example.com"); paths = context.getValueFactories().getPathFactory(); }
public MapRequestProcessor( ExecutionContext context, MapRepository repository, Observer observer, boolean updatesAllowed ) { super(repository.getSourceName(), context, observer); this.repository = repository; pathFactory = context.getValueFactories().getPathFactory(); propertyFactory = context.getPropertyFactory(); this.updatesAllowed = updatesAllowed; }
public CreateAt<Graph> and( Name name, Object... values ) { ExecutionContext context = getContext(); PropertyFactory factory = context.getPropertyFactory(); properties.add(factory.create(name, values)); return this; }
public ReadableVisitor( ExecutionContext context ) { CheckArg.isNotNull(context, "context"); this.context = context; this.registry = context == null ? null : context.getNamespaceRegistry(); }
@Before public void beforeEach() { context = new ExecutionContext(); propertyFactory = context.getPropertyFactory(); valueFactories = context.getValueFactories(); serializer = new Serializer(context, false); largeValues = new LargeValuesHolder(); references = Serializer.NO_REFERENCES_VALUES; }
public PathRequestProcessor( ExecutionContext context, PathRepository repository, Observer observer, boolean updatesAllowed, PathRepositoryTransaction txn ) { super(repository.getSourceName(), context, observer); this.repository = repository; pathFactory = context.getValueFactories().getPathFactory(); this.updatesAllowed = updatesAllowed; this.txn = txn; }
/** * Create an {@link ExecutionContext} that is the same as this context, but which uses the supplied {@link SecurityContext * security context}. * * @param securityContext the new security context to use; may be null * @return the execution context that is identical with this execution context, but with a different security context; never * null * @throws IllegalArgumentException if the <code>name</code> is null */ public ExecutionContext with( SecurityContext securityContext ) { return new ExecutionContext(this, securityContext); }
protected Set<String> getNamesOfComponentsUnder( Name parentName ) { Set<String> names = new HashSet<String>(); try { ConfigurationDefinition content = this.getConfigurationDefinition(); Path path = context.getValueFactories().getPathFactory().create(content.getPath(), parentName); for (Location child : content.graph().getChildren().of(path)) { names.add(child.getPath().getLastSegment().getString(context.getNamespaceRegistry())); } } catch (PathNotFoundException e) { // Nothing has been saved yet ... } return names; }
ExecutionContext loadContext = context.with(new SystemPropertyFactory(context.getValueFactories()));
@Test public void shouldHaveIdentifierThatIsUnique() { // Can't really test this, but we certainly can test that there are no duplicates in many contexts ... Set<String> ids = new HashSet<String>(); for (int i = 0; i != 50; ++i) { assertThat(ids.add(new ExecutionContext().getId()), is(true)); } }
protected String getMimeType( SequencerContext context, Property sequencedProperty, String name ) { SequencerException err = null; String mimeType = null; InputStream stream = null; try { // Parallel the JCR lemma for converting objects into streams stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes()); mimeType = context.getExecutionContext().getMimeTypeDetector().mimeTypeOf(name, stream); return mimeType; } catch (Exception error) { err = new SequencerException(error); } finally { if (stream != null) { try { stream.close(); } catch (IOException error) { // Only throw exception if an exception was not already thrown if (err == null) err = new SequencerException(error); } } } throw err; }
/** * Take any of the changes that have been accumulated by this processor and notify the observer. This should only be called * after {@link #close()} has been called. */ public void notifyObserverOfChanges() { if (observer == null) { if (changes != null) changes.clear(); return; } if (this.changes.isEmpty()) return; // then publish any changes ... String userName = context.getSecurityContext() != null ? context.getSecurityContext().getUserName() : null; if (userName == null) userName = ""; String contextId = context.getId(); String processId = context.getProcessId(); Map<String, String> userData = context.getData(); Changes changes = new Changes(processId, contextId, userName, getSourceName(), getNowInUtc(), this.changes, userData); observer.notify(changes); // Null the list, since this should have been closed this.changes = null; }
context.getLogger(Projection.class).trace(error, msg, definition, method);