Java tutorial
/* This file is part of Moose. Moose is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Moose is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Moose. If not, see <http://www.gnu.org/licenses/>. */ package com.quigley.moose.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.quigley.moose.mapping.Mapping; import com.quigley.moose.mapping.provider.MappingProvider; public class SpringMappingProvider implements MappingProvider { public SpringMappingProvider(Package contextPackage) { String[] contextPaths = new String[] { getThisPackagePath(contextPackage) + "/spring-beans.xml" }; applicationContext = new ClassPathXmlApplicationContext(contextPaths); } public Mapping getMapping() { return (Mapping) applicationContext.getBean("mapping"); } protected String getThisPackagePath(Package contextPackage) { return "classpath:/" + contextPackage.getName().replaceAll("[.]", "/"); } protected ApplicationContext applicationContext; }