@Override public void init( Workspace workspace ) { exceptionSerializers.clear(); Iterator<SerializerProvider> serializers = ServiceLoader.load( SerializerProvider.class, workspace.getModuleClassLoader() ).iterator(); while ( serializers.hasNext() ) { SerializerProvider p = serializers.next(); p.init( workspace ); exceptionSerializers.add( p ); } }
@Override public void serialize( InputStream capabilitiesXmlStream, OutputStream responseStream ) throws IOException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( workspace.getModuleClassLoader() ); try { XsltUtils.transform( capabilitiesXmlStream, this.xslt, responseStream ); } catch ( Exception e ) { LOG.warn( "Unable to transform Capabilities: {}.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } finally { Thread.currentThread().setContextClassLoader( loader ); } }
@SuppressWarnings("unchecked") private CustomParticleConverter<TypedObjectNode> instantiateConverter( CustomConverterJAXB config ) { String className = config.getClazz(); LOG.info( "Instantiating configured custom particle converter (class=" + className + ")" ); try { return (CustomParticleConverter<TypedObjectNode>) workspace.getModuleClassLoader().loadClass( className ).newInstance(); } catch ( Throwable t ) { String msg = "Unable to instantiate custom particle converter (class=" + className + "). " + " Maybe directory 'modules' in your workspace is missing the JAR with the " + " referenced converter class?! " + t.getMessage(); LOG.error( msg, t ); throw new IllegalArgumentException( msg ); } }
private void transform( InputStream stream, HttpResponseBuffer response ) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( workspace.getModuleClassLoader() ); try { OutputStream outputStream = response.getOutputStream(); XsltUtils.transform( stream, this.xsltUrl, outputStream ); } catch ( Exception e ) { LOG.warn( "Unable to transform Capabilities: {}.", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } finally { Thread.currentThread().setContextClassLoader( loader ); } }
@Override public void startup( Workspace workspace ) { this.workspace = workspace; // load providers Iterator<? extends ResourceProvider<T>> iter = ServiceLoader.load( metadata.getProviderClass(), workspace.getModuleClassLoader() ).iterator(); while ( iter.hasNext() ) { ResourceProvider<T> prov = iter.next(); nsToProvider.put( prov.getNamespace(), prov ); } }
@Override public void init( Workspace ws ) { functionLoader = ServiceLoader.load( SQLFunctionProvider.class, ws.getModuleClassLoader() ); for ( SQLFunctionProvider fp : functionLoader ) { try { fp.init( ws ); } catch ( Exception t ) { LOG.error( "Initialization of SQLFunctionProvider " + fp.getName() + " failed: " + t.getMessage() ); } } }
@Override public void startup( Workspace workspace ) { // Check for legacy JDBC drivers and warn if some are found in modules directory ClassLoader moduleClassLoader = workspace.getModuleClassLoader(); for ( Driver d : ServiceLoader.load( Driver.class, moduleClassLoader ) ) { warnIfDriversAreRegisteredInModulesClassLoader( moduleClassLoader, d ); } super.startup( workspace ); }
@Override public void init( Workspace ws ) { LOG.info( "Loading functions..." ); functionLoader = ServiceLoader.load( FunctionProvider.class, ws.getModuleClassLoader() ); for ( FunctionProvider fp : functionLoader ) { try { LOG.debug( "Loading function {}", fp.getName() ); fp.init( ws ); } catch ( Throwable t ) { LOG.error( "Initialization of FunctionProvider " + fp.getName() + " failed: " + t.getMessage() ); } } }
jc = JAXBContext.newInstance( jaxbPackage ); } else { jc = JAXBContext.newInstance( jaxbPackage, workspace.getModuleClassLoader() );
ServiceLoader<CRSStoreProvider> loaded; if ( workspace != null ) { loaded = ServiceLoader.load( CRSStoreProvider.class, workspace.getModuleClassLoader() ); } else { loaded = ServiceLoader.load( CRSStoreProvider.class );
@Override public ResourceBuilder<ApplicationContextHolder> prepare() { BootstrapApplicationContextHolderConfig config; try { config = (BootstrapApplicationContextHolderConfig) JAXBUtils.unmarshall( CONFIG_JAXB_PACKAGE, CONFIG_SCHEMA, location.getAsStream(), workspace ); } catch ( Exception e ) { LOG.trace( "Stack trace:", e ); throw new ResourceInitException( e.getLocalizedMessage(), e ); } return new BootstrapApplicationContextHolderBuilder( workspace.getModuleClassLoader(), this, config ); } }
private DataSource initializeDataSourceInstance() { try { final DataSourceInitializer initializer = new DataSourceInitializer( workspace.getModuleClassLoader() ); return initializer.getConfiguredDataSource( config ); } catch ( Exception e ) { String msg = getMessageOrCauseMessage( e ); LOG.error( msg, e ); throw new ResourceException( msg, e ); } }
FeatureCollection col = params.getFeatureCollection(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( workspace.getModuleClassLoader() ); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {
ImageSerializer imageSerializer; try { Class<?> clazz = workspace.getModuleClassLoader().loadClass( mf.getJavaClass() ); imageSerializer = clazz.asSubclass( ImageSerializer.class ).newInstance(); } catch ( ClassNotFoundException e ) {
try { @SuppressWarnings("unchecked") Class<FeatureInspector> inspectorClass = (Class<FeatureInspector>) workspace.getModuleClassLoader().loadClass( className ); inspectors.add( inspectorClass.newInstance() ); } catch ( Exception e ) {
@Override public void init() { for ( ProcessDefinition processDefinition : processDefs ) { CodeType processId = new CodeType( processDefinition.getIdentifier().getValue(), processDefinition.getIdentifier().getCodeSpace() ); String className = processDefinition.getJavaClass(); try { LOG.info( "Initializing process with id '" + processId + "'" ); LOG.info( "- process class: " + className ); Processlet processlet = (Processlet) Class.forName( className, true, workspace.getModuleClassLoader() ).newInstance(); processlet.init(); ExceptionCustomizer customizer = null; if ( processlet instanceof ExceptionAwareProcesslet ) { customizer = ( (ExceptionAwareProcesslet) processlet ).getExceptionCustomizer(); } WPSProcess process = new GenericWPSProcess( processDefinition, processlet, customizer ); idToProcess.put( processId, process ); } catch ( Exception e ) { String msg = "Could not create process instance. Class name ('" + className + "') was not found on the classpath. " + "Hint: spelling in configuration file might be incorrect."; throw new ResourceInitException( msg, e ); } } }
LOG.debug( "Could not find class from classname '" + resourceClassName + "'. Search in the additional modules in the workspace." ); t = Class.forName( resourceClassName, false, workspace.getModuleClassLoader() );
@Override public ConnectionProvider build() { String url = config.getUrl(); LegacyConnectionProvider cprov; cprov = new LegacyConnectionProvider( url, config.getUser(), config.getPassword(), config.isReadOnly() == null ? false : config.isReadOnly(), metadata ); ServiceLoader<SqlDialectProvider> dialectLoader = ServiceLoader.load( SqlDialectProvider.class, workspace.getModuleClassLoader() ); Iterator<SqlDialectProvider> iter = dialectLoader.iterator(); SQLDialect dialect = null; while ( iter.hasNext() ) { SqlDialectProvider prov = iter.next(); Connection conn = null; try { conn = cprov.getConnection(); if ( prov.supportsConnection( conn ) ) { dialect = prov.createDialect( conn ); break; } } finally { JDBCUtils.close( conn ); } } cprov.setDialect( dialect ); if ( dialect == null ) { LOG.warn( "No SQL dialect for {} found, trying to continue.", url ); } return cprov; }
@Override public ConnectionProvider build() { final DataSource ds = initializeDataSourceInstance(); final Method destroyMethod = getDestroyMethod( ds, config.getDataSource().getDestroyMethod() ); final Connection conn = checkConnectivity( ds ); final SQLDialect dialect = SqlDialects.lookupSqlDialect( conn, workspace.getModuleClassLoader() ); close( conn ); return new DataSourceConnectionProvider( metadata, ds, dialect, destroyMethod ); }
Class<?> clazz = workspace.getModuleClassLoader().loadClass( serializer.getJavaClass() ); featureInfoSerializer = clazz.asSubclass( FeatureInfoSerializer.class ).newInstance(); } catch ( ClassNotFoundException e ) {