Skip to content

Commit 3d62606

Browse files
committed
cleanup
1 parent b381713 commit 3d62606

File tree

86 files changed

+4785
-4778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+4785
-4778
lines changed

src/java/org/codehaus/groovy/grails/commons/AbstractGrailsClass.java

Lines changed: 143 additions & 142 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
/*
22
* Copyright 2004-2005 the original author or authors.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*/
15+
*/
1616
package org.codehaus.groovy.grails.commons;
17+
1718
/**
1819
* Configures Grails classe to be autowirable by name, always.
19-
*
20+
*
2021
* @author Graeme Rocher
2122
* @author Steven Devijver
22-
*
23+
*
2324
* @since 0.1
24-
*
25-
* Created: Jul 2, 2005
2625
*/
27-
public abstract class AbstractInjectableGrailsClass extends AbstractGrailsClass
28-
implements InjectableGrailsClass {
26+
public abstract class AbstractInjectableGrailsClass extends AbstractGrailsClass implements InjectableGrailsClass {
27+
28+
public AbstractInjectableGrailsClass(Class<?> clazz, String trailingName) {
29+
super(clazz, trailingName);
30+
}
2931

30-
public AbstractInjectableGrailsClass(Class clazz, String trailingName) {
31-
super(clazz, trailingName);
32-
}
32+
public boolean byName() {
33+
return true;
34+
}
3335

34-
public boolean byName() {
35-
return true;
36-
}
36+
public boolean byType() {
37+
return false;
38+
}
3739

38-
public boolean byType() {
39-
return false;
40-
}
41-
42-
public boolean getAvailable() {
43-
return true;
44-
}
40+
public boolean getAvailable() {
41+
return true;
42+
}
4543
}

src/java/org/codehaus/groovy/grails/commons/AnnotationDomainClassArtefactHandler.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
*/
1515
package org.codehaus.groovy.grails.commons;
1616

17-
import javax.persistence.Entity;
1817
import java.util.HashSet;
1918
import java.util.Set;
2019

20+
import javax.persistence.Entity;
21+
2122
/**
22-
* Detects annotated domain classes for EJB3 style mappings
23+
* Detects annotated domain classes for EJB3 style mappings.
2324
*
2425
* @author Graeme Rocher
2526
* @since 1.0
26-
* <p/>
27-
* Created: Dec 6, 2007
2827
*/
2928
public class AnnotationDomainClassArtefactHandler extends DomainClassArtefactHandler{
29+
3030
private static final String JPA_MAPPING_STRATEGY = "JPA";
3131

3232
private Set<String> jpaClassNames = new HashSet<String>();
@@ -35,22 +35,25 @@ public Set<String> getJpaClassNames() {
3535
return jpaClassNames;
3636
}
3737

38-
public boolean isArtefactClass(Class clazz) {
38+
@Override
39+
public boolean isArtefactClass(@SuppressWarnings("unchecked") Class clazz) {
3940
final boolean isJpaDomainClass = isJPADomainClass(clazz);
40-
if(isJpaDomainClass) {
41-
jpaClassNames.add(clazz.getName());
41+
if (isJpaDomainClass) {
42+
jpaClassNames.add(clazz.getName());
4243
}
4344
return super.isArtefactClass(clazz) ;
4445
}
4546

46-
public static boolean isJPADomainClass(Class clazz){
47+
public static boolean isJPADomainClass(Class <?>clazz){
4748
return clazz != null && clazz.getAnnotation(Entity.class) != null;
4849
}
4950

50-
public GrailsClass newArtefactClass(Class artefactClass) {
51+
@Override
52+
public GrailsClass newArtefactClass(@SuppressWarnings("unchecked") Class artefactClass) {
5153
GrailsDomainClass grailsClass = (GrailsDomainClass) super.newArtefactClass(artefactClass);
52-
if(isJPADomainClass(artefactClass))
53-
grailsClass.setMappingStrategy(JPA_MAPPING_STRATEGY);
54+
if (isJPADomainClass(artefactClass)) {
55+
grailsClass.setMappingStrategy(JPA_MAPPING_STRATEGY);
56+
}
5457
return grailsClass;
5558
}
5659
}

src/java/org/codehaus/groovy/grails/commons/ApplicationAttributes.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
import org.springframework.context.ApplicationContext;
44

55
/**
6-
* Class description here.
7-
*
86
* @author Graeme Rocher
97
* @since 0.4
10-
* <p/>
11-
* Created: Jan 19, 2007
12-
* Time: 6:03:55 PM
138
*/
149
public interface ApplicationAttributes {
10+
1511
String APPLICATION_CONTEXT = "org.codehaus.groovy.grails.APPLICATION_CONTEXT";
1612
String PARENT_APPLICATION_CONTEXT = "org.codehaus.groovy.grails.PARENT_APPLICATION_CONTEXT";
1713
String REQUEST_SCOPE_ID = "org.codehaus.groovy.grails.GRAILS_APPLICATION_ATTRIBUTES";
@@ -23,7 +19,6 @@ public interface ApplicationAttributes {
2319
ApplicationContext getApplicationContext();
2420

2521
/**
26-
*
2722
* @return Retrieves the grails application instance
2823
*/
2924
GrailsApplication getGrailsApplication();

src/java/org/codehaus/groovy/grails/commons/ApplicationHolder.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
/*
2-
* Copyright 2004-2005 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
2+
* Copyright 2004-2005 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616
package org.codehaus.groovy.grails.commons;
1717

1818
/**
19-
* <p>Static singleton holder for the GrailsApplication instance</p>
19+
* Static singleton holder for the GrailsApplication instance.
20+
*
2021
* @author Marc Palmer ([email protected])
2122
*/
2223
public abstract class ApplicationHolder {
24+
2325
private static GrailsApplication application;
2426

2527
public static GrailsApplication getApplication() {

src/java/org/codehaus/groovy/grails/commons/ArtefactHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* <p>The ArtefactHandler interface's purpose is to allow the analysis of conventions within a Grails application.
2020
* An artefact is represented by the GrailsClass interface and this interface provides methods that allow artefacts to
2121
* be identified, created and initialized.
22-
*
22+
*
2323
* <p>Artefacts need to provide info about themselves, and some callbacks are required
2424
* to verify whether or not a class is that kind of artefact/p>
2525
*
@@ -31,33 +31,33 @@
3131
public interface ArtefactHandler {
3232

3333
/**
34-
* Obtains the plugin name that deals with this artefact
34+
* Obtains the plugin name that deals with this artefact.
3535
* @return The plugin name or null if there isn't one
3636
*/
3737
String getPluginName();
3838

3939
/**
40-
* <p>Implementations must return a name such as "Domain" to indicate the type of artefact they represent</p>
40+
* Implementations must return a name such as "Domain" to indicate the type of artefact they represent.
4141
* @return The aretfact type, as a String
4242
*/
4343
String getType();
4444

4545
/**
46-
* <p>This method will be called by the GrailsApplication whenever it needs to know if a given class
46+
* <p>Called by the GrailsApplication whenever it needs to know if a given class
4747
* is considered to be the kind of artefact represented by this handler.</p>
48-
* <p>Typically you will check the name of the class and some other properties to see if it is of the correct
49-
* artefact type</p>
48+
* <p>Typically you will check the name of the class and some other properties to see
49+
* if it is of the correct artefact type</p>
5050
* @param aClass A class to test
5151
* @return True if the class looks like one of your artefacts
5252
*/
53-
boolean isArtefact(Class aClass);
53+
boolean isArtefact(@SuppressWarnings("unchecked") Class aClass);
5454

5555
/**
5656
* <p>Called by GrailsApplication when a new class is found and a GrailsClass wrapping it is required</p>
5757
* @param artefactClass The new class that has been loaded
5858
* @return A new custom GrailsClass wrapper containing any extra information your artefact type requires
5959
*/
60-
GrailsClass newArtefactClass(Class artefactClass);
60+
GrailsClass newArtefactClass(@SuppressWarnings("unchecked") Class artefactClass);
6161

6262
/**
6363
* <p>Called whenever the list of artefacts has changed or been reloaded.</p>

src/java/org/codehaus/groovy/grails/commons/ArtefactHandlerAdapter.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
/*
2-
* Copyright 2004-2005 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
2+
* Copyright 2004-2005 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616
package org.codehaus.groovy.grails.commons;
1717

18-
import org.apache.commons.logging.Log;
19-
import org.apache.commons.logging.LogFactory;
2018
import groovy.lang.Closure;
2119

2220
import java.lang.reflect.Constructor;
2321
import java.lang.reflect.InvocationTargetException;
2422
import java.lang.reflect.Modifier;
2523

24+
import org.apache.commons.logging.Log;
25+
import org.apache.commons.logging.LogFactory;
26+
2627
/**
2728
* @author Marc Palmer ([email protected])
2829
*/
2930
public class ArtefactHandlerAdapter implements ArtefactHandler {
31+
3032
private String type;
31-
private Class grailsClassType;
32-
private Class grailsClassImpl;
33+
private Class<?> grailsClassType;
34+
private Class<?> grailsClassImpl;
3335
private boolean allowAbstract;
3436

3537
protected Log log = LogFactory.getLog(ArtefactHandlerAdapter.class);
3638
private String artefactSuffix;
3739

38-
39-
public ArtefactHandlerAdapter(String type, Class grailsClassType, Class grailsClassImpl, String artefactSuffix) {
40+
public ArtefactHandlerAdapter(String type, Class<?> grailsClassType, Class<?> grailsClassImpl, String artefactSuffix) {
4041
this.artefactSuffix = artefactSuffix;
4142
this.type = type;
4243
this.grailsClassType = grailsClassType;
4344
this.grailsClassImpl = grailsClassImpl;
4445
}
4546

46-
public ArtefactHandlerAdapter(String type, Class grailsClassType, Class grailsClassImpl, String artefactSuffix,
47-
boolean allowAbstract) {
47+
public ArtefactHandlerAdapter(String type, Class<?> grailsClassType, Class<?> grailsClassImpl,
48+
String artefactSuffix, boolean allowAbstract) {
4849
this.artefactSuffix = artefactSuffix;
4950
this.type = type;
5051
this.grailsClassType = grailsClassType;
@@ -60,29 +61,29 @@ public String getType() {
6061
return type;
6162
}
6263

63-
public final boolean isArtefact(Class aClass) {
64+
public final boolean isArtefact(@SuppressWarnings("unchecked") Class aClass) {
6465
if (isArtefactClass(aClass)) {
6566
if (log.isDebugEnabled()) {
6667
log.debug("[" + aClass.getName() + "] is a " + type + " class.");
6768
}
6869
return true;
6970
}
70-
else {
71-
if (log.isDebugEnabled()) {
72-
log.debug("[" + aClass.getName() + "] is not a " + type + " class.");
73-
}
74-
return false;
71+
72+
if (log.isDebugEnabled()) {
73+
log.debug("[" + aClass.getName() + "] is not a " + type + " class.");
7574
}
75+
return false;
7676
}
7777

7878
/**
7979
* <p>Checks that class's name ends in the suffix specified for this handler.</p>
80-
* <p>Override for more complex criteria</p>
80+
* <p>Override for more complex criteria</p>
8181
* @param clazz The class to check
8282
* @return True if it is an artefact of this type
8383
*/
84-
public boolean isArtefactClass(Class clazz) {
84+
public boolean isArtefactClass(@SuppressWarnings("unchecked") Class clazz) {
8585
if(clazz == null) return false;
86+
8687
boolean ok = clazz.getName().endsWith(artefactSuffix) && !Closure.class.isAssignableFrom(clazz);
8788
if (ok && !allowAbstract) {
8889
ok &= !Modifier.isAbstract(clazz.getModifiers());
@@ -96,10 +97,9 @@ public boolean isArtefactClass(Class clazz) {
9697
* @param artefactClass Creates a new artefact for the given class
9798
* @return An instance of the GrailsClass interface representing the artefact
9899
*/
99-
public GrailsClass newArtefactClass(Class artefactClass) {
100-
100+
public GrailsClass newArtefactClass(@SuppressWarnings("unchecked") Class artefactClass) {
101101
try {
102-
Constructor c = grailsClassImpl.getDeclaredConstructor(new Class[] { Class.class } );
102+
Constructor<?> c = grailsClassImpl.getDeclaredConstructor(new Class[] { Class.class } );
103103
// TODO GRAILS-720 plugin class instance created here first
104104
return (GrailsClass) c.newInstance(new Object[] { artefactClass});
105105
}
@@ -119,9 +119,10 @@ public GrailsClass newArtefactClass(Class artefactClass) {
119119

120120
/**
121121
* Sets up the relationships between the domain classes, this has to be done after
122-
* the intial creation to avoid looping
122+
* the intial creation to avoid looping.
123123
*/
124124
public void initialize(ArtefactInfo artefacts) {
125+
// do nothing
125126
}
126127

127128
public GrailsClass getArtefactForFeature(Object feature) {

0 commit comments

Comments
 (0)