gpt4 book ai didi

bitronix.tm.resource.common.XAResourceProducer.getUniqueName()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 01:03:05 28 4
gpt4 key购买 nike

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

XAResourceProducer.getUniqueName介绍

[英]Get the resource name as registered in the transactions journal.
[中]获取在事务日志中注册的资源名称。

代码示例

代码示例来源:origin: bitronix/btm

String getUniqueName() {
  return producer.getUniqueName();
}

代码示例来源:origin: com.github.marcus-nl.btm/btm

String getUniqueName() {
  return producer.getUniqueName();
}

代码示例来源:origin: org.codehaus.btm/btm

/**
 * Unregister a previously registered {@link XAResourceProducer}.
 * @param producer the {@link XAResourceProducer}.
 */
public static void unregister(XAResourceProducer producer) {
  registrationLock.lock();
  try {
    String uniqueName = producer.getUniqueName();
    if (producer.getUniqueName() == null)
      throw new IllegalArgumentException("invalid resource with null uniqueName");
    if (!resources.containsKey(uniqueName)) {
      if (log.isDebugEnabled()) log.debug("resource with uniqueName '" + producer.getUniqueName() + "' has not been registered");
      return;
    }
    resources.remove(uniqueName);
  } finally {
    registrationLock.unlock();
  }
}

代码示例来源:origin: bitronix/btm

private ProducerHolder(XAResourceProducer producer) {
  if (producer == null)
    throw new IllegalArgumentException("XAResourceProducer may not be 'null'. Verify your call to ResourceRegistrar.[un]register(...).");
  final String uniqueName = producer.getUniqueName();
  if (uniqueName == null || uniqueName.length() == 0)
    throw new IllegalArgumentException("The given XAResourceProducer '" + producer + "' does not specify a uniqueName.");
  final String transcodedUniqueName = new String(uniqueName.getBytes(UNIQUE_NAME_CHARSET), UNIQUE_NAME_CHARSET);
  if (!transcodedUniqueName.equals(uniqueName)) {
    throw new IllegalArgumentException("The given XAResourceProducer's uniqueName '" + uniqueName + "' is not compatible with the charset " +
        "'US-ASCII' (transcoding results in '" + transcodedUniqueName + "'). " + System.getProperty("line.separator") +
        "BTM requires unique names to be compatible with US-ASCII when used with a transaction journal.");
  }
  this.producer = producer;
}

代码示例来源:origin: org.mule.btm/mule-btm

/**
 * Unregister a previously registered {@link XAResourceProducer}.
 * @param producer the {@link XAResourceProducer}.
 */
public static void unregister(XAResourceProducer producer) {
  registrationLock.lock();
  try {
    String uniqueName = producer.getUniqueName();
    if (producer.getUniqueName() == null)
      throw new IllegalArgumentException("invalid resource with null uniqueName");
    if (!resources.containsKey(uniqueName)) {
      if (log.isDebugEnabled()) log.debug("resource with uniqueName '" + producer.getUniqueName() + "' has not been registered");
      return;
    }
    resources.remove(uniqueName);
  } finally {
    registrationLock.unlock();
  }
}

代码示例来源:origin: com.github.marcus-nl.btm/btm

private ProducerHolder(XAResourceProducer producer) {
  if (producer == null)
    throw new IllegalArgumentException("XAResourceProducer may not be 'null'. Verify your call to ResourceRegistrar.[un]register(...).");
  final String uniqueName = producer.getUniqueName();
  if (uniqueName == null || uniqueName.length() == 0)
    throw new IllegalArgumentException("The given XAResourceProducer '" + producer + "' does not specify a uniqueName.");
  final String transcodedUniqueName = new String(uniqueName.getBytes(UNIQUE_NAME_CHARSET), UNIQUE_NAME_CHARSET);
  if (!transcodedUniqueName.equals(uniqueName)) {
    throw new IllegalArgumentException("The given XAResourceProducer's uniqueName '" + uniqueName + "' is not compatible with the charset " +
        "'US-ASCII' (transcoding results in '" + transcodedUniqueName + "'). " + System.getProperty("line.separator") +
        "BTM requires unique names to be compatible with US-ASCII when used with a transaction journal.");
  }
  this.producer = producer;
}

