当前位置: 首页>>代码示例>>Java>>正文


Java IScope类代码示例

本文整理汇总了Java中com.helger.scope.IScope的典型用法代码示例。如果您正苦于以下问题:Java IScope类的具体用法?Java IScope怎么用?Java IScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IScope类属于com.helger.scope包,在下文中一共展示了IScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onAfterInstantiation

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onAfterInstantiation (@Nonnull final IScope aScope)
{
  try
  {
    // MPC manager before PMode manager
    m_aMPCMgr = new MPCManager (MPC_XML);
    m_aPModeMgr = new PModeManager (PMODE_XML);
    m_aProfileMgr = new AS4ProfileManager ();
    m_aIncomingDuplicateMgr = new AS4DuplicateManager (INCOMING_DUPLICATE_XML);

    _initCallbacks ();

    // Validate content
    m_aPModeMgr.validateAllPModes ();

    s_aLogger.info (ClassHelper.getClassLocalName (this) + " was initialized");
  }
  catch (final Throwable t)
  {
    throw new InitializationException ("Failed to init " + ClassHelper.getClassLocalName (this), t);
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:24,代码来源:MetaAS4Manager.java

示例2: onAfterInstantiation

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onAfterInstantiation (@Nonnull final IScope aScope)
{
  try
  {
    m_aLucene = new PDLucene ();
    m_aStorageMgr = new PDStorageManager (m_aLucene);
    m_aIndexerMgr = new PDIndexerManager (m_aStorageMgr);
    m_aHttpClientMgr = new HttpClientManager ();

    s_aLogger.info (ClassHelper.getClassLocalName (this) + " was initialized");
  }
  catch (final Throwable t)
  {
    if (GlobalDebug.isProductionMode ())
    {
      new InternalErrorBuilder ().setThrowable (t)
                                 .addErrorMessage (ClassHelper.getClassLocalName (this) + " init failed")
                                 .handle ();
    }

    throw new InitializationException ("Failed to init " + ClassHelper.getClassLocalName (this), t);
  }
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:25,代码来源:PDMetaManager.java

示例3: getSingletonIfInstantiated

import com.helger.scope.IScope; //导入依赖的package包/类
/**
 * Get the singleton object if it is already instantiated inside a scope or
 * <code>null</code> if it is not instantiated.
 *
 * @param <T>
 *        The type to be returned
 * @param aScope
 *        The scope to check. May be <code>null</code> to avoid constructing a
 *        scope.
 * @param aClass
 *        The class to be checked. May not be <code>null</code>.
 * @return The singleton for the specified class is already instantiated,
 *         <code>null</code> otherwise.
 */
@Nullable
public static final <T extends AbstractSingleton> T getSingletonIfInstantiated (@Nullable final IScope aScope,
                                                                                @Nonnull final Class <T> aClass)
{
  ValueEnforcer.notNull (aClass, "Class");

  if (aScope != null)
  {
    final String sSingletonScopeKey = getSingletonScopeKey (aClass);
    final Object aObject = s_aRWLock.readLocked ( () -> aScope.attrs ().get (sSingletonScopeKey));
    if (aObject != null)
    {
      // Object is in the scope
      final T aCastedObject = aClass.cast (aObject);
      if (aCastedObject.isUsableObject ())
      {
        // Object has finished initialization
        return aCastedObject;
      }
    }
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:38,代码来源:AbstractSingleton.java

示例4: onDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onDestroy (@Nonnull final IScope aScopeInDestruction)
{
  m_aRWLock.writeLocked ( () -> {
    // Reschedule all existing scheduled items to run now
    for (final Map.Entry <String, WALListener.WALItem> aEntry : m_aScheduledItems.entrySet ())
    {
      final WALListener.WALItem aItem = aEntry.getValue ();
      if (aItem.m_aFuture.cancel (false))
      {
        // reschedule to perform it now
        m_aES.submit (aItem.m_aRunnable);
        s_aLogger.info ("Rescheduled DAO writing for " + aEntry.getKey () + " to happen now");
      }
      else
        s_aLogger.info ("Cannot reschedule DAO writing for " + aEntry.getKey () + " because it is already running");
    }
    // ensure all are cleared
    m_aScheduledItems.clear ();
  });

  // Wait until all tasks finished
  ExecutorServiceHelper.shutdownAndWaitUntilAllTasksAreFinished (m_aES);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:25,代码来源:WALListener.java

示例5: onDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onDestroy (@Nonnull final IScope aScopeInDestruction) throws Exception
{
  s_aLogger.info ("Global AS4 worker queue about to be closed");
  ExecutorServiceHelper.shutdownAndWaitUntilAllTasksAreFinished (m_aES);
  s_aLogger.info ("Global AS4 worker queue closed!");
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:8,代码来源:AS4WorkerPool.java

示例6: onAfterInstantiation

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onAfterInstantiation (@Nonnull final IScope aScope)
{
  try
  {
    // TODO add managers here

    // Use only the configured SML (if any)
    // By default both official PEPPOL SMLs are queried!
    final ISMLInfo aSML = PDServerConfiguration.getSMLToUse ();
    if (aSML != null)
      PDMetaManager.setBusinessCardProvider (new SMPBusinessCardProvider (aSML));

    s_aLogger.info (ClassHelper.getClassLocalName (this) + " was initialized");
  }
  catch (final Throwable t)
  {
    if (GlobalDebug.isProductionMode ())
    {
      new InternalErrorBuilder ().setThrowable (t)
                                 .addErrorMessage (ClassHelper.getClassLocalName (this) + " init failed")
                                 .handle ();
    }

    throw new InitializationException ("Failed to init " + ClassHelper.getClassLocalName (this), t);
  }
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:28,代码来源:PDPMetaManager.java

示例7: onDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onDestroy (@Nonnull final IScope aScopeInDestruction)
{
  StreamHelper.close (m_aLucene);
  StreamHelper.close (m_aStorageMgr);
  StreamHelper.close (m_aIndexerMgr);
  StreamHelper.close (m_aHttpClientMgr);
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:9,代码来源:PDMetaManager.java

示例8: onDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@SuppressFBWarnings ("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
@Override
protected void onDestroy (@Nonnull final IScope aScopeInDestruction)
{
  if (isDestroyAllSessionsOnScopeEnd ())
    destroyAllSessions ();
  else
    if (isEndAllSessionsOnScopeEnd ())
      _endAllSessionScopes ();
  s_aInstance = null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:12,代码来源:ScopeSessionManager.java

示例9: onBeforeScopeDestruction

import com.helger.scope.IScope; //导入依赖的package包/类
public final void onBeforeScopeDestruction (@Nonnull final IScope aScopeToBeDestroyed) throws Exception
{
  if (s_aLogger.isDebugEnabled ())
    s_aLogger.debug ("onBeforeScopeDestruction for '" +
                     toString () +
                     "' in scope " +
                     aScopeToBeDestroyed.toString ());

  // Check init state
  if (isInInstantiation ())
    s_aLogger.warn ("Object currently in instantiation is destroyed soon: " + toString ());
  else
    if (!isInstantiated ())
      s_aLogger.warn ("Object not instantiated is destroyed soon: " + toString ());

  // Check destruction state
  if (isInPreDestruction ())
    s_aLogger.error ("Object already in pre destruction is destroyed soon again: " + toString ());
  else
    if (isInDestruction ())
      s_aLogger.error ("Object already in destruction is destroyed soon again: " + toString ());
    else
      if (isDestroyed ())
        s_aLogger.error ("Object already destroyed is destroyed soon again: " + toString ());

  setInPreDestruction (true);

  onBeforeDestroy (aScopeToBeDestroyed);

  // do not reset PreDestruction - happens in onScopeDestruction
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:32,代码来源:AbstractSingleton.java

示例10: onScopeDestruction

import com.helger.scope.IScope; //导入依赖的package包/类
public final void onScopeDestruction (@Nonnull final IScope aScopeInDestruction) throws Exception
{
  if (s_aLogger.isDebugEnabled ())
    s_aLogger.debug ("onScopeDestruction for '" + toString () + "' in scope " + aScopeInDestruction.toString ());

  // Check init state
  if (isInInstantiation ())
    s_aLogger.warn ("Object currently in instantiation is now destroyed: " + toString ());
  else
    if (!isInstantiated ())
      s_aLogger.warn ("Object not instantiated is now destroyed: " + toString ());

  // Check destruction state
  if (!isInPreDestruction ())
    s_aLogger.error ("Object should be in pre destruction phase but is not: " + toString ());

  if (isInDestruction ())
    s_aLogger.error ("Object already in destruction is now destroyed again: " + toString ());
  else
    if (isDestroyed ())
      s_aLogger.error ("Object already destroyed is now destroyed again: " + toString ());

  setInDestruction (true);
  // Set after destruction is set to true
  setInPreDestruction (false);

  try
  {
    onDestroy (aScopeInDestruction);
  }
  finally
  {
    // Ensure scope is marked as "destroyed"
    setDestroyed (true);

    // Ensure field is reset even in case of an exception
    setInDestruction (false);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:40,代码来源:AbstractSingleton.java

示例11: getAllSingletons

import com.helger.scope.IScope; //导入依赖的package包/类
/**
 * Get all singleton objects registered in the respective sub-class of this
 * class.
 *
 * @param <T>
 *        The singleton type to be retrieved
 * @param aScope
 *        The scope to use. May be <code>null</code> to avoid creating a new
 *        scope.
 * @param aDesiredClass
 *        The desired sub-class of this class. May not be <code>null</code>.
 * @return A non-<code>null</code> list with all instances of the passed class
 *         in the passed scope.
 */
@Nonnull
@ReturnsMutableCopy
public static final <T extends AbstractSingleton> ICommonsList <T> getAllSingletons (@Nullable final IScope aScope,
                                                                                     @Nonnull final Class <T> aDesiredClass)
{
  ValueEnforcer.notNull (aDesiredClass, "DesiredClass");

  final ICommonsList <T> ret = new CommonsArrayList <> ();
  if (aScope != null)
    for (final Object aScopeValue : aScope.attrs ().values ())
      if (aScopeValue != null && aDesiredClass.isAssignableFrom (aScopeValue.getClass ()))
        ret.add (aDesiredClass.cast (aScopeValue));
  return ret;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:29,代码来源:AbstractSingleton.java

示例12: onAfterInstantiation

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onAfterInstantiation (@Nonnull final IScope aScope)
{
  ++m_nCountVirtual;
  final int nCountCtor = getInstance ().m_nCountCtor;
  assertEquals (1, nCountCtor);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:GlobalSingletonRecursionFuncTest.java

示例13: MockGlobalSingletonWithScopeCtor

import com.helger.scope.IScope; //导入依赖的package包/类
@Deprecated
@UsedViaReflection
public MockGlobalSingletonWithScopeCtor (@Nonnull final IScope aScope)
{
  m_aScope = ValueEnforcer.notNull (aScope, "Scope");
  s_nCtorCount++;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:MockGlobalSingletonWithScopeCtor.java

示例14: onDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onDestroy (@Nonnull final IScope aScopeInDestruction) throws Exception
{
  if (!m_aScope.equals (aScopeInDestruction))
    throw new IllegalStateException ("Saved scope and scope in destruction don't match!");
  s_nDtorCount++;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:MockGlobalSingletonWithScopeCtor.java

示例15: onBeforeDestroy

import com.helger.scope.IScope; //导入依赖的package包/类
@Override
protected void onBeforeDestroy (@Nonnull final IScope aScopeToBeDestroyed) throws Exception
{}
 
开发者ID:phax,项目名称:ph-as4,代码行数:4,代码来源:MetaAS4Manager.java


注:本文中的com.helger.scope.IScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。