Skip to content

Commit

Permalink
Move Application* and *FileWriter classes
Browse files Browse the repository at this point in the history
Move `ApplicationHome`, `ApplicationPid` and `ApplicationTemp` to the
`system` package. Since `system` package is now much lower level, the
existing `FileWriter` implementations also needed to move to prevent
package tangles.

Fixes spring-projectsgh-8614
  • Loading branch information
philwebb committed Feb 2, 2018
1 parent 3ff7729 commit c3ec316
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,6 @@
import com.atomikos.icatch.jta.UserTransactionManager;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
Expand All @@ -39,6 +38,7 @@
import org.springframework.boot.jta.atomikos.AtomikosProperties;
import org.springframework.boot.jta.atomikos.AtomikosXAConnectionFactoryWrapper;
import org.springframework.boot.jta.atomikos.AtomikosXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,6 @@
import bitronix.tm.jndi.BitronixContext;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
Expand All @@ -37,6 +36,7 @@
import org.springframework.boot.jta.bitronix.BitronixDependentBeanFactoryPostProcessor;
import org.springframework.boot.jta.bitronix.BitronixXAConnectionFactoryWrapper;
import org.springframework.boot.jta.bitronix.BitronixXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,6 @@
import org.jboss.tm.XAResourceRecoveryRegistry;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
Expand All @@ -41,6 +40,7 @@
import org.springframework.boot.jta.narayana.NarayanaRecoveryManagerBean;
import org.springframework.boot.jta.narayana.NarayanaXAConnectionFactoryWrapper;
import org.springframework.boot.jta.narayana.NarayanaXADataSourceWrapper;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
package org.springframework.boot.cli;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.web.context.WebServerPortFileWriter;
import org.springframework.context.ConfigurableApplicationContext;

/**
Expand All @@ -33,7 +33,7 @@ public CliTesterSpringApplication(Class<?>... sources) {

@Override
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
context.addApplicationListener(new EmbeddedServerPortFileWriter());
context.addApplicationListener(new WebServerPortFileWriter());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,8 @@ useful for process monitoring:

* `ApplicationPidFileWriter` creates a file containing the application PID (by default,
in the application directory with a file name of `application.pid`).
* `EmbeddedServerPortFileWriter` creates a file (or files) containing the ports of the
embedded server (by default, in the application directory with a file name of
* `WebServerPortFileWriter` creates a file (or files) containing the ports of the
running web server (by default, in the application directory with a file name of
`application.port`).

By default, these writers are not activated, but you can enable:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@

import org.apache.commons.logging.Log;

import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot.system;
package org.springframework.boot.context;

import java.io.File;
import java.io.IOException;
Expand All @@ -26,11 +26,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.boot.ApplicationPid;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.boot.system.SystemProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
Expand Down Expand Up @@ -58,7 +58,7 @@
* @author Phillip Webb
* @author Tomasz Przybyla
* @author Madhura Bhave
* @since 1.4.0
* @since 2.0.0
*/
public class ApplicationPidFileWriter
implements ApplicationListener<SpringApplicationEvent>, Ordered {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

package org.springframework.boot.logging;

import org.springframework.boot.ApplicationPid;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot;
package org.springframework.boot.system;

import java.io.File;
import java.io.IOException;
Expand All @@ -37,7 +37,7 @@
*
* @author Phillip Webb
* @author Raja Kolli
* @since 1.2.0
* @since 2.0.0
*/
public class ApplicationHome {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot;
package org.springframework.boot.system;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -32,6 +32,7 @@
* An application process ID.
*
* @author Phillip Webb
* @since 2.0.0
*/
public class ApplicationPid {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot;
package org.springframework.boot.system;

import java.io.File;
import java.security.MessageDigest;
Expand All @@ -28,7 +28,7 @@
* restarting an application will give the same location.
*
* @author Phillip Webb
* @since 1.3.0
* @since 2.0.0
*/
public class ApplicationTemp {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,8 +20,9 @@
* Access to system properties.
*
* @author Phillip Webb
* @since 2.0.0
*/
final class SystemProperties {
public final class SystemProperties {

private SystemProperties() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

package org.springframework.boot.system;
package org.springframework.boot.web.context;

import java.io.File;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.system.SystemProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.util.Assert;
Expand All @@ -38,42 +37,40 @@
* @author David Liu
* @author Phillip Webb
* @author Andy Wilkinson
* @since 1.4.0
* @since 2.0.0
*/
public class EmbeddedServerPortFileWriter
public class WebServerPortFileWriter
implements ApplicationListener<WebServerInitializedEvent> {

private static final String DEFAULT_FILE_NAME = "application.port";

private static final String[] PROPERTY_VARIABLES = { "PORTFILE", "portfile" };

private static final Log logger = LogFactory
.getLog(EmbeddedServerPortFileWriter.class);
private static final Log logger = LogFactory.getLog(WebServerPortFileWriter.class);

private final File file;

/**
* Create a new {@link EmbeddedServerPortFileWriter} instance using the filename
* Create a new {@link WebServerPortFileWriter} instance using the filename
* 'application.port'.
*/
public EmbeddedServerPortFileWriter() {
public WebServerPortFileWriter() {
this(new File(DEFAULT_FILE_NAME));
}

/**
* Create a new {@link EmbeddedServerPortFileWriter} instance with a specified
* filename.
* Create a new {@link WebServerPortFileWriter} instance with a specified filename.
* @param filename the name of file containing port
*/
public EmbeddedServerPortFileWriter(String filename) {
public WebServerPortFileWriter(String filename) {
this(new File(filename));
}

/**
* Create a new {@link EmbeddedServerPortFileWriter} instance with a specified file.
* Create a new {@link WebServerPortFileWriter} instance with a specified file.
* @param file the file containing port
*/
public EmbeddedServerPortFileWriter(File file) {
public WebServerPortFileWriter(File file) {
Assert.notNull(file, "File must not be null");
String override = SystemProperties.get(PROPERTY_VARIABLES);
if (override != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.File;

import org.springframework.boot.ApplicationHome;
import org.springframework.boot.ApplicationTemp;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.system.ApplicationTemp;
import org.springframework.util.Assert;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot.system;
package org.springframework.boot.context;

import java.io.File;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.junit.runner.RunWith;
import org.slf4j.bridge.SLF4JBridgeHandler;

import org.springframework.boot.ApplicationPid;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
Expand All @@ -51,6 +50,7 @@
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.boot.logging.LoggingSystemProperties;
import org.springframework.boot.logging.java.JavaLoggingSystem;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.boot.testsupport.rule.OutputCapture;
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.boot;
package org.springframework.boot.system;

import java.io.File;
import java.io.FileReader;
Expand All @@ -24,7 +24,6 @@
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;

import org.springframework.boot.ApplicationPid;
import org.springframework.util.FileCopyUtils;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Loading

0 comments on commit c3ec316

Please sign in to comment.