Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BS-157] Add support for MultipartConfig #2

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
381 changes: 196 additions & 185 deletions pom.xml

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions spring-bootstrap-actuator/docs/Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ the `*Properties` types in the Actuator jar.
Spring Profiles are a way to segregate parts of the application
configuration and make it only available in certain environments. Any
`@Component` that is marked with `@Profile` will only be loaded in the
profile specified by the latter annotation.
profile specified by the latter annotation.

Spring Bootstrap takes it a stage further. If you include in your
`application.properties` a value for a property named
`spring.active.profiles` then those profiles will be active by
default. E.g.

spring.active.profiles: dev,hsqldb

## Profile-dependent configuration

Spring Bootstrap loads additional properties files if there are active
Expand All @@ -90,7 +90,7 @@ and declare one either explicitly (with `@Bean`) or implicitly by
adding

@EnableConfigurationProperties(MyProperties.class)

to one of your `@Configuration` (or `@Component`) classes. Then you can

@Autowired
Expand Down Expand Up @@ -214,7 +214,7 @@ generic `ServerProperties`, you can also bind `server.tomcat.*`
properties in the application properties (see
`ServerProperties.Tomcat`).

* To enable the Tomcat access log valve (very common in production environments)
* To enable the Tomcat access log valve (very common in production environments)

More fine-grained control of the Tomcat container is available if you
need it. Instead of letting Spring Bootstrap create the container for
Expand Down Expand Up @@ -247,16 +247,11 @@ can be used to specify
on an internal or ops-facing network, for instance, or to only
listen for connections from localhost (by specifying "127.0.0.1")

* The context root of the management endpoints (TODO: does this work?)

The `EndpointsProperties` are also bound, and you can use those to
change the paths of the management endpoints, e.g.

endpoints.error.path: /errors/generic
* The context root of the management endpoints

## Error Handling

The Actuator provides an `/error` endpoint by default that handles all
The Actuator provides an `/error` mapping by default that handles all
errors in a sensible way. If you want more specific error pages for
some conditions, the embedded servlet containers support a uniform
Java DSL for customizing the error handling. To do this you have to
Expand Down Expand Up @@ -345,7 +340,7 @@ properties via placeholders, e.g.
info.build.name: ${project.name}
info.build.description: ${project.description}
info.build.version: ${project.version}

(notice that in the example we used `project.*` to set some values to
be used as fallbacks if the Maven resource filtering has for some
reason not been switched on).
Expand Down Expand Up @@ -381,7 +376,7 @@ entries to `application.properties`, e.g.

server.tomcat.remote_ip_header: x-forwarded-for
server.tomcat.protocol_header: x-forwarded-proto

(The presence of either of those properties will switch on the
valve. Or you can add the `RemoteIpValve` yourself by adding a
`TomcatEmbeddedServletContainerFactory` bean.)
Expand Down
5 changes: 5 additions & 0 deletions spring-bootstrap-actuator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@
<artifactId>tomcat-embed-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,118 @@

package org.springframework.bootstrap.actuate.audit;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.security.authentication.AuthenticationEventPublisher;
import org.springframework.util.Assert;

