Return-Path: Delivered-To: apmail-ws-juddi-cvs-archive@www.apache.org Received: (qmail 24367 invoked from network); 28 Sep 2007 21:14:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Sep 2007 21:14:34 -0000 Received: (qmail 34012 invoked by uid 500); 28 Sep 2007 21:14:24 -0000 Delivered-To: apmail-ws-juddi-cvs-archive@ws.apache.org Received: (qmail 33973 invoked by uid 500); 28 Sep 2007 21:14:24 -0000 Mailing-List: contact juddi-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list juddi-cvs@ws.apache.org Received: (qmail 33962 invoked by uid 99); 28 Sep 2007 21:14:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 14:14:24 -0700 X-ASF-Spam-Status: No, hits=-98.8 required=10.0 tests=ALL_TRUSTED,DNS_FROM_DOB,RCVD_IN_DOB X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 21:16:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5E9BA1A9832; Fri, 28 Sep 2007 14:14:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r580488 - in /webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local: AbstractService.java InquiryService.java PublishService.java RequestHandler.java Date: Fri, 28 Sep 2007 21:14:09 -0000 To: juddi-cvs@ws.apache.org From: kstam@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070928211410.5E9BA1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kstam Date: Fri Sep 28 14:14:09 2007 New Revision: 580488 URL: http://svn.apache.org/viewvc?rev=580488&view=rev Log: JUDDI-113, refactoring so that we can run the registry in a thread of it's own. Added: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/RequestHandler.java - copied, changed from r580359, webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/AbstractService.java Removed: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/AbstractService.java Modified: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/InquiryService.java webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/PublishService.java Modified: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/InquiryService.java URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/InquiryService.java?rev=580488&r1=580487&r2=580488&view=diff ============================================================================== --- webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/InquiryService.java (original) +++ webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/InquiryService.java Fri Sep 28 14:14:09 2007 @@ -27,14 +27,14 @@ /** * @author Kurt Stam (kurt.stam@redhat.com) */ -public class InquiryService extends AbstractService +public class InquiryService { // collection of valid operations - private TreeSet operations = null; + private TreeSet operations = null; public InquiryService() { super(); - operations = new TreeSet(); + operations = new TreeSet(); operations.add("find_business"); operations.add("find_service"); operations.add("find_binding"); @@ -47,6 +47,9 @@ operations.add("get_tmodeldetail"); } + //Verify that the appropriate endpoint was targeted for + // this service request. The validateRequest method will + // throw an UnsupportedException if anything's amiss. public void validateRequest(String operation,String version,Element uddiReq) throws RegistryException { @@ -74,7 +77,20 @@ } public Node inquire(Element uddiReq) throws Exception{ - return handleRequest(uddiReq); + + //new RequestHandler on it's own thread + RequestHandler requestHandler = new RequestHandler(); + requestHandler.setUddiReq(uddiReq); + String operation = requestHandler.getOperation(uddiReq); + String version = requestHandler.getVersion(uddiReq,operation); + validateRequest(operation, version, uddiReq); + Thread thread = new Thread(requestHandler, "WorkThread"); + thread.start(); + thread.join(); + if (requestHandler.getException()!=null) { + throw new Exception(requestHandler.getException()); + } + return requestHandler.getResponse(); } } Modified: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/PublishService.java URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/PublishService.java?rev=580488&r1=580487&r2=580488&view=diff ============================================================================== --- webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/PublishService.java (original) +++ webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/PublishService.java Fri Sep 28 14:14:09 2007 @@ -27,14 +27,14 @@ /** * @author Kurt Stam (kurt.stam@jboss.com) */ -public class PublishService extends AbstractService +public class PublishService { // collection of valid operations - private TreeSet operations = null; + private TreeSet operations = null; public PublishService() { super(); - operations = new TreeSet(); + operations = new TreeSet(); operations.add("get_authtoken"); operations.add("get_registeredinfo"); operations.add("discard_authtoken"); @@ -80,7 +80,20 @@ "supported by the UDDI version 2 Publish API."); } - public Node publish(Element uddiReq) throws Exception{ - return handleRequest(uddiReq); + public Node publish(Element uddiReq) throws Exception + { + //new RequestHandler on it's own thread + RequestHandler requestHandler = new RequestHandler(); + requestHandler.setUddiReq(uddiReq); + String operation = requestHandler.getOperation(uddiReq); + String version = requestHandler.getVersion(uddiReq, operation); + validateRequest(operation, version, uddiReq); + Thread thread = new Thread(requestHandler, "WorkThread"); + thread.start(); + thread.join(); + if (requestHandler.getException()!=null) { + throw new Exception(requestHandler.getException()); + } + return requestHandler.getResponse(); } } Copied: webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/RequestHandler.java (from r580359, webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/AbstractService.java) URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/RequestHandler.java?p2=webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/RequestHandler.java&p1=webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/AbstractService.java&r1=580359&r2=580488&rev=580488&view=diff ============================================================================== --- webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/AbstractService.java (original) +++ webservices/juddi/trunk/src/main/java/org/apache/juddi/registry/local/RequestHandler.java Fri Sep 28 14:14:09 2007 @@ -42,55 +42,72 @@ /** * @author Kurt Stam (kurt.stam@redhat.com) */ -public abstract class AbstractService +public class RequestHandler implements Runnable { // private reference to the webapp's logger. - private static Log log = LogFactory.getLog(AbstractService.class); + private static Log log = LogFactory.getLog(RequestHandler.class); // XML Document Builder private static DocumentBuilder docBuilder = null; - - public Node handleRequest(Element uddiReq) throws Exception + + private String version; + private String operation; + private Element uddiReq; + private Node response; + private String exception; + + /** + * Grab the local name of the UDDI request element + * from the UDDI Request. If a value isn't returned + * (either null or an empty String is returned) then + * throw a FatalError exception. This is probably a + * configuration problem related to the XML Parser + * that jUDDI is using. + * @param uddiReq + * @return + * @throws Exception + */ + public String getOperation(Element uddiReq) throws Exception { - try - { if (uddiReq == null) - throw new FatalErrorException("A UDDI request was not " + - "found in the SOAP message."); - - // Grab the local name of the UDDI request element - // from the UDDI Request. If a value isn't returned - // (either null or an empty String is returned) then - // throw a FatalError exception. This is probably a - // configuration problem related to the XML Parser - // that jUDDI is using. - + throw new FatalErrorException("A UDDI request was not " + + "found in the SOAP message."); + String operation = uddiReq.getLocalName(); if ((operation == null) || (operation.trim().length() == 0)) throw new FatalErrorException("The UDDI service operation " + "could not be identified."); - - // Grab the generic attribute value (version value). If - // one isn't specified or the value specified is not "2.0" - // then throw an exception (this value must be specified - // for all UDDI requests and currently only vesion 2.0 - // UDDI requests are supported). - + setOperation(operation); + return operation; + } + /** + * Grab the generic attribute value (version value). If + * one isn't specified or the value specified is not "2.0" + * then throw an exception (this value must be specified + * for all UDDI requests and currently only vesion 2.0 + * UDDI requests are supported). + * + * @param uddiReq + * @return + * @throws Exception + */ + public String getVersion(Element uddiReq, String operation) throws Exception + { String version = uddiReq.getAttribute("generic"); if (version == null) throw new FatalErrorException("A UDDI generic attribute " + "value was not found for UDDI request: "+operation+" (The " + "'generic' attribute must be present)"); - - // Verify that the appropriate endpoint was targeted for - // this service request. The validateRequest method will - // throw an UnsupportedException if anything's amiss. - - validateRequest(operation,version,uddiReq); - + setVersion(version); + return version; + } + + public void run() + { + try + { // Lookup the appropriate XML handler. Throw an // UnsupportedException if one could not be located. - HandlerMaker maker = HandlerMaker.getInstance(); IHandler requestHandler = maker.lookup(operation); if (requestHandler == null) @@ -141,8 +158,7 @@ // discarding the temp element) and append // this child to the soap response body document.appendChild(element.getFirstChild()); - - return document; + setResponse(document); } catch(Exception ex) // Catch ALL exceptions { @@ -266,15 +282,9 @@ String fault = "faultCode=" + faultCode + ", faultString=" + faultString + ", faultActor=" + faultActor + ", errno=" + errno + ", errCode=" + errCode + ", errText=" + errText; - throw new Exception(fault); + setException(fault); } } - - /** - * - */ - public abstract void validateRequest(String operation,String generic,Element uddiReq) - throws RegistryException; /** * @@ -307,4 +317,34 @@ return docBuilder; } +public String getOperation() { + return operation; +} +public void setOperation(String operation) { + this.operation = operation; +} +public Node getResponse() { + return response; +} +public void setResponse(Node response) { + this.response = response; +} +public Element getUddiReq() { + return uddiReq; +} +public void setUddiReq(Element uddiReq) { + this.uddiReq = uddiReq; +} +public String getVersion() { + return version; +} +public void setVersion(String version) { + this.version = version; +} +public String getException() { + return exception; +} +public void setException(String exception) { + this.exception = exception; +} } --------------------------------------------------------------------- To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: juddi-cvs-help@ws.apache.org