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

avoid useless allocations in the Values class #121

Merged
Merged
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
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Creaper uses Maven for build. Some build dependencies are only present in
the JBoss.org Maven repository, so it's recommended to
[configure Maven to use the JBoss Repository](https://developer.jboss.org/wiki/MavenGettingStarted-Developers).

For testing, the Surefire plugin is used and the tests that need a running
application server use Arquillian. This means that it's enough to run
For testing, the Surefire Maven plugin is used and the tests that need
a running application server use Arquillian. This means that it's enough to run
`mvn test` to execute all the tests. There are some tests that take a long
time to execute, so these are not executed by default. To execute them,
activate the `slow-tests` profile by running `mvn test -Pslow-tests`.
Expand All @@ -52,8 +52,8 @@ using a system property `maven.jboss.ga.repository.url` (again see `pom.xml`):
mvn clean test -Pas7 -Dmaven.jboss.ga.repository.url=...

To run a single test from the test suite, the following Maven invocation works:
`mvn clean test -DfailIfNoTests=false -pl testsuite/standalone/ -Dtest=...`
(possibly with a profile activation `-Pwildfly8`). See
`mvn clean test -pl testsuite/standalone/ -Dtest=...` (possibly with a profile
activation `-Pwildfly8`). See
[Surefire documentation](http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html)
for more details about `-Dtest`.

Expand Down Expand Up @@ -107,7 +107,7 @@ command is suitable for inclusion, refer to the following guidelines:
seldom used functionality. However, the ability to do corner cases
shouldn't obscure the ability to do common cases. As an example, see
the commands for datasources.
4. _Providing both online and offline implementation is highly desirable,
4. _Providing both online and offline implementation is desirable,
but not strictly mandatory._ Sometimes, either online or offline
implementation doesn't even make sense.
5. _Commands shouldn't perform server reload/restart themselves, unless
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Copyright 2014-2015 Creaper Authors (see the AUTHORS file).
Copyright 2014-2016 Creaper Authors (see the AUTHORS file).
License: Apache License 2.0 (see the LICENSE file
or http://www.apache.org/licenses/LICENSE-2.0).
2 changes: 1 addition & 1 deletion GOVERNANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ will then publish the roadmap in GitHub Issues.

The best way for you to suggest requirements for a future release is to enter
a feature request in GitHub Issues. Lobbying for features using the `+1`
comments in GitHub Issues is a great way to express interest as well.
(:+1:) markers in GitHub Issues is a great way to express interest as well.
Although, contributing is the single most expedient way to get a capability
into a particular release.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public ModelNode readChildrenNames(Address address, String childType) {

@Override
public ModelNode add(Address address) {
return add(address, Values.NONE);
return add(address, Values.empty());
}

@Override
Expand All @@ -191,7 +191,7 @@ public ModelNode remove(Address address) {

@Override
public ModelNode invoke(String operationName, Address address) {
return invoke(operationName, address, Values.NONE);
return invoke(operationName, address, Values.empty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* Values.of("foo", "bar").and("baz", "quux")
* </pre>
*
* <p>And creating a named value list of {@code foo=[bar, baz, quux], answer=42, a=&#123;b=>c, d=>e&#125;}
* <p>And creating a named value list of {@code foo=[bar, baz, quux], answer=42, a={b=>c, d=>e}}
* looks like this:</p>
*
* <pre>
Expand All @@ -60,56 +60,56 @@
* </pre>
*/
public final class Values {
static final Values NONE = new Values();
private static final Values EMPTY = new Values();

private final List<Property> namedValues;

public static Values empty() {
return new Values();
return EMPTY;
}

public static Values of(String name, boolean value) {
return new Values().and(name, value);
return EMPTY.and(name, value);
}

public static Values of(String name, int value) {
return new Values().and(name, value);
return EMPTY.and(name, value);
}

public static Values of(String name, long value) {
return new Values().and(name, value);
return EMPTY.and(name, value);
}

public static Values of(String name, String value) {
return new Values().and(name, value);
return EMPTY.and(name, value);
}

public static Values of(String name, ModelNode value) {
return new Values().and(name, value);
return EMPTY.and(name, value);
}

public static Values ofList(String name, boolean... value) {
return new Values().andList(name, value);
return EMPTY.andList(name, value);
}

public static Values ofList(String name, int... value) {
return new Values().andList(name, value);
return EMPTY.andList(name, value);
}

public static Values ofList(String name, long... value) {
return new Values().andList(name, value);
return EMPTY.andList(name, value);
}

public static Values ofList(String name, String... value) {
return new Values().andList(name, value);
return EMPTY.andList(name, value);
}

public static Values ofList(String name, ModelNode... value) {
return new Values().andList(name, value);
return EMPTY.andList(name, value);
}

public static Values ofObject(String name, Values object) {
return new Values().andObject(name, object);
return EMPTY.andObject(name, object);
}

/** @return {@code null} if {@code map} is {@code null} or empty; a filled {@code Values} object otherwise */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public final boolean isReloadRequired() {
}
}

/** Reloads the server. In domain, reloads the entire host. */
/** Reloads the server. In domain, reloads the entire host, which includes restarting all its servers. */
public final void reload() throws IOException, InterruptedException, TimeoutException {
ops.reload();
}

/**
* Reloads the server if required. In domain, reloads the entire host if at least one server requires reload.
* Reloading the host includes restarting all its servers.
* @return if the server was in fact reloaded; in domain, if the host was reloaded
*/
public final boolean reloadIfRequired() throws IOException, InterruptedException, TimeoutException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ public boolean isReloadRequired(String host) throws IOException {
return domainOps.isRestartOperationRequired(host, RestartOperation.RELOAD);
}

/** Reloads given {@code host}. This is a variant of {@link Administration#reload()}. */
/**
* Reloads given {@code host}, which includes restarting all its servers.
* This is a variant of {@link Administration#reload()}.
*/
public void reload(String host) throws IOException, InterruptedException, TimeoutException {
domainOps.performRestartOperation(host, RestartOperation.RELOAD);
}

/** Reloads given {@code host} if required. This is a variant of {@link Administration#reloadIfRequired()}. */
/**
* Reloads given {@code host} if required. Reloading the host includes restarting all its servers.
* This is a variant of {@link Administration#reloadIfRequired()}.
*/
public boolean reloadIfRequired(String host) throws IOException, InterruptedException, TimeoutException {
if (domainOps.isRestartOperationRequired(host, RestartOperation.RELOAD)) {
reload(host);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<maven.jboss.ga.repository.url>http://maven.repository.redhat.com/techpreview/all</maven.jboss.ga.repository.url>
<maven.jboss.ga.repository.url>https://maven.repository.redhat.com/ga/</maven.jboss.ga.repository.url>

<version.java>1.6</version.java>

Expand Down