代码示例来源:origin: org.codehaus.btm/btm

/**
 * Register a {@link XAResourceProducer}. If registration happens after the transaction manager started, incremental
 * recovery is run on that resource.
 * @param producer the {@link XAResourceProducer}.
 * @throws bitronix.tm.recovery.RecoveryException when an error happens during recovery.
 */
public static void register(XAResourceProducer producer) throws RecoveryException {
  registrationLock.lock();
  try {
    String uniqueName = producer.getUniqueName();
    if (producer.getUniqueName() == null)
      throw new IllegalArgumentException("invalid resource with null uniqueName");
    if (resources.containsKey(uniqueName))
      throw new IllegalArgumentException("resource with uniqueName '" + producer.getUniqueName() + "' has already been registered");
    if (TransactionManagerServices.isTransactionManagerRunning()) {
      if (log.isDebugEnabled()) log.debug("transaction manager is running, recovering resource " + uniqueName);
      IncrementalRecoverer.recover(producer);
    }
    resources.put(uniqueName, producer);
  } finally {
    registrationLock.unlock();
  }
}

代码示例来源:origin: org.mule.btm/mule-btm

/**
 * Register a {@link XAResourceProducer}. If registration happens after the transaction manager started, incremental
 * recovery is run on that resource.
 * @param producer the {@link XAResourceProducer}.
 * @throws bitronix.tm.recovery.RecoveryException when an error happens during recovery.
 */
public static void register(XAResourceProducer producer) throws RecoveryException {
  registrationLock.lock();
  try {
    String uniqueName = producer.getUniqueName();
    if (producer.getUniqueName() == null)
      throw new IllegalArgumentException("invalid resource with null uniqueName");
    if (resources.containsKey(uniqueName))
      throw new IllegalArgumentException("resource with uniqueName '" + producer.getUniqueName() + "' has already been registered");
    if (TransactionManagerServices.isTransactionManagerRunning()) {
      if (log.isDebugEnabled()) log.debug("transaction manager is running, recovering resource " + uniqueName);
      IncrementalRecoverer.recover(producer);
    }
    resources.put(uniqueName, producer);
  } finally {
    registrationLock.unlock();
  }
}

代码示例来源:origin: com.github.marcus-nl.btm/btm

/**
 * Initialize {@link XAResourceProducer}s given a set of properties.
 * @param properties the properties to use for initialization.
 * @return the number of resources which failed to initialize.
 */
int initXAResourceProducers(Properties properties) {
  Map<String, List<PropertyPair>> entries = buildConfigurationEntriesMap(properties);
  int errorCount = 0;
  for (Map.Entry<String, List<PropertyPair>> entry : entries.entrySet()) {
    String uniqueName = entry.getKey();
    List<PropertyPair> propertyPairs = entry.getValue();
    XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs);
    if (ResourceRegistrar.get(producer.getUniqueName()) != null) {
      if (log.isDebugEnabled()) { log.debug("resource already registered, skipping it:" + producer.getUniqueName()); }
      continue;
    }
    if (log.isDebugEnabled()) { log.debug("creating resource " + producer); }
    try {
      producer.init();
    } catch (ResourceConfigurationException ex) {
      log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex);
      producer.close();
      errorCount++;
    }
    resourcesByUniqueName.put(producer.getUniqueName(), producer);
  }
  return errorCount;
}

代码示例来源:origin: bitronix/btm

/**
 * Initialize {@link XAResourceProducer}s given a set of properties.
 * @param properties the properties to use for initialization.
 * @return the number of resources which failed to initialize.
 */
int initXAResourceProducers(Properties properties) {
  Map<String, List<PropertyPair>> entries = buildConfigurationEntriesMap(properties);
  int errorCount = 0;
  for (Map.Entry<String, List<PropertyPair>> entry : entries.entrySet()) {
    String uniqueName = entry.getKey();
    List<PropertyPair> propertyPairs = entry.getValue();
    XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs);
    if (ResourceRegistrar.get(producer.getUniqueName()) != null) {
      if (log.isDebugEnabled()) { log.debug("resource already registered, skipping it:" + producer.getUniqueName()); }
      continue;
    }
    if (log.isDebugEnabled()) { log.debug("creating resource " + producer); }
    try {
      producer.init();
    } catch (ResourceConfigurationException ex) {
      log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex);
      producer.close();
      errorCount++;
    }
    resourcesByUniqueName.put(producer.getUniqueName(), producer);
  }
  return errorCount;
}

