1 package de.juplo.plugins.hibernate4;
4 * Copyright 2001-2005 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import com.pyx4j.log4j.MavenLogAppender;
21 import java.io.FileInputStream;
22 import java.io.FileNotFoundException;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.ObjectInputStream;
27 import java.io.ObjectOutputStream;
28 import java.math.BigInteger;
30 import java.net.URLClassLoader;
31 import java.security.MessageDigest;
32 import java.security.NoSuchAlgorithmException;
33 import java.sql.Driver;
34 import java.sql.DriverPropertyInfo;
35 import java.sql.SQLException;
36 import java.sql.SQLFeatureNotSupportedException;
37 import java.util.Comparator;
38 import java.util.HashMap;
39 import java.util.HashSet;
40 import java.util.List;
42 import java.util.Map.Entry;
43 import java.util.Properties;
45 import java.util.TreeSet;
46 import java.util.logging.Logger;
47 import java.util.regex.Matcher;
48 import java.util.regex.Pattern;
49 import javax.persistence.Embeddable;
50 import javax.persistence.Entity;
51 import javax.persistence.MappedSuperclass;
52 import org.apache.maven.artifact.Artifact;
53 import org.apache.maven.model.Resource;
54 import org.apache.maven.plugin.AbstractMojo;
55 import org.apache.maven.plugin.MojoExecutionException;
56 import org.apache.maven.plugin.MojoFailureException;
57 import org.apache.maven.project.MavenProject;
58 import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
59 import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
60 import org.hibernate.cfg.Environment;
61 import org.hibernate.cfg.NamingStrategy;
62 import org.hibernate.envers.configuration.spi.AuditConfiguration;
63 import org.hibernate.internal.util.config.ConfigurationHelper;
64 import org.hibernate.tool.hbm2ddl.SchemaExport;
65 import org.hibernate.tool.hbm2ddl.SchemaExport.Type;
66 import org.hibernate.tool.hbm2ddl.Target;
67 import org.scannotation.AnnotationDB;
71 * Goal which extracts the hibernate-mapping-configuration and
72 * exports an according SQL-database-schema.
75 * @phase process-classes
77 * @requiresDependencyResolution runtime
79 public class Hbm2DdlMojo extends AbstractMojo
81 public final static String EXPORT_SKIPPED_PROPERTY = "hibernate.export.skipped";
83 public final static String DRIVER_CLASS = "hibernate.connection.driver_class";
84 public final static String URL = "hibernate.connection.url";
85 public final static String USERNAME = "hibernate.connection.username";
86 public final static String PASSWORD = "hibernate.connection.password";
87 public final static String DIALECT = "hibernate.dialect";
88 public final static String NAMING_STRATEGY="hibernate.ejb.naming_strategy";
89 public final static String ENVERS = "hibernate.export.envers";
91 public final static String MD5S = "hibernate4-generatedschema.md5s";
93 private final static Pattern split = Pattern.compile("[^,\\s]+");
99 * Only needed internally.
101 * @parameter property="project"
105 private MavenProject project;
110 * Only needed internally.
112 * @parameter property="project.build.directory"
116 private String buildDirectory;
119 * Classes-Directory to scan.
121 * This parameter defaults to the maven build-output-directory for classes.
122 * Additionally, all dependencies are scanned for annotated classes.
124 * @parameter property="project.build.outputDirectory"
127 private String outputDirectory;
130 * Whether to scan test-classes too, or not.
132 * If this parameter is set to <code>true</code> the test-classes of the
133 * artifact will be scanned for hibernate-annotated classes additionally.
135 * @parameter property="hibernate.export.scan_testclasses" default-value="false"
138 private boolean scanTestClasses;
141 * Dependency-Scopes, that should be scanned for annotated classes.
143 * By default, only dependencies in the scope <code>compile</code> are
144 * scanned for annotated classes. Multiple scopes can be seperated by
145 * white space or commas.
147 * If you do not want any dependencies to be scanned for annotated
148 * classes, set this parameter to <code>none</code>.
150 * The plugin does not scan for annotated classes in transitive
151 * dependencies. If some of your annotated classes are hidden in a
152 * transitive dependency, you can simply add that dependency explicitly.
154 * @parameter property="hibernate.export.scan_dependencies" default-value="compile"
157 private String scanDependencies;
160 * Test-Classes-Directory to scan.
162 * This parameter defaults to the maven build-output-directory for
165 * This parameter is only used, when <code>scanTestClasses</code> is set
166 * to <code>true</code>!
168 * @parameter property="project.build.testOutputDirectory"
171 private String testOutputDirectory;
176 * If set to <code>true</code>, the execution is skipped.
178 * A skipped execution is signaled via the maven-property
179 * <code>${hibernate.export.skipped}</code>.
181 * The execution is skipped automatically, if no modified or newly added
182 * annotated classes are found and the dialect was not changed.
184 * @parameter property="hibernate.skip" default-value="${maven.test.skip}"
187 private boolean skip;
192 * Force execution, even if no modified or newly added annotated classes
193 * where found and the dialect was not changed.
195 * <code>skip</code> takes precedence over <code>force</code>.
197 * @parameter property="hibernate.export.force" default-value="false"
200 private boolean force;
205 * @parameter property="hibernate.connection.driver_class"
208 private String driverClassName;
213 * @parameter property="hibernate.connection.url"
221 * @parameter property="hibernate.connection.username"
224 private String username;
229 * @parameter property="hibernate.connection.password"
232 private String password;
237 * @parameter property="hibernate.dialect"
240 private String hibernateDialect;
243 * Hibernate Naming Strategy
245 * @parameter property="hibernate.ejb.naming_strategy"
248 private String hibernateNamingStrategy;
251 * Path to Hibernate configuration file.
253 * @parameter default-value="${project.build.outputDirectory}/hibernate.properties"
256 private String hibernateProperties;
259 * List of Hibernate-Mapping-Files (XML).
260 * Multiple files can be separated with white-spaces and/or commas.
262 * @parameter property="hibernate.mapping"
265 private String hibernateMapping;
268 * Target of execution:
270 * <li><strong>NONE</strong> only export schema to SQL-script (forces execution, signals skip)</li>
271 * <li><strong>EXPORT</strong> create database (<strong>DEFAULT!</strong>). forces execution, signals skip)</li>
272 * <li><strong>SCRIPT</strong> export schema to SQL-script and print it to STDOUT</li>
273 * <li><strong>BOTH</strong></li>
276 * A database connection is only needed for EXPORT and BOTH, but a
277 * Hibernate-Dialect must always be chosen.
279 * @parameter property="hibernate.export.target" default-value="EXPORT"
282 private String target;
287 * <li><strong>NONE</strong> do nothing - just validate the configuration</li>
288 * <li><strong>CREATE</strong> create database-schema</li>
289 * <li><strong>DROP</strong> drop database-schema</li>
290 * <li><strong>BOTH</strong> (<strong>DEFAULT!</strong>)</li>
293 * If NONE is choosen, no databaseconnection is needed.
295 * @parameter property="hibernate.export.type" default-value="BOTH"
303 * @parameter property="hibernate.export.schema.filename" default-value="${project.build.directory}/schema.sql"
306 private String outputFile;
309 * Delimiter in output-file.
311 * @parameter property="hibernate.export.schema.delimiter" default-value=";"
314 private String delimiter;
317 * Format output-file.
319 * @parameter property="hibernate.export.schema.format" default-value="true"
322 private boolean format;
325 * Generate envers schema for auditing tables.
327 * @parameter property="hibernate.export.envers" default-value="false"
330 private boolean envers;
334 public void execute()
336 MojoFailureException,
337 MojoExecutionException
341 getLog().info("Execution of hibernate4-maven-plugin:export was skipped!");
342 project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true");
346 Map<String,String> md5s;
347 boolean modified = false;
348 File saved = new File(buildDirectory + File.separator + MD5S);
350 if (saved.isFile() && saved.length() > 0)
354 FileInputStream fis = new FileInputStream(saved);
355 ObjectInputStream ois = new ObjectInputStream(fis);
356 md5s = (HashMap<String,String>)ois.readObject();
361 md5s = new HashMap<String,String>();
362 getLog().warn("Cannot read timestamps from saved: " + e);
367 md5s = new HashMap<String,String>();
370 saved.createNewFile();
372 catch (IOException e)
374 getLog().debug("Cannot create file \"" + saved.getPath() + "\" for timestamps: " + e);
378 ClassLoader classLoader = null;
381 getLog().debug("Creating ClassLoader for project-dependencies...");
382 List<String> classpathFiles = project.getCompileClasspathElements();
384 classpathFiles.addAll(project.getTestClasspathElements());
385 URL[] urls = new URL[classpathFiles.size()];
386 for (int i = 0; i < classpathFiles.size(); ++i)
388 getLog().debug("Dependency: " + classpathFiles.get(i));
389 urls[i] = new File(classpathFiles.get(i)).toURI().toURL();
391 classLoader = new URLClassLoader(urls, getClass().getClassLoader());
395 getLog().error("Error while creating ClassLoader!", e);
396 throw new MojoExecutionException(e.getMessage());
399 Set<Class<?>> classes =
400 new TreeSet<Class<?>>(
401 new Comparator<Class<?>>() {
403 public int compare(Class<?> a, Class<?> b)
405 return a.getName().compareTo(b.getName());
412 AnnotationDB db = new AnnotationDB();
413 File dir = new File(outputDirectory);
416 getLog().info("Scanning directory " + outputDirectory + " for annotated classes...");
417 URL dirUrl = dir.toURI().toURL();
418 db.scanArchives(dirUrl);
422 dir = new File(testOutputDirectory);
425 getLog().info("Scanning directory " + testOutputDirectory + " for annotated classes...");
426 URL dirUrl = dir.toURI().toURL();
427 db.scanArchives(dirUrl);
430 if (scanDependencies != null)
432 Matcher matcher = split.matcher(scanDependencies);
433 while (matcher.find())
435 getLog().info("Scanning dependencies for scope " + matcher.group());
436 for (Artifact artifact : project.getDependencyArtifacts())
438 if (!artifact.getScope().equalsIgnoreCase(matcher.group()))
440 if (artifact.getFile() == null)
443 "Cannot scan dependency " +
445 ": no JAR-file available!"
450 "Scanning dependency " +
452 " for annotated classes..."
454 db.scanArchives(artifact.getFile().toURI().toURL());
459 Set<String> classNames = new HashSet<String>();
460 if (db.getAnnotationIndex().containsKey(Entity.class.getName()))
461 classNames.addAll(db.getAnnotationIndex().get(Entity.class.getName()));
462 if (db.getAnnotationIndex().containsKey(MappedSuperclass.class.getName()))
463 classNames.addAll(db.getAnnotationIndex().get(MappedSuperclass.class.getName()));
464 if (db.getAnnotationIndex().containsKey(Embeddable.class.getName()))
465 classNames.addAll(db.getAnnotationIndex().get(Embeddable.class.getName()));
467 MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
468 for (String name : classNames)
470 Class<?> annotatedClass = classLoader.loadClass(name);
471 classes.add(annotatedClass);
472 String resourceName = annotatedClass.getName();
473 resourceName = resourceName.substring(resourceName.lastIndexOf(".") + 1, resourceName.length()) + ".class";
476 .getResourceAsStream(resourceName);
477 byte[] buffer = new byte[1024*4]; // copy data in 4MB-chunks
479 while((i = is.read(buffer)) > -1)
480 digest.update(buffer, 0, i);
482 byte[] bytes = digest.digest();
483 BigInteger bi = new BigInteger(1, bytes);
484 String newMd5 = String.format("%0" + (bytes.length << 1) + "x", bi);
485 String oldMd5 = !md5s.containsKey(name) ? "" : md5s.get(name);
486 if (!newMd5.equals(oldMd5))
488 getLog().debug("Found new or modified annotated class: " + name);
490 md5s.put(name, newMd5);
494 getLog().debug(oldMd5 + " -> class unchanged: " + name);
498 catch (ClassNotFoundException e)
500 getLog().error("Error while adding annotated classes!", e);
501 throw new MojoExecutionException(e.getMessage());
505 getLog().error("Error while scanning!", e);
506 throw new MojoFailureException(e.getMessage());
509 if (classes.isEmpty())
511 if (hibernateMapping == null || hibernateMapping.isEmpty())
512 throw new MojoFailureException("No annotated classes found in directory " + outputDirectory);
516 getLog().debug("Detected classes with mapping-annotations:");
517 for (Class<?> annotatedClass : classes)
518 getLog().debug(" " + annotatedClass.getName());
522 Properties properties = new Properties();
524 /** Try to read configuration from properties-file */
527 File file = new File(hibernateProperties);
530 getLog().info("Reading properties from file " + hibernateProperties + "...");
531 properties.load(new FileInputStream(file));
534 getLog().info("No hibernate-properties-file found! (Checked path: " + hibernateProperties + ")");
536 catch (IOException e)
538 getLog().error("Error while reading properties!", e);
539 throw new MojoExecutionException(e.getMessage());
542 /** Overwrite values from properties-file or set, if given */
543 if (driverClassName != null)
545 if (properties.containsKey(DRIVER_CLASS))
547 "Overwriting property " +
548 DRIVER_CLASS + "=" + properties.getProperty(DRIVER_CLASS) +
549 " with the value " + driverClassName
552 getLog().debug("Using the value " + driverClassName);
553 properties.setProperty(DRIVER_CLASS, driverClassName);
557 if (properties.containsKey(URL))
559 "Overwriting property " +
560 URL + "=" + properties.getProperty(URL) +
561 " with the value " + url
564 getLog().debug("Using the value " + url);
565 properties.setProperty(URL, url);
567 if (username != null)
569 if (properties.containsKey(USERNAME))
571 "Overwriting property " +
572 USERNAME + "=" + properties.getProperty(USERNAME) +
573 " with the value " + username
576 getLog().debug("Using the value " + username);
577 properties.setProperty(USERNAME, username);
579 if (password != null)
581 if (properties.containsKey(PASSWORD))
583 "Overwriting property " +
584 PASSWORD + "=" + properties.getProperty(PASSWORD) +
585 " with value " + password
588 getLog().debug("Using value " + password + " for property " + PASSWORD);
589 properties.setProperty(PASSWORD, password);
591 if (hibernateDialect != null)
593 if (properties.containsKey(DIALECT))
595 "Overwriting property " +
596 DIALECT + "=" + properties.getProperty(DIALECT) +
597 " with value " + hibernateDialect
601 "Using value " + hibernateDialect + " for property " + DIALECT
603 properties.setProperty(DIALECT, hibernateDialect);
607 hibernateDialect = properties.getProperty(DIALECT);
609 if ( hibernateNamingStrategy != null )
611 if ( properties.contains(NAMING_STRATEGY))
613 "Overwriting property " +
614 NAMING_STRATEGY + "=" + properties.getProperty(NAMING_STRATEGY) +
615 " with value " + hibernateNamingStrategy
619 "Using value " + hibernateNamingStrategy + " for property " +
622 properties.setProperty(NAMING_STRATEGY, hibernateNamingStrategy);
625 /** The generated SQL varies with the dialect! */
626 if (md5s.containsKey(DIALECT))
628 String dialect = properties.getProperty(DIALECT);
629 if (md5s.get(DIALECT).equals(dialect))
630 getLog().debug("SQL-dialect unchanged.");
636 getLog().debug("SQL-dialect was unset.");
637 md5s.remove(DIALECT);
641 getLog().debug("SQL-dialect changed: " + dialect);
642 md5s.put(DIALECT, dialect);
648 String dialect = properties.getProperty(DIALECT);
652 md5s.put(DIALECT, properties.getProperty(DIALECT));
656 /** The generated SQL varies with the envers-configuration */
657 if (md5s.get(ENVERS) != null)
659 if (md5s.get(ENVERS).equals(Boolean.toString(envers)))
660 getLog().debug("Envers-Configuration unchanged. Enabled: " + envers);
663 getLog().debug("Envers-Configuration changed. Enabled: " + envers);
665 md5s.put(ENVERS, Boolean.toString(envers));
671 md5s.put(ENVERS, Boolean.toString(envers));
674 if (properties.isEmpty())
676 getLog().error("No properties set!");
677 throw new MojoFailureException("Hibernate configuration is missing!");
680 final ValidationConfiguration config = new ValidationConfiguration(hibernateDialect);
682 config.setProperties(properties);
684 if ( properties.containsKey(NAMING_STRATEGY))
686 String namingStrategy = properties.getProperty(NAMING_STRATEGY);
687 getLog().debug("Explicitly set NamingStrategy: " + namingStrategy);
690 @SuppressWarnings("unchecked")
691 Class<NamingStrategy> namingStrategyClass = (Class<NamingStrategy>) Class.forName(namingStrategy);
692 config.setNamingStrategy(namingStrategyClass.newInstance());
696 getLog().error("Error setting NamingStrategy", e);
697 throw new MojoExecutionException(e.getMessage());
701 ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
702 MavenLogAppender.startPluginLog(this);
706 * Change class-loader of current thread, so that hibernate can
707 * see all dependencies!
709 Thread.currentThread().setContextClassLoader(classLoader);
711 getLog().debug("Adding annotated classes to hibernate-mapping-configuration...");
712 // build annotated packages
713 Set<String> packages = new HashSet<String>();
714 for (Class<?> annotatedClass : classes)
716 String packageName = annotatedClass.getPackage().getName();
717 if (!packages.contains(packageName))
719 getLog().debug("Add package " + packageName);
720 packages.add(packageName);
721 config.addPackage(packageName);
722 getLog().debug("type definintions" + config.getTypeDefs());
724 getLog().debug("Class " + annotatedClass);
725 config.addAnnotatedClass(annotatedClass);
728 if (hibernateMapping != null)
732 MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
733 for (String filename : hibernateMapping.split("[\\s,]+"))
735 // First try the filename as absolute/relative path
736 File file = new File(filename);
739 // If the file was not found, search for it in the resource-directories
740 for (Resource resource : project.getResources())
742 file = new File(resource.getDirectory() + File.separator + filename);
747 if (file != null && file.exists())
749 InputStream is = new FileInputStream(file);
750 byte[] buffer = new byte[1024*4]; // copy data in 4MB-chunks
752 while((i = is.read(buffer)) > -1)
753 digest.update(buffer, 0, i);
755 byte[] bytes = digest.digest();
756 BigInteger bi = new BigInteger(1, bytes);
757 String newMd5 = String.format("%0" + (bytes.length << 1) + "x", bi);
758 String oldMd5 = !md5s.containsKey(filename) ? "" : md5s.get(filename);
759 if (!newMd5.equals(oldMd5))
761 getLog().debug("Found new or modified mapping-file: " + filename);
763 md5s.put(filename, newMd5);
767 getLog().debug(oldMd5 + " -> mapping-file unchanged: " + filename);
769 getLog().debug("Adding mappings from XML-configurationfile: " + file);
770 config.addFile(file);
773 throw new MojoFailureException("File " + filename + " could not be found in any of the configured resource-directories!");
776 catch (NoSuchAlgorithmException e)
778 throw new MojoFailureException("Cannot calculate MD5 sums!", e);
780 catch (FileNotFoundException e)
782 throw new MojoFailureException("Cannot calculate MD5 sums!", e);
784 catch (IOException e)
786 throw new MojoFailureException("Cannot calculate MD5 sums!", e);
790 Target target = null;
793 target = Target.valueOf(this.target.toUpperCase());
795 catch (IllegalArgumentException e)
797 getLog().error("Invalid value for configuration-option \"target\": " + this.target);
798 getLog().error("Valid values are: NONE, SCRIPT, EXPORT, BOTH");
799 throw new MojoExecutionException("Invalid value for configuration-option \"target\"");
804 type = Type.valueOf(this.type.toUpperCase());
806 catch (IllegalArgumentException e)
808 getLog().error("Invalid value for configuration-option \"type\": " + this.type);
809 getLog().error("Valid values are: NONE, CREATE, DROP, BOTH");
810 throw new MojoExecutionException("Invalid value for configuration-option \"type\"");
813 if (target.equals(Target.SCRIPT) || target.equals(Target.NONE))
815 project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true");
819 && !target.equals(Target.SCRIPT)
820 && !target.equals(Target.NONE)
824 getLog().info("No modified annotated classes or mapping-files found and dialect unchanged.");
825 getLog().info("Skipping schema generation!");
826 project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true");
830 getLog().info("Gathered hibernate-configuration (turn on debugging for details):");
831 for (Entry<Object,Object> entry : properties.entrySet())
832 getLog().info(" " + entry.getKey() + " = " + entry.getValue());
834 Environment.verifyProperties( properties );
835 ConfigurationHelper.resolvePlaceHolders( properties );
836 StandardServiceRegistryImpl registry =
837 (StandardServiceRegistryImpl)
838 new StandardServiceRegistryBuilder().applySettings(properties).build();
840 config.buildMappings();
844 getLog().info("Automatic auditing via hibernate-envers enabled!");
845 AuditConfiguration.getFor(config);
848 SchemaExport export = new SchemaExport(registry, config);
849 export.setDelimiter(delimiter);
850 export.setFormat(format);
852 File outF = new File(outputFile);
854 if (!outF.isAbsolute())
856 // Interpret relative file path relative to build directory
857 outF = new File(buildDirectory, outputFile);
858 getLog().info("Adjusted relative path, resulting path is " + outF.getPath());
861 // Ensure that directory path for specified file exists
862 File outFileParentDir = outF.getParentFile();
863 if (null != outFileParentDir && !outFileParentDir.exists())
867 getLog().info("Creating directory path for output file:" + outFileParentDir.getPath());
868 outFileParentDir.mkdirs();
872 getLog().error("Error creating directory path for output file: " + e.getLocalizedMessage());
876 export.setOutputFile(outF.getPath());
877 export.execute(target, type);
879 for (Object exception : export.getExceptions())
880 getLog().debug(exception.toString());
884 /** Stop Log-Capturing */
885 MavenLogAppender.endPluginLog(this);
887 /** Restore the old class-loader (TODO: is this really necessary?) */
888 Thread.currentThread().setContextClassLoader(contextClassLoader);
891 /** Write md5-sums for annotated classes to file */
894 FileOutputStream fos = new FileOutputStream(saved);
895 ObjectOutputStream oos = new ObjectOutputStream(fos);
896 oos.writeObject(md5s);
902 getLog().error("Cannot write md5-sums to file: " + e);
907 * Needed, because DriverManager won't pick up drivers, that were not
908 * loaded by the system-classloader!
910 * http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-fromodifiedm-an-arbitrary-location
912 static final class DriverProxy implements Driver
914 private final Driver target;
916 DriverProxy(Driver target)
919 throw new NullPointerException();
920 this.target = target;
923 public java.sql.Driver getTarget()
929 public boolean acceptsURL(String url) throws SQLException
931 return target.acceptsURL(url);
935 public java.sql.Connection connect(
937 java.util.Properties info
942 return target.connect(url, info);
946 public int getMajorVersion()
948 return target.getMajorVersion();
952 public int getMinorVersion()
954 return target.getMinorVersion();
958 public DriverPropertyInfo[] getPropertyInfo(
965 return target.getPropertyInfo(url, info);
969 public boolean jdbcCompliant()
971 return target.jdbcCompliant();
975 * This Method cannot be annotated with @Override, becaus the plugin
976 * will not compile then under Java 1.6!
978 public Logger getParentLogger() throws SQLFeatureNotSupportedException
980 throw new SQLFeatureNotSupportedException("Not supported, for backward-compatibility with Java 1.6");
984 public String toString()
986 return "Proxy: " + target;
990 public int hashCode()
992 return target.hashCode();
996 public boolean equals(Object obj)
998 if (!(obj instanceof DriverProxy))
1000 DriverProxy other = (DriverProxy) obj;
1001 return this.target.equals(other.target);