org.jvnet.hk2.annotations.Scoped类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中org.jvnet.hk2.annotations.Scoped类的一些代码示例,展示了Scoped类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scoped类的具体详情如下:
包路径:org.jvnet.hk2.annotations.Scoped
类名称:Scoped

Scoped介绍

暂无

代码示例

代码示例来源:origin: org.glassfish.admin/config-api

@Service
  @Scoped(PerLookup.class)
  public class CrDecorator implements CreationDecorator<SecureAdminInternalUser> {

    @Param(optional=false, primary=true)
    private String username;
    
    @Param(optional=false)
    private String passwordAlias;
    
    @Inject
    private SecureAdminHelper helper;
    
    @Override
    public void decorate(AdminCommandContext context, SecureAdminInternalUser instance) throws TransactionFailure, PropertyVetoException {
      
      try {
        helper.validateInternalUsernameAndPasswordAlias(
            username, passwordAlias);
      } catch (Exception ex) {
        throw new TransactionFailure("create", ex);
      }
      instance.setUsername(username);
      instance.setPasswordAlias(passwordAlias);
    }
    
  }
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

/**
 * Start a stopped virtual machine.
 * @author Jerome Dochez
 */
@Service(name="start-vm")
@Scoped(PerLookup.class)
public class StartVirtualMachine extends VirtualMachineMgt implements AdminCommand {
  @Inject
  VirtualMachineLifecycle vmLifecycle;

  @Override
  void doWork(VirtualMachine vm) throws VirtException {
    vmLifecycle.start(vm);
  }
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

/**
 * Stop a running virtual machine
 * @author Jerome Dochez
 */
@Service(name="stop-vm")
@Scoped(PerLookup.class)
public class StopVirtualMachine extends VirtualMachineMgt implements AdminCommand {

  @Override
  void doWork(VirtualMachine vm) throws VirtException {
    vm.stop();
  }
}

代码示例来源:origin: org.glassfish.admin/admin-cli

@Service(name = "unset")
@Scoped(PerLookup.class)
public class UnsetCommand extends CLICommand {
  @Param(name = "environment-variable", primary = true, multiple = true)
  private List<String> vars;

代码示例来源:origin: org.glassfish.admin/admin-cli

if (scoped == null) {
    throw new CommandException(strings.get("NoScope", name));
  } else if (scoped.value() == Singleton.class) {
  if (opt.getParam().password())
    continue;       // passwords are handled later
if (opt.getParam().obsolete() && getOption(opt.getName()) != null)
logger.info(
  strings.get("ObsoleteOption", opt.getName()));
  if (opt.getParam().optional())
    continue;
  if (opt.getParam().primary())

代码示例来源:origin: com.sun.enterprise/auto-depends

/**
 * {@link Scope} local to each invocation.
 *
 * <p>
 * Components in this scope will create new instances every time someone asks for it. 
 *
 * @author Kohsuke Kawaguchi
 */
@Scoped(Singleton.class)
public class PerLookup extends Scope {
  @Override
  public ScopeInstance current() {
    return new ScopeInstance(new HashMap());
  }
}

代码示例来源:origin: com.sun.enterprise/auto-depends

/**
 * Creates a {@link Inhabitant} by wrapping {@link Creator} to handle scoping right.
 */
public static <T> Inhabitant<T> wrapByScope(Class<T> c, Creator<T> creator, Habitat habitat) {
  Scoped scoped = c.getAnnotation(Scoped.class);
  if (scoped==null) {
    return new SingletonInhabitant<T>(creator); // treated as singleton
  }
  Class<? extends Scope> scopeClass = scoped.value();
  return wrapByScope(creator, habitat, scopeClass);
}

代码示例来源:origin: org.glassfish.admin/config-api

@Service
  @Scoped(PerLookup.class)
  class DeleteDecorator implements DeletionDecorator<LbConfigs, LbConfig> {
    @Inject
    private Domain domain;

    @Override
    public void decorate(AdminCommandContext context, LbConfigs parent, LbConfig child)
        throws PropertyVetoException, TransactionFailure {
      Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER);
      LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class);

      String lbConfigName = child.getName();
      LbConfig lbConfig = domain.getLbConfigs().getLbConfig(lbConfigName);

      //Ensure there are no refs 
      if ( (lbConfig.getClusterRefOrServerRef().size() != 0 ) ) {
        String msg = localStrings.getLocalString("LbConfigNotEmpty", lbConfigName);
        throw new TransactionFailure(msg);
      }
      logger.info(localStrings.getLocalString("http_lb_admin.LbConfigDeleted", lbConfigName));
    }
  }
}

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

/**
 * suspend a running virtual machine.
 * @author Jerome Dochez
 */
@Service(name="suspend-vm")
@Scoped(PerLookup.class)
public class SuspendVirtualMachine extends VirtualMachineMgt implements AdminCommand {
  @Override
  void doWork(VirtualMachine vm) throws VirtException {
    vm.suspend();
  }
}

代码示例来源:origin: com.sun.enterprise/auto-depends

/**
 * Singleton scope.
 *
 * @author Kohsuke Kawaguchi
 */
