View Javadoc
1 /* 2 * AdviceCfgImpl.java 3 * Created on August 16, 2003 4 * 5 * The Blues Framework - A lightweight application framework 6 * Copyright (C) 2003 Lonnie Pryor 7 * http://blues.lonniepryor.com 8 * 9 * This library is free software; you can redistribute it and/or modify it under the 10 * terms of the GNU Lesser General Public License as published by the Free Software 11 * Foundation; either version 2.1 of the License, or (at your option) any later 12 * version. 13 * 14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 16 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along 19 * with this library; if not, write to: 20 * 21 * The Free Software Foundation, Inc. 22 * 59 Temple Place, Suite 330 23 * Boston, MA 02111-1307 USA 24 * 25 */ 26 package com.lonniepryor.blues.cfg; 27 28 import com.lonniepryor.blues.aop.Pointcut; 29 30 /*** 31 * Generic implementation of {@link AdviceCfg}. 32 * 33 * @author Lonnie Pryor 34 * @version $Revision: 1.1 $ 35 */ 36 public class AdviceCfgImpl extends AbstractBeanCfg implements AdviceCfg, Verifiable { 37 /*** The type used to implement the advice. */ 38 private Class adviceType = null; 39 /*** The specification used to evaluate join points for this advice. */ 40 private Pointcut pointcut = null; 41 42 /*** 43 * Creates a new AdviceCfgImpl object. 44 */ 45 public AdviceCfgImpl () { 46 } 47 48 /*** 49 * Sets the type used to implement the advice. 50 * 51 * @param adviceType The type used to implement the advice. 52 */ 53 public void setClass (Class adviceType) { 54 this.adviceType = adviceType; 55 } 56 57 /*** 58 * Sets the specification used to evaluate join points for this advice. 59 * 60 * @param pointcutDef The pointcut pattern expression. 61 */ 62 public void setPointcut (String pointcutDef) { 63 this.pointcut = (pointcutDef == null) ? null 64 : Pointcut.parseExpression(pointcutDef); 65 } 66 67 /* (non-Javadoc) 68 * @see com.lonniepryor.blues.cfg.Verifiable#verify() 69 */ 70 public void verify () { 71 if (adviceType == null) 72 throw new IllegalStateException("No advice type specified"); 73 if (!validAdviceTypes.isSatisfiedBy(adviceType)) 74 throw new IllegalStateException( 75 adviceType.getName() + " is not a valid advice class"); 76 if (pointcut == null) 77 throw new IllegalStateException("No pointcut specified"); 78 } 79 80 /* (non-Javadoc) 81 * @see com.lonniepryor.blues.cfg.AdviceCfg#getAdviceClass() 82 */ 83 public Class getAdviceType () { 84 return adviceType; 85 } 86 87 /* (non-Javadoc) 88 * @see com.lonniepryor.blues.cfg.AdviceCfg#getPointcut() 89 */ 90 public Pointcut getPointcutToAdvise () { 91 return pointcut; 92 } 93 94 /* (non-Javadoc) 95 * @see com.lonniepryor.blues.cfg.AdviceCfg#configure(java.lang.Object, 96 * com.lonniepryor.blues.cfg.Directory) 97 */ 98 public void configure (Object adviceInstance, Directory serviceDirectory) { 99 configureBean(adviceInstance, serviceDirectory); 100 } 101 }

This page was automatically generated by Maven