Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make it easier to create a new RegisteredService implementation #6

Merged
merged 3 commits into from

3 participants

@frett

I need to track a couple additional flags with the RegisteredService object and would like to utilize as much of the existing RegisteredServiceImpl framework as possible.

These commits make it easier to create a new implementation of RegisteredService and utilize several existing objects for management of RegisteredServices.

frett added some commits
@frett frett Make it easier to override clone in subclasses
created the cloned object using the class of the sourced object to allow
classes that extend RegisteredServiceImpl to only need to track their
own attributes in the clone method
df298d8
@frett frett Update the supports method to support any implementation 3e11ee5
@frett frett Utilize the underlying createCommand method
This change will allow the command class to be overridden to support
subclasses of RegisteredServiceImpl
f0c242b
@battags
Owner

Hi,

Can you open a JIRA issue for this?

Thanks!
Scott

@apetro
Owner

These look like fine improvements. I have customized FancyRegisteredServiceImpls in some CAS customizations I did for a client, and while it didn't occur to me to extend RegisteredServiceImpl, if I had tried that I would have benefited from these changes.

@apetro apetro merged commit 494b05e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2011
  1. @frett

    Make it easier to override clone in subclasses

    frett authored
    created the cloned object using the class of the sourced object to allow
    classes that extend RegisteredServiceImpl to only need to track their
    own attributes in the clone method
  2. @frett
  3. @frett

    Utilize the underlying createCommand method

    frett authored
    This change will allow the command class to be overridden to support
    subclasses of RegisteredServiceImpl
This page is out of date. Refresh to see the latest.
View
7 cas-server-core/src/main/java/org/jasig/cas/services/RegisteredServiceImpl.java
@@ -219,7 +219,12 @@ public int getEvaluationOrder() {
}
public Object clone() throws CloneNotSupportedException {
- final RegisteredServiceImpl registeredServiceImpl = new RegisteredServiceImpl();
+ final RegisteredServiceImpl registeredServiceImpl;
+ try {
+ registeredServiceImpl = this.getClass().newInstance();
+ } catch (final Exception e) {
+ throw new CloneNotSupportedException("error creating new object");
+ }
registeredServiceImpl.setAllowedAttributes(this.allowedAttributes);
registeredServiceImpl.setAllowedToProxy(this.allowedToProxy);
View
3  cas-server-core/src/main/java/org/jasig/cas/services/web/RegisteredServiceSimpleFormController.java
@@ -46,6 +46,7 @@ public RegisteredServiceSimpleFormController(
final IPersonAttributeDao attributeRepository) {
this.servicesManager = servicesManager;
this.personAttributeDao = attributeRepository;
+ this.setCommandClass(RegisteredServiceImpl.class);
}
/**
@@ -93,7 +94,7 @@ protected Object formBackingObject(final HttpServletRequest request)
if (!StringUtils.hasText(id)) {
logger.debug("Created new service.");
- return new RegisteredServiceImpl();
+ return this.createCommand();
}
final RegisteredService service = this.servicesManager.findServiceBy(Long.parseLong(id));
View
5 cas-server-core/src/main/java/org/jasig/cas/services/web/support/RegisteredServiceValidator.java
@@ -6,7 +6,6 @@
package org.jasig.cas.services.web.support;
import org.jasig.cas.services.RegisteredService;
-import org.jasig.cas.services.RegisteredServiceImpl;
import org.jasig.cas.services.ServicesManager;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@@ -36,12 +35,12 @@
private int maxDescriptionLength = DEFAULT_MAX_DESCRIPTION_LENGTH;
/**
- * Supports the RegisteredServiceImpl.
+ * Supports RegisteredService objects.
*
* @see org.springframework.validation.Validator#supports(java.lang.Class)
*/
public boolean supports(final Class clazz) {
- return RegisteredServiceImpl.class.equals(clazz);
+ return RegisteredService.class.isAssignableFrom(clazz);
}
public void validate(final Object o, final Errors errors) {
Something went wrong with that request. Please try again.