View Javadoc
1   package org.apache.turbine.services;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.turbine.annotation.AnnotationProcessor;
23  import org.apache.turbine.util.TurbineException;
24  
25  /**
26   * <p>This class provides a <code>Service</code> implementation that
27   * Services used in Turbine are required to extend. 
28   * This class provides the ability to process field and method annotations {@link TurbineServices} in a Turbine service.
29   * You could also enable scanning globally by annotating the class (service) with the annotation {@link TurbineServices}, 
30   * then method annotation could be omitted, if the argument class is {@link TurbineServices} annotated.  
31   * </p>
32   *
33   */
34  public abstract class MethodAnnotatedTurbineBaseService
35          extends TurbineBaseService
36  {
37      
38      /**
39       * Performs late initialization.
40       *
41       * If your class relies on early initialization, and the object it
42       * expects was not received, you can use late initialization to
43       * throw an exception and complain.
44       *
45       * @throws InitializationException if initialization of this
46       * class was not successful.
47       */
48      @Override
49      public void init() throws InitializationException
50      {
51          setInit(true);
52          try {
53              // if second parameter is true, we get into an endless loop if setInit is done last
54              AnnotationProcessor.process(this, true);
55          } catch (TurbineException e) {
56              throw new InitializationException(e.getMessage(), e);
57          }
58      }
59  }