代码示例来源:origin: org.codehaus.btm/btm

/**
 * Initialize {@link XAResourceProducer}s given a set of properties.
 * @param properties the properties to use for initialization.
 * @return the number of resources which failed to initialize.
 */
int initXAResourceProducers(Properties properties) {
  Map<String, List<PropertyPair>> entries = buildConfigurationEntriesMap(properties);
  int errorCount = 0;
  for (Map.Entry<String, List<PropertyPair>> entry : entries.entrySet()) {
    String uniqueName = entry.getKey();
    List<PropertyPair> propertyPairs = entry.getValue();
    XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs);
    if (ResourceRegistrar.get(producer.getUniqueName()) != null) {
      if (log.isDebugEnabled()) log.debug("resource already registered, skipping it:" + producer.getUniqueName());
      continue;
    }
    if (log.isDebugEnabled()) log.debug("creating resource " + producer);
    try {
      producer.init();
    } catch (ResourceConfigurationException ex) {
      log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex);
      producer.close();
      errorCount++;
    }
    resourcesByUniqueName.put(producer.getUniqueName(), producer);
  }
  return errorCount;
}

代码示例来源:origin: org.mule.btm/mule-btm

/**
 * Initialize {@link XAResourceProducer}s given a set of properties.
 * @param properties the properties to use for initialization.
 * @return the number of resources which failed to initialize.
 */
int initXAResourceProducers(Properties properties) {
  Map<String, List<PropertyPair>> entries = buildConfigurationEntriesMap(properties);
  int errorCount = 0;
  for (Map.Entry<String, List<PropertyPair>> entry : entries.entrySet()) {
    String uniqueName = entry.getKey();
    List<PropertyPair> propertyPairs = entry.getValue();
    XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs);
    if (ResourceRegistrar.get(producer.getUniqueName()) != null) {
      if (log.isDebugEnabled()) log.debug("resource already registered, skipping it:" + producer.getUniqueName());
      continue;
    }
    if (log.isDebugEnabled()) log.debug("creating resource " + producer);
    try {
      producer.init();
    } catch (ResourceConfigurationException ex) {
      log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex);
      producer.close();
      errorCount++;
    }
    resourcesByUniqueName.put(producer.getUniqueName(), producer);
  }
  return errorCount;
}

代码示例来源:origin: com.github.marcus-nl.btm/btm

private XAResourceProducer createMockProducer(String uniqueName) throws RecoveryException {
  XAResourceProducer producer;
  producer = mock(XAResourceProducer.class);
  when(producer.getUniqueName()).thenReturn(uniqueName);
  ResourceBean resourceBean = mock(ResourceBean.class);
  when(resourceBean.getUniqueName()).thenReturn(uniqueName);
  XAResourceHolder resourceHolder = mock(XAResourceHolder.class);
  when(resourceHolder.getResourceBean()).thenReturn(resourceBean);
  XAResource xaResource = mock(XAResource.class);
  when(resourceHolder.getXAResource()).thenReturn(xaResource);
  when(producer.startRecovery()).thenReturn(new XAResourceHolderState(resourceHolder, resourceBean));
  return producer;
}

代码示例来源:origin: bitronix/btm

private XAResourceProducer createMockProducer(String uniqueName) throws RecoveryException {
  XAResourceProducer producer;
  producer = mock(XAResourceProducer.class);
  when(producer.getUniqueName()).thenReturn(uniqueName);
  ResourceBean resourceBean = mock(ResourceBean.class);
  when(resourceBean.getUniqueName()).thenReturn(uniqueName);
  XAResourceHolder resourceHolder = mock(XAResourceHolder.class);
  when(resourceHolder.getResourceBean()).thenReturn(resourceBean);
  XAResource xaResource = mock(XAResource.class);
  when(resourceHolder.getXAResource()).thenReturn(xaResource);
  when(producer.startRecovery()).thenReturn(new XAResourceHolderState(resourceHolder, resourceBean));
  return producer;
}

代码示例来源:origin: bitronix/btm

