List of usage examples for javax.resource ResourceException ResourceException
public ResourceException(String message, String errorCode)
From source file:org.apache.openejb.resource.AutoConnectionTracker.java
private void proxyConnection(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo) throws ResourceException { // no-op if we have opted to not use proxies if (connectionInfo.getConnectionProxy() != null) { return;//from ww w.j a v a2s .c om } // DissociatableManagedConnection do not need to be proxied if (connectionInfo.getManagedConnectionInfo() .getManagedConnection() instanceof DissociatableManagedConnection) { return; } try { final Object handle = connectionInfo.getConnectionHandle(); final ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle); final Object proxy = newProxy(handle, invocationHandler); connectionInfo.setConnectionProxy(proxy); final ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue); references.put(connectionInfo.getManagedConnectionInfo(), reference); } catch (final Throwable e) { throw new ResourceException("Unable to construct connection proxy", e); } }
From source file:org.apache.webdav.connector.WebDAVManagedConnectionFactory.java
/** * @see ManagedConnectionFactory#createManagedConnection(Subject, * ConnectionRequestInfo)//from ww w . ja v a 2s. com */ public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (subject != null) { Properties props = new Properties(); WebDAVSubjectAction action = new WebDAVSubjectAction(subject, props, this); Boolean matched = (Boolean) AccessController.doPrivileged(action); if (matched.booleanValue()) { String userName = props.getProperty("userName"); String password = props.getProperty("password"); try { WebDAVConnectionSpec spec = new WebDAVConnectionSpec(connectionURL, userName, password, timeout.intValue()); System.out.println("Creating WebDAVConnection using JAAS Subject: " + userName); return new WebDAVManagedConnection(spec); } catch (IOException e) { throw new ResourceException("Could not create managed connection", e.toString()); } } else { // No matching credentials were found on the subject throw new ResourceException("Could not create managed connection"); } } if (cxRequestInfo instanceof WebDAVConnectionSpec) { try { System.out.println("Creating WebDAVConnection with WebDAVConnectionSpec"); return new WebDAVManagedConnection(cxRequestInfo); } catch (HttpException e) { if (writer != null) { writer.println("Exception: " + e); e.printStackTrace(writer); } // XXX only in 1.4 // throw new ResourceException("Could not create managed connection", e); throw new ResourceException("Could not create managed connection", e.toString()); } catch (IOException e) { if (writer != null) { writer.println("Exception: " + e); e.printStackTrace(writer); } // XXX only in 1.4 // throw new ResourceException("Could not create managed connection", e); throw new ResourceException("Could not create managed connection", e.toString()); } } try { if (connectionURL != null && username != null) { System.out.println("Creating WebDAVConnection with configured properties"); WebDAVConnectionSpec spec = new WebDAVConnectionSpec(connectionURL, username, password, timeout.intValue()); return new WebDAVManagedConnection(spec); } else { throw new ResourceException("Could not create managed connection"); } } catch (Exception e) { throw new ResourceException("Could not create managed connection", e.toString()); } }
From source file:org.ikasan.connector.basefiletransfer.outbound.command.ChunkingRetrieveFileCommand.java
@Override protected ExecutionOutput performExecute() throws ResourceException { logger.info("execute called on this command: [" + this + "]"); //$NON-NLS-1$ //$NON-NLS-2$ ClientListEntry entry = (ClientListEntry) executionContext.get(ExecutionContext.RETRIEVABLE_FILE_PARAM); this.sourcePath = entry.getUri().getPath(); File file = new File(entry.getUri().getPath()); try {/*w ww .j av a 2 s .c o m*/ String directory = file.getParent() + "/"; chunker.chunkFile(directory, file.getName(), chunkSize); } catch (ChunkException e) { throw new ResourceException("Exception caught whilst trying to chunk", e); //$NON-NLS-1$ } FileChunkHeader fileChunkHeader = ((ChunkerImpl) chunker).getFileChunkHeader(); clientId = (String) executionContext.get(ExecutionContext.CLIENT_ID); entry.setClientId(clientId); dao.persistClientListEntry(entry); return new ExecutionOutput(fileChunkHeader); }
From source file:org.ikasan.connector.ftp.net.FileTransferProtocolClient.java
public void ensureConnection() throws ResourceException { if (!isConnected()) { try {//from ww w . j a v a2s. com connect(); login(); } catch (ClientConnectionException e1) { throw new ResourceException( "Failed to ensure that the underlying ftp connection is still open. Likely this was previously open, closed prematurely, and now cannot be reestablished", //$NON-NLS-1$ e1); } } }
From source file:org.nuxeo.ecm.core.jca.JCAManagedConnection.java
/** * Used by the container to change the association of an * application-level connection handle with a ManagedConnection instance. */// ww w.j ava 2 s. c o m public synchronized void associateConnection(Object connection) throws ResourceException { //System.out.println("JCA >>>>>>>>>>>>>>>>>>>>>> calling associateConnection"); JCAConnection handle = (JCAConnection) connection; if (handle.getManagedConnection() != this) { try { closeHandle(this.handle); this.handle = handle; this.handle.getManagedConnection().handle = null; this.handle.setManagedConnection(this); } catch (DocumentException e) { throw new ResourceException("Failed to close handle " + this.handle.getSession(), e); } } }
From source file:org.soulwing.oaq.OAQManagedConnectionFactory.java
/** * {@inheritDoc}/*from w ww .ja v a 2 s .co m*/ */ @Override public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { OAQConnectionRequestInfo info = resourceAdapter.getConnectionRequestInfo(); if (connectionRequestInfo instanceof OAQConnectionRequestInfo) { info = (OAQConnectionRequestInfo) connectionRequestInfo; } try { OAQManagedConnection connection = new OAQManagedConnection(subject, info, resourceAdapter.createConnection(info)); connection.setLogWriter(getLogWriter()); return connection; } catch (JMSException ex) { throw new ResourceException("failed to create connection", ex); } }
From source file:org.teiid.resource.adapter.ftp.FtpFileConnectionImpl.java
public FtpFileConnectionImpl(FTPClient client, String pathname, Map<String, String> fileMapping) throws ResourceException { this.client = client; if (fileMapping == null) { this.fileMapping = Collections.emptyMap(); } else {/*ww w . j av a 2 s . c o m*/ this.fileMapping = fileMapping; } try { if (this.client.cwd(pathname) != 250) { throw new InvalidPropertyException(UTIL.getString("parentdirectory_not_set")); //$NON-NLS-1$ } this.client.changeWorkingDirectory(pathname); this.mountPoint = VFS.getChild(pathname); this.closeable = VFS.mount(mountPoint, new FtpFileSystem(this.client)); } catch (IOException e) { throw new ResourceException(UTIL.getString("vfs_mount_error", pathname), e); //$NON-NLS-1$ } }
From source file:org.teiid.resource.adapter.ftp.FtpFileConnectionImpl.java
@Override public boolean add(InputStream in, VirtualFile file) throws ResourceException { try {/* www . j av a 2s . c o m*/ return this.client.storeFile(file.getName(), in); } catch (IOException e) { throw new ResourceException( UTIL.getString("ftp_failed_write", file.getName(), this.client.getReplyString()), e); //$NON-NLS-1$ } }