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

FACES-2796 Provide information about statefulness, thread-safety, etc. of objects returned by factories (also made other JavaDoc consistent with Factories) #46

Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

FACES-2796 Provide information about statefulness, thread-safety, etc…

…. of objects returned by factories (also made other JavaDoc

consistent with Factories)
  • Loading branch information...
stiemannkj1 committed Jul 7, 2016
commit 08ac6dee50927052e76eefef94da7506c1d94fe8
@@ -28,7 +28,7 @@ private ApplicationUtil() {
}

/**
* @return true if the JSF application is starting up or shutting down.
* Returns true if the JSF application is starting up or shutting down.
*/
public static boolean isStartupOrShutdown(FacesContext facesContext) {

@@ -142,17 +142,17 @@ public String toString() {
protected abstract String filter(String resourceText);

/**
* @return the character buffer size used to convert the wrapped resource's {@link InputStream} to a string.
* Override this method to provide a different buffer size than the default (1024).
* Returns the character buffer size used to convert the wrapped resource's {@link InputStream} to a string.
* Override this method to provide a different buffer size than the default (1024).
*/
protected int getBufferSize() {
return 1024;
}

/**
* @return the encoding of the wrapped resource's {@link InputStream}. If the Content-Encoding request header is
* not specified, the encoding returned from this method is used to read the InputStream. Override this
* method to provide a different encoding than the default ("UTF-8").
* Returns the encoding of the wrapped resource's {@link InputStream}. If the Content-Encoding request header is not
* specified, the encoding returned from this method is used to read the InputStream. Override this method to
* provide a different encoding than the default ("UTF-8").
*/
protected String getEncoding() {
return "UTF-8";
@@ -26,8 +26,12 @@
public abstract class ResourceValidatorFactory implements FacesWrapper<ResourceValidatorFactory> {

/**
* @return an instance of {@link ResourceValidator} from the {@link ResourceValidatorFactory} found by the {@link
* FactoryExtensionFinder}.
* Returns a stateless, thread-safe, singleton instance of {@link ResourceValidator} from the {@link
* ResourceValidatorFactory} found by the {@link FactoryExtensionFinder}. ResourceValidator is stateless,
* thread-safe, singleton because it is designed to be used by a {@link javax.faces.application.ResourceHandler},
* which is a <a
* href="https://javaserverfaces.java.net/nonav/docs/2.2/javadocs/javax/faces/application/Application.html#getResourceHandler()">
* stateless, thread-safe singleton</a>.
*/
public static ResourceValidator getResourceValidatorInstance() {

@@ -37,5 +41,18 @@ public static ResourceValidator getResourceValidatorInstance() {
return resourceValidatorFactory.getResourceValidator();
}

/**
* Returns a stateless, thread-safe, singleton instance of {@link ResourceValidator}. ResourceValidator is
* stateless, thread-safe, singleton because it is designed to be used by a {@link
* javax.faces.application.ResourceHandler}, which is a <a
* href="https://javaserverfaces.java.net/nonav/docs/2.2/javadocs/javax/faces/application/Application.html#getResourceHandler()">
* stateless, thread-safe singleton</a>.
*/
public abstract ResourceValidator getResourceValidator();

/**
* Returns the wrapped factory instance if this factory has been decorated. Otherwise, this method returns null.
*/
@Override
public abstract ResourceValidatorFactory getWrapped();
}
@@ -31,8 +31,10 @@
public abstract class ResourceVerifierFactory implements FacesWrapper<ResourceVerifierFactory> {

/**
* @return an instance of {@link ResourceVerifier} from the {@link ResourceVerifierFactory} found by the {@link
* FactoryExtensionFinder}.
* Returns a stateless, thread-safe, singleton instance of {@link ResourceVerifier} from the {@link
* ResourceVerifierFactory} found by the {@link FactoryExtensionFinder}. ResourceVerifier is stateless, thread-safe
* , singleton because it is designed to be used by a {@link javax.faces.render.Renderer}, which is stateless and
* thread-safe, singleton.
*/
public static ResourceVerifier getResourceVerifierInstance() {

@@ -43,12 +45,15 @@ public static ResourceVerifier getResourceVerifierInstance() {
}

/**
* Gets an instance of {@link ResourceVerifier} which is the first member of the delegation chain.
* Returns a stateless, thread-safe, singleton instance of {@link ResourceVerifier}. The returned ResourceVerifier
* is the first member of a delegation chain. ResourceVerifier is stateless, thread-safe (and potentially singleton)
* because it is designed to be used by a {@link javax.faces.render.Renderer}, which is stateless and thread-safe,
* singleton.
*/
public abstract ResourceVerifier getResourceVerifier();

/**
* If this factory has been decorated then this method provides access to the wrapped factory instance.
* Returns the wrapped factory instance if this factory has been decorated. Otherwise, this method returns null.
*/
@Override
public abstract ResourceVerifierFactory getWrapped();
@@ -15,8 +15,8 @@
*/
package com.liferay.faces.util.application.internal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import javax.faces.application.ResourceHandler;
@@ -32,14 +32,16 @@
/**
* @author Neil Griffin
*/
public class ResourceValidatorFactoryImpl extends ResourceValidatorFactory {
public class ResourceValidatorFactoryImpl extends ResourceValidatorFactory implements Serializable {

// serialVersionUID
private static final long serialVersionUID = 1540511281114845438L;

// Logger
private static final Logger logger = LoggerFactory.getLogger(ResourceValidatorFactoryImpl.class);

// Private Data Members
private List<Pattern> excludeResourcePatterns;
private List<Pattern> excludeLibraryPatterns;
private ResourceValidator resourceValidator;

public ResourceValidatorFactoryImpl() {

@@ -57,11 +59,15 @@ public ResourceValidatorFactoryImpl() {
}
}

// The list of patterns are declared as ArrayList to ensure that they are Serializable.
ArrayList<Pattern> excludeResourcePatterns = null;
ArrayList<Pattern> excludeLibraryPatterns = null;

if (excludeResourceExtensions != null) {

String[] extensions = excludeResourceExtensions.split(" ");

this.excludeResourcePatterns = new ArrayList<Pattern>(extensions.length + 1);
excludeResourcePatterns = new ArrayList<Pattern>(extensions.length + 1);

for (String extension : extensions) {
Pattern pattern = Pattern.compile(".*\\" + extension + ".*");
@@ -71,17 +77,19 @@ public ResourceValidatorFactoryImpl() {

// Prevent for a leading dot character for resource names and library names
Pattern pattern = Pattern.compile("^\\..*");
this.excludeResourcePatterns.add(pattern);
excludeResourcePatterns.add(pattern);
logger.debug("Excluding resource pattern=[{0}]", pattern);
this.excludeLibraryPatterns = new ArrayList<Pattern>(1);
this.excludeLibraryPatterns.add(pattern);
excludeLibraryPatterns = new ArrayList<Pattern>(1);
excludeLibraryPatterns.add(pattern);
logger.debug("Excluding library pattern=[{0}]", pattern);
}

resourceValidator = new ResourceValidatorImpl(excludeResourcePatterns, excludeLibraryPatterns);
}

@Override
public ResourceValidator getResourceValidator() {
return new ResourceValidatorImpl(excludeResourcePatterns, excludeLibraryPatterns);
return resourceValidator;
}

@Override
@@ -15,6 +15,7 @@
*/
package com.liferay.faces.util.application.internal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -36,7 +37,10 @@
/**
* @author Neil Griffin
*/
public class ResourceValidatorImpl implements ResourceValidator {
public class ResourceValidatorImpl implements ResourceValidator, Serializable {

// serialVersionUID
private static final long serialVersionUID = 1439627171348715228L;

// Logger
private static final Logger logger = LoggerFactory.getLogger(ResourceValidatorImpl.class);
@@ -53,13 +57,30 @@
ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME, "facelets.VIEW_MAPPINGS"
};

// Private Data Members
private List<Pattern> excludeResourcePatterns;
private List<Pattern> excludeLibraryPatterns;
// Private Constants
private final List<Pattern> EXCLUDE_RESOURCE_PATTERNS;
private final List<Pattern> EXCLUDE_LIBRARY_PATTERNS;

/**
* @param excludeResourcePatterns a {@link java.io.Serializable} {@link ArrayList} of excluded resource patterns.
* @param excludeLibraryPatterns a {@link java.io.Serializable} {@link ArrayList} of excluded library patterns.
*/
public ResourceValidatorImpl(ArrayList<Pattern> excludeResourcePatterns,
ArrayList<Pattern> excludeLibraryPatterns) {

if (excludeResourcePatterns != null) {
this.EXCLUDE_RESOURCE_PATTERNS = Collections.unmodifiableList(excludeResourcePatterns);
}
else {
this.EXCLUDE_RESOURCE_PATTERNS = null;
}

public ResourceValidatorImpl(List<Pattern> excludeResourcePatterns, List<Pattern> excludeLibraryPatterns) {
this.excludeResourcePatterns = excludeResourcePatterns;
this.excludeLibraryPatterns = excludeLibraryPatterns;
if (excludeLibraryPatterns != null) {
this.EXCLUDE_LIBRARY_PATTERNS = Collections.unmodifiableList(excludeLibraryPatterns);
}
else {
this.EXCLUDE_LIBRARY_PATTERNS = null;
}
}

@Override
@@ -188,9 +209,9 @@ public boolean isValidLibraryName(String libraryName) {

boolean validLibraryName = true;

if (excludeLibraryPatterns != null) {
if (EXCLUDE_LIBRARY_PATTERNS != null) {

for (Pattern excludeLibraryPattern : excludeLibraryPatterns) {
for (Pattern excludeLibraryPattern : EXCLUDE_LIBRARY_PATTERNS) {

Matcher matcher = excludeLibraryPattern.matcher(libraryName);

@@ -212,9 +233,9 @@ public boolean isValidResourceName(String resourceName) {

boolean validResourceName = true;

if (excludeResourcePatterns != null) {
if (EXCLUDE_RESOURCE_PATTERNS != null) {

for (Pattern excludeResourcePattern : excludeResourcePatterns) {
for (Pattern excludeResourcePattern : EXCLUDE_RESOURCE_PATTERNS) {

Matcher matcher = excludeResourcePattern.matcher(resourceName);

@@ -15,14 +15,19 @@
*/
package com.liferay.faces.util.application.internal;

import java.io.Serializable;

import com.liferay.faces.util.application.ResourceVerifier;
import com.liferay.faces.util.application.ResourceVerifierFactory;


/**
* @author Kyle Stiemann
*/
public class ResourceVerifierFactoryImpl extends ResourceVerifierFactory {
public class ResourceVerifierFactoryImpl extends ResourceVerifierFactory implements Serializable {

// serialVersionUID
private static final long serialVersionUID = 1703402757138333720L;

// Private Data Members
private ResourceVerifier resourceVerifier = new ResourceVerifierImpl();
@@ -15,6 +15,8 @@
*/
package com.liferay.faces.util.application.internal;

import java.io.Serializable;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

@@ -24,7 +26,10 @@
/**
* @author Kyle Stiemann
*/
public class ResourceVerifierImpl implements ResourceVerifier {
public class ResourceVerifierImpl implements ResourceVerifier, Serializable {

// serialVersionUID
private static final long serialVersionUID = 4133463355765570238L;

@Override
public boolean isDependencySatisfied(FacesContext facestContext, UIComponent componentResource) {
@@ -27,8 +27,8 @@
public abstract class BrowserSnifferFactory implements FacesWrapper<BrowserSnifferFactory> {

/**
* @return an instance of {@link BrowserSniffer} from the {@link BrowserSnifferFactory} found by the {@link
* FactoryExtensionFinder}.
* Returns a new instance of {@link BrowserSniffer} from the {@link BrowserSnifferFactory} found by the {@link
* FactoryExtensionFinder}. The returned instance is designed to be used during execution of a request thread.
*/
public static BrowserSniffer getBrowserSnifferInstance(ExternalContext externalContext) {

@@ -38,5 +38,15 @@ public static BrowserSniffer getBrowserSnifferInstance(ExternalContext externalC
return browserSnifferFactory.getBrowserSniffer(externalContext);
}

/**
* Returns a new instance of {@link BrowserSniffer}. The returned instance is designed to be used during execution
* of a request thread.
*/
public abstract BrowserSniffer getBrowserSniffer(ExternalContext externalContext);

/**
* Returns the wrapped factory instance if this factory has been decorated. Otherwise, this method returns null.
*/
@Override
public abstract BrowserSnifferFactory getWrapped();
}
@@ -33,18 +33,18 @@
}

/**
* @return An array of modules which the Script depends on. Returns null if the Script does not depend on any
* modules.
* Returns An array of modules which the Script depends on. Returns null if the Script does not depend on any
* modules.
*/
public String[] getModules();

/**
* @return The {@link Script.ModulesType} of the Script.
* Returns The {@link Script.ModulesType} of the Script.
*/
public ModulesType getModulesType();

/**
* @return The Script's text.
* Returns The Script's text.
*/
public String getSourceCode();
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.