juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi build.xml
Date Wed, 02 Jun 2004 22:20:45 GMT
sviens      2004/06/02 15:20:45

  Modified:    .        build.xml
  Added:       src/java/org/apache/juddi/validator Validator.java
                        DefaultValidator.java ValidatorFactory.java
  Log:
  Adding plumbing to support UDDI validate_values service.
  
  Revision  Changes    Path
  1.1                  ws-juddi/src/java/org/apache/juddi/validator/Validator.java
  
  Index: Validator.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.juddi.validator;
  
  import org.apache.juddi.datatype.CategoryBag;
  import org.apache.juddi.datatype.IdentifierBag;
  import org.apache.juddi.datatype.KeyedReference;
  import org.apache.juddi.error.RegistryException;
  
  /**
   * @author Steve Viens (sviens@apache.org)
   */
  public interface Validator 
  {
    /**
     *
     * @param object
     * @return A DispositionReport containing the validation results
     * @throws RegistryException
     */
    boolean validate(CategoryBag bag)
    	throws RegistryException;
  
    /**
     *
     * @param object
     * @return A DispositionReport containing the validation results
     * @throws RegistryException
     */
    boolean validate(IdentifierBag bag)
    	throws RegistryException;
  
    /**
     *
     * @param object
     * @return A DispositionReport containing the validation results
     * @throws RegistryException
     */
    boolean validate(KeyedReference ref)
    	throws RegistryException;
  }
  
  
  
  1.1                  ws-juddi/src/java/org/apache/juddi/validator/DefaultValidator.java
  
  Index: DefaultValidator.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.juddi.validator;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.juddi.datatype.CategoryBag;
  import org.apache.juddi.datatype.IdentifierBag;
  import org.apache.juddi.datatype.KeyedReference;
  import org.apache.juddi.error.RegistryException;
  
  /**
   * This is a simple implementation of jUDDI's Validation interface.
   *
   * @author Steve Viens (sviens@apache.org)
   */
  public class DefaultValidator implements Validator
  {
    // private reference to the jUDDI logger
    private static Log log = LogFactory.getLog(DefaultValidator.class);
  
    /**
     *
     */
    public DefaultValidator()
    {
    }
  
    /**
     *
     */
    public boolean validate(CategoryBag bag)
      throws RegistryException
    {
    	return true;
    }
  
    /**
     *
     */
    public boolean validate(IdentifierBag bag)
      throws RegistryException
    {
    	return true;
    }
  
    /**
     *
     */
    public boolean validate(KeyedReference ref)
      throws RegistryException
    {
    	return true;
    }
  
  
    /***************************************************************************/
    /***************************** TEST DRIVER *********************************/
    /***************************************************************************/
  
  
    public static void main(String[] args)
      throws Exception
    {
      Validator validation = new DefaultValidator();
    }
  }
  
  
  1.1                  ws-juddi/src/java/org/apache/juddi/validator/ValidatorFactory.java
  
  Index: ValidatorFactory.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.juddi.validator;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.juddi.datatype.CategoryBag;
  import org.apache.juddi.util.Config;
  import org.apache.juddi.util.Loader;
  
  /**
   * Implementation of Factory pattern used to create an implementation of
   * the org.apache.juddi.validation.Validation interface.
   *
   * The name of the Validation implementation to create is passed to the
   * getValidation method.  If a null value is passed then the default
   * Validation implementation "org.apache.juddi.validation.DefaultValidation" 
   * is created.
   *
   * @author Steve Viens (sviens@apache.org)
   */
  public class ValidatorFactory
  {
    // private reference to the jUDDI logger
    private static Log log = LogFactory.getLog(ValidatorFactory.class);
  
    // Validation property key & default implementation
    private static final String IMPL_KEY = "juddi.validation";
    private static final String DEFAULT_IMPL = "org.apache.juddi.validation.DefaultValidation";
  
    // the shared Validation instance
    private static Validator validation = null;
  
    /**
     * Returns a new instance of a ValidationFactory.
     *
     * @return Validation
     */
    public static Validator getValidation()
    {
      if (validation == null)
        validation = createValidation();
      return validation;
    }
  
    /**
     * Returns a new instance of a Validation.
     *
     * @return Validation
     */
    private static synchronized Validator createValidation()
    {
      if (validation != null)
        return validation;
  
      // grab class name of the Validation implementation to create
      String className = Config.getStringProperty(IMPL_KEY,DEFAULT_IMPL);
  
      // write the Validation implementation name to the log
      log.debug("Validation Implementation = " + className);
  
      Class implClass = null;
      try
      {
        // Use Loader to locate & load the Validation implementation
        implClass = Loader.getClassForName(className);
      }
      catch(ClassNotFoundException e)
      {
        log.error("The specified Validation class '" + className +
          "' was not found in classpath.");
        log.error(e);
      }
  
      try
      {
        // try to instantiate the Validation implementation
        validation = (Validator)implClass.newInstance();
      }
      catch(Exception e)
      {
        log.error("Exception while attempting to instantiate the " +
          "implementation of Validation: " + implClass.getName() +
          "\n" + e.getMessage());
        log.error(e);
      }
  
      return validation;
    }
  
  
    /***************************************************************************/
    /***************************** TEST DRIVER *********************************/
    /***************************************************************************/
  
  
    public static void main(String[] args)
      throws Exception
    {
        Validator validation = ValidatorFactory.getValidation();
        if (validation != null)
        {
          System.out.println("Got a Validation instance: "+validation.getClass().getName());
  
          if (validation.validate(new CategoryBag()))
          	System.out.println("The objct was successfully validated.");
          else
          	System.out.println("Sorry validation failed.");
        }
        else
          System.out.println("Couldn't get a Validation instance.");
    }
  }
  
  
  1.28      +6 -4      ws-juddi/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ws-juddi/build.xml,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- build.xml	2 Jun 2004 17:20:03 -0000	1.27
  +++ build.xml	2 Jun 2004 22:20:45 -0000	1.28
  @@ -168,7 +168,8 @@
                   org/apache/juddi/registry/**,
                   org/apache/juddi/transport/**,
                   org/apache/juddi/util/jdbc/**,
  -                org/apache/juddi/uuidgen/**"/>
  +                org/apache/juddi/uuidgen/**,
  +    	        org/apache/juddi/validator/**"/>
     </target>
     <!-- =================================================================== -->
     <!-- Build the jUDDI Web Application (juddi.war)                         -->
  @@ -257,8 +258,9 @@
              org.apache.juddi.util,
              org.apache.juddi.util.jdbc,
              org.apache.juddi.util.xml,
  -           org.apache.juddi.uuidgen"
  -        author="true"
  +           org.apache.juddi.uuidgen,
  +           org.apache.juddi.validator"
  +    	author="true"
           version="true"
           windowtitle="${title}"
           doctitle="${title}"
  
  
  

Mime
View raw message