Tidy up warnings in AssemblyHelper
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/68ecc616 Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/68ecc616 Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/68ecc616 Branch: refs/heads/develop Commit: 68ecc616c8e05920b9dbca17e11a55121bc2b14e Parents: 87f6584 Author: Niclas Hedhman <[email protected]> Authored: Mon Oct 24 09:44:00 2016 +0800 Committer: Niclas Hedhman <[email protected]> Committed: Mon Oct 24 09:44:00 2016 +0800 ---------------------------------------------------------------------- core/runtime/src/docs/runtime.txt | 2 +- .../zest/runtime/bootstrap/AssemblyHelper.java | 23 +++--- .../runtime/bootstrap/DocumentationSupport.java | 80 -------------------- .../bootstrap/docs/DocumentationSupport.java | 80 ++++++++++++++++++++ 4 files changed, 93 insertions(+), 92 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/68ecc616/core/runtime/src/docs/runtime.txt ---------------------------------------------------------------------- diff --git a/core/runtime/src/docs/runtime.txt b/core/runtime/src/docs/runtime.txt index 3d5e7cb..9d1e181 100644 --- a/core/runtime/src/docs/runtime.txt +++ b/core/runtime/src/docs/runtime.txt @@ -48,6 +48,6 @@ Fictitious example of using a hypothetical Dalvik capable classloader; [source,java] -------------- -source=core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DocumentationSupport.java +source=core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/docs/DocumentationSupport.java tag=customAssemblyHelper -------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/68ecc616/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java index 9a4ff0d..e181c8b 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/AssemblyHelper.java @@ -42,29 +42,30 @@ import org.apache.zest.runtime.composite.SideEffectModel; * This helper is used when building the application model. It keeps track * of already created classloaders and various models */ +@SuppressWarnings("WeakerAccess") public class AssemblyHelper { - Map<Class, Class> instantiationClasses = new HashMap<>(); - Map<Class, ConstraintDeclaration> constraintDeclarations = new HashMap<>(); - Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>(); - Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>(); + private Map<Class, Class> instantiationClasses = new HashMap<>(); + private Map<Class, ConstraintDeclaration> constraintDeclarations = new HashMap<>(); + private Map<ClassLoader, FragmentClassLoader> modifierClassLoaders = new HashMap<>(); + private Map<Class<?>, AppliesToFilter> appliesToInstances = new HashMap<>(); - public MixinModel getMixinModel( Class mixinClass ) + protected MixinModel getMixinModel(Class mixinClass) { return new MixinModel( mixinClass, instantiationClass( mixinClass ) ); } - public ConcernModel getConcernModel( Class concernClass ) + protected ConcernModel getConcernModel(Class concernClass) { return new ConcernModel( concernClass, instantiationClass( concernClass ) ); } - public SideEffectModel getSideEffectModel( Class sideEffectClass ) + protected SideEffectModel getSideEffectModel(Class sideEffectClass) { return new SideEffectModel( sideEffectClass, instantiationClass( sideEffectClass ) ); } - protected Class instantiationClass( Class fragmentClass ) + protected Class instantiationClass(Class fragmentClass) { Class instantiationClass = fragmentClass; if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) ) @@ -88,7 +89,7 @@ public class AssemblyHelper return instantiationClass; } - private FragmentClassLoader getModifierClassLoader( ClassLoader classLoader ) + protected FragmentClassLoader getModifierClassLoader( ClassLoader classLoader ) { FragmentClassLoader cl = modifierClassLoaders.get( classLoader ); if( cl == null ) @@ -122,7 +123,7 @@ public class AssemblyHelper return false; } - public AppliesToFilter createAppliesToFilter( Class<?> fragmentClass ) + protected AppliesToFilter createAppliesToFilter( Class<?> fragmentClass ) { AppliesToFilter result = null; if( !InvocationHandler.class.isAssignableFrom( fragmentClass ) ) @@ -141,7 +142,7 @@ public class AssemblyHelper return result; } - private AppliesToFilter applyAppliesTo( AppliesToFilter existing, Class<?> modifierClass ) + protected AppliesToFilter applyAppliesTo( AppliesToFilter existing, Class<?> modifierClass ) { AppliesTo appliesTo = modifierClass.getAnnotation( AppliesTo.class ); if( appliesTo != null ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/68ecc616/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DocumentationSupport.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DocumentationSupport.java b/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DocumentationSupport.java deleted file mode 100644 index b962077..0000000 --- a/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/DocumentationSupport.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.zest.runtime.bootstrap; - -import org.apache.zest.api.structure.Application; -import org.apache.zest.bootstrap.ApplicationAssembler; -import org.apache.zest.bootstrap.ApplicationAssembly; -import org.apache.zest.bootstrap.ApplicationAssemblyFactory; -import org.apache.zest.bootstrap.AssemblyException; -import org.apache.zest.bootstrap.Energy4Java; -import org.apache.zest.runtime.bootstrap.AssemblyHelper; -import org.apache.zest.runtime.composite.FragmentClassLoader; - -public class DocumentationSupport -{ - // START SNIPPET: customAssemblyHelper - private static Energy4Java zest; - - private static Application application; - - public static void main( String[] args ) - throws Exception - { - // Create a Zest Runtime - zest = new Energy4Java(); - application = zest.newApplication( new ApplicationAssembler() - { - - @Override - public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory ) - throws AssemblyException - { - ApplicationAssembly assembly = appFactory.newApplicationAssembly(); - assembly.setMetaInfo( new DalvikAssemblyHelper() ); - // END SNIPPET: customAssemblyHelper - // START SNIPPET: customAssemblyHelper - return assembly; - } - } ); - // activate the application - application.activate(); - } - - public static class DalvikAssemblyHelper extends AssemblyHelper - { - @Override - protected FragmentClassLoader instantiateFragmentClassLoader( ClassLoader parent ) - { - return new DalvikFragmentClassLoader( parent ); - } - } - - public static class DalvikFragmentClassLoader extends FragmentClassLoader - { - - public DalvikFragmentClassLoader( ClassLoader parent ) - { - super( parent ); - } - } - // END SNIPPET: customAssemblyHelper -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/68ecc616/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/docs/DocumentationSupport.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/docs/DocumentationSupport.java b/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/docs/DocumentationSupport.java new file mode 100644 index 0000000..c74a100 --- /dev/null +++ b/core/runtime/src/test/java/org/apache/zest/runtime/bootstrap/docs/DocumentationSupport.java @@ -0,0 +1,80 @@ +/* + * 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.zest.runtime.bootstrap.docs; + +import org.apache.zest.api.structure.Application; +import org.apache.zest.bootstrap.ApplicationAssembler; +import org.apache.zest.bootstrap.ApplicationAssembly; +import org.apache.zest.bootstrap.ApplicationAssemblyFactory; +import org.apache.zest.bootstrap.AssemblyException; +import org.apache.zest.bootstrap.Energy4Java; +import org.apache.zest.runtime.bootstrap.AssemblyHelper; +import org.apache.zest.runtime.composite.FragmentClassLoader; + +public class DocumentationSupport +{ + // START SNIPPET: customAssemblyHelper + private static Energy4Java zest; + + private static Application application; + + public static void main( String[] args ) + throws Exception + { + // Create a Zest Runtime + zest = new Energy4Java(); + application = zest.newApplication( new ApplicationAssembler() + { + + @Override + public ApplicationAssembly assemble( ApplicationAssemblyFactory appFactory ) + throws AssemblyException + { + ApplicationAssembly assembly = appFactory.newApplicationAssembly(); + assembly.setMetaInfo( new DalvikAssemblyHelper() ); + // END SNIPPET: customAssemblyHelper + // START SNIPPET: customAssemblyHelper + return assembly; + } + } ); + // activate the application + application.activate(); + } + + public static class DalvikAssemblyHelper extends AssemblyHelper + { + @Override + protected FragmentClassLoader instantiateFragmentClassLoader( ClassLoader parent ) + { + return new DalvikFragmentClassLoader( parent ); + } + } + + public static class DalvikFragmentClassLoader extends FragmentClassLoader + { + + public DalvikFragmentClassLoader( ClassLoader parent ) + { + super( parent ); + } + } + // END SNIPPET: customAssemblyHelper +}
