[jboss-svn-commits] JBL Code SVN: r8281 - in labs/jbossesb/trunk/product/core/rosetta/src/org/jboss: internal/soa/esb/addressing/helpers soa/esb/addressing/eprs soa/esb/addressing/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Dec 13 06:14:30 EST 2006
Author: mark.little at jboss.com
Date: 2006-12-13 06:14:26 -0500 (Wed, 13 Dec 2006)
New Revision: 8281
Added:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.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
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java
Log:
Added SFTP EPR helper for Bruno.
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-12-13 10:15:23 UTC (rev 8280)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java 2006-12-13 11:14:26 UTC (rev 8281)
@@ -39,10 +39,12 @@
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.SFTPEpr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import com.sun.corba.se.impl.presentation.rmi.StubFactoryProxyImpl;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
@@ -234,6 +236,8 @@
eprType = JMSEpr.type().toString();
else if (epr instanceof FileEpr)
eprType = FileEpr.type().toString();
+ else if (epr instanceof SFTPEpr)
+ eprType = SFTPEpr.type().toString();
if (eprType != null)
header.setAttribute(EPR_TYPE, eprType);
@@ -264,6 +268,8 @@
return new JMSEpr(epr);
else if (eprType.equals(FileEpr.type().toString()))
return new FileEpr(epr);
+ else if (eprType.equals(SFTPEpr.type().toString()))
+ return new SFTPEpr(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-12-13 10:15:23 UTC (rev 8280)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java 2006-12-13 11:14:26 UTC (rev 8281)
@@ -177,7 +177,7 @@
}
- public static final URI type ()
+ public static URI type ()
{
return _type;
}
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java 2006-12-13 10:15:23 UTC (rev 8280)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java 2006-12-13 11:14:26 UTC (rev 8281)
@@ -0,0 +1,130 @@
+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 SFTPEpr extends FTPEpr
+{
+ public static final String CERTIFICATE_TAG = "certificate";
+
+ public SFTPEpr(EPR epr)
+ {
+ super(epr);
+
+ copy(epr);
+ }
+
+ public SFTPEpr(URL url) throws URISyntaxException
+ {
+ super(url);
+ }
+
+ public SFTPEpr(URL url, URL cert) throws URISyntaxException
+ {
+ super(url);
+ }
+
+ public SFTPEpr(String url, String cert) throws URISyntaxException
+ {
+ super(url);
+ }
+
+ /**
+ * Set the Certificate URL for this endpoint.
+ *
+ * @param url
+ * the address.
+ * @throws URISyntaxException
+ * thrown if this EPR is malformed.
+ */
+
+ public final void setCertificateURL(URL cert) throws URISyntaxException
+ {
+ if (cert == null)
+ throw new IllegalArgumentException();
+
+ if (certificateSet)
+ throw new IllegalStateException("Certificate URL already set.");
+
+ getAddr().addExtension(CERTIFICATE_TAG, cert.toString());
+ certificateSet = true;
+ }
+
+ /**
+ * @return the certificate URL for this EPR.
+ * @throws URISyntaxException
+ * thrown if this EPR is malformed.
+ */
+
+ public final URL getCertificateURL () throws URISyntaxException,
+ MalformedURLException
+ {
+ String cert = getAddr().getExtensionValue(CERTIFICATE_TAG);
+
+ if (cert != null)
+ return new URL(cert);
+ else
+ return null;
+ }
+
+ public static URI type ()
+ {
+ return _type;
+ }
+
+ private boolean certificateSet = false;
+
+ private static URI _type;
+
+ static
+ {
+ try
+ {
+ _type = new URI("urn:jboss:esb:epr:type:sftp");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+
+ throw new ExceptionInInitializerError(ex.toString());
+ }
+ }
+}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java 2006-12-13 10:15:23 UTC (rev 8280)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java 2006-12-13 11:14:26 UTC (rev 8281)
@@ -48,172 +48,171 @@
public class EPRManager
{
- /**
- * All EPRs are saves in files within the current working directory.
- *
- * @return the manager for the cwd.
- */
+ /**
+ * All EPRs are saves in files within the current working directory.
+ *
+ * @return the manager for the cwd.
+ */
- public static final EPRManager getInstance ()
- {
- return getInstance("");
- }
+ public static final EPRManager getInstance()
+ {
+ return getInstance("");
+ }
- /**
- * All EPRs are saves in files within a defined directory. Get the right
- * manager for that directory.
- *
- * @param domain
- * the name of the directory. If <code>null</code> then
- * the null String is assumed.
- * @return the manager for the directory. If it does not exist, then one
- * will be created.
- */
+ /**
+ * All EPRs are saves in files within a defined directory. Get the right
+ * manager for that directory.
+ *
+ * @param domain
+ * the name of the directory. If <code>null</code> then the
+ * null String is assumed.
+ * @return the manager for the directory. If it does not exist, then one
+ * will be created.
+ */
- public static final EPRManager getInstance (String domain)
- {
- if (domain == null)
- domain = "";
-
- synchronized (_instances)
+ public static final EPRManager getInstance(String domain)
{
- EPRManager theInstance = _instances.get(domain);
+ if (domain == null)
+ domain = "";
- if (theInstance == null)
- {
- theInstance = new EPRManager(domain);
+ synchronized (_instances)
+ {
+ EPRManager theInstance = _instances.get(domain);
- _instances.put(domain, theInstance);
- }
+ if (theInstance == null)
+ {
+ theInstance = new EPRManager(domain);
- return theInstance;
+ _instances.put(domain, theInstance);
+ }
+
+ return theInstance;
+ }
}
- }
- public final String getDomain ()
- {
- return _directory;
- }
-
- public boolean equals (Object manager)
- {
- if (manager instanceof EPRManager)
+ public final String getDomain()
{
- EPRManager comp = (EPRManager) manager;
-
- if (_directory.equals(comp.getDomain()))
- return true;
+ return _directory;
}
- return false;
- }
+ public boolean equals(Object manager)
+ {
+ if (manager instanceof EPRManager)
+ {
+ EPRManager comp = (EPRManager) manager;
- /**
- * Save the EPR into the specified file.
- *
- * @param name
- * the name of the file to use (the logical service
- * name).
- * @param address
- * the EPR to save.
- *
- * @throws IOException
- * thrown if there is an error.
- */
+ if (_directory.equals(comp.getDomain()))
+ return true;
+ }
- public final void saveEPR (String name, EPR address) throws IOException
- {
- if ((name == null) || (address == null))
- throw new IllegalArgumentException();
+ return false;
+ }
- try
+ /**
+ * Save the EPR into the specified file.
+ *
+ * @param name
+ * the name of the file to use (the logical service name).
+ * @param address
+ * the EPR to save.
+ *
+ * @throws IOException
+ * thrown if there is an error.
+ */
+
+ public final void saveEPR(String name, EPR address) throws IOException
{
- String documentAsString = EPRHelper.toXMLString(address);
+ if ((name == null) || (address == null))
+ throw new IllegalArgumentException();
- FileOutputStream output = new FileOutputStream(_directory
- + File.separator + name);
+ try
+ {
+ String documentAsString = EPRHelper.toXMLString(address);
- output.write(documentAsString.getBytes());
- output.flush();
- output.getFD().sync(); // make sure it's on disk!
+ FileOutputStream output = new FileOutputStream(_directory
+ + File.separator + name);
+
+ output.write(documentAsString.getBytes());
+ output.flush();
+ output.getFD().sync(); // make sure it's on disk!
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
}
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
- /**
- * Remove the EPR-to-file association.
- *
- * @param name
- * the logical name for the service.
- * @throws IOException
- * thrown if there are any errors.
- */
+ /**
+ * Remove the EPR-to-file association.
+ *
+ * @param name
+ * the logical name for the service.
+ * @throws IOException
+ * thrown if there are any errors.
+ */
- public final void removeEPR (String name) throws IOException
- {
- if (name == null)
- throw new IllegalArgumentException();
+ public final void removeEPR(String name) throws IOException
+ {
+ if (name == null)
+ throw new IllegalArgumentException();
- File theFile = new File(_directory + File.separator + name);
+ File theFile = new File(_directory + File.separator + name);
- if (theFile.exists())
- theFile.delete();
- else
- throw new FileNotFoundException();
- }
+ if (theFile.exists())
+ theFile.delete();
+ else
+ throw new FileNotFoundException();
+ }
- /**
- * Get the EPR specified by the logical name.
- *
- * @param name
- * the service name.
- * @return the EPR, or <code>null</code> if none exists.
- * @throws IOException
- * thrown if there is an error.
- */
+ /**
+ * Get the EPR specified by the logical name.
+ *
+ * @param name
+ * the service name.
+ * @return the EPR, or <code>null</code> if none exists.
+ * @throws IOException
+ * thrown if there is an error.
+ */
- public final EPR loadEPR (String name) throws IOException
- {
- if (name == null)
- throw new IllegalArgumentException();
+ public final EPR loadEPR(String name) throws IOException
+ {
+ if (name == null)
+ throw new IllegalArgumentException();
- File theFile = new File(_directory + File.separator + name);
+ File theFile = new File(_directory + File.separator + name);
- try
- {
- if (theFile.exists())
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(theFile);
- Element rootElement = doc.getDocumentElement();
+ try
+ {
+ if (theFile.exists())
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(theFile);
+ Element rootElement = doc.getDocumentElement();
- return EPRHelper.fromXML(rootElement);
- }
- else
- throw new FileNotFoundException(theFile.toString());
+ return EPRHelper.fromXML(rootElement);
+ }
+ else
+ throw new FileNotFoundException(theFile.toString());
+ }
+ catch (SAXException ex)
+ {
+ throw new IOException(ex.toString());
+ }
+ catch (ParserConfigurationException ex)
+ {
+ throw new IllegalArgumentException(ex.toString());
+ }
}
- catch (SAXException ex)
+
+ protected EPRManager(String domain)
{
- throw new IOException(ex.toString());
+ _directory = domain;
}
- catch (ParserConfigurationException ex)
- {
- throw new IllegalArgumentException(ex.toString());
- }
- }
- protected EPRManager(String domain)
- {
- _directory = domain;
- }
+ private String _directory;
- private String _directory;
+ private static Hashtable<String, EPRManager> _instances = new Hashtable<String, EPRManager>();
- private static Hashtable<String, EPRManager> _instances = new Hashtable<String, EPRManager>();
-
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list