KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hivemind > test > services > SimpleModule


1 // Copyright 2007 The Apache Software Foundation
2
//
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 at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// 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 and
13
// 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 ModuleDefinitionImpl
33 {
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 JavaDoc 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
Popular Tags