incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1358111 [7/13] - in /incubator/isis/trunk/framework/core/commons: ./ src/main/java/org/apache/isis/core/commons/authentication/ src/main/java/org/apache/isis/core/commons/components/ src/main/java/org/apache/isis/core/commons/config/ src/m...
Date Fri, 06 Jul 2012 10:51:21 GMT
Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/HexUtils.java Fri Jul  6 10:51:16 2012
@@ -1,63 +1,63 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.encoding;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public final class HexUtils {
-    
-    private HexUtils() {
-    }
-
-    public static String encoded(final Object object) {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        final DataOutputStreamExtended outputImpl = new DataOutputStreamExtended(baos);
-        try {
-            outputImpl.writeEncodable(object);
-            final byte[] byteArray = baos.toByteArray();
-            return new String(Hex.encodeHex(byteArray));
-        } catch (final IOException e) {
-            throw new IsisException("Failed to write object", e);
-        }
-    }
-
-    public static <T> T decoded(final String hexEncoded, Class<T> cls) {
-        final char[] chars = hexEncoded.toCharArray();
-        byte[] bytes;
-        try {
-            bytes = Hex.decodeHex(chars);
-            final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-            final DataInputStreamExtended inputImpl = new DataInputStreamExtended(bais);
-            return inputImpl.readEncodable(cls);
-        } catch (final IOException ex) {
-            throw new IsisException("Failed to read object", ex);
-        } catch (final DecoderException ex) {
-            throw new IsisException("Failed to hex decode object", ex);
-        }
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.encoding;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public final class HexUtils {
+    
+    private HexUtils() {
+    }
+
+    public static String encoded(final Object object) {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final DataOutputStreamExtended outputImpl = new DataOutputStreamExtended(baos);
+        try {
+            outputImpl.writeEncodable(object);
+            final byte[] byteArray = baos.toByteArray();
+            return new String(Hex.encodeHex(byteArray));
+        } catch (final IOException e) {
+            throw new IsisException("Failed to write object", e);
+        }
+    }
+
+    public static <T> T decoded(final String hexEncoded, Class<T> cls) {
+        final char[] chars = hexEncoded.toCharArray();
+        byte[] bytes;
+        try {
+            bytes = Hex.decodeHex(chars);
+            final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+            final DataInputStreamExtended inputImpl = new DataInputStreamExtended(bais);
+            return inputImpl.readEncodable(cls);
+        } catch (final IOException ex) {
+            throw new IsisException("Failed to read object", ex);
+        } catch (final DecoderException ex) {
+            throw new IsisException("Failed to hex decode object", ex);
+        }
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/encoding/package-info.java Fri Jul  6 10:51:16 2012
@@ -1,30 +1,30 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * The {@link org.apache.isis.core.commons.ensure.Ensure} and {@link org.junit.Assert}
- * classes provide the ability to specify assertions about state,
- * throwing an exception ("fail early") if the assertion fails.
- * 
- * <p>
- * The {@link org.apache.isis.core.commons.ensure.Ensure} class
- * uses {@link org.hamcrest.Matcher Hamcrest matcher}s and is
- * more powerful so generally to be preferred.
- */
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * The {@link org.apache.isis.core.commons.ensure.Ensure} and {@link org.junit.Assert}
+ * classes provide the ability to specify assertions about state,
+ * throwing an exception ("fail early") if the assertion fails.
+ * 
+ * <p>
+ * The {@link org.apache.isis.core.commons.ensure.Ensure} class
+ * uses {@link org.hamcrest.Matcher Hamcrest matcher}s and is
+ * more powerful so generally to be preferred.
+ */
 package org.apache.isis.core.commons.encoding;
\ No newline at end of file

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Assert.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Assert.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Assert.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Assert.java Fri Jul  6 10:51:16 2012
@@ -1,92 +1,92 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.ensure;
-
-public final class Assert {
-
-    public static void assertEquals(final Object expected, final Object actual) {
-        assertEquals("", expected, actual);
-    }
-
-    public static void assertEquals(final String message, final int expected, final int value) {
-        if (expected != value) {
-            throw new IsisAssertException(message + " expected " + expected + "; but was " + value);
-        }
-    }
-
-    public static void assertEquals(final String message, final Object expected, final Object actual) {
-        assertTrue(message + ": expected " + expected + " but was " + actual, (expected == null && actual == null) || (expected != null && expected.equals(actual)));
-    }
-
-    public static void assertFalse(final boolean flag) {
-        assertFalse("expected false", flag);
-    }
-
-    public static void assertFalse(final String message, final boolean flag) {
-        assertTrue(message, !flag);
-    }
-
-    public static void assertFalse(final String message, final Object target, final boolean flag) {
-        assertTrue(message, target, !flag);
-    }
-
-    public static void assertNotNull(final Object object) {
-        assertNotNull("", object);
-    }
-
-    public static void assertNotNull(final String message, final Object object) {
-        assertTrue("unexpected null: " + message, object != null);
-    }
-
-    public static void assertNotNull(final String message, final Object target, final Object object) {
-        assertTrue(message, target, object != null);
-    }
-
-    public static void assertNull(final Object object) {
-        assertTrue("unexpected reference; should be null", object == null);
-    }
-
-    public static void assertNull(final String message, final Object object) {
-        assertTrue(message, object == null);
-    }
-
-    public static void assertSame(final Object expected, final Object actual) {
-        assertSame("", expected, actual);
-    }
-
-    public static void assertSame(final String message, final Object expected, final Object actual) {
-        assertTrue(message + ": expected " + expected + " but was " + actual, expected == actual);
-    }
-
-    public static void assertTrue(final boolean flag) {
-        assertTrue("expected true", flag);
-    }
-
-    public static void assertTrue(final String message, final boolean flag) {
-        assertTrue(message, null, flag);
-    }
-
-    public static void assertTrue(final String message, final Object target, final boolean flag) {
-        if (!flag) {
-            throw new IsisAssertException(message + (target == null ? "" : (": " + target)));
-        }
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.ensure;
+
+public final class Assert {
+
+    public static void assertEquals(final Object expected, final Object actual) {
+        assertEquals("", expected, actual);
+    }
+
+    public static void assertEquals(final String message, final int expected, final int value) {
+        if (expected != value) {
+            throw new IsisAssertException(message + " expected " + expected + "; but was " + value);
+        }
+    }
+
+    public static void assertEquals(final String message, final Object expected, final Object actual) {
+        assertTrue(message + ": expected " + expected + " but was " + actual, (expected == null && actual == null) || (expected != null && expected.equals(actual)));
+    }
+
+    public static void assertFalse(final boolean flag) {
+        assertFalse("expected false", flag);
+    }
+
+    public static void assertFalse(final String message, final boolean flag) {
+        assertTrue(message, !flag);
+    }
+
+    public static void assertFalse(final String message, final Object target, final boolean flag) {
+        assertTrue(message, target, !flag);
+    }
+
+    public static void assertNotNull(final Object object) {
+        assertNotNull("", object);
+    }
+
+    public static void assertNotNull(final String message, final Object object) {
+        assertTrue("unexpected null: " + message, object != null);
+    }
+
+    public static void assertNotNull(final String message, final Object target, final Object object) {
+        assertTrue(message, target, object != null);
+    }
+
+    public static void assertNull(final Object object) {
+        assertTrue("unexpected reference; should be null", object == null);
+    }
+
+    public static void assertNull(final String message, final Object object) {
+        assertTrue(message, object == null);
+    }
+
+    public static void assertSame(final Object expected, final Object actual) {
+        assertSame("", expected, actual);
+    }
+
+    public static void assertSame(final String message, final Object expected, final Object actual) {
+        assertTrue(message + ": expected " + expected + " but was " + actual, expected == actual);
+    }
+
+    public static void assertTrue(final boolean flag) {
+        assertTrue("expected true", flag);
+    }
+
+    public static void assertTrue(final String message, final boolean flag) {
+        assertTrue(message, null, flag);
+    }
+
+    public static void assertTrue(final String message, final Object target, final boolean flag) {
+        if (!flag) {
+            throw new IsisAssertException(message + (target == null ? "" : (": " + target)));
+        }
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/Ensure.java Fri Jul  6 10:51:16 2012
@@ -1,157 +1,157 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.ensure;
-
-import org.hamcrest.Matcher;
-import org.hamcrest.StringDescription;
-
-/**
- * Uses the {@link Matcher Hamcrest API} as a means of verifying arguments and
- * so on.
- */
-public final class Ensure {
-
-    private Ensure() {
-    }
-
-    /**
-     * To ensure that the provided assertion is true
-     * 
-     * @throws IllegalArgumentException
-     */
-    public static void ensure(final String expectation, final boolean expression) {
-        if (!expression) {
-            throw new IllegalArgumentException("illegal argument, expected: " + expectation);
-        }
-    }
-
-    /**
-     * To ensure that the provided argument is correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher,State)
-     * @see #ensureThatState(Object, Matcher, String)
-     * @see #ensureThatContext(Object, Matcher)
-     * 
-     * @throws IllegalArgumentException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatArg(final T object, final Matcher<T> matcher) {
-        if (!matcher.matches(object)) {
-            throw new IllegalArgumentException("illegal argument, expected: " + descriptionOf(matcher));
-        }
-        return object;
-    }
-
-
-    /**
-     * To ensure that the provided argument is correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher)
-     * @see #ensureThatState(Object, Matcher, String)
-     * @see #ensureThatContext(Object, Matcher)
-     * 
-     * @throws IllegalArgumentException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatArg(final T arg, final Matcher<T> matcher, final String message) {
-        if (!matcher.matches(arg)) {
-            throw new IllegalArgumentException(message);
-        }
-        return arg;
-    }
-
-    /**
-     * To ensure that the current state of this object (instance fields) is
-     * correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher)
-     * @see #ensureThatContext(Object, Matcher)
-     * @see #ensureThatState(Object, Matcher, String)
-     * 
-     * @throws IllegalStateException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatState(final T field, final Matcher<T> matcher) {
-        if (!matcher.matches(field)) {
-            throw new IllegalStateException("illegal argument, expected: " + descriptionOf(matcher));
-        }
-        return field;
-    }
-
-    /**
-     * To ensure that the current state of this object (instance fields) is
-     * correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher)
-     * @see #ensureThatContext(Object, Matcher)
-     * @see #ensureThatState(Object, Matcher)
-     * 
-     * @throws IllegalStateException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatState(final T field, final Matcher<T> matcher, final String message) {
-        if (!matcher.matches(field)) {
-            throw new IllegalStateException(message);
-        }
-        return field;
-    }
-
-    /**
-     * To ensure that the current context (<tt>IsisContext</tt>) is correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher)
-     * @see #ensureThatState(Object, Matcher)
-     * @see #ensureThatContext(Object, Matcher, String)
-     * 
-     * @throws IllegalThreadStateException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher) {
-        if (!matcher.matches(contextProperty)) {
-            throw new IllegalThreadStateException("illegal argument, expected: " + descriptionOf(matcher));
-        }
-        return contextProperty;
-    }
-
-    /**
-     * To ensure that the current context (<tt>IsisContext</tt>) is correct.
-     * 
-     * @see #ensureThatArg(Object, Matcher)
-     * @see #ensureThatState(Object, Matcher)
-     * @see #ensureThatContext(Object, Matcher, String)
-     * 
-     * @throws IllegalThreadStateException
-     *             if matcher does not {@link Matcher#matches(Object) match}.
-     */
-    public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher, final String message) {
-        if (!matcher.matches(contextProperty)) {
-            throw new IllegalThreadStateException(message);
-        }
-        return contextProperty;
-    }
-
-    private static <T> String descriptionOf(final Matcher<T> matcher) {
-        final StringDescription stringDescription = new StringDescription();
-        matcher.describeTo(stringDescription);
-        final String description = stringDescription.toString();
-        return description;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.ensure;
+
+import org.hamcrest.Matcher;
+import org.hamcrest.StringDescription;
+
+/**
+ * Uses the {@link Matcher Hamcrest API} as a means of verifying arguments and
+ * so on.
+ */
+public final class Ensure {
+
+    private Ensure() {
+    }
+
+    /**
+     * To ensure that the provided assertion is true
+     * 
+     * @throws IllegalArgumentException
+     */
+    public static void ensure(final String expectation, final boolean expression) {
+        if (!expression) {
+            throw new IllegalArgumentException("illegal argument, expected: " + expectation);
+        }
+    }
+
+    /**
+     * To ensure that the provided argument is correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher,State)
+     * @see #ensureThatState(Object, Matcher, String)
+     * @see #ensureThatContext(Object, Matcher)
+     * 
+     * @throws IllegalArgumentException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatArg(final T object, final Matcher<T> matcher) {
+        if (!matcher.matches(object)) {
+            throw new IllegalArgumentException("illegal argument, expected: " + descriptionOf(matcher));
+        }
+        return object;
+    }
+
+
+    /**
+     * To ensure that the provided argument is correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher)
+     * @see #ensureThatState(Object, Matcher, String)
+     * @see #ensureThatContext(Object, Matcher)
+     * 
+     * @throws IllegalArgumentException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatArg(final T arg, final Matcher<T> matcher, final String message) {
+        if (!matcher.matches(arg)) {
+            throw new IllegalArgumentException(message);
+        }
+        return arg;
+    }
+
+    /**
+     * To ensure that the current state of this object (instance fields) is
+     * correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher)
+     * @see #ensureThatContext(Object, Matcher)
+     * @see #ensureThatState(Object, Matcher, String)
+     * 
+     * @throws IllegalStateException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatState(final T field, final Matcher<T> matcher) {
+        if (!matcher.matches(field)) {
+            throw new IllegalStateException("illegal argument, expected: " + descriptionOf(matcher));
+        }
+        return field;
+    }
+
+    /**
+     * To ensure that the current state of this object (instance fields) is
+     * correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher)
+     * @see #ensureThatContext(Object, Matcher)
+     * @see #ensureThatState(Object, Matcher)
+     * 
+     * @throws IllegalStateException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatState(final T field, final Matcher<T> matcher, final String message) {
+        if (!matcher.matches(field)) {
+            throw new IllegalStateException(message);
+        }
+        return field;
+    }
+
+    /**
+     * To ensure that the current context (<tt>IsisContext</tt>) is correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher)
+     * @see #ensureThatState(Object, Matcher)
+     * @see #ensureThatContext(Object, Matcher, String)
+     * 
+     * @throws IllegalThreadStateException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher) {
+        if (!matcher.matches(contextProperty)) {
+            throw new IllegalThreadStateException("illegal argument, expected: " + descriptionOf(matcher));
+        }
+        return contextProperty;
+    }
+
+    /**
+     * To ensure that the current context (<tt>IsisContext</tt>) is correct.
+     * 
+     * @see #ensureThatArg(Object, Matcher)
+     * @see #ensureThatState(Object, Matcher)
+     * @see #ensureThatContext(Object, Matcher, String)
+     * 
+     * @throws IllegalThreadStateException
+     *             if matcher does not {@link Matcher#matches(Object) match}.
+     */
+    public static <T> T ensureThatContext(final T contextProperty, final Matcher<T> matcher, final String message) {
+        if (!matcher.matches(contextProperty)) {
+            throw new IllegalThreadStateException(message);
+        }
+        return contextProperty;
+    }
+
+    private static <T> String descriptionOf(final Matcher<T> matcher) {
+        final StringDescription stringDescription = new StringDescription();
+        matcher.describeTo(stringDescription);
+        final String description = stringDescription.toString();
+        return description;
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/IsisAssertException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/IsisAssertException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/IsisAssertException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/IsisAssertException.java Fri Jul  6 10:51:16 2012
@@ -1,35 +1,35 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.ensure;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class IsisAssertException extends IsisException {
-
-    private static final long serialVersionUID = 1L;
-
-    public IsisAssertException() {
-        super();
-    }
-
-    public IsisAssertException(final String s) {
-        super(s);
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.ensure;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class IsisAssertException extends IsisException {
+
+    private static final long serialVersionUID = 1L;
+
+    public IsisAssertException() {
+        super();
+    }
+
+    public IsisAssertException(final String s) {
+        super(s);
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/ensure/package-info.java Fri Jul  6 10:51:16 2012
@@ -1,30 +1,30 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * Provides an infrastructure for encoding {@link org.apache.isis.core.commons.encoding.Encodable}
- * into an {@link org.apache.isis.core.commons.encoding.DataOutputExtended output stream}
- * or from an {@link org.apache.isis.core.commons.encoding.DataInputExtended input stream}.
- * 
- * <p>
- * This is primarily for remoting (marshalling objects across the wire) but
- * is also used in various other places, including the creation of
- * mementos (to capture state at a point in time). 
- */
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * Provides an infrastructure for encoding {@link org.apache.isis.core.commons.encoding.Encodable}
+ * into an {@link org.apache.isis.core.commons.encoding.DataOutputExtended output stream}
+ * or from an {@link org.apache.isis.core.commons.encoding.DataInputExtended input stream}.
+ * 
+ * <p>
+ * This is primarily for remoting (marshalling objects across the wire) but
+ * is also used in various other places, including the creation of
+ * mementos (to capture state at a point in time). 
+ */
 package org.apache.isis.core.commons.ensure;
\ No newline at end of file

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisApplicationException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisApplicationException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisApplicationException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisApplicationException.java Fri Jul  6 10:51:16 2012
@@ -1,49 +1,49 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.exceptions;
-
-/**
- * Indicates an error raised by the application code.
- * 
- * <p>
- * The viewer is expected to render the message within the application in a
- * user-friendly fashion.
- */
-public class IsisApplicationException extends IsisException {
-
-    private static final long serialVersionUID = 1L;
-
-    public IsisApplicationException() {
-        super();
-    }
-
-    public IsisApplicationException(final String msg) {
-        super(msg);
-    }
-
-    public IsisApplicationException(final Throwable cause) {
-        super(cause);
-    }
-
-    public IsisApplicationException(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.exceptions;
+
+/**
+ * Indicates an error raised by the application code.
+ * 
+ * <p>
+ * The viewer is expected to render the message within the application in a
+ * user-friendly fashion.
+ */
+public class IsisApplicationException extends IsisException {
+
+    private static final long serialVersionUID = 1L;
+
+    public IsisApplicationException() {
+        super();
+    }
+
+    public IsisApplicationException(final String msg) {
+        super(msg);
+    }
+
+    public IsisApplicationException(final Throwable cause) {
+        super(cause);
+    }
+
+    public IsisApplicationException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/IsisException.java Fri Jul  6 10:51:16 2012
@@ -1,109 +1,109 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.exceptions;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-
-/**
- * General exception raised by the framework, typically a system exception.
- */
-public class IsisException extends RuntimeException {
-    private static final long serialVersionUID = 1L;
-    private static boolean THROWABLE_SUPPORTS_CAUSE;
-
-    static {
-        // Java 1.4, and after, holds a cause; Java 1.1, 1.2 and .Net do not, so
-        // we need to
-        // do the work ourselves.
-        final Class<?> c = Throwable.class;
-        try {
-            THROWABLE_SUPPORTS_CAUSE = c.getMethod("getCause", new Class[0]) != null;
-        } catch (final Exception ignore) {
-            // this should never occur in proper Java environment
-            THROWABLE_SUPPORTS_CAUSE = false;
-        }
-    }
-
-    private final Throwable cause;
-
-    public IsisException() {
-        super("");
-        cause = null;
-    }
-
-    public IsisException(final String message) {
-        super(message);
-        cause = null;
-    }
-
-    public IsisException(final String messageFormat, final Object... args) {
-        super(MessageFormat.format(messageFormat, args));
-        cause = null;
-    }
-
-    public IsisException(final String message, final Throwable cause) {
-        super(message);
-        this.cause = cause;
-    }
-
-    public IsisException(final Throwable cause) {
-        super(cause == null ? null : cause.toString());
-        this.cause = cause;
-    }
-
-    @Override
-    public Throwable getCause() {
-        return (cause == this ? null : cause);
-    }
-
-    @Override
-    public void printStackTrace(final PrintStream s) {
-        if (THROWABLE_SUPPORTS_CAUSE) {
-            super.printStackTrace(s);
-        } else {
-            synchronized (s) {
-                super.printStackTrace(s);
-                final Throwable c = getCause();
-                if (c != null) {
-                    s.print("Root cause: ");
-                    c.printStackTrace(s);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void printStackTrace(final PrintWriter s) {
-        if (THROWABLE_SUPPORTS_CAUSE) {
-            super.printStackTrace(s);
-        } else {
-            synchronized (s) {
-                super.printStackTrace(s);
-                final Throwable c = getCause();
-                if (c != null) {
-                    s.println("Root cause: ");
-                    c.printStackTrace(s);
-                }
-            }
-        }
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.exceptions;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+
+/**
+ * General exception raised by the framework, typically a system exception.
+ */
+public class IsisException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+    private static boolean THROWABLE_SUPPORTS_CAUSE;
+
+    static {
+        // Java 1.4, and after, holds a cause; Java 1.1, 1.2 and .Net do not, so
+        // we need to
+        // do the work ourselves.
+        final Class<?> c = Throwable.class;
+        try {
+            THROWABLE_SUPPORTS_CAUSE = c.getMethod("getCause", new Class[0]) != null;
+        } catch (final Exception ignore) {
+            // this should never occur in proper Java environment
+            THROWABLE_SUPPORTS_CAUSE = false;
+        }
+    }
+
+    private final Throwable cause;
+
+    public IsisException() {
+        super("");
+        cause = null;
+    }
+
+    public IsisException(final String message) {
+        super(message);
+        cause = null;
+    }
+
+    public IsisException(final String messageFormat, final Object... args) {
+        super(MessageFormat.format(messageFormat, args));
+        cause = null;
+    }
+
+    public IsisException(final String message, final Throwable cause) {
+        super(message);
+        this.cause = cause;
+    }
+
+    public IsisException(final Throwable cause) {
+        super(cause == null ? null : cause.toString());
+        this.cause = cause;
+    }
+
+    @Override
+    public Throwable getCause() {
+        return (cause == this ? null : cause);
+    }
+
+    @Override
+    public void printStackTrace(final PrintStream s) {
+        if (THROWABLE_SUPPORTS_CAUSE) {
+            super.printStackTrace(s);
+        } else {
+            synchronized (s) {
+                super.printStackTrace(s);
+                final Throwable c = getCause();
+                if (c != null) {
+                    s.print("Root cause: ");
+                    c.printStackTrace(s);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void printStackTrace(final PrintWriter s) {
+        if (THROWABLE_SUPPORTS_CAUSE) {
+            super.printStackTrace(s);
+        } else {
+            synchronized (s) {
+                super.printStackTrace(s);
+                final Throwable c = getCause();
+                if (c != null) {
+                    s.println("Root cause: ");
+                    c.printStackTrace(s);
+                }
+            }
+        }
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/NotYetImplementedException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/NotYetImplementedException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/NotYetImplementedException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/NotYetImplementedException.java Fri Jul  6 10:51:16 2012
@@ -1,37 +1,37 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.exceptions;
-
-/**
- * Flags a method as not having been implemented yet, but is be implemented.
- */
-public class NotYetImplementedException extends IsisException {
-
-    private static final long serialVersionUID = 1L;
-
-    public NotYetImplementedException() {
-        super("This method is not implemented yet");
-    }
-
-    public NotYetImplementedException(final String arg0) {
-        super(arg0);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.exceptions;
+
+/**
+ * Flags a method as not having been implemented yet, but is be implemented.
+ */
+public class NotYetImplementedException extends IsisException {
+
+    private static final long serialVersionUID = 1L;
+
+    public NotYetImplementedException() {
+        super("This method is not implemented yet");
+    }
+
+    public NotYetImplementedException(final String arg0) {
+        super(arg0);
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnexpectedCallException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnexpectedCallException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnexpectedCallException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnexpectedCallException.java Fri Jul  6 10:51:16 2012
@@ -1,37 +1,37 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.exceptions;
-
-/**
- * Indicates that a call was made to a method (normally an overridden one) that
- * was not expected, and hence not coded for.
- */
-public class UnexpectedCallException extends IsisException {
-    private static final long serialVersionUID = 1L;
-
-    public UnexpectedCallException() {
-        super("This method call was not expected");
-    }
-
-    public UnexpectedCallException(final String arg0) {
-        super(arg0);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.exceptions;
+
+/**
+ * Indicates that a call was made to a method (normally an overridden one) that
+ * was not expected, and hence not coded for.
+ */
+public class UnexpectedCallException extends IsisException {
+    private static final long serialVersionUID = 1L;
+
+    public UnexpectedCallException() {
+        super("This method call was not expected");
+    }
+
+    public UnexpectedCallException(final String arg0) {
+        super(arg0);
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnknownTypeException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnknownTypeException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnknownTypeException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/UnknownTypeException.java Fri Jul  6 10:51:16 2012
@@ -1,45 +1,45 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.exceptions;
-
-public class UnknownTypeException extends IsisException {
-    private static final long serialVersionUID = 1L;
-
-    public UnknownTypeException() {
-        super();
-    }
-
-    public UnknownTypeException(final String message) {
-        super(message);
-    }
-
-    public UnknownTypeException(final Throwable cause) {
-        super(cause);
-    }
-
-    public UnknownTypeException(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-    public UnknownTypeException(final Object object) {
-        this(object == null ? "null" : object.toString());
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.exceptions;
+
+public class UnknownTypeException extends IsisException {
+    private static final long serialVersionUID = 1L;
+
+    public UnknownTypeException() {
+        super();
+    }
+
+    public UnknownTypeException(final String message) {
+        super(message);
+    }
+
+    public UnknownTypeException(final Throwable cause) {
+        super(cause);
+    }
+
+    public UnknownTypeException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+    public UnknownTypeException(final Object object) {
+        this(object == null ? "null" : object.toString());
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/package-info.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/package-info.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/package-info.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/exceptions/package-info.java Fri Jul  6 10:51:16 2012
@@ -1,25 +1,25 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * Defines {@link org.apache.isis.core.commons.exceptions.IsisException base class}
- * for exceptions raised either by Isis itself or by the domain model
- * running on top of Isis.  
- */
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * Defines {@link org.apache.isis.core.commons.exceptions.IsisException base class}
+ * for exceptions raised either by Isis itself or by the domain model
+ * running on top of Isis.  
+ */
 package org.apache.isis.core.commons.exceptions;
\ No newline at end of file

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationClassException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationClassException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationClassException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationClassException.java Fri Jul  6 10:51:16 2012
@@ -1,42 +1,42 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.factory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class InstanceCreationClassException extends IsisException {
-    private static final long serialVersionUID = 1L;
-
-    public InstanceCreationClassException() {
-        super();
-    }
-
-    public InstanceCreationClassException(final String s) {
-        super(s);
-    }
-
-    public InstanceCreationClassException(final Throwable cause) {
-        super(cause);
-    }
-
-    public InstanceCreationClassException(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.factory;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class InstanceCreationClassException extends IsisException {
+    private static final long serialVersionUID = 1L;
+
+    public InstanceCreationClassException() {
+        super();
+    }
+
+    public InstanceCreationClassException(final String s) {
+        super(s);
+    }
+
+    public InstanceCreationClassException(final Throwable cause) {
+        super(cause);
+    }
+
+    public InstanceCreationClassException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceCreationException.java Fri Jul  6 10:51:16 2012
@@ -1,42 +1,42 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.factory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class InstanceCreationException extends IsisException {
-    private static final long serialVersionUID = 1L;
-
-    public InstanceCreationException() {
-        super();
-    }
-
-    public InstanceCreationException(final String s) {
-        super(s);
-    }
-
-    public InstanceCreationException(final Throwable cause) {
-        super(cause);
-    }
-
-    public InstanceCreationException(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.factory;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class InstanceCreationException extends IsisException {
+    private static final long serialVersionUID = 1L;
+
+    public InstanceCreationException() {
+        super();
+    }
+
+    public InstanceCreationException(final String s) {
+        super(s);
+    }
+
+    public InstanceCreationException(final Throwable cause) {
+        super(cause);
+    }
+
+    public InstanceCreationException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceUtil.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceUtil.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceUtil.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/InstanceUtil.java Fri Jul  6 10:51:16 2012
@@ -1,142 +1,142 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.factory;
-
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.lang.CastUtils;
-
-public final class InstanceUtil {
-
-    private InstanceUtil() {
-    }
-
-    public static Object createInstance(final String className) {
-        return createInstance(className, (Class<?>) null, null);
-    }
-
-    public static Object createInstance(final Class<?> cls) {
-        return createInstance(cls, (Class<?>) null, null);
-    }
-
-    public static <T> T createInstance(final String className, final Class<T> requiredClass) {
-        return createInstance(className, (Class<T>) null, requiredClass);
-    }
-
-    public static <T> T createInstance(final Class<?> cls, final Class<T> requiredClass) {
-        return createInstance(cls, (Class<T>) null, requiredClass);
-    }
-
-    public static <T> T createInstance(final String className, final String defaultTypeName, final Class<T> requiredType) {
-        Class<? extends T> defaultType = null;
-        if (defaultTypeName != null) {
-            try {
-                defaultType = CastUtils.cast(Thread.currentThread().getContextClassLoader().loadClass(defaultTypeName));
-                if (defaultType == null) {
-                    throw new InstanceCreationClassException("Failed to load default type '" + defaultTypeName + "'");
-                }
-            } catch (final ClassNotFoundException e) {
-                throw new UnavailableClassException("The default type '" + defaultTypeName + "' cannot be found");
-            } catch (final NoClassDefFoundError e) {
-                throw new InstanceCreationClassException("Default type '" + defaultTypeName + "' found, but is missing a dependent class: " + e.getMessage(), e);
-            }
-        }
-        return createInstance(className, defaultType, requiredType);
-    }
-
-    public static <T> T createInstance(final Class<?> cls, final String defaultTypeName, final Class<T> requiredType) {
-        Class<? extends T> defaultType = null;
-        if (defaultTypeName != null) {
-            defaultType = loadClass(defaultTypeName, requiredType);
-            try {
-                defaultType = CastUtils.cast(Thread.currentThread().getContextClassLoader().loadClass(defaultTypeName));
-                if (defaultType == null) {
-                    throw new InstanceCreationClassException("Failed to load default type '" + defaultTypeName + "'");
-                }
-            } catch (final ClassNotFoundException e) {
-                throw new UnavailableClassException("The default type '" + defaultTypeName + "' cannot be found");
-            } catch (final NoClassDefFoundError e) {
-                throw new InstanceCreationClassException("Default type '" + defaultTypeName + "' found, but is missing a dependent class: " + e.getMessage(), e);
-            }
-        }
-        return createInstance(cls, defaultType, requiredType);
-    }
-
-    public static <T> T createInstance(final String className, final Class<? extends T> defaultType, final Class<T> requiredType) {
-        Assert.assertNotNull("Class to instantiate must be specified", className);
-        Class<?> cls = null;
-        try {
-            cls = Thread.currentThread().getContextClassLoader().loadClass(className);
-            if (cls == null) {
-                throw new InstanceCreationClassException("Failed to load class '" + className + "'");
-            }
-            return createInstance(cls, defaultType, requiredType);
-        } catch (final ClassNotFoundException e) {
-            if (className.indexOf('.') == -1) {
-                throw new UnavailableClassException("The component '" + className + "' cannot be found");
-            }
-            throw new UnavailableClassException("The class '" + className + "' cannot be found");
-        } catch (final NoClassDefFoundError e) {
-            throw new InstanceCreationClassException("Class '" + className + "' found , but is missing a dependent class: " + e.getMessage(), e);
-        }
-    }
-
-    public static <T> T createInstance(final Class<?> cls, final Class<? extends T> defaultType, final Class<T> requiredType) {
-        Assert.assertNotNull("Class to instantiate must be specified", cls);
-        try {
-            if (requiredType == null || requiredType.isAssignableFrom(cls)) {
-                final Class<T> tClass = CastUtils.cast(cls);
-                return tClass.newInstance();
-            } else {
-                throw new InstanceCreationClassException("Class '" + cls.getName() + "' is not of type '" + requiredType + "'");
-            }
-        } catch (final NoClassDefFoundError e) {
-            throw new InstanceCreationClassException("Class '" + cls + "'found , but is missing a dependent class: " + e.getMessage(), e);
-        } catch (final InstantiationException e) {
-            throw new InstanceCreationException("Could not instantiate an object of class '" + cls.getName() + "'; " + e.getMessage());
-        } catch (final IllegalAccessException e) {
-            throw new InstanceCreationException("Could not access the class '" + cls.getName() + "'; " + e.getMessage());
-        }
-    }
-
-    public static Class<?> loadClass(final String className) {
-        Assert.assertNotNull("Class to instantiate must be specified", className);
-        try {
-            return Thread.currentThread().getContextClassLoader().loadClass(className);
-        } catch (final ClassNotFoundException e) {
-            throw new UnavailableClassException("The default type '" + className + "' cannot be found");
-        } catch (final NoClassDefFoundError e) {
-            throw new InstanceCreationClassException("Default type '" + className + "' found, but is missing a dependent class: " + e.getMessage(), e);
-        }
-    }
-
-    public static <R, T extends R> Class<T> loadClass(final String className, final Class<R> requiredType) {
-        Assert.assertNotNull("Class to instantiate must be specified", className);
-        try {
-            final Class<?> loadedClass = loadClass(className);
-            if (requiredType != null && !requiredType.isAssignableFrom(loadedClass)) {
-                throw new InstanceCreationClassException("Class '" + className + "' is not of type '" + requiredType + "'");
-            }
-            return CastUtils.cast(loadedClass);
-        } catch (final NoClassDefFoundError e) {
-            throw new InstanceCreationClassException("Default type '" + className + "' found, but is missing a dependent class: " + e.getMessage(), e);
-        }
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.factory;
+
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.commons.lang.CastUtils;
+
+public final class InstanceUtil {
+
+    private InstanceUtil() {
+    }
+
+    public static Object createInstance(final String className) {
+        return createInstance(className, (Class<?>) null, null);
+    }
+
+    public static Object createInstance(final Class<?> cls) {
+        return createInstance(cls, (Class<?>) null, null);
+    }
+
+    public static <T> T createInstance(final String className, final Class<T> requiredClass) {
+        return createInstance(className, (Class<T>) null, requiredClass);
+    }
+
+    public static <T> T createInstance(final Class<?> cls, final Class<T> requiredClass) {
+        return createInstance(cls, (Class<T>) null, requiredClass);
+    }
+
+    public static <T> T createInstance(final String className, final String defaultTypeName, final Class<T> requiredType) {
+        Class<? extends T> defaultType = null;
+        if (defaultTypeName != null) {
+            try {
+                defaultType = CastUtils.cast(Thread.currentThread().getContextClassLoader().loadClass(defaultTypeName));
+                if (defaultType == null) {
+                    throw new InstanceCreationClassException("Failed to load default type '" + defaultTypeName + "'");
+                }
+            } catch (final ClassNotFoundException e) {
+                throw new UnavailableClassException("The default type '" + defaultTypeName + "' cannot be found");
+            } catch (final NoClassDefFoundError e) {
+                throw new InstanceCreationClassException("Default type '" + defaultTypeName + "' found, but is missing a dependent class: " + e.getMessage(), e);
+            }
+        }
+        return createInstance(className, defaultType, requiredType);
+    }
+
+    public static <T> T createInstance(final Class<?> cls, final String defaultTypeName, final Class<T> requiredType) {
+        Class<? extends T> defaultType = null;
+        if (defaultTypeName != null) {
+            defaultType = loadClass(defaultTypeName, requiredType);
+            try {
+                defaultType = CastUtils.cast(Thread.currentThread().getContextClassLoader().loadClass(defaultTypeName));
+                if (defaultType == null) {
+                    throw new InstanceCreationClassException("Failed to load default type '" + defaultTypeName + "'");
+                }
+            } catch (final ClassNotFoundException e) {
+                throw new UnavailableClassException("The default type '" + defaultTypeName + "' cannot be found");
+            } catch (final NoClassDefFoundError e) {
+                throw new InstanceCreationClassException("Default type '" + defaultTypeName + "' found, but is missing a dependent class: " + e.getMessage(), e);
+            }
+        }
+        return createInstance(cls, defaultType, requiredType);
+    }
+
+    public static <T> T createInstance(final String className, final Class<? extends T> defaultType, final Class<T> requiredType) {
+        Assert.assertNotNull("Class to instantiate must be specified", className);
+        Class<?> cls = null;
+        try {
+            cls = Thread.currentThread().getContextClassLoader().loadClass(className);
+            if (cls == null) {
+                throw new InstanceCreationClassException("Failed to load class '" + className + "'");
+            }
+            return createInstance(cls, defaultType, requiredType);
+        } catch (final ClassNotFoundException e) {
+            if (className.indexOf('.') == -1) {
+                throw new UnavailableClassException("The component '" + className + "' cannot be found");
+            }
+            throw new UnavailableClassException("The class '" + className + "' cannot be found");
+        } catch (final NoClassDefFoundError e) {
+            throw new InstanceCreationClassException("Class '" + className + "' found , but is missing a dependent class: " + e.getMessage(), e);
+        }
+    }
+
+    public static <T> T createInstance(final Class<?> cls, final Class<? extends T> defaultType, final Class<T> requiredType) {
+        Assert.assertNotNull("Class to instantiate must be specified", cls);
+        try {
+            if (requiredType == null || requiredType.isAssignableFrom(cls)) {
+                final Class<T> tClass = CastUtils.cast(cls);
+                return tClass.newInstance();
+            } else {
+                throw new InstanceCreationClassException("Class '" + cls.getName() + "' is not of type '" + requiredType + "'");
+            }
+        } catch (final NoClassDefFoundError e) {
+            throw new InstanceCreationClassException("Class '" + cls + "'found , but is missing a dependent class: " + e.getMessage(), e);
+        } catch (final InstantiationException e) {
+            throw new InstanceCreationException("Could not instantiate an object of class '" + cls.getName() + "'; " + e.getMessage());
+        } catch (final IllegalAccessException e) {
+            throw new InstanceCreationException("Could not access the class '" + cls.getName() + "'; " + e.getMessage());
+        }
+    }
+
+    public static Class<?> loadClass(final String className) {
+        Assert.assertNotNull("Class to instantiate must be specified", className);
+        try {
+            return Thread.currentThread().getContextClassLoader().loadClass(className);
+        } catch (final ClassNotFoundException e) {
+            throw new UnavailableClassException("The default type '" + className + "' cannot be found");
+        } catch (final NoClassDefFoundError e) {
+            throw new InstanceCreationClassException("Default type '" + className + "' found, but is missing a dependent class: " + e.getMessage(), e);
+        }
+    }
+
+    public static <R, T extends R> Class<T> loadClass(final String className, final Class<R> requiredType) {
+        Assert.assertNotNull("Class to instantiate must be specified", className);
+        try {
+            final Class<?> loadedClass = loadClass(className);
+            if (requiredType != null && !requiredType.isAssignableFrom(loadedClass)) {
+                throw new InstanceCreationClassException("Class '" + className + "' is not of type '" + requiredType + "'");
+            }
+            return CastUtils.cast(loadedClass);
+        } catch (final NoClassDefFoundError e) {
+            throw new InstanceCreationClassException("Default type '" + className + "' found, but is missing a dependent class: " + e.getMessage(), e);
+        }
+    }
+
+}

Modified: incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/UnavailableClassException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/UnavailableClassException.java?rev=1358111&r1=1358110&r2=1358111&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/UnavailableClassException.java (original)
+++ incubator/isis/trunk/framework/core/commons/src/main/java/org/apache/isis/core/commons/factory/UnavailableClassException.java Fri Jul  6 10:51:16 2012
@@ -1,42 +1,42 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.isis.core.commons.factory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class UnavailableClassException extends IsisException {
-    private static final long serialVersionUID = 1L;
-
-    public UnavailableClassException() {
-        super();
-    }
-
-    public UnavailableClassException(final String s) {
-        super(s);
-    }
-
-    public UnavailableClassException(final Throwable cause) {
-        super(cause);
-    }
-
-    public UnavailableClassException(final String msg, final Throwable cause) {
-        super(msg, cause);
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.core.commons.factory;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class UnavailableClassException extends IsisException {
+    private static final long serialVersionUID = 1L;
+
+    public UnavailableClassException() {
+        super();
+    }
+
+    public UnavailableClassException(final String s) {
+        super(s);
+    }
+
+    public UnavailableClassException(final Throwable cause) {
+        super(cause);
+    }
+
+    public UnavailableClassException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+}



Mime
View raw message