Search in sources :

Example 6 with IExporter

use of org.jboss.tools.hibernate.runtime.spi.IExporter in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateExporter.

@Test
public void testCreateExporter() {
    Exporter exporter = (Exporter) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Exporter.class }, new TestInvocationHandler());
    IExporter facade = facadeFactory.createExporter(exporter);
    Assert.assertSame(exporter, ((IFacade) facade).getTarget());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IHibernateMappingExporter(org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateMappingExporter(org.hibernate.tool.hbm2x.HibernateMappingExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) Test(org.junit.Test)

Example 7 with IExporter

use of org.jboss.tools.hibernate.runtime.spi.IExporter in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateExporter.

@Test
public void testCreateExporter() {
    Exporter exporter = (Exporter) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Exporter.class }, new TestInvocationHandler());
    IExporter facade = facadeFactory.createExporter(exporter);
    Assert.assertSame(exporter, ((IFacade) facade).getTarget());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IHibernateMappingExporter(org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateMappingExporter(org.hibernate.tool.hbm2x.HibernateMappingExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) Test(org.junit.Test)

Example 8 with IExporter

use of org.jboss.tools.hibernate.runtime.spi.IExporter in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateExporter.

@Test
public void testCreateExporter() {
    Exporter exporter = (Exporter) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Exporter.class }, new TestInvocationHandler());
    IExporter facade = facadeFactory.createExporter(exporter);
    Assert.assertTrue(facade instanceof ExporterFacadeImpl);
    Assert.assertSame(exporter, ((IFacade) facade).getTarget());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateMappingExporter(org.hibernate.tool.hbm2x.HibernateMappingExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) IHibernateMappingExporter(org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) Test(org.junit.Test)

Example 9 with IExporter

use of org.jboss.tools.hibernate.runtime.spi.IExporter in project jbosstools-hibernate by jbosstools.

the class CodeGenerationLaunchDelegate method runExporters.

private IArtifactCollector runExporters(final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor) throws CoreException {
    monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
    if (monitor.isCanceled())
        return null;
    ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
    if (attributes.isReverseEngineer()) {
        monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
    }
    final IConfiguration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
    monitor.worked(1);
    if (monitor.isCanceled())
        return null;
    final IService service = cc.getHibernateExtension().getHibernateService();
    return (IArtifactCollector) cc.execute(new Command() {

        public Object execute() {
            IArtifactCollector artifactCollector = service.newArtifactCollector();
            // Global properties
            Properties props = new Properties();
            // $NON-NLS-1$
            props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled());
            // $NON-NLS-1$
            props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled());
            for (int i = 0; i < exporterFactories.length; i++) {
                monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
                Properties globalProperties = new Properties();
                globalProperties.putAll(props);
                IExporter exporter;
                try {
                    exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector, service);
                } catch (CoreException e) {
                    throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
                }
                try {
                    exporter.start();
                } catch (HibernateException he) {
                    throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
                }
                monitor.worked(1);
            }
            return artifactCollector;
        }
    });
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) CoreException(org.eclipse.core.runtime.CoreException) Command(org.hibernate.console.execution.ExecutionContext.Command) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Properties(java.util.Properties) IService(org.jboss.tools.hibernate.runtime.spi.IService)

Example 10 with IExporter

use of org.jboss.tools.hibernate.runtime.spi.IExporter in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateExporter.

@Test
public void testCreateExporter() {
    Exporter exporter = (Exporter) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { Exporter.class }, new TestInvocationHandler());
    IExporter facade = facadeFactory.createExporter(exporter);
    Assert.assertSame(exporter, ((IFacade) facade).getTarget());
}
Also used : PersistentClass(org.hibernate.mapping.PersistentClass) IPOJOClass(org.jboss.tools.hibernate.runtime.spi.IPOJOClass) RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) POJOClass(org.hibernate.tool.hbm2x.pojo.POJOClass) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateMappingExporter(org.hibernate.tool.hbm2x.HibernateMappingExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) IHibernateMappingExporter(org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) Test(org.junit.Test)

Aggregations

IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)18 Test (org.junit.Test)12 IGenericExporter (org.jboss.tools.hibernate.runtime.spi.IGenericExporter)10 IHbm2DDLExporter (org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter)10 Exporter (org.hibernate.tool.hbm2x.Exporter)9 IHibernateMappingExporter (org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter)9 IQueryExporter (org.jboss.tools.hibernate.runtime.spi.IQueryExporter)9 PersistentClass (org.hibernate.mapping.PersistentClass)8 RootClass (org.hibernate.mapping.RootClass)8 GenericExporter (org.hibernate.tool.hbm2x.GenericExporter)8 Hbm2DDLExporter (org.hibernate.tool.hbm2x.Hbm2DDLExporter)8 HibernateMappingExporter (org.hibernate.tool.hbm2x.HibernateMappingExporter)8 QueryExporter (org.hibernate.tool.hbm2x.QueryExporter)8 POJOClass (org.hibernate.tool.hbm2x.pojo.POJOClass)8 IPOJOClass (org.jboss.tools.hibernate.runtime.spi.IPOJOClass)8 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)8 Properties (java.util.Properties)4 POJOExporter (org.hibernate.tool.hbm2x.POJOExporter)4 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 CoreException (org.eclipse.core.runtime.CoreException)3