View Javadoc

1   /*
2    * Copyright 2004-2007 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.cubby.dxo;
17  
18  import org.seasar.cubby.action.FormatPattern;
19  import org.seasar.cubby.action.impl.FormatPatternImpl;
20  import org.seasar.extension.dxo.annotation.AnnotationReader;
21  import org.seasar.extension.dxo.annotation.AnnotationReaderFactory;
22  import org.seasar.framework.container.S2Container;
23  
24  public class CubbyAnnotationReaderFactoryImpl implements
25  		AnnotationReaderFactory {
26  
27  	private AnnotationReaderFactory annotationReaderFactory;
28  
29  	private final FormatPattern formatPattern;
30  
31  	public CubbyAnnotationReaderFactoryImpl(final S2Container container) {
32  		if (container.getRoot().hasComponentDef(FormatPattern.class)) {
33  			this.formatPattern = (FormatPattern) container.getRoot().getComponent(FormatPattern.class);
34  		} else {
35  			this.formatPattern = new FormatPatternImpl();
36  		}
37  	}
38  
39  	public void setAnnotationReaderFactory(final AnnotationReaderFactory annotationReaderFactory) {
40  		this.annotationReaderFactory = annotationReaderFactory;
41  	}
42  
43  	public AnnotationReader getAnnotationReader() {
44  		final AnnotationReader annotationReader = annotationReaderFactory
45  				.getAnnotationReader();
46  		return new CubbyAnnotationReaderWrapper(annotationReader, formatPattern);
47  	}
48  
49  }