org.apache.isis.core.metamodel.adapter.version.Version.different()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(97)

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

Version.different介绍

[英]Compares this version against the specified version and returns true if they are different versions.

This is use for optimistic checking, where the existence of a different version will normally cause a concurrency exception.
[中]将此版本与指定的版本进行比较,如果它们是不同的版本,则返回true。
这用于乐观检查,不同版本的存在通常会导致并发异常。

代码示例

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

private boolean shouldSetVersion(final Version version) {
  return this.version == null || version == null || version.different(this.version);
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

@Override
public void checkLock(final Version version) {
  if (this.version != null && this.version.different(version)) {
    LOG.info("concurrency conflict on " + this + " (" + version + ")");
    throw new ConcurrencyException(this, version);
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

private boolean shouldSetVersion(final Version otherVersion) {
  final Version version = getOid().getVersion();
  return version == null || otherVersion == null || otherVersion.different(version);
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

if( thisVersion != null &&
      otherVersion != null &&
      thisVersion.different(otherVersion)) {
if(recreatedVersion != null && (
    originalVersion == null ||
        recreatedVersion.different(originalVersion))
    ) {
  if(LOG.isDebugEnabled()) {

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

@Override
public void checkLock(final Version version) {
  if (this.version.different(version)) {
    throw new ConcurrencyException("", getOid());
  }
}

代码示例来源:origin: org.apache.isis.runtimes.dflt.remoting/common

private void setUpCollectionFieldForNoContents(final ObjectData parentData, final ObjectAdapter adapter, final ObjectAssociation field) {
  final ObjectAdapter collection = field.get(adapter);
  if (collection.getResolveState() == ResolveState.GHOST) {
    return;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("No data for collection: " + field.getId());
  }
  final Version adapterVersion = adapter.getVersion();
  final Version parentVersion = parentData.getVersion();
  if (adapterVersion.different(parentVersion)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("clearing collection as versions differ: " + adapter.getVersion() + " " + parentData.getVersion());
    }
    final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
    facet.init(collection, new ObjectAdapter[0]);
    collection.changeState(ResolveState.GHOST);
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

@Override
public void checkLock(final Version otherVersion) {
  if(isParentedCollection()) {
    getAggregateRoot().checkLock(otherVersion);
    return;
  }
  
  Oid thisOid = getOid();
  final Version thisVersion = thisOid.getVersion();
  
  // check for exception, but don't throw if suppressed through thread-local
  if(thisVersion != null && 
    otherVersion != null && 
    thisVersion.different(otherVersion)) {
    
    if(AdapterManager.ConcurrencyChecking.isCurrentlyEnabled()) {
      LOG.info("concurrency conflict detected on {} ({})", thisOid, otherVersion);
      final String currentUser = authenticationSession.getUserName();
      throw new ConcurrencyException(currentUser, thisOid, thisVersion, otherVersion);
    } else {
      LOG.info("concurrency conflict detected but suppressed, on {} ({})", thisOid, otherVersion );
    }
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-metamodel

@Test
public void whenEqual() throws Exception {
  version1 = Version.create(123L);
  version2 = Version.create(123L);
  assertThat(version1.different(version2), is(false));
}

代码示例来源:origin: org.apache.isis.core/isis-core-metamodel

@Test
public void whenNotEqual() throws Exception {
  version1 = Version.create(123L);
  version2 = Version.create(124L);
  assertThat(version1.different(version2), is(true));
}

代码示例来源:origin: org.apache.isis.runtimes.dflt.remoting/common

private void updateLoadedObject(final ObjectAdapter adapter, final ObjectData adapterData, final KnownObjectsRequest knownObjects) {
  // object known and we have all the latest data; update/resolve the
  // object
  if (adapterData.getFieldContent() != null) {
    adapter.setOptimisticLock(adapterData.getVersion());
    final ResolveState state = nextState(adapter.getResolveState(), adapterData.hasCompleteData());
    if (state != null) {
      LOG.debug("updating existing object (" + state.name() + ") " + adapter);
      setupFields(adapter, adapterData, state, knownObjects);
      getUpdateNotifier().addChangedObject(adapter);
    }
  } else {
    if (adapterData.getVersion() != null && adapterData.getVersion().different(adapter.getVersion())) {
      // TODO reload the object
    }
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-plugins-jdo-datanucleus-5

@Test
public void checkLock_whenVersionsSame() throws Exception {
  context.checking(new Expectations() {
    {
      oneOf(mockVersion).different(mockVersion2);
      will(returnValue(false));
    }
  });
  
  adapter.checkLock(mockVersion2);
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

thisVersion.different(otherVersion)) {

代码示例来源:origin: org.apache.isis.viewer/scimpi-dispatcher

final Version adapterVersion = adapter.getVersion();
final Version formVersion = context.getVersion(version);
if (formVersion != null && adapterVersion.different(formVersion)) {

代码示例来源:origin: org.apache.isis.core/isis-core-plugins-jdo-datanucleus-5

@Test(expected=ConcurrencyException.class)
public void checkLock_whenVersionsDifferent() throws Exception {
  adapter = PojoAdapterBuilder.create()
      .with(mockSpecificationLoader)
      .withTitleString("some pojo")
      .with(mockVersion)
      .with(mockAuthenticationSession)
      .build();
  
  context.checking(new Expectations() {
    {
      oneOf(mockVersion).different(mockVersion2);
      will(returnValue(true));
    }
  });
  
  adapter.checkLock(mockVersion2);
}

相关文章