View Javadoc

1   /*
2      Copyright 2007 Ramon Servadei
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of the License at
7   
8          http://www.apache.org/licenses/LICENSE-2.0
9   
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15   */
16  package fulmine.event;
17  
18  import fulmine.Domain;
19  import fulmine.IDomain;
20  import fulmine.IType;
21  import fulmine.Type;
22  import fulmine.model.component.AbstractComponent;
23  import fulmine.protocol.wire.IWireIdentity;
24  import fulmine.protocol.wire.operation.IOperationScope;
25  import fulmine.util.log.AsyncLog;
26  
27  /**
28   * A simple event source. All sub-classes will use the same
29   * {@link EventProcessor} (the zeroth event processor).
30   * 
31   * @author Ramon Servadei
32   * 
33   */
34  public class EventSource extends AbstractComponent
35  {
36      private final static AsyncLog LOG = new AsyncLog(EventSource.class);
37  
38      /**
39       * Standard constructor
40       * 
41       * @param identity
42       *            the identity for the source
43       */
44      public EventSource(String identity)
45      {
46          super(identity, Type.SYSTEM, Domain.FRAMEWORK);
47      }
48  
49      /**
50       * Constructor for sub-classes
51       * 
52       * @param identity
53       *            the identity
54       * @param type
55       *            the source
56       * @param domain
57       *            the domain
58       */
59      protected EventSource(String identity, IType type, IDomain domain)
60      {
61          super(identity, type, domain);
62      }
63  
64      @Override
65      protected boolean doReadState(IOperationScope scope, byte[] buffer,
66          int start, int numberOfBytes) throws Exception
67      {
68          return true;
69      }
70  
71      @Override
72      protected boolean doWriteState(IOperationScope scope, IWireIdentity wireId,
73          byte[][] headerBuffer, int[] headerBufferPosition, byte[][] dataBuffer,
74          int[] dataBufferPosition, boolean completeState) throws Exception
75      {
76          return true;
77      }
78  
79      @Override
80      protected AsyncLog getLog()
81      {
82          return LOG;
83      }
84  }