當前位置: 首頁>>代碼示例>>Java>>正文


Java AnnotationLiteral類代碼示例

本文整理匯總了Java中javax.enterprise.util.AnnotationLiteral的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationLiteral類的具體用法?Java AnnotationLiteral怎麽用?Java AnnotationLiteral使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AnnotationLiteral類屬於javax.enterprise.util包,在下文中一共展示了AnnotationLiteral類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServices

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
/**
 * Retrieves the services that are available for use with the description for each service. 
 * The Services are determined by looking up all of the implementations of the 
 * Customer Service interface that are using the  DataService qualifier annotation. 
 * The DataService annotation contains the service name and description information. 
 * @return Map containing a list of services available and a description of each one.
 */
public Map<String,String> getServices (){
	TreeMap<String,String> services = new TreeMap<String,String>();
	logger.fine("Getting CustomerService Impls");
   	Set<Bean<?>> beans = beanManager.getBeans(CustomerService.class,new AnnotationLiteral<Any>() {
		private static final long serialVersionUID = 1L;});
   	for (Bean<?> bean : beans) {    		
   		for (Annotation qualifer: bean.getQualifiers()){
   			if(DataService.class.getName().equalsIgnoreCase(qualifer.annotationType().getName())){
   				DataService service = (DataService) qualifer;
   				logger.fine("   name="+service.name()+" description="+service.description());
   				services.put(service.name(), service.description());
   			}
   		}
   	}    	
   	return services;
}
 
開發者ID:ibmruntimes,項目名稱:acmeair-modular,代碼行數:24,代碼來源:ServiceLocator.java

