本文整理了Java中javax.inject.Provider.get()
方法的一些代码示例,展示了Provider.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Provider.get()
方法的具体详情如下:
包路径:javax.inject.Provider
类名称:Provider
方法名:get
[英]Provides a fully-constructed and injected instance of T.
[中]提供一个完全构造和注入的T。
代码示例来源:origin: org.eclipse.che.core/che-core-api-ssh
@Transactional
protected void doCreate(SshPairImpl entity) {
EntityManager manager = managerProvider.get();
manager.persist(entity);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-installer
@Transactional(rollbackOn = {RuntimeException.class, InstallerException.class})
protected void doCreate(InstallerImpl installer) throws InstallerException {
EntityManager manage = managerProvider.get();
manage.persist(installer);
manage.flush();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-machine-authentication
@Transactional
protected void doCreate(SignatureKeyPairImpl key) {
final EntityManager manager = managerProvider.get();
manager.persist(key);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-api-resource
@Transactional
protected void doRemove(String id) {
final EntityManager manager = managerProvider.get();
final FreeResourcesLimitImpl resourcesLimit = manager.find(FreeResourcesLimitImpl.class, id);
if (resourcesLimit != null) {
manager.remove(resourcesLimit);
manager.flush();
}
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-api-resource
@Transactional
protected FreeResourcesLimitImpl doGet(String accountId) {
return managerProvider
.get()
.createNamedQuery("FreeResourcesLimit.get", FreeResourcesLimitImpl.class)
.setParameter("accountId", accountId)
.getSingleResult();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-machine-authentication
@Transactional
protected void doRemove(String workspaceId) {
final EntityManager manager = managerProvider.get();
final SignatureKeyPairImpl keyPair = manager.find(SignatureKeyPairImpl.class, workspaceId);
if (keyPair != null) {
manager.remove(keyPair);
manager.flush();
}
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional
protected WorkerImpl doGet(String userId, String instanceId) {
return managerProvider
.get()
.createNamedQuery("Worker.getByUserAndWorkspaceId", WorkerImpl.class)
.setParameter("workspaceId", instanceId)
.setParameter("userId", userId)
.getSingleResult();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional
protected StackPermissionsImpl doGet(String userId, String instanceId) {
if (userId == null) {
return managerProvider
.get()
.createNamedQuery("StackPermissions.getByStackIdPublic", StackPermissionsImpl.class)
.setParameter("stackId", instanceId)
.getSingleResult();
} else {
return managerProvider
.get()
.createNamedQuery("StackPermissions.getByUserAndStackId", StackPermissionsImpl.class)
.setParameter("stackId", instanceId)
.setParameter("userId", userId)
.getSingleResult();
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-installer
@Override
@Transactional
public long getTotalCount() throws InstallerException {
try {
return managerProvider
.get()
.createNamedQuery("Inst.getTotalCount", Long.class)
.getSingleResult();
} catch (RuntimeException x) {
throw new InstallerException(x.getMessage(), x);
}
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-installer
@Transactional
protected void doRemove(InstallerFqn fqn) {
final EntityManager manager = managerProvider.get();
InstallerImpl installer =
manager
.createNamedQuery("Inst.getByKey", InstallerImpl.class)
.setParameter("id", fqn.getId())
.setParameter("version", fqn.getVersion())
.getSingleResult();
manager.remove(installer);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-installer
@Override
@Transactional
public List<String> getVersions(String id) throws InstallerException {
try {
return managerProvider
.get()
.createNamedQuery("Inst.getAllById", InstallerImpl.class)
.setParameter("id", id)
.getResultList()
.stream()
.map(InstallerImpl::getVersion)
.collect(Collectors.toList());
} catch (RuntimeException x) {
throw new InstallerException(x.getMessage(), x);
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-ssh
@Transactional
protected void doRemove(String owner, String service, String name) throws NotFoundException {
EntityManager manager = managerProvider.get();
SshPairImpl entity =
manager.find(SshPairImpl.class, new SshPairPrimaryKey(owner, service, name));
if (entity == null) {
throw new NotFoundException(
format("Ssh pair with service '%s' and name '%s' was not found.", service, name));
}
manager.remove(entity);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-ssh
@Override
@Transactional
public List<SshPairImpl> get(String owner) throws ServerException {
requireNonNull(owner, "Required non-null owner");
try {
return managerProvider
.get()
.createNamedQuery("SshKeyPair.getByOwner", SshPairImpl.class)
.setParameter("owner", owner)
.getResultList();
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-ssh
@Override
@Transactional
public List<SshPairImpl> get(String owner, String service) throws ServerException {
requireNonNull(owner);
requireNonNull(service);
try {
return managerProvider
.get()
.createNamedQuery("SshKeyPair.getByOwnerAndService", SshPairImpl.class)
.setParameter("owner", owner)
.setParameter("service", service)
.getResultList();
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace
@Transactional
protected void doCreate(WorkspaceImpl workspace) {
if (workspace.getConfig() != null) {
workspace.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
EntityManager manager = managerProvider.get();
manager.persist(workspace);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional
protected void doCreate(WorkspaceImpl workspace) {
if (workspace.getConfig() != null) {
workspace.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
EntityManager manager = managerProvider.get();
manager.persist(workspace);
manager.flush();
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional
protected List<StackPermissionsImpl> doGetByUser(@Nullable String userId) throws ServerException {
try {
return managerProvider
.get()
.createNamedQuery("StackPermissions.getByUserId", StackPermissionsImpl.class)
.setParameter("userId", userId)
.getResultList();
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional
protected List<WorkerImpl> doGetByUser(@Nullable String userId) throws ServerException {
try {
return managerProvider
.get()
.createNamedQuery("Worker.getByUserId", WorkerImpl.class)
.setParameter("userId", userId)
.getResultList();
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class})
protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException {
final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id);
if (workspace == null) {
return Optional.empty();
}
final EntityManager manager = managerProvider.get();
eventService
.publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace)))
.propagateException();
manager.remove(workspace);
manager.flush();
return Optional.of(workspace);
}
代码示例来源:origin: org.eclipse.che.multiuser/che-multiuser-permission-workspace
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class})
protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException {
final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id);
if (workspace == null) {
return Optional.empty();
}
final EntityManager manager = managerProvider.get();
eventService
.publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace)))
.propagateException();
manager.remove(workspace);
manager.flush();
return Optional.of(workspace);
}
内容来源于网络,如有侵权,请联系作者删除!