org.modeshape.jcr.ExecutionContext类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.modeshape.jcr.ExecutionContext类的一些代码示例,展示了ExecutionContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext类的具体详情如下:
包路径:org.modeshape.jcr.ExecutionContext
类名称:ExecutionContext

ExecutionContext介绍

[英]An ExecutionContext is a representation of the environment or context in which a component or operation is operating. Some components require this context to be passed into individual methods, allowing the context to vary with each method invocation. Other components require the context to be provided before it's used, and will use that context for all its operations (until it is given a different one).

ExecutionContext instances are Immutable, so components may hold onto references to them without concern of those contexts changing. Contexts may be used to create other contexts that vary the environment and/or security context. For example, an ExecutionContext could be used to create another context that references the same #getNamespaceRegistry() but which has a different #getSecurityContext().
[中]ExecutionContext是组件或操作所在环境或上下文的表示。一些组件要求将此上下文传递到各个方法中,从而允许上下文随每个方法调用而变化。其他组件要求在使用该上下文之前提供该上下文,并将在其所有操作中使用该上下文(直到为其提供不同的上下文)。
ExecutionContext实例是不可变的,因此组件可以保留对它们的引用,而不必担心这些上下文的更改。上下文可用于创建改变环境和/或安全上下文的其他上下文。例如,ExecutionContext可用于创建另一个引用相同#getNamespaceRegistry()但具有不同#getSecurityContext()的上下文。

代码示例

代码示例来源:origin: ModeShape/modeshape

