|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.management.NotificationBroadcasterSupport
org.jboss.system.ServiceMBeanSupport
org.backsource.jmx.ServiceMBeanSupport
org.backsource.adaptor.ftp.FTPConnectionFactory
First scetch of a J2ee/jdbc like ftp adaptor.
This factory is currently hardwired to use the NetFTPConnection.
The typical usage scenarion is much like usage of JDBC. Either you have a preconfigured factory that you lookup through JDBC, or it is configured manually. It is however not serializable.
FTPConnectionFactory connectionFactory = new FTPConnectionFactory();
connectionFactory.setHostName( "localhost" );
connectionFactory.setUser( "pra@tim.se" );
connectionFactory.setPassword( anonymous );
FTPConnection ftp = null;
try {
// Transfer a file
ftp.put("topfile.xml", new FileInputStream( new File(dir,"topfile.xml") ) );
// Create subdir an populate
ftp.mkdir("mysub");
ftp.put("mysub/subfile1.xml", new FileInputStream( new File(dir,"subfile1.xml") ) );
// Remove stuff
ftp.deleteFile("topfile.xml");
ftp.deleteFile("mysub/subfile1.xml");
// delete dir
ftp.deleteFile("mysub");
} catch (FTPException e) {
// throw some own exception
} finally {
if ( ftp != null) {
ftp.close();
} // end of if ()
} // end of finally
connectionFactory.stop();
| Field Summary | |
protected EDU.oswego.cs.dl.util.concurrent.LinkedQueue |
connections
|
static int |
DEFAULT_TIMEOUT
|
protected javax.management.ObjectName |
name
|
static javax.management.ObjectName |
OBJECT_NAME
|
protected javax.management.MBeanServer |
server
|
protected org.backsource.utils.io.CachedStream |
stream
|
protected org.backsource.utils.io.CachedStreamFactory |
streamFactory
|
| Fields inherited from class org.jboss.system.ServiceMBeanSupport |
log, serviceName |
| Fields inherited from interface org.jboss.system.ServiceMBean |
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, STARTED, STARTING, states, STOPPED, STOPPING |
| Constructor Summary | |
FTPConnectionFactory()
|
|
| Method Summary | |
org.backsource.utils.io.CachedStream |
getCachedStream()
Get the cached stream (not the factory). |
FTPConnection |
getConnection()
Get a new FTPConnection, may have been cached/pooled. |
java.lang.String |
getHostName()
Name of the ftp server. |
protected javax.management.ObjectName |
getObjectName(javax.management.MBeanServer server,
javax.management.ObjectName name)
|
java.lang.String |
getPassword()
Password. |
int |
getTimeout()
Timeout. |
java.lang.String |
getUser()
Name of the user. |
protected void |
releaseConnection(FTPConnection ftp)
Hook from the connection to return the connection to the pool. |
void |
setCachedStreamFactory(org.backsource.utils.io.CachedStreamFactory streamFactory)
The a CachedStreamFactory to use for stream handling; if not supplied the default one according the default configuration rules are used. |
void |
setHostName(java.lang.String hostName)
Name of the ftp server. |
void |
setPassword(java.lang.String pwd)
Password. |
void |
setTimeout(int timeout)
Timeout. |
void |
setUser(java.lang.String user)
Name of the user. |
void |
stop()
|
| Methods inherited from class org.jboss.system.ServiceMBeanSupport |
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getServer, getServiceName, getState, getStateString, postDeregister, postRegister, preDeregister, preRegister, start, startService, stopService |
| Methods inherited from class javax.management.NotificationBroadcasterSupport |
addNotificationListener, getNotificationInfo, removeNotificationListener, sendNotification |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jboss.system.ServiceMBean |
getName, getState, getStateString |
| Methods inherited from interface org.jboss.system.Service |
create, destroy, start |
| Field Detail |
public static final javax.management.ObjectName OBJECT_NAME
public static final int DEFAULT_TIMEOUT
protected javax.management.ObjectName name
protected javax.management.MBeanServer server
protected EDU.oswego.cs.dl.util.concurrent.LinkedQueue connections
protected org.backsource.utils.io.CachedStreamFactory streamFactory
protected org.backsource.utils.io.CachedStream stream
| Constructor Detail |
public FTPConnectionFactory()
| Method Detail |
protected javax.management.ObjectName getObjectName(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws javax.management.MalformedObjectNameException
javax.management.MalformedObjectNameExceptionpublic void setHostName(java.lang.String hostName)
setHostName in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic java.lang.String getHostName()
getHostName in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic void setUser(java.lang.String user)
setUser in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic java.lang.String getUser()
getUser in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic void setPassword(java.lang.String pwd)
setPassword in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic java.lang.String getPassword()
getPassword in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic void setTimeout(int timeout)
setTimeout in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic void setCachedStreamFactory(org.backsource.utils.io.CachedStreamFactory streamFactory)
CachedStreamFactory to use for stream handling; if not supplied the default one according the default configuration rules are used.
public org.backsource.utils.io.CachedStream getCachedStream()
throws FTPException
FTPExceptionpublic int getTimeout()
getTimeout in interface org.backsource.adaptor.ftp.FTPConnectionFactoryMBeanpublic void stop()
stop in interface org.jboss.system.Service
public FTPConnection getConnection()
throws FTPException
The connection MUST be close after usage, use it much like you would use a JDBC connection.
FTPExceptionprotected void releaseConnection(FTPConnection ftp)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||