org.hibernate.boot.registry.StandardServiceRegistry Java Examples
The following examples show how to use
org.hibernate.boot.registry.StandardServiceRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateSampleApplication.java From java-docs-samples with Apache License 2.0 | 6 votes |
/** * Main method that runs a simple console application that saves a {@link Person} entity and then * retrieves it to print to the console. */ public static void main(String[] args) { // Create Hibernate environment objects. StandardServiceRegistry registry = new StandardServiceRegistryBuilder() .configure() .build(); SessionFactory sessionFactory = new MetadataSources(registry).buildMetadata() .buildSessionFactory(); Session session = sessionFactory.openSession(); // Save an entity into Spanner Table. savePerson(session); session.close(); }
Example #2
Source File: App.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
/** * The main method that does the CRUD operations. */ public static void main(String[] args) { // create a Hibernate sessionFactory and session StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build(); SessionFactory sessionFactory = new MetadataSources(registry).buildMetadata() .buildSessionFactory(); Session session = sessionFactory.openSession(); clearData(session); writeData(session); readData(session); // close Hibernate session and sessionFactory session.close(); sessionFactory.close(); }
Example #3
Source File: TransactionsTest.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void jdbc() { //tag::transactions-api-jdbc-example[] StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() // "jdbc" is the default, but for explicitness .applySetting( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jdbc" ) .build(); Metadata metadata = new MetadataSources( serviceRegistry ) .addAnnotatedClass( Customer.class ) .getMetadataBuilder() .build(); SessionFactory sessionFactory = metadata.getSessionFactoryBuilder() .build(); Session session = sessionFactory.openSession(); try { // calls Connection#setAutoCommit( false ) to // signal start of transaction session.getTransaction().begin(); session.createQuery( "UPDATE customer set NAME = 'Sir. '||NAME" ) .executeUpdate(); // calls Connection#commit(), if an error // happens we attempt a rollback session.getTransaction().commit(); } catch ( Exception e ) { // we may need to rollback depending on // where the exception happened if ( session.getTransaction().getStatus() == TransactionStatus.ACTIVE || session.getTransaction().getStatus() == TransactionStatus.MARKED_ROLLBACK ) { session.getTransaction().rollback(); } // handle the underlying error } finally { session.close(); sessionFactory.close(); } //end::transactions-api-jdbc-example[] }
Example #4
Source File: BaseReactiveTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
private void mysqlConfiguration(StandardServiceRegistry registry) { registry.getService( ConnectionProvider.class ); //force the NoJdbcConnectionProvider to load first registry.getService( SchemaManagementTool.class ) .setCustomDatabaseGenerationTarget( new ReactiveGenerationTarget(registry) { @Override public void prepare() { super.prepare(); if ( dbType() == DBType.MYSQL ) { accept("set foreign_key_checks = 0"); } } @Override public void release() { if ( dbType() == DBType.MYSQL ) { accept("set foreign_key_checks = 1"); } super.release(); } } ); }
Example #5
Source File: NamedParameterUnitTest.java From tutorials with MIT License | 6 votes |
@Before public void setUp() throws Exception { final StandardServiceRegistry registry = new StandardServiceRegistryBuilder() .configure() .build(); try { sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); session.save(new Event("Event 1")); session.save(new Event("Event 2")); session.getTransaction().commit(); session.close(); } catch (Exception e) { fail(e); StandardServiceRegistryBuilder.destroy(registry); } }
Example #6
Source File: FastBootMetadataBuilder.java From quarkus with Apache License 2.0 | 6 votes |
private void registerIdentifierGenerators(StandardServiceRegistry ssr) { final StrategySelector strategySelector = ssr.getService(StrategySelector.class); // apply id generators final Object idGeneratorStrategyProviderSetting = buildTimeSettings .get(AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER); if (idGeneratorStrategyProviderSetting != null) { final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector .resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting); final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr .getService(MutableIdentifierGeneratorFactory.class); if (identifierGeneratorFactory == null) { throw persistenceException("Application requested custom identifier generator strategies, " + "but the MutableIdentifierGeneratorFactory could not be found"); } for (Map.Entry<String, Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) { identifierGeneratorFactory.register(entry.getKey(), entry.getValue()); } } }
Example #7
Source File: FastBootMetadataBuilder.java From quarkus with Apache License 2.0 | 6 votes |
/** * Greatly simplified copy of * org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl#populate(org.hibernate.boot.MetadataBuilder, * org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.MergedSettings, * org.hibernate.boot.registry.StandardServiceRegistry, java.util.List) */ protected void populate(MetadataBuilder metamodelBuilder, List<CacheRegionDefinition> cacheRegionDefinitions, StandardServiceRegistry ssr) { ((MetadataBuilderImplementor) metamodelBuilder).getBootstrapContext().markAsJpaBootstrap(); metamodelBuilder.applyScanEnvironment(new StandardJpaScanEnvironmentImpl(persistenceUnit)); metamodelBuilder.applyScanOptions(new StandardScanOptions( (String) buildTimeSettings.get(org.hibernate.cfg.AvailableSettings.SCANNER_DISCOVERY), persistenceUnit.isExcludeUnlistedClasses())); if (cacheRegionDefinitions != null) { cacheRegionDefinitions.forEach(metamodelBuilder::applyCacheRegionDefinition); } final TypeContributorList typeContributorList = (TypeContributorList) buildTimeSettings .get(EntityManagerFactoryBuilderImpl.TYPE_CONTRIBUTORS); if (typeContributorList != null) { typeContributorList.getTypeContributors().forEach(metamodelBuilder::applyTypes); } }
Example #8
Source File: HibernateLoggingIntegrationTest.java From tutorials with MIT License | 6 votes |
@Before public void setUp() throws IOException { final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure("hibernate-logging.cfg.xml") .build(); try { sessionFactory = new MetadataSources(registry).buildMetadata() .buildSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); session.save(new Employee("John Smith", "001")); session.getTransaction() .commit(); session.close(); } catch (Exception e) { fail(e); StandardServiceRegistryBuilder.destroy(registry); } }
Example #9
Source File: FastBootHibernatePersistenceProvider.java From quarkus with Apache License 2.0 | 6 votes |
private StandardServiceRegistry rewireMetadataAndExtractServiceRegistry(RuntimeSettings runtimeSettings, RecordedState rs) { PreconfiguredServiceRegistryBuilder serviceRegistryBuilder = new PreconfiguredServiceRegistryBuilder(rs); runtimeSettings.getSettings().forEach((key, value) -> { serviceRegistryBuilder.applySetting(key, value); }); for (ProvidedService<?> providedService : rs.getProvidedServices()) { serviceRegistryBuilder.addService(providedService); } // TODO serviceRegistryBuilder.addInitiator( ) StandardServiceRegistryImpl standardServiceRegistry = serviceRegistryBuilder.buildNewServiceRegistry(); return standardServiceRegistry; }
Example #10
Source File: HibernateUtil.java From tutorials with MIT License | 6 votes |
/** * Generates database create commands for the specified entities using Hibernate native API, SchemaExport. * Creation commands are exported into the create.sql file. */ public static void generateSchema() { Map<String, String> settings = new HashMap<>(); settings.put(Environment.URL, "jdbc:h2:mem:schema"); StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(settings).build(); MetadataSources metadataSources = new MetadataSources(serviceRegistry); metadataSources.addAnnotatedClass(Account.class); metadataSources.addAnnotatedClass(AccountSetting.class); Metadata metadata = metadataSources.buildMetadata(); SchemaExport schemaExport = new SchemaExport(); schemaExport.setFormat(true); schemaExport.setOutputFile("create.sql"); schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), metadata); }
Example #11
Source File: SchemaBuilderUtility.java From teiid-spring-boot with Apache License 2.0 | 6 votes |
public static ArtifactCollector generateHibernateModel(MetadataFactory source, StandardServiceRegistry serviceRegistry) { ReverseEngineeringStrategy strategy = new DefaultReverseEngineeringStrategy(); MetadataBuildingOptions options = new MetadataBuildingOptionsImpl(serviceRegistry); BootstrapContext bootstrapContext = new BootstrapContextImpl(serviceRegistry, options); InFlightMetadataCollectorImpl metadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, options); MetadataBuildingContext buildingContext = new MetadataBuildingContextRootImpl(bootstrapContext, options, metadataCollector); TeiidJDBCBinder binder = new TeiidJDBCBinder(serviceRegistry, new Properties(), buildingContext, strategy, false, metadataCollector, source); Metadata metadata = metadataCollector.buildMetadataInstance(buildingContext); binder.readFromDatabase(null, null, buildMapping(metadata)); HibernateMappingExporter exporter = new HibernateMappingExporter() { @Override public Metadata getMetadata() { return metadata; } }; exporter.setOutputDirectory(TMP_DIR); exporter.start(); return exporter.getArtifactCollector(); }
Example #12
Source File: TeiidServer.java From teiid-spring-boot with Apache License 2.0 | 6 votes |
private Metadata getMetadata(Set<BeanDefinition> components, PhysicalNamingStrategy namingStrategy, MetadataFactory mf) { ServiceRegistry registry = metadataSources.getServiceRegistry(); StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder( (BootstrapServiceRegistry) registry).applySetting(AvailableSettings.DIALECT, TeiidDialect.class) .build(); // Generate Hibernate model based on @Entity definitions for (BeanDefinition c : components) { try { Class<?> clazz = Class.forName(c.getBeanClassName()); metadataSources.addAnnotatedClass(clazz); } catch (ClassNotFoundException e) { } } return metadataSources.getMetadataBuilder(serviceRegistry).applyPhysicalNamingStrategy(namingStrategy).build(); }
Example #13
Source File: SchemaExport.java From lams with GNU General Public License v2.0 | 6 votes |
public static void execute(CommandLineArgs commandLineArgs) throws Exception { StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry( commandLineArgs ); try { final MetadataImplementor metadata = buildMetadata( commandLineArgs, serviceRegistry ); new SchemaExport() .setHaltOnError( commandLineArgs.halt ) .setOutputFile( commandLineArgs.outputFile ) .setDelimiter( commandLineArgs.delimiter ) .setFormat( commandLineArgs.format ) .setManageNamespaces( commandLineArgs.manageNamespaces ) .setImportFiles( commandLineArgs.importFile ) .execute( commandLineArgs.targetTypes, commandLineArgs.action, metadata, serviceRegistry ); } finally { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } }
Example #14
Source File: SchemaUpdate.java From lams with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { try { final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs( args ); final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry( parsedArgs ); try { final MetadataImplementor metadata = buildMetadata( parsedArgs, serviceRegistry ); new SchemaUpdate() .setOutputFile( parsedArgs.outputFile ) .setDelimiter( parsedArgs.delimiter ) .execute( parsedArgs.targetTypes, metadata, serviceRegistry ); } finally { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } } catch (Exception e) { LOG.unableToRunSchemaUpdate( e ); } }
Example #15
Source File: ReactiveServiceRegistryBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
/** * Build the StandardServiceRegistry. * * @return The StandardServiceRegistry. */ @SuppressWarnings("unchecked") public StandardServiceRegistry build() { applyServiceContributingIntegrators(); applyServiceContributors(); @SuppressWarnings("rawtypes") final Map settingsCopy = new HashMap( settings ); settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml ); ConfigurationHelper.resolvePlaceHolders( settingsCopy ); return new StandardServiceRegistryImpl( autoCloseRegistry, bootstrapServiceRegistry, initiators, providedServices, settingsCopy ); }
Example #16
Source File: HibernateDatabase.java From livingdoc-confluence with GNU General Public License v3.0 | 6 votes |
public HibernateDatabase(Properties properties) throws HibernateException { StandardServiceRegistry registry = new StandardServiceRegistryBuilder().applySettings(properties).build(); MetadataSources metadataSources = new MetadataSources(registry); metadataSources.addAnnotatedClass(SystemInfo.class) .addAnnotatedClass(Project.class) .addAnnotatedClass(Runner.class) .addAnnotatedClass(Repository.class) .addAnnotatedClass(RepositoryType.class) .addAnnotatedClass(SystemUnderTest.class) .addAnnotatedClass(Requirement.class) .addAnnotatedClass(Specification.class) .addAnnotatedClass(Reference.class) .addAnnotatedClass(Execution.class); this.properties = properties; this.metadata = metadataSources.buildMetadata(); }
Example #17
Source File: ConfigPropertiesTest.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testGridNameOverrideConfigBuilder() { IgniteConfiguration config = createConfig( CUSTOM_GRID_NAME ); try ( Ignite ignite = Ignition.start( config ) ) { StandardServiceRegistry registry = registryBuilder() .applySetting( IgniteProperties.CONFIGURATION_CLASS_NAME, MyTinyGridConfigBuilder.class.getName() ) .applySetting( IgniteProperties.IGNITE_INSTANCE_NAME, CUSTOM_GRID_NAME ) .build(); try ( OgmSessionFactory sessionFactory = createFactory( registry ) ) { assertThat( Ignition.allGrids() ).hasSize( 1 ); assertThat( Ignition.allGrids().get( 0 ).name() ).isEqualTo( CUSTOM_GRID_NAME ); } } }
Example #18
Source File: PersistentTableBulkIdStrategy.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected void initialize(MetadataBuildingOptions buildingOptions, SessionFactoryOptions sessionFactoryOptions) { final StandardServiceRegistry serviceRegistry = buildingOptions.getServiceRegistry(); final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); final String catalogName = configService.getSetting( CATALOG, StandardConverters.STRING, configService.getSetting( AvailableSettings.DEFAULT_CATALOG, StandardConverters.STRING ) ); final String schemaName = configService.getSetting( SCHEMA, StandardConverters.STRING, configService.getSetting( AvailableSettings.DEFAULT_SCHEMA, StandardConverters.STRING ) ); this.catalog = jdbcEnvironment.getIdentifierHelper().toIdentifier( catalogName ); this.schema = jdbcEnvironment.getIdentifierHelper().toIdentifier( schemaName ); this.dropIdTables = configService.getSetting( DROP_ID_TABLES, StandardConverters.BOOLEAN, false ); }
Example #19
Source File: MetadataBuilderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry getStandardServiceRegistry(ServiceRegistry serviceRegistry) { if ( serviceRegistry == null ) { throw new HibernateException( "ServiceRegistry passed to MetadataBuilder cannot be null" ); } if ( StandardServiceRegistry.class.isInstance( serviceRegistry ) ) { return ( StandardServiceRegistry ) serviceRegistry; } else if ( BootstrapServiceRegistry.class.isInstance( serviceRegistry ) ) { log.debugf( "ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; this likely wont end well" + "if attempt is made to build SessionFactory" ); return new StandardServiceRegistryBuilder( (BootstrapServiceRegistry) serviceRegistry ).build(); } else { throw new HibernateException( String.format( "Unexpected type of ServiceRegistry [%s] encountered in attempt to build MetadataBuilder", serviceRegistry.getClass().getName() ) ); } }
Example #20
Source File: App.java From juddi with Apache License 2.0 | 6 votes |
/** * Method that actually creates the file. * * @param dbDialect to use */ private void generate(Dialect dialect) { StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(); ssrb.applySetting("hibernate.dialect", dialect.getDialectClass()); StandardServiceRegistry standardServiceRegistry = ssrb.build(); MetadataSources metadataSources = new MetadataSources(standardServiceRegistry); for (Class clzz : jpaClasses) { metadataSources.addAnnotatedClass(clzz); } Metadata metadata = metadataSources.buildMetadata(); SchemaExport export = new SchemaExport(); export.setDelimiter(";"); export.setOutputFile(dialect.name().toLowerCase() + ".ddl"); //export.execute(true, false, false, true); export.execute(EnumSet.of(TargetType.SCRIPT), Action.BOTH, metadata); }
Example #21
Source File: DbInitializer.java From cosmo with Apache License 2.0 | 6 votes |
/** * Schema validation */ // TODO private void validateSchema() { try { SessionFactory factory = this.localSessionFactory.unwrap(SessionFactory.class); StandardServiceRegistry registry = factory.getSessionFactoryOptions().getServiceRegistry(); MetadataSources sources = new MetadataSources(registry); sources.addPackage("org.unitedinternet.cosmo.model.hibernate"); Metadata metadata = sources.buildMetadata(registry); new SchemaValidator().validate(metadata); LOG.info("Schema validation passed"); } catch (HibernateException e) { LOG.error("error validating schema", e); throw e; } }
Example #22
Source File: SchemaValidator.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( parsedArgs.cfgXmlFile != null ) { ssrBuilder.configure( parsedArgs.cfgXmlFile ); } if ( parsedArgs.propertiesFile != null ) { Properties properties = new Properties(); properties.load( new FileInputStream( parsedArgs.propertiesFile ) ); ssrBuilder.applySettings( properties ); } return ssrBuilder.build(); }
Example #23
Source File: SchemaValidator.java From lams with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { try { final CommandLineArgs parsedArgs = CommandLineArgs.parseCommandLineArgs( args ); final StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry( parsedArgs ); try { final MetadataImplementor metadata = buildMetadata( parsedArgs, serviceRegistry ); new SchemaValidator().validate( metadata, serviceRegistry ); } finally { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } } catch (Exception e) { LOG.unableToRunSchemaUpdate( e ); } }
Example #24
Source File: SchemaUpdate.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs parsedArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( parsedArgs.cfgXmlFile != null ) { ssrBuilder.configure( parsedArgs.cfgXmlFile ); } if ( parsedArgs.propertiesFile != null ) { Properties props = new Properties(); props.load( new FileInputStream( parsedArgs.propertiesFile ) ); ssrBuilder.applySettings( props ); } return ssrBuilder.build(); }
Example #25
Source File: SchemaExport.java From lams with GNU General Public License v2.0 | 6 votes |
private static StandardServiceRegistry buildStandardServiceRegistry(CommandLineArgs commandLineArgs) throws Exception { final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build(); final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder( bsr ); if ( commandLineArgs.cfgXmlFile != null ) { ssrBuilder.configure( commandLineArgs.cfgXmlFile ); } Properties properties = new Properties(); if ( commandLineArgs.propertiesFile != null ) { properties.load( new FileInputStream( commandLineArgs.propertiesFile ) ); } ssrBuilder.applySettings( properties ); return ssrBuilder.build(); }
Example #26
Source File: GlobalTemporaryTableBulkIdStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected void initialize(MetadataBuildingOptions buildingOptions, SessionFactoryOptions sessionFactoryOptions) { final StandardServiceRegistry serviceRegistry = buildingOptions.getServiceRegistry(); final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); this.dropIdTables = configService.getSetting( DROP_ID_TABLES, StandardConverters.BOOLEAN, false ); }
Example #27
Source File: BaseReactiveTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void before() { Configuration configuration = constructConfiguration(); StandardServiceRegistry registry = new ReactiveServiceRegistryBuilder() .applySettings( configuration.getProperties() ) .build(); mysqlConfiguration( registry ); sessionFactory = configuration.buildSessionFactory( registry ); poolProvider = registry.getService( ReactiveConnectionPool.class ); }
Example #28
Source File: BaseMutinyTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void before() { StandardServiceRegistry registry = new ReactiveServiceRegistryBuilder() .applySettings( constructConfiguration().getProperties() ) .build(); sessionFactory = constructConfiguration().buildSessionFactory( registry ); poolProvider = registry.getService( ReactiveConnectionPool.class ); }
Example #29
Source File: SchemaValidatorTask.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") private void configure(MetadataBuilder metadataBuilder, StandardServiceRegistry serviceRegistry) { final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); if ( implicitNamingStrategy != null ) { metadataBuilder.applyImplicitNamingStrategy( strategySelector.resolveStrategy( ImplicitNamingStrategy.class, implicitNamingStrategy ) ); } if ( physicalNamingStrategy != null ) { metadataBuilder.applyPhysicalNamingStrategy( strategySelector.resolveStrategy( PhysicalNamingStrategy.class, physicalNamingStrategy ) ); } }
Example #30
Source File: SchemaValidator.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Intended for test usage only. Builds a Metadata using the same algorithm as * {@link #main} * * @param args The "command line args" * * @return The built Metadata * * @throws Exception Problems building the Metadata */ public static MetadataImplementor buildMetadataFromMainArgs(String[] args) throws Exception { final CommandLineArgs commandLineArgs = CommandLineArgs.parseCommandLineArgs( args ); StandardServiceRegistry serviceRegistry = buildStandardServiceRegistry( commandLineArgs ); try { return buildMetadata( commandLineArgs, serviceRegistry ); } finally { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } }