1 57 package com.myeis.j2c; 58 59 import java.io.*; 60 import javax.resource.*; 61 import javax.resource.cci.*; 62 import javax.resource.spi.*; 63 import javax.security.auth.*; 64 import javax.transaction.xa.XAResource ; 65 import org.apache.wsif.providers.jca.toolplugin.*; 66 import org.apache.wsif.providers.jca.WSIFFormatHandler_JCA; 67 import com.myeis.repository.*; 68 import com.myeis.*; 69 import org.apache.wsif.WSIFException; 70 import org.apache.wsif.providers.jca.*; 71 72 public class MyEISManagedConnection implements ManagedConnection { 73 74 private Subject fieldSubject = null; 75 private ConnectionRequestInfo fieldConnectionRequestInfo = null; 76 private MyEISManagedConnectionFactory fieldManagedConnectionFactory = null; 77 78 81 public MyEISManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo, ManagedConnectionFactory managedConnectionFactory) { 82 83 this.fieldSubject = subject; 84 this.fieldConnectionRequestInfo = connectionRequestInfo; 85 this.fieldManagedConnectionFactory = (MyEISManagedConnectionFactory) managedConnectionFactory; 86 } 87 88 91 public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException { 92 93 return new MyEISConnection(this); 94 } 95 96 99 public void destroy() throws ResourceException { 100 } 101 102 105 public void cleanup() throws ResourceException { 106 } 107 108 111 public void associateConnection(Object arg0) throws ResourceException { 112 } 113 114 117 public void addConnectionEventListener(ConnectionEventListener arg0) { 118 } 119 120 123 public void removeConnectionEventListener(ConnectionEventListener arg0) { 124 } 125 126 129 public XAResource getXAResource() throws ResourceException { 130 return null; 131 } 132 133 136 public javax.resource.spi.LocalTransaction getLocalTransaction() throws ResourceException { 137 return null; 138 } 139 140 143 public ManagedConnectionMetaData getMetaData() throws ResourceException { 144 return null; 145 } 146 147 150 public void setLogWriter(PrintWriter arg0) throws ResourceException { 151 } 152 153 156 public PrintWriter getLogWriter() throws ResourceException { 157 return null; 158 } 159 160 163 public void close() throws ResourceException { 164 165 } 166 167 170 public boolean call(InteractionSpec interactionSpec, Record inputRecord, Record outputRecord) throws ResourceException { 171 181 try { 182 185 if ((this.fieldManagedConnectionFactory.getRepositoryLocation().equals("local")) && (((MyEISInteractionSpec) interactionSpec).getFunctionName().equals("IMPORT_PORTTYPES"))) { 186 String queryString = (String ) ((WSIFMessage_JCAStreamable) inputRecord).getObjectPart("queryString"); 188 PortTypeArray portTypeArray = (new Repository()).getPortTypes(queryString); 189 ((WSIFMessage_JCAStreamable) outputRecord).setObjectPart("result", portTypeArray); 190 191 return true; 192 } 193 if ((this.fieldManagedConnectionFactory.getRepositoryLocation().equals("local")) && (((MyEISInteractionSpec) interactionSpec).getFunctionName().equals("IMPORT_DEFINITION"))) { 194 PortTypeSelection selection = (PortTypeSelection) ((WSIFMessage_JCAStreamable) inputRecord).getObjectPart("portTypeSelection"); 196 ImportDefinition importDefinition = (new Repository()).getDefinition(selection); 197 ((WSIFMessage_JCAStreamable) outputRecord).setObjectPart("result", importDefinition); 198 199 return true; 200 } 201 } catch (WSIFException e) { 202 e.printStackTrace(); 203 throw new ResourceException(e.getMessage()); 204 } 205 206 try { 208 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 209 210 ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); 211 objectOutputStream.writeObject(((MyEISInteractionSpec) interactionSpec).getFunctionName()); 212 objectOutputStream.flush(); 213 214 ((WSIFMessage_JCAStreamable) inputRecord).write(outputStream); 215 216 MyEIS myEIS = new MyEIS(); 218 byte[] outBytes = myEIS.doIt(outputStream.toByteArray()); 219 220 ByteArrayInputStream inputStream = new ByteArrayInputStream(outBytes); 221 ((WSIFMessage_JCAStreamable) outputRecord).read(inputStream); 222 } 223 catch (IOException e) { 224 e.printStackTrace(); 225 throw new ResourceException(e.getMessage()); 226 } 227 228 return true; 229 } 230 } | Popular Tags |