@Override
public final void addContextData( String key,
                 String value ) {
  this.context = context.with(key, value);
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

protected SessionQueryContext( JcrSession session, Locale locale ) {
  this.session = session;  
  this.executionContext = (locale == null) ? session.context() : session.context().with(locale);
  this.factories = executionContext.getValueFactories();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

SystemNamespaceRegistry( JcrRepository.RunningState repository ) {
  this.repository = repository;
  this.cache = new SimpleNamespaceRegistry();
  // Pre-load all of the built-in namespaces ...
  this.cache.register(new ExecutionContext().getNamespaceRegistry().getNamespaces());
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

protected JcrValueFactory( ExecutionContext context ) {
  this.valueFactories = context.getValueFactories();
  this.namespaces = context.getNamespaceRegistry();
  this.executionContextProcessId = context.getProcessId();
}

代码示例来源:origin: ModeShape/modeshape

/**
 * 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, null, null, null, null, null, null, null,
     null, null, null, null, null, null, null, null);
  initializeDefaultNamespaces(this.getNamespaceRegistry());
  assert securityContext != null;
}

代码示例来源:origin: org.overlord.sramp/s-ramp-repository-jcr-modeshape

/**
 * @see org.modeshape.jcr.security.JaasProvider#authenticate(javax.jcr.Credentials, java.lang.String, java.lang.String, org.modeshape.jcr.ExecutionContext, java.util.Map)
 */
@Override
public ExecutionContext authenticate(Credentials credentials, String repositoryName,
    String workspaceName, ExecutionContext repositoryContext, Map<String, Object> sessionAttributes) {
  ExecutionContext ctx = super.authenticate(credentials, repositoryName, workspaceName, repositoryContext, sessionAttributes);
  if (ctx != null) {
    return repositoryContext.with(new SrampSecurityContext(ctx.getSecurityContext()));
  }
  return ctx;
}

代码示例来源:origin: ModeShape/modeshape

protected MockJcrTypeSystem( JcrValueFactory valueFactory ) {
  this.executionContext = new ExecutionContext();
  this.valueFactory = valueFactory;
  this.delegate = this.executionContext.getValueFactories().getTypeSystem();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

public AllPathsCache( NodeCache cache,
           NodeCache removedCache,
           ExecutionContext context ) {
  this.cache = cache;
  this.removedCache = removedCache;
  this.pathFactory = context.getValueFactories().getPathFactory();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

public final void setAccessControlEnabled( boolean enabled ) {
  if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) {
    refreshRepositoryMetadata(true);
    // And notify the others ...
    String userId = context.getSecurityContext().getUserName();
    Map<String, String> userData = context.getData();
    DateTime timestamp = context.getValueFactories().getDateFactory().create();
    RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null,
                            repositoryEnvironment.journalId());
    changes.repositoryMetadataChanged();
    changes.freeze(userId, userData, timestamp);
    this.changeBus.notify(changes);
  }
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

/**
 * Create a new importer that will place the content in the supplied destination under the supplied path.
 *
 * @param context the context in which the importing should be performed; may not be null
 *
 */
public CndImporter( ExecutionContext context ) {
  assert context != null;
  this.localRegistry = new LocalNamespaceRegistry(context.getNamespaceRegistry());
  this.context = context.with(this.localRegistry);
  this.valueFactory = new JcrValueFactory(this.context);
  this.nameFactory = this.context.getValueFactories().getNameFactory();
  this.stringFactory = this.context.getValueFactories().getStringFactory();
  this.nodeTypes = new LinkedList<NodeTypeDefinition>();
}

代码示例来源:origin: ModeShape/modeshape

protected LegacySidecarExtraPropertyStore( FileSystemConnector connector ) {
  this.connector = connector;
  this.registry = this.connector.registry();
  this.propertyFactory = this.connector.getContext().getPropertyFactory();
  this.factories = this.connector.getContext().getValueFactories();
  this.stringFactory = factories.getStringFactory();
}

代码示例来源:origin: ModeShape/modeshape

@BeforeClass
public static void beforeAll() throws Exception {
  File gitDir = new File("../../.git");
  RepositoryBuilder builder = new RepositoryBuilder();
  repository = builder.setGitDir(gitDir).readEnvironment().findGitDir().build();
  git = new Git(repository);
  context = new ExecutionContext();
  values = new Values(context.getValueFactories(), context.getBinaryStore());
}

代码示例来源:origin: ModeShape/modeshape

@Before
public void beforeEach() {
  context = new ExecutionContext();
  context.getNamespaceRegistry().register("x", "http://example.com");
  typeSystem = context.getValueFactories().getTypeSystem();
  parser = new XPathParser(typeSystem);
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

private ConnectorChangeSetFactory createConnectorChangedSetFactory( final Connector c ) {
  return () -> {
    PathMappings mappings = getPathMappings(c);
    RunningState repository1 = repository();
    final ExecutionContext context = repository1.context();
    return new ConnectorChangeSetImpl(Connectors.this, mappings,
                     context.getId(), context.getProcessId(),
                     repository1.repositoryKey(), repository1.changeBus(),
                     context.getValueFactories().getDateFactory(),
                     repository().journalId());
  };
}

代码示例来源:origin: ModeShape/modeshape

protected BasicSaveContext( ExecutionContext context ) {
  this.now = context.getValueFactories().getDateFactory().create();
  this.userId = context.getSecurityContext().getUserName();
}

代码示例来源:origin: ModeShape/modeshape

@Test
  public void shouldCreateSubcontextsWithDifferentIdentifiers() {
    ExecutionContext newContext = context.with(mock(BinaryStore.class));
    assertThat(newContext.getId(), is(not(context.getId())));
  }
}

代码示例来源:origin: ModeShape/modeshape

@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();
}

代码示例来源:origin: ModeShape/modeshape

@Test
public void shouldUseJcrCardinalityPerPropertyDefinition() throws Exception {
  initializeData();
  // Verify that the node does exist in the source ...
  Path pathToNode = session.context().getValueFactories().getPathFactory().create("/a/b");
  Node carsNode = session.node(pathToNode);
  String mixinTypesName = JcrLexicon.MIXIN_TYPES.getString(session.context().getNamespaceRegistry());
  Property mixinTypes = carsNode.getProperty(mixinTypesName);
  // Check that the JCR property is a MultiProperty - this call will throw an exception if the property is not.
  mixinTypes.getValues();
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

RepositoryLockManager with( JcrRepository.RunningState repository,
              RepositoryConfiguration.GarbageCollection gcConfig ) {
  assert this.systemWorkspaceName == repository.repositoryCache().getSystemWorkspaceName();
  assert this.processId == repository.context().getProcessId();
  PathFactory pathFactory = repository.context().getValueFactories().getPathFactory();
  Path locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, ModeShapeLexicon.LOCKS);
  assert this.locksPath.equals(locksPath);
  return new RepositoryLockManager(repository, gcConfig);
}

代码示例来源:origin: ModeShape/modeshape

@Before
public void beforeEach() {
  context = new QueryContext(new ExecutionContext(), mock(RepositoryCache.class), Collections.singleton("workspace"),
                mock(Schemata.class), mock(RepositoryIndexes.class), mock(NodeTypes.class),
                mock(BufferManager.class));
  rule = AddAccessNodes.INSTANCE;
}

相关文章