Class: Seasar::Container::Deployer::SingletonComponentDeployer

Inherits:
AbstractComponentDeployer show all
Defined in:
lib/seasar/container/deployer/singleton-component-deployer.rb

Overview

コンポーネントのインスタンス管理をSingletonとするDeployerクラスです。

Instance Method Summary collapse

Methods inherited from AbstractComponentDeployer

#setup_assembler

Constructor Details

#initialize(component_def) ⇒ SingletonComponentDeployer

SingletonComponentDeployerを構築します。

  • args

    1. Seasar::Container::ComponentDef component_def



28
29
30
31
32
# File 'lib/seasar/container/deployer/singleton-component-deployer.rb', line 28

def initialize(component_def)
  super
  @component = nil
  @instantiating = false
end

Instance Method Details

#deployObject

コンポーネントを構築します。

  • args

    • none

  • return

    • Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/seasar/container/deployer/singleton-component-deployer.rb', line 39

def deploy
  if @component.nil?
      if @instantiating
        raise Seasar::Container::Exception::CyclicReferenceRuntimeException.new(@component_def.component_class)
      end
      @instantiating = true
      @component     = @constructor_assembler.assemble
      @instantiating = false
      @property_assembler.assemble(@component)
  end
  return @component
end

#destroyObject

  • args

    • none

  • return

    • none



64
65
66
67
68
69
70
# File 'lib/seasar/container/deployer/singleton-component-deployer.rb', line 64

def destroy
  return if @component.nil?
  if @component_def.destructor
    @component_def.destructor.call(@component)
  end
  @component = nil
end

#initObject

  • args

    • none

  • return

    • none



56
57
58
# File 'lib/seasar/container/deployer/singleton-component-deployer.rb', line 56

def init
  self.deploy
end