Changeset 922 -- 2009-06-04 17:01:47
- Author
localdisk
- Comment
- ちょっと整理した
Diffs
AspectP/trunk/annotation/Annotation.php
@@ -10,6 +10,8 @@
* @version Release: 0.10.0
*/
class Annotation {
+ const INTERCEPTER = 'intercepter';
+ const ANNOTATION = 'annotation';
/**
* アノテーションを取得します
* アノテーションサンプル
@@ -21,21 +23,26 @@
*/
public static function getAnnotation($ref, $key) {
$comment = self::formatComment(self::getComment($ref));
+ $ret = array();
foreach ($comment as $c) {
if (!preg_match("/@$key\s*/", $c, $matches)) {
continue;
}
- $annotation = self::newInstance($key);
+ $annotation = self::newInstance($key, self::ANNOTATION);
if (preg_match('/\((.*?\))/', $c, $matches)) {
$expression = self::formatExpression(trim($matches[0]));
- }
- if (isset($expression)) {
- return array($annotation, $expression);
+ if (array_key_exists(self::INTERCEPTER, $expression)) {
+ $interCepter = self::newInstance($expression[self::INTERCEPTER], self::INTERCEPTER);
+ $annotation->setInterCepters($interCepter, $ref->getName());
+ } else {
+ throw new AspectException('intercepter is required.');
+ }
} else {
- return $annotation;
+ throw new AspectException('intercepter is required.');
}
+ $ret[] = $annotation;
}
- return null;
+ return $ret;
}
/**
@@ -71,13 +78,14 @@
* アノテーションで指定されたオブジェクトのインスタンスを作成します
*
* @param string $name
+ * @param string $path
* @return object
*/
- public static function newInstance($name) {
+ public static function newInstance($name, $path) {
if (class_exists($name, false)) {
return new $name;
}
- $fileName = '../intercepter/' . ucfirst($name) . '.php';
+ $fileName = '../' . $path . '/' . ucfirst($name) . '.php';
if (file_exists($fileName) && is_readable($fileName)) {
include_once $fileName;
if (class_exists($name, false)) {
@@ -97,5 +105,4 @@
$src = 'return array' . $src . ';';
return eval($src);
}
-}
-?>
+}
\ No newline at end of file
AspectP/trunk/annotation/Aspect.php
@@ -1,15 +1,38 @@
<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of Aspect
+/*
+ * Aspect
*
- * @author smoochy
+ * @package annotation
+ * @author localdisk <smoochyinfo@gmail.com>
+ * @author devworks <smoochynet@gmail.com>
+ * @access public
+ * @version Release: 0.10.0
*/
class Aspect {
- //put your code here
-}
-?>
+ private $interCepters = array();
+ /**
+ * コンストラクタ
+ */
+ public function __construct() {
+ ;
+ }
+
+ /**
+ * インターセプターを取得します
+ *
+ * @return array
+ */
+ public function getInterCepters() {
+ return $this->interCepters;
+ }
+
+ /**
+ * インターセプターを設定します
+ *
+ * @param object $interCepter
+ * @param string $joinPoint
+ */
+ public function setInterCepters($interCepter, $joinPoint) {
+ $this->interCepters[$joinPoint] = $interCepter;
+ }
+}
\ No newline at end of file
AspectP/trunk/exception/AspectException.php
@@ -9,5 +9,4 @@
* @version Release: 0.10.0
*/
class AspectException extends Exception {
-}
-?>
+}
\ No newline at end of file
属性に変更があったパス: AspectP/trunk
___________________________________________________________________
追加: svn:ignore
+ nbproject