[jboss-svn-commits] JBL Code SVN: r7735 - in labs/jbossesb/trunk/product/core/rosetta/src/org/jboss: internal/soa/esb/addressing/helpers soa/esb/addressing/eprs

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Nov 21 07:00:13 EST 2006


Author: mark.little at jboss.com
Date: 2006-11-21 07:00:08 -0500 (Tue, 21 Nov 2006)
New Revision: 7735

Added:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
Modified:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
Log:
Added FileEpr and enhanced FTPEpr.

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2006-11-21 08:10:58 UTC (rev 7734)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2006-11-21 12:00:08 UTC (rev 7735)
@@ -38,6 +38,8 @@
 import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
 import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
 import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+	
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
@@ -231,9 +233,9 @@
 		    eprType = JDBCEpr.type().toString();
 		else if (epr instanceof JMSEpr)
 		    eprType = JMSEpr.type().toString();
+		else if (epr instanceof FileEpr)
+			eprType = FileEpr.type().toString();
 		
-		System.err.println("**eprType "+eprType);
-		
 		if (eprType != null)
 		    header.setAttribute(EPR_TYPE, eprType);
 	}
@@ -261,6 +263,8 @@
 		    return new JDBCEpr(epr);
 		else if (eprType.equals(JMSEpr.type().toString()))
 		    return new JMSEpr(epr);
+		else if (eprType.equals(FileEpr.type().toString()))
+			return new FileEpr(epr);
 		else
 		    return epr;
 	    }

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2006-11-21 08:10:58 UTC (rev 7734)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2006-11-21 12:00:08 UTC (rev 7735)
@@ -42,13 +42,16 @@
  * @author marklittle
  *
  */
-public class FTPEpr extends EPR
+public class FTPEpr extends FileEpr
 {
 	public static final String USERNAME_TAG = "username";
 	public static final String PASSWORD_TAG = "password";
+	public static final String PASSIVE_TAG = "passive";
 	
 	public FTPEpr (EPR epr)
 	{
+		super(epr);
+		
 		copy(epr);
 	}
 	
@@ -143,6 +146,37 @@
 		return getAddr().getExtensionValue(PASSWORD_TAG);
 	}
 	