String uniqueName = xaResourceProducer.getUniqueName();
if (log.isDebugEnabled()) { log.debug("start of incremental recovery on resource " + uniqueName); }

代码示例来源:origin: org.codehaus.btm/btm

String uniqueName = xaResourceProducer.getUniqueName();
if (log.isDebugEnabled()) log.debug("start of incremental recovery on resource " + uniqueName);

代码示例来源:origin: bitronix/btm

/**
 * Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name.
 * @param configuredName index name of the config file.
 * @param propertyPairs the properties attached to this index.
 * @return a populated {@link XAResourceProducer}.
 * @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built.
 */
private XAResourceProducer buildXAResourceProducer(String configuredName, List<PropertyPair> propertyPairs) throws ResourceConfigurationException {
  String lastPropertyName = "className";
  try {
    XAResourceProducer producer = createBean(configuredName, propertyPairs);
    for (PropertyPair propertyPair : propertyPairs) {
      lastPropertyName = propertyPair.getName();
      String propertyValue = propertyPair.getValue();
      PropertyUtils.setProperty(producer, lastPropertyName, propertyValue);
    }
    if (producer.getUniqueName() == null)
      throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file");
    return producer;
  } catch (ResourceConfigurationException ex) {
    throw ex;
  } catch (Exception ex) {
    throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex);
  }
}

代码示例来源:origin: com.github.marcus-nl.btm/btm

/**
 * Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name.
 * @param configuredName index name of the config file.
 * @param propertyPairs the properties attached to this index.
 * @return a populated {@link XAResourceProducer}.
 * @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built.
 */
private XAResourceProducer buildXAResourceProducer(String configuredName, List<PropertyPair> propertyPairs) throws ResourceConfigurationException {
  String lastPropertyName = "className";
  try {
    XAResourceProducer producer = createBean(configuredName, propertyPairs);
    for (PropertyPair propertyPair : propertyPairs) {
      lastPropertyName = propertyPair.getName();
      String propertyValue = propertyPair.getValue();
      PropertyUtils.setProperty(producer, lastPropertyName, propertyValue);
    }
    if (producer.getUniqueName() == null)
      throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file");
    return producer;
  } catch (ResourceConfigurationException ex) {
    throw ex;
  } catch (Exception ex) {
    throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex);
  }
}

代码示例来源:origin: org.codehaus.btm/btm

/**
 * Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name.
 * @param configuredName index name of the config file.
 * @param propertyPairs the properties attached to this index.
 * @return a populated {@link XAResourceProducer}.
 * @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built.
 */
private XAResourceProducer buildXAResourceProducer(String configuredName, List<PropertyPair> propertyPairs) throws ResourceConfigurationException {
  String lastPropertyName = "className";
  try {
    XAResourceProducer producer = createBean(configuredName, propertyPairs);
    for (PropertyPair propertyPair : propertyPairs) {
      lastPropertyName = propertyPair.getName();
      String propertyValue = propertyPair.getValue();
      PropertyUtils.setProperty(producer, lastPropertyName, propertyValue);
    }
    if (producer.getUniqueName() == null)
      throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file");
    return producer;
  } catch (ResourceConfigurationException ex) {
    throw ex;
  } catch (Exception ex) {
    throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex);
  }
}

代码示例来源:origin: org.mule.btm/mule-btm

/**
 * Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name.
 * @param configuredName index name of the config file.
 * @param propertyPairs the properties attached to this index.
 * @return a populated {@link XAResourceProducer}.
 * @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built.
 */
private XAResourceProducer buildXAResourceProducer(String configuredName, List<PropertyPair> propertyPairs) throws ResourceConfigurationException {
  String lastPropertyName = "className";
  try {
    XAResourceProducer producer = createBean(configuredName, propertyPairs);
    for (PropertyPair propertyPair : propertyPairs) {
      lastPropertyName = propertyPair.getName();
      String propertyValue = propertyPair.getValue();
      PropertyUtils.setProperty(producer, lastPropertyName, propertyValue);
    }
    if (producer.getUniqueName() == null)
      throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file");
    return producer;
  } catch (ResourceConfigurationException ex) {
    throw ex;
  } catch (Exception ex) {
    throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex);
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com