001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.spring.aop;
016    
017    /**
018     * @author Shuyang Zhou
019     */
020    public class ServiceBeanMatcher implements BeanMatcher {
021    
022            public ServiceBeanMatcher() {
023                    this(false);
024            }
025    
026            public ServiceBeanMatcher(boolean counterMatcher) {
027                    _counterMatcher = counterMatcher;
028            }
029    
030            @Override
031            public boolean match(Class<?> beanClass, String beanName) {
032                    if (_counterMatcher) {
033                            return beanName.equals(_COUNTER_SERVICE_BEAN_NAME);
034                    }
035                    else if (!beanName.equals(_COUNTER_SERVICE_BEAN_NAME) &&
036                                     beanName.endsWith(_SERVICE_SUFFIX)) {
037    
038                            return true;
039                    }
040    
041                    return false;
042            }
043    
044            private static final String _COUNTER_SERVICE_BEAN_NAME =
045                    "com.liferay.counter.service.CounterLocalService";
046    
047            private static final String _SERVICE_SUFFIX = "Service";
048    
049            private boolean _counterMatcher;
050    
051    }