Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now only public top-level and static inner Adapter classes are allowed.

  • Loading branch information...
commit 71700dc1910843661d4e30b7d45bbf01052842c7 1 parent dfde6a2
@aroemers authored
View
38 src-java/test/adapter/BtoA.java
@@ -4,26 +4,30 @@
import test.modela.A;
import test.modelb.B;
-@Adapter
-public class BtoA implements A {
-
- private B adaptee;
- public BtoA(B adaptee) {
- this.adaptee = adaptee;
- }
+public class BtoA {
- public void superSuperAMethod() {
- System.out.println("{test.adapter.BtoA} How to implement this?");
- }
+ @Adapter
+ public static class BtoA_Inner implements A {
+
+ private B adaptee;
- public void superAMethod() {
- System.out.println("{test.adapter.BtoA} Forwarding call to superBMethod.");
- adaptee.superBMethod();
- }
+ public BtoA_Inner(B adaptee) {
+ this.adaptee = adaptee;
+ }
+
+ public void superSuperAMethod() {
+ System.out.println("{test.adapter.BtoA} How to implement this?");
+ }
+
+ public void superAMethod() {
+ System.out.println("{test.adapter.BtoA} Forwarding call to superBMethod.");
+ adaptee.superBMethod();
+ }
- public void aMethod() {
- System.out.println("{test.adapter.BtoA} Forwarding call to bMethod.");
- adaptee.bMethod();
+ public void aMethod() {
+ System.out.println("{test.adapter.BtoA} Forwarding call to bMethod.");
+ adaptee.bMethod();
+ }
}
}
View
6 src-java/test/bind.gluer
@@ -1,5 +1,5 @@
-associate field test.Main.a with new test.modelb.B
+associate field test.Main.a with new test.modelb.B
-associate field test.Main.superA with call test.modelb.ModelFactory.geta()
+associate field test.Main.superA with call test.modelb.ModelFactory.get()
-associate field test.Main.superSuperA with single test.modelb.SubSubB using test.adapter.BtoA
+associate field test.Main.superSuperA with single test.modelb.SubSubB using test.adapter.BtoA$BtoA_Inner
View
2  src-java/test/modelb/ModelFactory.java
@@ -2,7 +2,7 @@
public abstract class ModelFactory {
- public static SuperB get() {
+ public static B get() {
System.out.println("{test.modelb.ModelFactory} Creating new SubB.");
return new SubB();
}
View
22 src/gluer/core.clj
@@ -20,19 +20,19 @@
The resulting format string currently requires one parameter: the
switches that can be used at the command-line."
(apply str (interpose "\n" (list
- "Welcome to the Gluer checker. This tools checks the specified gluer files"
- "for consistency. Use as follows:"
+ "Welcome to the Gluer checker. This tools checks the specified gluer files for"
+ "consistency. Use as follows:"
""
- " java -cp <class-path> -jar gluer-VERSION-standalone.jar [switches] [gluer-files]"
+ " java -cp <class-path> -jar gluer-VERSION-standalone.jar [switches] <config-file>"
""
- "The <class-path> should at least contain the components you want to glue"
- "and optionally plug-ins. The following switches can be used:"
+ "The <class-path> should at least contain the components you want to glue, the"
+ "Adapter classes and optionally the plug-ins. The following switches can be used:"
"%1$s" ; the command-line switches
- "To use the tool as a framework for your application, start your application"
- "as follows:"
+ "To use the tool as a framework for your application, start your application as"
+ "follows:"
""
- " java -cp <class-path>:"
- " -javaagent:gluer-VERSION-standalone.jar=<gluer-file>[:<other-gluer-files>]"
+ " java -cp <class-path>"
+ " -javaagent:gluer-VERSION-standalone.jar=<config-file>"
" <your.app.Main>"))))
@@ -44,7 +44,7 @@
(def commandline-opts
[["-h" "--help" "Print this help." :flag true]
- ["-v" "--verbose" "Be verbose in output. Overwrites the setting in the configuration file."
+ ["-v" "--verbose" "Verbose output. Overrules configuration file setting."
:flag true :default nil]])
;;; The functions that direct the checking.
@@ -81,7 +81,7 @@
adapter-library (r/build-adapter-library)
_ (log-verbose "Adapter library:" adapter-library)
_ (log-verbose "Checking adapter library data..." adapter-library)
- ;_ (do-check (l/check-adapter-library adapter-library))
+ _ (do-check (l/check-adapter-library adapter-library))
_ (log-verbose "Parsing .gluer files...")
parsed-files (r/parse-gluer-files gluer-file-names)
_ (log-verbose "Parsed .gluer files:" parsed-files)
View
8 src/gluer/logic.clj
@@ -40,7 +40,7 @@
"Adapter %s is not declared public.")
(def adapter-not-statically-accesible
- "Adapter %s is not statically accessible. Make sure it is an outer class, or a static inner class.")
+ "Adapter %s is not statically accessible. Make sure it is a top-level class, or a static inner class.")
(defn format-issue
[message file-name line-nr]
@@ -142,8 +142,8 @@
(when (empty? (:adapts-to data)) (format adapts-to-nothing-error name))
(when (empty? (:adapts-from data)) (format adapts-from-nothing-error name))
(when-not (r/public? ctclass) (format adapter-not-public name))
- (when (and (r/inner? ctclass)) (format adapter-not-statically-accesible name)))))]
- ;--- TODO: public static inner classes should be allowed.
+ (when (and (r/inner? ctclass) (not (r/static? ctclass)))
+ (format adapter-not-statically-accesible name)))))]
(-> (reduce check-adapter {} adapter-library)
(update-in [:errors] #(filter not-nil? %)))))
@@ -210,7 +210,7 @@
(reduce (partial merge-with concat)
(map #(check-association % file-name adapter-library) associations))))
-(defn- check-valid-files ;--- TODO: public static inner classes should be allowed.files
+(defn- check-valid-files
[valid-files adapter-library]
(reduce (partial merge-with concat) (map #(check-valid-file % adapter-library) valid-files)))
View
20 src/gluer/resources.clj
@@ -16,7 +16,7 @@
(:require [gluer.parser :as p])
(:use [clojure.string :only (split)]
[clojure.set :only (difference union)])
- (:import [javassist ClassPool]
+ (:import [javassist ClassPool Modifier]
[java.io File]
[org.scannotation AnnotationDB]))
@@ -50,14 +50,26 @@
(.get (ClassPool/getDefault) class-name)
(catch Exception e nil)))
+(defn- modifiers
+ "Returns the modifiers of the specified class, encoded in an integer."
+ [ctclass]
+ (.getModifiers ctclass))
+
(defn public? ;--- Make a stand-alone Clojure javassist wrapper altogether?
"Returns true if the supplied class is declared public, false otherwise."
- [ctclass])
+ [ctclass]
+ (Modifier/isPublic (modifiers ctclass)))
(defn inner?
"Returns true if the supplied class is declared within another class,
false otherwise."
- [ctclass])
+ [ctclass]
+ (not (nil? (.getDeclaringClass ctclass))))
+
+(defn static?
+ "Returns true if the supplied class is a static inner class, false otherwise."
+ [ctclass]
+ (Modifier/isStatic (modifiers ctclass)))
(def supertypes-of
"A function that returns a set of the names of the direct supertypes
@@ -136,7 +148,7 @@
:where #{ :where-clause-field }
:what #{ :what-clause-new :what-clause-call :what-clause-single}
:using ["using" :class]
- :class #"(\w+\.)*\w+"
+ :class #"((\w+\.)*)((\w|\$)+)"
; Where clauses
:where-clause-field ["field" :field]
Please sign in to comment.
Something went wrong with that request. Please try again.