+	/**
+	 * Passive FTP?
+	 * 
+	 * @param passive the value.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPassive (boolean passive) throws URISyntaxException
+	{
+		if (passiveSet)
+			throw new IllegalStateException("Cannot change passive");
+		
+		if (passive)
+			getAddr().addExtension(PASSIVE_TAG, "true");
+		else
+			getAddr().addExtension(PASSIVE_TAG, "false");
+		
+		passiveSet = true;
+	}
+	
+	/**
+	 * @return the passive value associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final boolean getPassive () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(PASSIVE_TAG).equals("true");
+	}
+	
+	
 	public static final URI type ()
 	{
 	    return _type;
@@ -150,6 +184,7 @@
 
 	private boolean passwordSet = false;
 	private boolean userSet = false;
+	private boolean passiveSet = false;
 	
 	private static URI _type;
 	

Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java	2006-11-21 08:10:58 UTC (rev 7734)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java	2006-11-21 12:00:08 UTC (rev 7735)
@@ -0,0 +1,271 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+
+/**
+ * This class represents the endpoint reference for services.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+
+/**
+ * A helper class for using FTP style EPRs. Simply create instances of this
+ * class instead of the base EPR. Since URLs can use FTP, we try to leverage
+ * that as much as possible.
+ * 
+ * @author marklittle
+ *
+ */
+public class FileEpr extends EPR
+{
+	public static final String INPUT_SUFFIX_TAG = "inputsuffix";
+	public static final String WORK_SUFFIX_TAG = "worksuffix";
+	public static final String POST_DIR_TAG = "postdir";
+	public static final String POST_SUFFIX_TAG = "postsuffix";
+	public static final String POST_DEL_TAG = "postdel";
+	
+	public FileEpr (EPR epr)
+	{
+		copy(epr);
+	}
+	
+	public FileEpr (URL url) throws URISyntaxException
+	{
+		super(new URI(url.toString()));
+	}
+	
+	public FileEpr (String url) throws URISyntaxException
+	{
+		super(new URI(url));
+	}
+
+	/**
+	 * Set the URL for this endpoint.
+	 * 
+	 * @param url the address.
+	 */
+	
+	public void setURL (URL url)
+	{
+		super.setAddr(new PortReference(url.toString()));
+	}
+	
+	/**
+	 * Get the URL address.
+	 * 
+	 * @return the address.
+	 * @throws URISyntaxException thrown if the address is invalid.
+	 */
+	
+	public URL getURL () throws MalformedURLException, URISyntaxException
+	{
+		return new URL(super.getAddr().getAddress());
+	}
+
+	/**
+	 * Set the file input suffix.
+	 * 
+	 * @param suffix the input suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setInputSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (inputSet)
+			throw new IllegalStateException("Input suffix already set.");
+		
+		getAddr().addExtension(INPUT_SUFFIX_TAG, suffix);
+		inputSet = true;
+	}
+	
+	/**
+	 * @return the input suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getInputSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(INPUT_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the work suffix for this EPR.
+	 * 
+	 * @param suffix the suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setWorkSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (workSet)
+			throw new IllegalStateException("Cannot change work suffix");
+		
+		getAddr().addExtension(WORK_SUFFIX_TAG, suffix);
+		workSet = true;
+	}
+	
+	/**
+	 * @return the work suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getWorkSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(WORK_SUFFIX_TAG);
+	}
+	
+	/**
+	 * Set the post directory for this EPR.
+	 * 
+	 * @param dir the directory to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostDirectory (String dir) throws URISyntaxException
+	{
+		if (dir == null)
+			throw new IllegalArgumentException();
+		
+		if (postDirSet)
+			throw new IllegalStateException("Cannot change post directory");
+		
+		getAddr().addExtension(POST_DIR_TAG, dir);
+		postDirSet = true;
+	}
+	
+	/**
+	 * @return the post directory associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPostDirectory () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(POST_DIR_TAG);
+	}
+	
+	/**
+	 * Set the post suffix for this EPR.
+	 * 
+	 * @param suffix the suffix to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostSuffix (String suffix) throws URISyntaxException
+	{
+		if (suffix == null)
+			throw new IllegalArgumentException();
+		
+		if (postSuffixSet)
+			throw new IllegalStateException("Cannot change post suffix");
+		
+		getAddr().addExtension(POST_SUFFIX_TAG, suffix);
+		postSuffixSet = true;
+	}
+	
+	/**
+	 * @return the post suffix associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final String getPostSuffix () throws URISyntaxException
+	{
+		return getAddr().getExtensionValue(POST_DIR_TAG);
+	}
+	
+	/**
+	 * Set the post delete for this EPR.
+	 * 
+	 * @param del the deleted value to use.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final void setPostDelete (boolean del) throws URISyntaxException
+	{		
+		if (postDelSet)
+			throw new IllegalStateException("Cannot change post delete");
+		
+		if (del)
+			getAddr().addExtension(POST_DEL_TAG, "true");
+		else
+			getAddr().addExtension(POST_DEL_TAG, "false");
+		
+		postDelSet = true;
+	}
+	
+	/**
+	 * @return the delete vazlue associated with this EPR.
+	 * @throws URISyntaxException thrown if this EPR is malformed.
+	 */
+	
+	public final boolean getPostDelete () throws URISyntaxException
+	{
+		if (getAddr().getExtensionValue(POST_DEL_TAG).equals("true"))
+			return true;
+		else
+			return false;
+	}
+		
+	public static URI type ()
+	{
+	    return _type;
+	}
+	
+	protected FileEpr (URI uri)
+	{
+		super(uri);
+	}
+
+	private boolean inputSet = false;
+	private boolean workSet = false;
+	private boolean postDirSet = false;
+	private boolean postSuffixSet = false;
+	private boolean postDelSet = false;
+	
+	private static URI _type;
+	
+	static
+	{
+	    try
+		{
+		    _type = new URI("urn:jboss:esb:epr:type:file");
+		}
+		catch (Exception ex)
+		{
+		    ex.printStackTrace();
+		    
+		    throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+}
\ No newline at end of file




More information about the jboss-svn-commits mailing list