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

Lps 94399 #72206

Closed
wants to merge 36 commits into from
Closed

Lps 94399 #72206

Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c1e549f
LPS-93659 Rename to what it is.
Preston-Crary Apr 18, 2019
459cf64
LPS-93659 Not thrown.
Preston-Crary Apr 18, 2019
40cfb0a
LPS-93659 At least log it.
Preston-Crary Apr 18, 2019
6155e5d
LPS-93659 Inline method with only one usage.
Preston-Crary Apr 18, 2019
4a31760
LPS-93659 Inline var.
Preston-Crary Apr 18, 2019
52b18ad
LPS-93659 Inline simple method.
Preston-Crary Apr 18, 2019
2b1e053
LPS-93659 As used.
Preston-Crary Apr 18, 2019
bef09af
LPS-93659 Pull up common logic.
Preston-Crary Apr 18, 2019
81feb71
LPS-93659 Pull up the duplicate logic and remove the adaptor to our o…
Preston-Crary Apr 18, 2019
0da3818
LPS-93659 Allow the exception instead of hiding it.
Preston-Crary Apr 18, 2019
7da730c
LPS-93659 Pull up creation logic into factory.
Preston-Crary Apr 18, 2019
7c74640
LPS-93659 This case is impossible.
Preston-Crary Apr 18, 2019
837050d
LPS-94399 Pull up logic. Remove tautology test, after this it was ass…
Preston-Crary Apr 18, 2019
6901022
LPS-94399 Extract method.
Preston-Crary Apr 18, 2019
752c293
LPS-94399 Simplify.
Preston-Crary Apr 18, 2019
f23f318
LPS-94399 Inline method.
Preston-Crary Apr 18, 2019
5446a40
LPS-94399 Remove extra substring() call.
Preston-Crary Apr 18, 2019
ce338bc
LPS-94399 Measure twice, cut once.
Preston-Crary Apr 18, 2019
c4770da
LPS-94399 As used.
Preston-Crary Apr 18, 2019
24df5e9
LPS-94399 It's one-to-one. Remove other tautology tests.
Preston-Crary Apr 18, 2019
b160c36
LPS-94399 Combine calls.
Preston-Crary Apr 19, 2019
5fa4d5c
LPS-94399 No difference between ConfigurationDescriptions but that ge…
Preston-Crary Apr 19, 2019
3044fec
LPS-94399 No need for interface.
Preston-Crary Apr 19, 2019
dcf2f84
LPS-94399 Push down.
Preston-Crary Apr 19, 2019
eea526b
LPS-94399 Pull up getProperties().
Preston-Crary Apr 19, 2019
99e1318
LPS-94399 Reduce duplication with base class.
Preston-Crary Apr 19, 2019
86ef155
LPS-94399 Replace abstract class with concrete class.
Preston-Crary Apr 19, 2019
11c6b63
LPS-94399 One return.
Preston-Crary Apr 19, 2019
a07674e
LPS-94399 Merge ConfigurationDescription with NamedConfigurationContent.
Preston-Crary Apr 19, 2019
4f17be5
LPS-94399 Move the string parsing to a single place.
Preston-Crary Apr 19, 2019
b17b179
LPS-94399 Less substring() calls.
Preston-Crary Apr 19, 2019
c7786e7
LPS-94399 Update test.
Preston-Crary Apr 19, 2019
9b96f80
LPS-94399 Make the inputStreams are closed
shuyangzhou Apr 24, 2019
c729e56
LPS-94399 Be strict, abort Extension creation on any failure.
shuyangzhou Apr 24, 2019
df01d43
LPS-94399 Mute the confusing the System.err print. Change this to log…
shuyangzhou Apr 24, 2019
44f90db
LPS-94399 There is nothing to destroy
shuyangzhou Apr 24, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

LPS-94399 Pull up getProperties().

  • Loading branch information...
Preston-Crary authored and shuyangzhou committed Apr 19, 2019
commit eea526bfb20e782c674721c33c3ab742d5b62177
@@ -16,21 +16,14 @@

import com.liferay.petra.string.StringBundler;

import java.util.Dictionary;
import java.util.function.Supplier;

