Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
23991dd9
Commit
23991dd9
authored
Feb 20, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Participant -> Listener
parent
2aa56231
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
17 deletions
+18
-17
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+11
-11
SpringApplicationRunListener.java
...rg/springframework/boot/SpringApplicationRunListener.java
+3
-2
EventPublishingRunListener.java
...mework/boot/context/event/EventPublishingRunListener.java
+4
-4
No files found.
spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
23991dd9
...
@@ -261,8 +261,8 @@ public class SpringApplication {
...
@@ -261,8 +261,8 @@ public class SpringApplication {
System
.
setProperty
(
"java.awt.headless"
,
Boolean
.
toString
(
this
.
headless
));
System
.
setProperty
(
"java.awt.headless"
,
Boolean
.
toString
(
this
.
headless
));
Collection
<
SpringApplicationRun
Participant
>
participants
=
createRunParticipants
(
args
);
Collection
<
SpringApplicationRun
Listener
>
participants
=
createRunParticipants
(
args
);
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
participant
.
started
();
participant
.
started
();
}
}
...
@@ -271,7 +271,7 @@ public class SpringApplication {
...
@@ -271,7 +271,7 @@ public class SpringApplication {
ConfigurableEnvironment
environment
=
getOrCreateEnvironment
();
ConfigurableEnvironment
environment
=
getOrCreateEnvironment
();
addPropertySources
(
environment
,
args
);
addPropertySources
(
environment
,
args
);
setupProfiles
(
environment
);
setupProfiles
(
environment
);
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
participant
.
environmentPrepared
(
environment
);
participant
.
environmentPrepared
(
environment
);
}
}
...
@@ -287,7 +287,7 @@ public class SpringApplication {
...
@@ -287,7 +287,7 @@ public class SpringApplication {
context
.
setEnvironment
(
environment
);
context
.
setEnvironment
(
environment
);
postProcessApplicationContext
(
context
);
postProcessApplicationContext
(
context
);
applyInitializers
(
context
);
applyInitializers
(
context
);
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
participant
.
contextPrepared
(
context
);
participant
.
contextPrepared
(
context
);
}
}
if
(
this
.
logStartupInfo
)
{
if
(
this
.
logStartupInfo
)
{
...
@@ -298,14 +298,14 @@ public class SpringApplication {
...
@@ -298,14 +298,14 @@ public class SpringApplication {
Set
<
Object
>
sources
=
getSources
();
Set
<
Object
>
sources
=
getSources
();
Assert
.
notEmpty
(
sources
,
"Sources must not be empty"
);
Assert
.
notEmpty
(
sources
,
"Sources must not be empty"
);
load
(
context
,
sources
.
toArray
(
new
Object
[
sources
.
size
()]));
load
(
context
,
sources
.
toArray
(
new
Object
[
sources
.
size
()]));
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
participant
.
contextLoaded
(
context
);
participant
.
contextLoaded
(
context
);
}
}
// Refresh the context
// Refresh the context
refresh
(
context
);
refresh
(
context
);
afterRefresh
(
context
,
args
);
afterRefresh
(
context
,
args
);
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
participant
.
finished
(
context
,
null
);
participant
.
finished
(
context
,
null
);
}
}
...
@@ -317,7 +317,7 @@ public class SpringApplication {
...
@@ -317,7 +317,7 @@ public class SpringApplication {
return
context
;
return
context
;
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
for
(
SpringApplicationRun
Participant
participant
:
participants
)
{
for
(
SpringApplicationRun
Listener
participant
:
participants
)
{
finishWithException
(
participant
,
context
,
ex
);
finishWithException
(
participant
,
context
,
ex
);
}
}
if
(
context
!=
null
)
{
if
(
context
!=
null
)
{
...
@@ -330,11 +330,11 @@ public class SpringApplication {
...
@@ -330,11 +330,11 @@ public class SpringApplication {
}
}
}
}
private
Collection
<
SpringApplicationRun
Participant
>
createRunParticipants
(
private
Collection
<
SpringApplicationRun
Listener
>
createRunParticipants
(
String
[]
args
)
{
String
[]
args
)
{
List
<
SpringApplicationRun
Participant
>
participants
=
new
ArrayList
<
SpringApplicationRunParticipant
>();
List
<
SpringApplicationRun
Listener
>
participants
=
new
ArrayList
<
SpringApplicationRunListener
>();
participants
.
addAll
(
getSpringFactoriesInstances
(
participants
.
addAll
(
getSpringFactoriesInstances
(
SpringApplicationRun
Participant
.
class
,
new
Class
<?>[]
{
SpringApplicationRun
Listener
.
class
,
new
Class
<?>[]
{
SpringApplication
.
class
,
String
[].
class
},
this
,
args
));
SpringApplication
.
class
,
String
[].
class
},
this
,
args
));
return
participants
;
return
participants
;
}
}
...
@@ -625,7 +625,7 @@ public class SpringApplication {
...
@@ -625,7 +625,7 @@ public class SpringApplication {
runCommandLineRunners
(
context
,
args
);
runCommandLineRunners
(
context
,
args
);
}
}
private
void
finishWithException
(
SpringApplicationRun
Participant
participant
,
private
void
finishWithException
(
SpringApplicationRun
Listener
participant
,
ConfigurableApplicationContext
context
,
Exception
exception
)
{
ConfigurableApplicationContext
context
,
Exception
exception
)
{
try
{
try
{
participant
.
finished
(
context
,
exception
);
participant
.
finished
(
context
,
exception
);
...
...
spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java
View file @
23991dd9
...
@@ -26,11 +26,12 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
...
@@ -26,11 +26,12 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
* {@code run} method is called. Participants are loaded via the
* {@code run} method is called. Participants are loaded via the
* {@link SpringFactoriesLoader} and should declare a public constructor that accepts a
* {@link SpringFactoriesLoader} and should declare a public constructor that accepts a
* {@link SpringApplication} instance and a {@code String[]} of arguments. A new
* {@link SpringApplication} instance and a {@code String[]} of arguments. A new
* {@link SpringApplicationRun
Participant
} instance will be created for each run.
* {@link SpringApplicationRun
Listener
} instance will be created for each run.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
*/
*/
public
interface
SpringApplicationRun
Participant
{
public
interface
SpringApplicationRun
Listener
{
/**
/**
* Called immediately when the run method has first started. Can be used for very
* Called immediately when the run method has first started. Can be used for very
...
...
spring-boot/src/main/java/org/springframework/boot/context/event/EventPublishingRunListener.java
View file @
23991dd9
...
@@ -18,7 +18,7 @@ package org.springframework.boot.context.event;
...
@@ -18,7 +18,7 @@ package org.springframework.boot.context.event;
import
org.springframework.beans.factory.BeanFactoryAware
;
import
org.springframework.beans.factory.BeanFactoryAware
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationRun
Participant
;
import
org.springframework.boot.SpringApplicationRun
Listener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.event.ApplicationEventMulticaster
;
import
org.springframework.context.event.ApplicationEventMulticaster
;
...
@@ -27,11 +27,11 @@ import org.springframework.context.support.AbstractApplicationContext;
...
@@ -27,11 +27,11 @@ import org.springframework.context.support.AbstractApplicationContext;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
/**
/**
* {@link SpringApplicationRun
Participant
} to publish {@link SpringApplicationEvent}s.
* {@link SpringApplicationRun
Listener
} to publish {@link SpringApplicationEvent}s.
*
*
* @author Phillip Webb
* @author Phillip Webb
*/
*/
public
class
EventPublishingRun
Participant
implements
SpringApplicationRunParticipant
{
public
class
EventPublishingRun
Listener
implements
SpringApplicationRunListener
{
private
final
ApplicationEventMulticaster
multicaster
;
private
final
ApplicationEventMulticaster
multicaster
;
...
@@ -39,7 +39,7 @@ public class EventPublishingRunParticipant implements SpringApplicationRunPartic
...
@@ -39,7 +39,7 @@ public class EventPublishingRunParticipant implements SpringApplicationRunPartic
private
String
[]
args
;
private
String
[]
args
;
public
EventPublishingRun
Participant
(
SpringApplication
application
,
String
[]
args
)
{
public
EventPublishingRun
Listener
(
SpringApplication
application
,
String
[]
args
)
{
this
.
application
=
application
;
this
.
application
=
application
;
this
.
args
=
args
;
this
.
args
=
args
;
this
.
multicaster
=
new
SimpleApplicationEventMulticaster
();
this
.
multicaster
=
new
SimpleApplicationEventMulticaster
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment