/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder("Execution context for "); if (getSecurityContext() == null) sb.append("null"); else sb.append(getSecurityContext().getUserName()); sb.append(" (").append(id).append(')'); return sb.toString(); }
newData = Collections.unmodifiableMap(newData); return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), getMimeTypeDetector(), getTextExtractor(), getClassLoaderFactory(), newData, getProcessId());
/** * 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; }
/** * Create a new execution context that mirrors this context but that contains the supplied data. Note that the supplied map is * always copied to ensure that it is immutable. * * @param data the data that is to be affiliated with the resulting context or null if the resulting context should have no * data * @return the execution context that is identical with this execution context, but which uses the supplied data; never null * @since 2.0 */ public ExecutionContext with( Map<String, String> data ) { Map<String, String> newData = data; if (data == null) { if (this.data.isEmpty()) return this; } else { // Copy the data in the map ... newData = Collections.unmodifiableMap(new HashMap<String, String>(data)); } return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), getMimeTypeDetector(), getTextExtractor(), getClassLoaderFactory(), newData, 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()); }
/** * Create a new execution context that mirrors this context but that uses the supplied {@link ClassLoaderFactory class loader * factory}. * * @param classLoaderFactory the new class loader factory 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 class loader * factory implementation; never null */ public ExecutionContext with( ClassLoaderFactory classLoaderFactory ) { return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), getMimeTypeDetector(), getTextExtractor(), classLoaderFactory, getData(), getProcessId()); }
/** * 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 contains the supplied process identifier. * * @param processId the identifier of the process * @return the execution context that is identical with this execution context, but which uses the supplied process * identifier; never null * @since 2.1 */ public ExecutionContext with( String processId ) { return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), getMimeTypeDetector(), getTextExtractor(), getClassLoaderFactory(), getData(), processId); }
/** * Create a new execution context that is the same as this context, but which uses the supplied {@link TextExtractor text * extractor}. * * @param textExtractor the new text extractor implementation, or null if the context should use a {@link TextExtractors} * instance with no default extractor * @return the execution context that is identical with this execution context, but which uses the supplied detector * implementation; never null */ public ExecutionContext with( TextExtractor textExtractor ) { return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), getMimeTypeDetector(), textExtractor, getClassLoaderFactory(), getData(), getProcessId()); }
/** * Create a new execution context that is the same as this context, but which uses the supplied {@link MimeTypeDetector MIME * type detector}. * * @param mimeTypeDetector the new MIME type detector implementation, or null if the context should use a * {@link MimeTypeDetectors} instance with an {@link ExtensionBasedMimeTypeDetector} * @return the execution context that is identical with this execution context, but which uses the supplied detector * implementation; never null */ public ExecutionContext with( MimeTypeDetector mimeTypeDetector ) { return new ExecutionContext(getSecurityContext(), getNamespaceRegistry(), getValueFactories(), getPropertyFactory(), mimeTypeDetector, getTextExtractor(), getClassLoaderFactory(), getData(), getProcessId()); }
/** * Create a copy of the supplied execution context. * * @param original the original * @throws IllegalArgumentException if the original is null */ public ExecutionContext( ExecutionContext original ) { CheckArg.isNotNull(original, "original"); this.securityContext = original.getSecurityContext(); this.namespaceRegistry = original.getNamespaceRegistry(); this.valueFactories = original.getValueFactories(); this.propertyFactory = original.getPropertyFactory(); this.classLoaderFactory = original.getClassLoaderFactory(); this.mimeTypeDetector = original.getMimeTypeDetector(); this.textExtractor = original.getTextExtractor(); this.data = original.getData(); this.processId = original.getProcessId(); }