Skip to content

Commit

Permalink
jdbcconfig: Don't use jdbcstore for logging.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsCharlier committed Apr 14, 2017
1 parent dced227 commit f62b0f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.geoserver.ows.util.OwsUtils;
import org.geoserver.ows.util.ClassProperties;
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.resource.ResourceStore;
import org.geotools.util.logging.Logging;
import org.opengis.filter.Filter;
import org.opengis.filter.sort.SortBy;
Expand All @@ -60,11 +61,17 @@ public class JDBCGeoServerFacade implements GeoServerFacade {

private final ConfigDatabase db;

private ResourceStore ddResourceStore;

private GeoServerResourceLoader resourceLoader;

public void setResourceLoader(GeoServerResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}

public void setDdResourceStore(ResourceStore ddResourceStore) {
this.ddResourceStore = ddResourceStore;
}

public JDBCGeoServerFacade(final ConfigDatabase db) {
this.db = db;
Expand All @@ -77,7 +84,8 @@ private void reinitializeLogging() {
if (realLogInfo == null) {
return;
}
LoggingInfo startLogInfo = LoggingStartupContextListener.getLogging(resourceLoader);
LoggingInfo startLogInfo = LoggingStartupContextListener.getLogging(
ddResourceStore == null ? resourceLoader : ddResourceStore);

// Doing this reflectively so that if LoggingInfo gets new properties, this should still
// work. KS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<bean id="JDBCGeoServerFacade" class="org.geoserver.jdbcconfig.config.JDBCGeoServerFacade">
<constructor-arg ref="JDBCConfigDB" />
<property name="resourceLoader" ref="resourceLoader" />
<property name="ddResourceStore" ref="dataDirectoryResourceStore" />
</bean>

<bean id="JDBCGeoServerLoader" class="org.geoserver.jdbcconfig.JDBCGeoServerLoader">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -24,6 +23,7 @@
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.platform.GeoServerResourceLoader;
import org.geoserver.platform.resource.Resource;
import org.geoserver.platform.resource.ResourceStore;
import org.geotools.util.logging.CommonsLoggerFactory;
import org.geotools.util.logging.Log4JLoggerFactory;
import org.geotools.util.logging.Logging;
Expand Down Expand Up @@ -67,7 +67,6 @@ public void contextInitialized(ServletContextEvent event) {
File baseDir = new File(GeoServerResourceLoader.lookupGeoServerDataDirectory(context));
GeoServerResourceLoader loader = new GeoServerResourceLoader(baseDir);

File f= loader.find( "logging.xml" );
LoggingInfo loginfo = getLogging(loader);
if ( loginfo != null ) {
final String location = LoggingUtils.getLogFileLocation(loginfo.getLocation(), event.getServletContext());
Expand All @@ -76,7 +75,7 @@ public void contextInitialized(ServletContextEvent event) {
}
else {
//check for old style data directory
f = loader.find( "services.xml" );
File f = loader.find( "services.xml" );
if ( f != null ) {
LegacyLoggingImporter loggingImporter = new LegacyLoggingImporter();
loggingImporter.imprt(baseDir);
Expand All @@ -102,11 +101,11 @@ public void contextInitialized(ServletContextEvent event) {
* exist
*/
@Deprecated
public static @Nullable LoggingInfo getLogging(GeoServerResourceLoader loader) throws IOException {
public static @Nullable LoggingInfo getLogging(ResourceStore store) throws IOException {
// Exposing this is a hack to provide JDBCConfig with the information it needs to compute
// the "change" between logging.xml and the versions stored in JDBC. KS
// TODO find a better solution than re-initializing on JDBCCOnfig startup.
Resource f= loader.get( "logging.xml" );
Resource f= store.get( "logging.xml" );
if ( f != null ) {
XStreamPersister xp = new XStreamPersisterFactory().createXMLPersister();
try (BufferedInputStream in = new BufferedInputStream(f.in())) {
Expand Down

0 comments on commit f62b0f8

Please sign in to comment.