View Javadoc

1   package org.csc.phynixx.connection.loggersystem;
2   
3   /*
4    * #%L
5    * phynixx-common
6    * %%
7    * Copyright (C) 2014 csc
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  
24  import org.csc.phynixx.common.logger.IPhynixxLogger;
25  import org.csc.phynixx.common.logger.PhynixxLogManager;
26  import org.csc.phynixx.connection.*;
27  import org.csc.phynixx.loggersystem.logrecord.IDataRecord;
28  import org.csc.phynixx.loggersystem.logrecord.IDataRecordReplay;
29  import org.csc.phynixx.loggersystem.logrecord.IXADataRecorder;
30  import org.csc.phynixx.loggersystem.logrecord.XALogRecordType;
31  
32  import java.util.ArrayList;
33  import java.util.Collections;
34  import java.util.List;
35  
36  /**
37   * written data are fired an forgotten. Their are not stored as if wriiten to dev0.
38   */
39  
40  public class Dev0Strategy<C extends IPhynixxConnection> extends PhynixxManagedConnectionListenerAdapter<C> implements IPhynixxLoggerSystemStrategy<C> {
41  
42      private static final IPhynixxLogger LOG = PhynixxLogManager.getLogger(Dev0Strategy.class);
43  
44  
45      public static final Dev0Logger THE_DEV0_LOGGER = new Dev0Logger();
46  
47      private static class Dev0Logger implements IXADataRecorder {
48  
49          @Override
50          public void writeRollforwardData(byte[][] data) {
51          }
52  
53          @Override
54          public void writeRollforwardData(byte[] data) {
55          }
56  
57          public boolean isCommitting() {
58              return false;
59          }
60  
61          public boolean isCompleted() {
62              return false;
63          }
64  
65          @Override
66          public boolean isEmpty() {
67              return false;
68          }
69  
70          public boolean isPrepared() {
71              return false;
72          }
73  
74          @Override
75          public void replayRecords(IDataRecordReplay replay) {
76          }
77  
78          @Override
79          public boolean isClosed() {
80              return false;
81          }
82  
83          @Override
84          public IDataRecord createDataRecord(XALogRecordType logRecordType, byte[][] recordData) {
85              return null;
86          }
87  
88          @Override
89          public IDataRecord createDataRecord(XALogRecordType logRecordType, byte[] recordData) {
90              return null;
91          }
92  
93          @Override
94          public void writeRollbackData(byte[] data) {
95          }
96  
97          @Override
98          public void writeRollbackData(byte[][] data) {
99          }
100 
101         @Override
102         public void close() {
103         }
104 
105         @Override
106         public void reset() {
107 
108         }
109 
110         @Override
111         public void destroy() {
112         }
113 
114         @Override
115         public List<IDataRecord> getDataRecords() {
116             return Collections.emptyList();
117         }
118 
119         @Override
120         public long getXADataRecorderId() {
121             return -1;
122         }
123 
124         @Override
125         public void recover() {
126 
127         }
128     }
129 
130     @Override
131     public void close() {
132     }
133 
134     @Override
135     public IPhynixxManagedConnection<C> decorate(IPhynixxManagedConnection<C> managedConnection) {
136         managedConnection.addConnectionListener(this);
137         return managedConnection;
138     }
139 
140 
141     @Override
142     public void connectionRequiresTransaction(IManagedConnectionEvent<C> event) {
143         IPhynixxConnection con = event.getManagedConnection().getCoreConnection();
144         if (con == null || !(con instanceof IXADataRecorderAware)) {
145             return;
146         }
147         IXADataRecorderAware messageAwareConnection = (IXADataRecorderAware) con;
148         // Transaction is close and the LOG is destroyed ...
149         IXADataRecorder logger = messageAwareConnection.getXADataRecorder();
150         if (logger == null) {
151             messageAwareConnection.setXADataRecorder(THE_DEV0_LOGGER);
152         }
153         event.getManagedConnection().addConnectionListener(this);
154     }
155 
156 
157     @Override
158     public List<IXADataRecorder> readIncompleteTransactions() {
159         return new ArrayList(0);
160     }
161 
162 
163 }