/**
* A value object representing an audit event: at a particular time, a particular user or
* agent carried out an action of a particular type. This object records the details of
* such an event.
*
* <p>
* Users can inject a {@link AuditEventRepository} to publish their own events or
* alternatively use Springs {@link AuthenticationEventPublisher} (usually obtained by
* implementing {@link ApplicationEventPublisherAware}).
*
* @author Dave Syer
* @see AuditEventRepository
*/
public class AuditEvent {
public class AuditEvent implements Serializable {

private final Date timestamp;

private final String principal;

final private Date timestamp;
final private String principal;
final private String type;
final private Map<String, Object> data;
private final String type;

private final Map<String, Object> data;

/**
* Create a new audit event for the current time from data provided as name-value
* pairs
* Create a new audit event for the current time.
* @param principal The user principal responsible
* @param type the event type
* @param data The event data
*/
public AuditEvent(String principal, String type, String... data) {
this(new Date(), principal, type, convert(data));
public AuditEvent(String principal, String type, Map<String, Object> data) {
this(new Date(), principal, type, data);
}

/**
* Create a new audit event for the current time
* Create a new audit event for the current time from data provided as name-value
* pairs
* @param principal The user principal responsible
* @param type the event type
* @param data The event data in the form 'key=value' or simply 'key'
*/
public AuditEvent(String principal, String type, Map<String, Object> data) {
this(new Date(), principal, type, data);
public AuditEvent(String principal, String type, String... data) {
this(new Date(), principal, type, convert(data));
}

/**
* Create a new audit event.
* @param timestamp The date/time of the event
* @param principal The user principal responsible
* @param type the event type
* @param data The event data
*/
public AuditEvent(Date timestamp, String principal, String type,
Map<String, Object> data) {
Assert.notNull(timestamp, "Timestamp must not be null");
Assert.notNull(type, "Type must not be null");
this.timestamp = timestamp;
this.principal = principal;
this.type = type;
this.data = Collections.unmodifiableMap(data);
}

private static Map<String, Object> convert(String[] data) {
Map<String, Object> result = new HashMap<String, Object>();
for (String entry : data) {
if (entry.contains("=")) {
int index = entry.indexOf("=");
result.put(entry.substring(0, index), entry.substring(index + 1));
} else {
result.put(entry, null);
}
}
return result;
}

/**
* Returns the date/time that the even was logged.
*/
public Date getTimestamp() {
return this.timestamp;
}

/**
* Returns the user principal responsible for the event or {@code null}.
*/
public String getPrincipal() {
return this.principal;
}

/**
* Returns the type of event.
*/
public String getType() {
return this.type;
}

/**
* Returns the event data.
*/
public Map<String, Object> getData() {
return this.data;
}

private static Map<String, Object> convert(String[] data) {
Map<String, Object> result = new HashMap<String, Object>();
for (String entry : data) {
if (entry.contains("=")) {
int index = entry.indexOf("=");
result.put(entry.substring(0, index), entry.substring(index + 1));
} else {
result.put(entry, null);
}
}
return result;
}

@Override
public String toString() {
return "AuditEvent [timestamp=" + this.timestamp + ", principal="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.bootstrap.actuate.audit;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@

package org.springframework.bootstrap.actuate.audit.listener;

import java.util.Date;
import java.util.Map;

import org.springframework.bootstrap.actuate.audit.AuditEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.util.Assert;

/**
* {@link ApplicationEvent} to encapsulate {@link AuditEvent}s.
* Spring {@link ApplicationEvent} to encapsulate {@link AuditEvent}s.
*
* @author Dave Syer
*/
Expand All @@ -29,10 +33,41 @@ public class AuditApplicationEvent extends ApplicationEvent {
private AuditEvent auditEvent;

/**
* Create a new {@link AuditApplicationEvent} that wraps a newly created
* {@link AuditEvent}.
* @see AuditEvent#AuditEvent(String, String, Map)
*/
public AuditApplicationEvent(String principal, String type, Map<String, Object> data) {
this(new AuditEvent(principal, type, data));
}

/**
* Create a new {@link AuditApplicationEvent} that wraps a newly created
* {@link AuditEvent}.
* @see AuditEvent#AuditEvent(String, String, String...)
*/
public AuditApplicationEvent(String principal, String type, String... data) {
this(new AuditEvent(principal, type, data));
}

/**
* Create a new {@link AuditApplicationEvent} that wraps a newly created
* {@link AuditEvent}.
* @see AuditEvent#AuditEvent(Date, String, String, Map)
*/
public AuditApplicationEvent(Date timestamp, String principal, String type,
Map<String, Object> data) {
this(new AuditEvent(timestamp, principal, type, data));
}

/**
* Create a new {@link AuditApplicationEvent} that wraps the specified
* {@link AuditEvent}.
* @param auditEvent the source of this event
*/
public AuditApplicationEvent(AuditEvent auditEvent) {
super(auditEvent);
Assert.notNull(auditEvent, "AuditEvent must not be null");
this.auditEvent = auditEvent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.springframework.context.ApplicationListener;

/**
* {@link ApplicationListener} for {@link AuditEvent}s.
* {@link ApplicationListener} that listens for {@link AuditEvent}s and stores them in a
* {@link AuditEventRepository}.
*
* @author Dave Syer
*/
Expand Down

This file was deleted.

Loading