示例2: removeUser

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID})
@Override
public Workspace removeUser(String pWorkspaceId, String login) throws UserNotFoundException, AccessRightException, AccountNotFoundException, WorkspaceNotFoundException, FolderNotFoundException, EntityConstraintException, UserNotActiveException, DocumentRevisionNotFoundException {
    Account account = new AccountDAO(em).loadAccount(contextManager.getCallerPrincipalLogin());
    Workspace workspace = new WorkspaceDAO(new Locale(account.getLanguage()), em).loadWorkspace(pWorkspaceId);
    checkAdmin(workspace, account);

    Locale locale = new Locale(account.getLanguage());
    UserDAO userDAO = new UserDAO(locale, em);
    User user = userDAO.loadUser(new UserKey(pWorkspaceId, login));

    userEvent.select(new AnnotationLiteral<Removed>() {
    }).fire(new UserEvent(user));
    userDAO.removeUser(user);

    return workspace;
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:18,代碼來源:UserManagerBean.java

示例3: removeUserGroups

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID, UserGroupMapping.ADMIN_ROLE_ID})
@Override
public void removeUserGroups(String pWorkspaceId, String[] pIds) throws UserGroupNotFoundException, AccessRightException, AccountNotFoundException, WorkspaceNotFoundException, EntityConstraintException {
    Account account = checkAdmin(pWorkspaceId);
    Locale locale = new Locale(account.getLanguage());
    UserGroupDAO groupDAO = new UserGroupDAO(locale, em);
    for (String id : pIds) {
        UserGroupKey userGroupKey = new UserGroupKey(pWorkspaceId, id);
        if (groupDAO.hasACLConstraint(userGroupKey)) {
            throw new EntityConstraintException(locale, "EntityConstraintException11");
        }
        UserGroup group = groupDAO.loadUserGroup(userGroupKey);
        groupEvent.select(new AnnotationLiteral<Removed>() {
        }).fire(new UserGroupEvent(group));
        groupDAO.removeUserGroup(group);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:18,代碼來源:UserManagerBean.java

示例4: checkWorkspaceReadAccess

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID})
@Override
public User checkWorkspaceReadAccess(String pWorkspaceId) throws UserNotFoundException, UserNotActiveException, WorkspaceNotFoundException, WorkspaceNotEnabledException {
    String login = contextManager.getCallerPrincipalLogin();
    UserDAO userDAO = new UserDAO(em);
    WorkspaceUserMembership userMS = userDAO.loadUserMembership(new WorkspaceUserMembershipKey(pWorkspaceId, pWorkspaceId, login));
    Workspace wks = new WorkspaceDAO(em).loadWorkspace(pWorkspaceId);
    User user = userDAO.loadUser(new UserKey(pWorkspaceId, login));
    Locale locale = new Locale(user.getLanguage());

    if (!wks.isEnabled()) {
        throw new WorkspaceNotEnabledException(locale, pWorkspaceId);
    } else if (userMS != null) {
        user = userMS.getMember();
    } else if (!wks.getAdmin().getLogin().equals(login)) {
        WorkspaceUserGroupMembership[] groupMS = new UserGroupDAO(em).getUserGroupMemberships(pWorkspaceId, user);
        if (groupMS.length == 0) {
            throw new UserNotActiveException(locale, login);
        }
    }

    workspaceAccessEvent.select(new AnnotationLiteral<Read>() {
    }).fire(new WorkspaceAccessEvent(user));

    return user;
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:27,代碼來源:UserManagerBean.java

示例5: deleteTag

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID)
@Override
public void deleteTag(TagKey pKey) throws WorkspaceNotFoundException, AccessRightException, TagNotFoundException, UserNotFoundException, WorkspaceNotEnabledException {
    User user = userManager.checkWorkspaceWriteAccess(pKey.getWorkspace());
    Locale userLocale = new Locale(user.getLanguage());
    Tag tagToRemove = new Tag(user.getWorkspace(), pKey.getLabel());
    List<DocumentRevision> docRs = new DocumentRevisionDAO(userLocale, em).findDocRsByTag(tagToRemove);
    for (DocumentRevision docR : docRs) {
        docR.getTags().remove(tagToRemove);
    }
    List<ChangeItem> changeItems = new ChangeItemDAO(userLocale, em).findChangeItemByTag(pKey.getWorkspace(), tagToRemove);
    for (ChangeItem changeItem : changeItems) {
        changeItem.getTags().remove(tagToRemove);
    }

    List<PartRevision> partRevisions = new PartRevisionDAO(userLocale, em).findPartByTag(tagToRemove);
    for (PartRevision partRevision : partRevisions) {
        partRevision.getTags().remove(tagToRemove);
    }

    tagEvent.select(new AnnotationLiteral<Removed>() {
    }).fire(new TagEvent(tagToRemove));

    new TagDAO(userLocale, em).removeTag(pKey);
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:26,代碼來源:DocumentManagerBean.java

示例6: removeTag

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID)
@Override
public DocumentRevision removeTag(DocumentRevisionKey pDocRPK, String pTag)
        throws UserNotFoundException, WorkspaceNotFoundException, UserNotActiveException, AccessRightException, DocumentRevisionNotFoundException, NotAllowedException, WorkspaceNotEnabledException {

    User user = checkDocumentRevisionWriteAccess(pDocRPK);

    DocumentRevision docR = getDocumentRevision(pDocRPK);
    Tag tagToRemove = new Tag(user.getWorkspace(), pTag);
    docR.getTags().remove(tagToRemove);

    tagEvent.select(new AnnotationLiteral<Untagged>() {
    }).fire(new TagEvent(tagToRemove, docR));

    if (isCheckoutByAnotherUser(user, docR)) {
        em.detach(docR);
        docR.removeLastIteration();
    }

    for (DocumentIteration documentIteration : docR.getDocumentIterations()) {
        indexerManager.indexDocumentIteration(documentIteration);
    }
    return docR;
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:25,代碼來源:DocumentManagerBean.java

示例7: removeTag

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@RolesAllowed(UserGroupMapping.REGULAR_USER_ROLE_ID)
@Override
public PartRevision removeTag(PartRevisionKey partRevisionKey, String tagName) throws UserNotFoundException, WorkspaceNotFoundException, UserNotActiveException, PartRevisionNotFoundException, AccessRightException, WorkspaceNotEnabledException {
    User user = checkPartRevisionWriteAccess(partRevisionKey);

    PartRevision partRevision = getPartRevision(partRevisionKey);
    Tag tagToRemove = new Tag(user.getWorkspace(), tagName);
    partRevision.getTags().remove(tagToRemove);

    tagEvent.select(new AnnotationLiteral<Untagged>() {
    }).fire(new TagEvent(tagToRemove, partRevision));

    if (isCheckoutByAnotherUser(user, partRevision)) {
        em.detach(partRevision);
        partRevision.removeLastIteration();
    }

    for (PartIteration partIteration : partRevision.getPartIterations()) {
        indexerManager.indexPartIteration(partIteration);
    }
    return partRevision;
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:23,代碼來源:ProductManagerBean.java

示例8: persist

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@Transactional
public boolean persist()
{
    final EntityManager entityManager = getEntityManager();
    entityManager.persist(getInstance());
    entityManager.flush();
    for (ManagedPersistenceContext context : managedPersistenceContexts) {
        final Object id = context.getProvider().getId(getInstance(), getEntityManager());
        if (id != null) {
            assignId(id);
            break;
        }
    }
    beanManager.fireEvent(getInstance(), new AnnotationLiteral<EntityPersisted>() {
    });
    return true;
}
 
開發者ID:Inspiredsoft,項目名稱:parco,代碼行數:18,代碼來源:EntityHome.java

示例9: start

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@Override
public void start(Stage initStage) throws Exception {
    final Stage primaryStage = new Stage(StageStyle.DECORATED);
    Task<ObservableValue<Stage>> mainStageTask = new Task<ObservableValue<Stage>>() {
        @Override
        protected ObservableValue<Stage> call() throws Exception {
            Weld weld = new Weld();
            WeldContainer container = weld.initialize(); // Initialize Weld CDI
            primaryStage.setTitle("StudyGuide");
            primaryStage.setOnCloseRequest(event -> {
                logger.debug("Closing down Weld.");
                weld.shutdown();
            });
            primaryStage.getIcons().add(new Image(StudyGuideApplication.class.getResourceAsStream(logoResource)));
            container.event().select(Stage.class, new AnnotationLiteral<StartupStage>() {
            }).fire(primaryStage);
            return new ReadOnlyObjectWrapper<>(primaryStage);
        }
    };
    mainStageTask.exceptionProperty().addListener((observable, oldValue, newValue) -> {
        Platform.runLater(() -> {
            throw new IllegalStateException("Main stage loading failed.", newValue);
        });
    });
    showSplashScreen(initStage, mainStageTask);
}
 
開發者ID:oskopek,項目名稱:StudyGuide,代碼行數:27,代碼來源:StudyGuideApplication.java

示例10: initialize

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
/**
 * {@inheritDoc}.
 */
@Override
@SuppressWarnings("rawtypes")
public void initialize(final Unique annotation) {
	qualifier = new AnnotationLiteral() {
		private static final long serialVersionUID = 1L;

		@Override
		public Class annotationType() {
			return annotation.qualifier();
		}
	};
	type = annotation.type();
	paths = annotation.path();
	hints = annotation.hints();
}
 
開發者ID:clairton,項目名稱:unique-validator,代碼行數:19,代碼來源:UniqueValidator.java

示例11: ClientProxyBean

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
/**
 * Public constructor.
 *
 * @param serviceName   The name of the ESB Service being proxied to.
 * @param proxyInterface The proxy Interface.
 * @param qualifiers     The CDI bean qualifiers.  Copied from the injection point.
 * @param beanDeploymentMetaData Deployment metadata.
 */
public ClientProxyBean(String serviceName, Class<?> proxyInterface, Set<Annotation> qualifiers, BeanDeploymentMetaData beanDeploymentMetaData) {
    this._serviceName = serviceName;
    this._serviceInterface = proxyInterface;

    if (qualifiers != null) {
        this._qualifiers = qualifiers;
    } else {
        this._qualifiers = new HashSet<Annotation>();
        this._qualifiers.add(new AnnotationLiteral<Default>() {
        });
        this._qualifiers.add(new AnnotationLiteral<Any>() {
        });
    }

    _proxyBean = Proxy.newProxyInstance(beanDeploymentMetaData.getDeploymentClassLoader(),
            new Class[]{_serviceInterface},
            new ClientProxyInvocationHandler(_serviceInterface));
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:27,代碼來源:ClientProxyBean.java

示例12: initMetrics

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
public void initMetrics() throws IOException {
    String hostname = metricNameService.getHostName();

    Observable.from(beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {}))
            .map(Bean::getBeanClass)
            .filter(this::isRESTHandler)
            .flatMap(c -> Observable.from(c.getMethods()))
            .filter(this::isRESTHandlerMethod)
            .subscribe(
                    method -> {
                        HTTPMethod httpMethod = getHttpMethod(method);
                        String uri = getURI(method);
                        if (isWrite(method, uri)) {
                            register(RESTMetaData.forWrite(httpMethod, uri, hostname));
                        } else {
                            register(RESTMetaData.forRead(httpMethod, uri, hostname));
                        }
                    },
                    t -> logger.warn("Failed to register meta data for REST metrics", t),
                    () -> {}
            );
}
 
開發者ID:hawkular,項目名稱:hawkular-metrics,代碼行數:23,代碼來源:RESTMetrics.java

示例13: sendMessageToProducer

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@Test
public void sendMessageToProducer(@Uri("direct:produce") ProducerTemplate producer) throws InterruptedException {
    long random =  Math.round(Math.random() * Long.MAX_VALUE);

    produced.expectedMessageCount(1);
    produced.expectedBodiesReceived(random);
    produced.message(0).predicate(exchange -> {
        EventMetadata metadata = exchange.getIn().getHeader("metadata", EventMetadata.class);
        return metadata.getType().equals(Long.class) && metadata.getQualifiers().equals(new HashSet<>(Arrays.asList(new AnnotationLiteral<Any>() {}, new AnnotationLiteral<Default>() {})));
    });

    consumed.expectedMessageCount(1);
    consumed.expectedBodiesReceived(random);

    producer.sendBody(random);

    assertIsSatisfied(2L, TimeUnit.SECONDS, consumed, produced);
}
 
開發者ID:astefanutti,項目名稱:camel-cdi,代碼行數:19,代碼來源:RawEventEndpointTest.java

示例14: getBeanInstance

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private static <T> T getBeanInstance(final Class<T> type) throws Exception {
	BeanManager beanManager = getBeanManager();

       final Set<Bean<?>> beans = beanManager.getBeans(Object.class,new AnnotationLiteral<Any>() {

		private static final long serialVersionUID = 3612602223649004820L;});
       
       for (Bean<?> iterateBean : beans) {
           if(iterateBean.getBeanClass().getName() == type.getName()){
           	Bean<T> bean = (Bean<T>) iterateBean;
               final CreationalContext<T> creationalContext = beanManager.createCreationalContext(bean);
               return (T) beanManager.getReference(bean, type,creationalContext);
           }
       }
       return null;
}
 
開發者ID:cgi-soa-masterclass,項目名稱:onlinepay,代碼行數:18,代碼來源:InjectingConstraintValidatorFactory.java

示例15: cacheBeans

import javax.enterprise.util.AnnotationLiteral; //導入依賴的package包/類
@PostConstruct
public void cacheBeans() {
    LOG.info("> Initializing ProviderTypes. ");
    final Set<Bean<?>> beans = beanManager.getBeans(ProviderType.class,
                                                    new AnnotationLiteral<Any>() {
                                                    });
    for (final Bean b : beans) {
        try {
            // I don't want to register the CDI proxy, I need a fresh instance :(
            ProviderType pt = (ProviderType) b.getBeanClass().newInstance();
            LOG.info("> Registering ProviderType: " + pt.getProviderTypeName());
            runtimeRegistry.registerProviderType(pt);
        } catch (InstantiationException | IllegalAccessException ex) {
            LOG.error("Something went wrong with registering Provider Types!",
                      ex);
        }
    }
}
 
開發者ID:kiegroup,項目名稱:kie-wb-common,代碼行數:19,代碼來源:RestRuntimeProvisioningServiceImpl.java


注:本文中的javax.enterprise.util.AnnotationLiteral類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。