@Scoped(Singleton.class)
public class Singleton extends Scope {
  /**
   * @deprecated
   *  Singleton instances are not stored in a single map.
   */
  @Override
  public ScopeInstance current() {
    throw new UnsupportedOperationException();
  }
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

/**
 * Creates a {@link Inhabitant} by wrapping {@link Creator} to handle scoping right.
 */
public static <T> Inhabitant<T> wrapByScope(Class<T> c, Creator<T> creator, Habitat habitat) {
  Scoped scoped = c.getAnnotation(Scoped.class);
  if (scoped==null) {
    return new SingletonInhabitant<T>(creator); // treated as singleton
  }
  Class<? extends Scope> scopeClass = scoped.value();
  return wrapByScope(creator, habitat, scopeClass);
}

代码示例来源:origin: org.glassfish.admin/config-api

@Service
@Scoped(PerLookup.class)
public static class CrDecorator implements CreationDecorator<SecureAdminPrincipal> {
  @Inject(/*name=CREATION_DECORATOR_NAME*/)
  private SecureAdminHelper helper;
  @Param(optional=false, name="value", primary=true)
  private String value;
  @Param(optional=true, name="alias", defaultValue="false")
  private boolean isAlias = true;

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

/**
 * List existing virtual machines
 * @author Jerome Dochez
 */
@Service(name="list-vms")
@Scoped(PerLookup.class)
public class ListVirtualMachines implements AdminCommand {

  @Inject
  IAAS gm;

  @Override
  public void execute(AdminCommandContext context) {
    //To change body of implemented methods use File | Settings | File Templates.
    try {
      for (ServerPool group : gm) {
        context.getActionReport().setMessage("For Group : " + group.getName());
        for (VirtualMachine vm : group.getVMs()) {
          context.getActionReport().getTopMessagePart().addChild().setMessage(
              "Virtual Machine: " + vm.getName() + " is "  + vm.getInfo().getState());
        }
      }
    } catch(VirtException e) {
      context.getActionReport().failure(Logger.getAnonymousLogger(), "Exception while listing machines ", e);
    }
  }
}

代码示例来源:origin: org.glassfish.common/container-common

@Service
@Scoped(Singleton.class)
public class DummyCallFlowAgentImpl
  implements CallFlowAgent {

  public boolean isEnabled() {return false;}

  public void entityManagerMethodStart(EntityManagerMethod val) {}

  public void entityManagerMethodEnd() {}

  public void entityManagerQueryStart(EntityManagerQueryMethod val) {}

  public void entityManagerQueryEnd() {}
}

代码示例来源:origin: org.glassfish.admin/admin-util

/**
 *
 * @author PRASHANTH ABBAGANI
 * 
 * Factory class which returns the appropriate ResourceManager
 */
@Service(name="resource-factory")
@Scoped(PerLookup.class)
@I18n("add.resources")
public class ResourceFactory {

  @Inject
  private Habitat habitat;

  public ResourceManager getResourceManager(Resource resource) {
    String resourceType = resource.getType();

    ResourceManager resourceManager = null;
    for (ResourceManager rm : habitat.getAllByContract(ResourceManager.class)) {
      if ((rm.getResourceType()).equals(resourceType)) {
        resourceManager = rm;
        break;
      }
    }

    return resourceManager;
  }
  
}

代码示例来源:origin: org.glassfish.deployment/dol

@Service
@Scoped(PerLookup.class)
public class WLApplicationArchivist extends ExtensionsArchivist {
  @Inject
  private Habitat habitat;

代码示例来源:origin: org.glassfish.main.virtualization/virt-core

/**
 * resume a suspended virtual machine
 * @author Jerome Dochez
 */
@Service(name="resume-vm")
@Scoped(PerLookup.class)
public class ResumeVirtualMachine extends VirtualMachineMgt implements AdminCommand {
  @Override
  void doWork(VirtualMachine vm) throws VirtException {
    vm.resume();
  }
}

代码示例来源:origin: org.glassfish.security/realms

@Service(name="list-auth-realms")
@Scoped(PerLookup.class)
@I18n("list.auth.realm")
public class ListAuthRealm implements AdminCommand {
    new LocalStringManagerImpl(ListAuthRealm.class);    
  @Param(optional=true)
  String target;
  @Inject
  Configs configs;

代码示例来源:origin: org.glassfish.main/paas.orchestrator

@Service
@Scoped(PerLookup.class)
public class RemoteCommandExecutor {
  @Inject
  private SSHLauncher sshLauncher;
  @Inject
  private Logger logger;

代码示例来源:origin: org.glassfish.deployment/dol

/**
 * Scans for annotations relevant to persistence units that indicate an app
 * client depends on at least one persistence unit.
 *
 * @author tjquinn
 */
@Service(name="car")
@Scoped(Singleton.class)
public class AppClientPersistenceDependencyAnnotationScanner extends AbstractAnnotationScanner {

  protected void init(java.util.Set<String> annotationsSet) {
    annotationsSet.add("Ljavax/persistence/PersistenceUnit");
    annotationsSet.add("Ljavax/persistence/PersistenceUnits");
  }
  
}

相关文章