/**
* @author Carlos Sierra Andrés
*/
public class ConfigurationDescription {

public ConfigurationDescription(
String factoryPid, String pid,
Supplier<Dictionary<String, Object>> propertiesSupplier) {

public ConfigurationDescription(String factoryPid, String pid) {
_factoryPid = factoryPid;
_pid = pid;
_propertiesSupplier = propertiesSupplier;
}

public String getFactoryPid() {
@@ -41,27 +34,20 @@ public String getPid() {
return _pid;
}

public Dictionary<String, Object> getProperties() {
return _propertiesSupplier.get();
}

@Override
public String toString() {
StringBundler sb = new StringBundler(7);
StringBundler sb = new StringBundler(5);

sb.append("{factoryPid=");
sb.append(_factoryPid);
sb.append(", pid=");
sb.append(_pid);
sb.append(", propertiesSupplier=");
sb.append(_propertiesSupplier);
sb.append("}");

return sb.toString();
}

private final String _factoryPid;
private final String _pid;
private final Supplier<Dictionary<String, Object>> _propertiesSupplier;

}
@@ -104,7 +104,7 @@ private void _process(NamedConfigurationContent namedConfigurationContent)
Dictionary<String, Object> properties = null;

try {
properties = configurationDescription.getProperties();
properties = namedConfigurationContent.getProperties();
}
catch (Throwable t) {
_logger.log(
@@ -14,8 +14,11 @@

package com.liferay.portal.configuration.extender.internal;

import java.io.IOException;
import java.io.InputStream;

import java.util.Dictionary;

/**
* @author Carlos Sierra Andrés
*/
@@ -27,4 +30,6 @@

public String getName();

public Dictionary<String, Object> getProperties() throws IOException;

}
@@ -20,7 +20,6 @@
import java.io.InputStream;

import java.util.Dictionary;
import java.util.function.Supplier;

/**
* @author Carlos Sierra Andrés
@@ -47,14 +46,12 @@ public ConfigurationDescription getConfigurationDescription() {
String factoryPid = name.substring(0, index);
pid = name.substring(index + 1);

return new ConfigurationDescription(
factoryPid, pid, new PropertiesSupplier(_inputStream));
return new ConfigurationDescription(factoryPid, pid);
}

pid = name;

return new ConfigurationDescription(
null, pid, new PropertiesSupplier(_inputStream));
return new ConfigurationDescription(null, pid);
}

@Override
@@ -67,37 +64,16 @@ public String getName() {
return _name;
}

private final InputStream _inputStream;
private final String _name;

private class PropertiesSupplier
implements Supplier<Dictionary<String, Object>> {

public PropertiesSupplier(InputStream inputStream) {
_inputStream = inputStream;
}

@Override
public Dictionary<String, Object> get() {
try {
return _loadProperties();
}
catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}

private Dictionary<String, Object> _loadProperties()
throws IOException {

Dictionary<?, ?> properties = PropertiesUtil.load(
_inputStream, "UTF-8");

return (Dictionary<String, Object>)properties;
}

private final InputStream _inputStream;
@Override
@SuppressWarnings("unchecked")
public Dictionary<String, Object> getProperties() throws IOException {
Dictionary<?, ?> properties = PropertiesUtil.load(
_inputStream, "UTF-8");

return (Dictionary<String, Object>)properties;
}

private final InputStream _inputStream;
private final String _name;

}
@@ -21,7 +21,6 @@
import java.io.InputStream;

import java.util.Dictionary;
import java.util.function.Supplier;

import org.apache.felix.cm.file.ConfigurationHandler;

@@ -50,14 +49,12 @@ public ConfigurationDescription getConfigurationDescription() {
String factoryPid = name.substring(0, index);
pid = name.substring(index + 1);

return new ConfigurationDescription(
factoryPid, pid, new PropertiesSupplier(_inputStream));
return new ConfigurationDescription(factoryPid, pid);
}

pid = name;

return new ConfigurationDescription(
null, pid, new PropertiesSupplier(_inputStream));
return new ConfigurationDescription(null, pid);
}

@Override
@@ -70,37 +67,13 @@ public String getName() {
return _name;
}

@Override
@SuppressWarnings("unchecked")
public Dictionary<String, Object> getProperties() throws IOException {
return ConfigurationHandler.read(_inputStream);
}

private final InputStream _inputStream;
private final String _name;

private class PropertiesSupplier
implements Supplier<Dictionary<String, Object>> {

public PropertiesSupplier(InputStream inputStream) {
_inputStream = inputStream;
}

@Override
public Dictionary<String, Object> get() {
try {
return _loadProperties();
}
catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}

private Dictionary<String, Object> _loadProperties()
throws IOException {

Dictionary<?, ?> properties = ConfigurationHandler.read(
_inputStream);

return (Dictionary<String, Object>)properties;
}

private final InputStream _inputStream;

}

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.