Changeset 6602


Ignore:
Timestamp:
06/29/10 15:40:37 (9 years ago)
Author:
melissa
Message:

Throw a nicer exception if LuraWaveServiceImpl is instantiated with lwf-stubs.jar in the CLASSPATH.

Location:
trunk/components
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/services/LuraWaveServiceImpl.java

    r6128 r6602  
    2626import java.io.IOException; 
    2727import java.io.InputStream; 
     28import java.lang.reflect.Field; 
    2829 
    2930import loci.common.services.AbstractService; 
     
    6162  public static final String INVALID_LICENSE_MSG = "Invalid license code: "; 
    6263 
     64  /** Identifying field in stub class. */ 
     65  public static final String STUB_FIELD = "IS_STUB"; 
     66 
    6367  /** LuraWave decoder delegate. */ 
    6468  private lwfDecoder delegate; 
     
    7074   * Default constructor. 
    7175   */ 
    72   public LuraWaveServiceImpl() { 
     76  public LuraWaveServiceImpl() throws DependencyException { 
    7377    license = System.getProperty(LICENSE_PROPERTY); 
    7478    checkClassDependency(com.luratech.lwf.lwfDecoder.class); 
     79    try { 
     80      Field isStub = com.luratech.lwf.lwfDecoder.class.getField(STUB_FIELD); 
     81      if (isStub != null) { 
     82        throw new DependencyException(NO_LURAWAVE_MSG); 
     83      } 
     84    } 
     85    catch (NoSuchFieldException e) { } 
    7586  } 
    7687 
  • trunk/components/stubs/lwf-stubs/src/com/luratech/lwf/lwfDecoder.java

    r6155 r6602  
    4545 */ 
    4646public class lwfDecoder { 
     47 
     48  // NB: This field is used to distinguish between this stub class and the 
     49  // actual lwfDecoder implementation. 
     50  public static final boolean IS_STUB = true; 
    4751 
    4852  /** 
Note: See TracChangeset for help on using the changeset viewer.