commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jelly/jelly-tags/validate/src/java/org/apache/commons/jelly/tags/validate VerifierTag.java
Date Sun, 20 Apr 2003 03:16:25 GMT
dion        2003/04/19 20:16:25

  Modified:    jelly/jelly-tags/validate/src/java/org/apache/commons/jelly/tags/validate
                        VerifierTag.java
  Log:
  Ensure that msv is not needed as a dependency by using class loading
  rather than hard coding the name
  
  Revision  Changes    Path
  1.3       +28 -12    jakarta-commons/jelly/jelly-tags/validate/src/java/org/apache/commons/jelly/tags/validate/VerifierTag.java
  
  Index: VerifierTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/validate/src/java/org/apache/commons/jelly/tags/validate/VerifierTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VerifierTag.java	26 Jan 2003 08:44:58 -0000	1.2
  +++ VerifierTag.java	20 Apr 2003 03:16:24 -0000	1.3
  @@ -103,9 +103,6 @@
               throw new MissingAttributeException("var");
           }
   
  -        if ( factory == null ) {
  -            factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
  -        }
           InputStream in = null;
           if ( uri != null ) {
               in = context.getResourceAsStream( uri );
  @@ -115,7 +112,6 @@
           }
           else {
               String text = getBodyText();
  -            byte[] data = text.getBytes();
               in = new ByteArrayInputStream( text.getBytes() );
           }
   
  @@ -123,13 +119,13 @@
           try {
               Schema schema = null;
               if (systemId != null) {
  -                schema = factory.compileSchema(in, systemId);
  +                schema = getFactory().compileSchema(in, systemId);
               }
               else if ( uri != null ) {
  -                schema = factory.compileSchema(in, uri);
  +                schema = getFactory().compileSchema(in, uri);
               }
               else{
  -                schema = factory.compileSchema(in);
  +                schema = getFactory().compileSchema(in);
               }
               
               if ( schema == null ) {
  @@ -192,6 +188,26 @@
           this.factory = factory;
       }
           
  +    public VerifierFactory getFactory() throws JellyTagException {
  +		if ( factory == null ) {
  +			try {
  +				ClassLoader loader = Thread.currentThread().getContextClassLoader();
  +				if (loader == null) {
  +					loader = getClass().getClassLoader();
  +				}
  +				factory = (VerifierFactory)loader.loadClass(
  +					"com.sun.msv.verifier.jarv.TheFactoryImpl").newInstance();
  +			} catch (ClassNotFoundException e) {
  +				throw new JellyTagException(e);
  +			} catch (InstantiationException e) {
  +				throw new JellyTagException(e);
  +			} catch (IllegalAccessException e) {
  +				throw new JellyTagException(e);
  +			}
  +		}
  +		return factory;
  +    }
  +  
       // Implementation methods
       //-------------------------------------------------------------------------       
            
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message