3.3. S2ContainerFactory Reference


3.3.1. Creation of a DICON file

In order to use S2Container, it is necessary to create a definition file called DICON file. DICON file is like the design specifications for assembling a component. The extension of a definition file is .dicon or .xml.

The definition of S2Container in a DICON file is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
"http://www.seasar.org/dtd/components21.dtd">
<components>
    <component name="..." class="...">
            ...
    </component>
    <component name="..." class="...">
            ...
    </component>
</components>

DOCTYPE is not omissible. When you create a dicon file, please copy & paste the above sample. A root is a components tag. A component tag is defined for every component. For details, please refer to S2Container definition tag reference.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
"http://www.seasar.org/dtd/components21.dtd">
<components>
    <component name="action" class="IndexAction"/>
</components>

3.3.2. Generation of S2Container

S2Container is generated from a DICON file using the create method of S2ContainerFactory.

/**
 * @param string $path
 */
S2ContainerFactory::create($path)
  • The 1st argument : path to DICON file

As follows, the path of a DICON file is specified and S2Container is generated.

<?php
require_once('S2Container/S2Container.php');

$PATH = "path/to/ccc.dicon";
$container = seasar\container\factory\S2ContainerFactory::create($PATH);
. . .



© Copyright The Seasar Foundation and the others 2005-2010, all rights reserved.