1 // Copyright 2007 The Apache Software Foundation2 //3 // Licensed under the Apache License, Version 2.0 (the "License");4 // you may not use this file except in compliance with the License.5 // You may obtain a copy of the License at6 //7 // http://www.apache.org/licenses/LICENSE-2.08 //9 // Unless required by applicable law or agreed to in writing, software10 // distributed under the License is distributed on an "AS IS" BASIS,11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12 // See the License for the specific language governing permissions and13 // limitations under the License.14 15 package hivemind.test.services;16 17 import hivemind.test.services.impl.SimpleServiceImpl;18 19 import org.apache.hivemind.Location;20 import org.apache.hivemind.Resource;21 import org.apache.hivemind.definition.ServicePointDefinition;22 import org.apache.hivemind.definition.impl.ModuleDefinitionHelper;23 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl;24 import org.apache.hivemind.impl.DefaultClassResolver;25 import org.apache.hivemind.impl.LocationImpl;26 import org.apache.hivemind.internal.ServiceModel;27 import org.apache.hivemind.util.ClasspathResource;28 29 /**30 * Defines a module with one service.31 */32 public class SimpleModule extends ModuleDefinitionImpl33 {34 public SimpleModule()35 {36 super("hivemind.test.services", createLocation(), new DefaultClassResolver(), null);37 38 ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);39 ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class.getName());40 helper.addSimpleServiceImplementation(sp, SimpleServiceImpl.class.getName(), ServiceModel.SINGLETON);41 }42 43 private static Location createLocation()44 {45 String path = "/" + SimpleModule.class.getName().replace('.', '/');46 47 Resource r = new ClasspathResource(new DefaultClassResolver(), path);48 49 return new LocationImpl(r, 1);50 }51 52 }53