- 浏览: 41932 次
- 性别:
- 来自: 长沙
文章分类
最新评论
package org.jboss.seam.wiki.preferences.metamodel; import org.jboss.seam.Component; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.Startup; import org.jboss.seam.annotations.intercept.BypassInterceptors; import org.jboss.seam.log.LogProvider; import org.jboss.seam.log.Logging; import org.jboss.seam.wiki.preferences.PreferenceVisibility; import org.jboss.seam.wiki.preferences.annotations.Preferences; import org.jboss.seam.wiki.util.AnnotationDeploymentHelper; import java.util.*; @Name("preferenceRegistry") @Scope(ScopeType.APPLICATION) @Startup(depends = "pluginI18NBinder") @BypassInterceptors public class PreferenceRegistry { private static final LogProvider log = Logging.getLogProvider(PreferenceRegistry.class); Set<PreferenceEntity> preferenceEntities = new HashSet<PreferenceEntity>(); Map<String, PreferenceEntity> preferenceEntitiesByName = new HashMap<String, PreferenceEntity>(); Set<PreferenceEntity> preferenceEntitiesSystem = new HashSet<PreferenceEntity>(); Set<PreferenceEntity> preferenceEntitiesUser = new HashSet<PreferenceEntity>(); Set<PreferenceEntity> preferenceEntitiesInstance = new HashSet<PreferenceEntity>(); @Create public void startup() { log.debug("initializing preferences registry"); Set<Class<?>> preferencesClasses = AnnotationDeploymentHelper.getAnnotatedClasses(Preferences.class); if (preferencesClasses == null) throw new RuntimeException("No preference entities found, add @Preferences annotation to META-INF/seam-deployment.properties"); for (Class preferencesClass : preferencesClasses) { PreferenceEntity preferenceEntity = new PreferenceEntity(preferencesClass); log.debug("adding '" + preferenceEntity.getEntityName() + "', " + preferenceEntity); if (preferenceEntitiesByName.containsKey(preferenceEntity.getEntityName())) { throw new RuntimeException("Duplicate preference entity name: " + preferenceEntity.getEntityName()); } preferenceEntities.add(preferenceEntity); preferenceEntitiesByName.put(preferenceEntity.getEntityName(), preferenceEntity); if (preferenceEntity.isSystemPropertiesVisible()) preferenceEntitiesSystem.add(preferenceEntity); if (preferenceEntity.isUserPropertiesVisible()) preferenceEntitiesUser.add(preferenceEntity); if (preferenceEntity.isInstancePropertiesVisible()) preferenceEntitiesInstance.add(preferenceEntity); } log.info("registered preference entities: " + preferenceEntities.size()); } public Set<PreferenceEntity> getPreferenceEntities() { return preferenceEntities; } public Map<String, PreferenceEntity> getPreferenceEntitiesByName() { return preferenceEntitiesByName; } public Set<PreferenceEntity> getPreferenceEntitiesSystem() { return preferenceEntitiesSystem; } public Set<PreferenceEntity> getPreferenceEntitiesUser() { return preferenceEntitiesUser; } public Set<PreferenceEntity> getPreferenceEntitiesInstance() { return preferenceEntitiesInstance; } public SortedSet<PreferenceEntity> getPreferenceEntities(PreferenceVisibility... visibilities) { if (visibilities == null) return null; SortedSet<PreferenceEntity> entities = new TreeSet<PreferenceEntity>(); List<PreferenceVisibility> visibilityList = Arrays.asList(visibilities); if (visibilityList.contains(PreferenceVisibility.SYSTEM)) entities.addAll(getPreferenceEntitiesSystem()); if (visibilityList.contains(PreferenceVisibility.USER)) entities.addAll(getPreferenceEntitiesUser()); if (visibilityList.contains(PreferenceVisibility.INSTANCE)) entities.addAll(getPreferenceEntitiesInstance()); return entities; } public static PreferenceRegistry instance() { return (PreferenceRegistry) Component.getInstance(PreferenceRegistry.class); } }
/* * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.seam.wiki.util; import org.jboss.seam.deployment.AnnotationDeploymentHandler; import org.jboss.seam.deployment.DeploymentStrategy; import org.jboss.seam.Component; import java.util.Set; /** * A convenience class that allows us to access Seam deployment handlers without @In'jecting them. * <p> * This is useful because we can optimize things such as registries with @BypassInterceptors. * </p> * * @author Christian Bauer */ public class AnnotationDeploymentHelper { public static Set<Class<?>> getAnnotatedClasses(String annotationFQN) { DeploymentStrategy deployment = (DeploymentStrategy) Component.getInstance("deploymentStrategy"); AnnotationDeploymentHandler handler = (AnnotationDeploymentHandler)deployment.getDeploymentHandlers().get(AnnotationDeploymentHandler.NAME); return handler.getClassMap().get(annotationFQN); } public static Set<Class<?>> getAnnotatedClasses(Class annotationType) { return getAnnotatedClasses(annotationType.getName()); } }
1.从ClassLoader中塞选所有Preferences Annotation Class.
2.Registry there prefernece class to seession scope.
3.That registry class it is plugin install,real have power is Preferences class @see Preferences
发表评论
-
Preferences -- about -Reflections warpped reflection
2009-08-01 15:04 813//$Id: Reflections.java 9572 ... -
Preferences -- PreferenceValue example
2009-08-01 14:54 632package org.jboss.seam.wiki.c ... -
Preferences -- PreferenceProvider the Implment
2009-08-01 14:52 669package org.jboss.seam.wiki.c ... -
Preferences -- PreferenceValue the Implment
2009-08-01 14:38 702/* * JBoss, Home of Profess ... -
Preferences -- PreferenceValue the Hibernate user define type
2009-08-01 14:37 829package org.jboss.seam.wiki.c ... -
Preferences -- PreferenceValue and Visibility and Template
2009-08-01 14:35 853package org.jboss.seam.wiki.p ... -
Preferences -- RealPreferences
2009-08-01 14:33 818package org.jboss.seam.wiki.p ... -
Preferences -- matemodel
2009-08-01 14:20 342package org.jboss.seam.wiki.p ... -
Preferences -- Anotation
2009-08-01 14:19 736package org.jboss.seam.wiki.p ...
相关推荐
IntelliJ编辑器中的Spring Boot DevTools + Live Reload问题首先启用自动构建IntelliJ -> Preferences -> Build Execution Deployment -> Compiler -> Build Project Automatically 第二次使用以下命令Command + Alt...
InstantClient安装使用 新安装系统,从未安装过任何版本... 打开pl sql-tools-preferences-connection设置Oracle Home为 C:\instantclient11.2;OCI Library为 C:\instantclient11.2\oci.dll (一般为空手动输入)
java.rmi.registry java.rmi.server java.security java.security.acl java.security.cert java.security.interfaces java.security.spec java.sql java.text java.text.spi java.util java.util....
Troubleshoot Group Policy using tools, logs, Resource Kit utilities, Registry hacks, and third-party tools Manage printers, restrict hardware, and configure Internet Explorer Deploy software to your ...
右键点击桌面顶栏的 docker 图标,选择 Preferences ,在 Daemon 标签(Docker 17.03 之前版本为 Advanced 标签)下的 Registry mirrors 列表中将复制的地址加到”registry-mirrors”的数组里,点击 Apply & Restart...
to remove core system files, services and deeply rooted registry trees. We have grouped some of the more "serious" components into an Advanced Features section of the Add\Remove options tree. To ...
Java 核心技术 卷1 Index Chapter 1: An Introduction to Java 1 Java As a Programming Platform 2 The Java “White Paper” Buzzwords...A Complete Example: Accessing the Windows Registry 975 Index 991
ORACLE OSB开发指南,英文版。 目录: Part I IDE Help for Oracle Service Bus 1 Introduction to Oracle Service Bus 2 Tasks Working with Projects, Folders, Resources, and Configurations .....................
右键点击桌面顶栏的 docker 图标,选择 Preferences ,在 Daemon 标签(Docker 17.03 之前版本为 Advanced 标签)下的 Registry mirrors 列表中加入下面的镜像地址: http://f1361db2.m.daocloud.io 点击 Apply & ...
For clarity's sake I made it write user color preferences. <END><br>63,capture.zip This program captures the active window and displays it to a Picture box. <END><br>64,TransIco.zip An update ...