KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > StandardWorker


1 // Copyright 2004, 2005 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 org.apache.hivemind.impl;
16
17 import org.apache.hivemind.Messages;
18 import org.apache.hivemind.ShutdownCoordinator;
19 import org.apache.hivemind.service.ClassFactory;
20 import org.apache.hivemind.service.ThreadLocalStorage;
21
22 /**
23  * A service referenced by {@link org.apache.hivemind.impl.TestServiceModelThreading}.
24  *
25  * @author Howard Lewis Ship
26  */

27 public class StandardWorker implements Worker
28 {
29     // The issue may be in wiring/autowiring properties ... so add a bunch!
30

31     private ClassFactory _classFactory;
32
33     private Messages _messages;
34
35     private String JavaDoc _serviceId;
36
37     private ShutdownCoordinator _shutdownCoordinator;
38
39     private ThreadLocalStorage _threadLocalStorage;
40
41     public ClassFactory getClassFactory()
42     {
43         return _classFactory;
44     }
45
46     public Messages getMessages()
47     {
48         return _messages;
49     }
50
51     public String JavaDoc getServiceId()
52     {
53         return _serviceId;
54     }
55
56     public ShutdownCoordinator getShutdownCoordinator()
57     {
58         return _shutdownCoordinator;
59     }
60
61     public ThreadLocalStorage getThreadLocalStorage()
62     {
63         return _threadLocalStorage;
64     }
65
66     public void initializeService()
67     {
68     }
69
70     public void run(Runnable JavaDoc runnable)
71     {
72         _threadLocalStorage.put("thread-runnable", runnable);
73
74         runnable.run();
75     }
76
77     public void setClassFactory(ClassFactory factory)
78     {
79         _classFactory = factory;
80     }
81
82     public void setMessages(Messages messages)
83     {
84         _messages = messages;
85     }
86
87     public void setServiceId(String JavaDoc string)
88     {
89         _serviceId = string;
90     }
91
92     public void setShutdownCoordinator(ShutdownCoordinator coordinator)
93     {
94         _shutdownCoordinator = coordinator;
95     }
96
97     public void setThreadLocalStorage(ThreadLocalStorage storage)
98     {
99         _threadLocalStorage = storage;
100     }
101
102 }
Popular Tags