@Service @PerLookup 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); } } }
@Service public class ElasticServiceResolver implements CrudResolver { @Param(name="name") String name; @Inject ElasticServices elasticServices; @Override @SuppressWarnings("unchecked") public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { for (ElasticServiceConfig elasticService : elasticServices.getElasticService()) { if (elasticService.getName().equals(name)) { return (T) elasticService; } } return null; } }
@Service(name = "list-nodes") @Scoped(PerLookup.class) @CommandLock(CommandLock.LockType.NONE) @I18n("list.nodes.command") public class ListNodesCommand implements AdminCommand{ private Nodes nodes; @Param(optional = true, defaultValue = "false", name="long", shortName="l") private boolean long_opt; @Param(optional = true) private boolean terse;
@Service(name="list-lifecycle-modules") @I18n("list.lifecycle.modules") @Scoped(PerLookup.class) @CommandLock(CommandLock.LockType.NONE) @ExecuteOn(value={RuntimeType.DAS}) @TargetType(value={CommandTarget.DOMAIN, CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER}) public class ListLifecycleModulesCommand implements AdminCommand { @Param(primary=true, optional=true) public String target = "server"; @Param(optional=true, defaultValue="false", shortName="t") public Boolean terse = false;
/** * Resolver based on type + name. * * @author Jerome Dochez */ @Service public class TypeAndNameResolver implements CrudResolver { @Param(primary = true) String name; @Inject ServiceLocator habitat; final protected static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(GenericCrudCommand.class); @SuppressWarnings("unchecked") @Override public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { T proxy = (T) habitat.getService(type, name); return proxy; } public String name() { return name; } }
@Service(name = "list-nodes-config") @Scoped(PerLookup.class) @CommandLock(CommandLock.LockType.NONE) @I18n("list.nodes.config.command") public class ListNodesConfigCommand implements AdminCommand{ private Nodes nodes; @Param(optional = true, defaultValue = "false", name="long", shortName="l") private boolean long_opt; @Param(optional = true) private boolean terse;
@Service(name = "list-supported-cipher-suites") @Scoped(PerLookup.class) @CommandLock(CommandLock.LockType.NONE) @I18n("list.supported.cipher.suites") @ExecuteOn({RuntimeType.DAS}) @TargetType({CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTERED_INSTANCE}) public class ListSupportedCipherSuites implements AdminCommand { @Param(optional = true, primary = true, defaultValue = SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME) private String target;
@Service(name = "update-node-ssh") @I18n("update.node.ssh") @PerLookup @ExecuteOn({RuntimeType.DAS}) @RestEndpoints({ @RestEndpoint(configBean=Node.class, opType=RestEndpoint.OpType.POST, }) public class UpdateNodeSshCommand extends UpdateNodeRemoteCommand { @Param(name = "sshport", optional = true) private String sshportInSubClass; @Param(name = "sshuser", optional = true) private String sshuserInSubClass; @Param(name = "sshkeyfile", optional = true) private String sshkeyfileInSubClass; @Param(name = "sshpassword", optional = true, password = true) private String sshpasswordInSubClass; @Param(name = "sshkeypassphrase", optional = true, password = true) private String sshkeypassphraseInSubClass;
@Service public class WithinGroupResolver extends ServerPoolResolver { @Param(primary=true) String name; @Override public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { ServerPoolConfig serverPool = (ServerPoolConfig) super.resolve(context,type); if (serverPool!=null) { MachineConfig mc = serverPool.machineByName(name); if (mc!=null) return (T) mc; context.getActionReport().failure(context.getLogger(), "Cannot find a machine by the name of " + serverPool); } return null; } } }
@Service(name = "list-nodes-ssh") @Scoped(PerLookup.class) @CommandLock(CommandLock.LockType.NONE) @I18n("list.nodes.ssh.command") public class ListNodesSshCommand implements AdminCommand{ private Nodes nodes; @Param(optional = true, defaultValue = "false", name="long", shortName="l") private boolean long_opt; @Param(optional = true) private boolean terse;
@Service @PerLookup abstract class UninstallNodeBaseCommand extends NativeRemoteCommandsBase { @Param(name = "installdir", optional = true, defaultValue = "${com.sun.aas.productRoot}") private String installDir; @Param(optional = true, defaultValue = "false") private boolean force; @Inject private ServiceLocator habitat;
@Service public class MachineResolver implements CrudResolver { @Param(name="serverPool") String serverPool; @Param(name="machine") String machine; @Param(optional = true) String virtualization=null; @Inject Virtualizations virts; @Override public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { Virtualization virt = virtualization==null?virts.getVirtualizations().get(0):virts.byName(virtualization); ServerPoolConfig config = virt.serverPoolByName(serverPool); if (config!=null) { return (T) config.machineByName(machine); } context.getActionReport().failure(context.getLogger(), "Cannot find a machine by the name of " + machine); return null; } }
@Service(name = "_create-node-implicit") @I18n("create.node.implicit") @PerLookup @ExecuteOn({RuntimeType.DAS}) @RestEndpoints({ @RestEndpoint(configBean=Domain.class, opType=RestEndpoint.OpType.POST, public class CreateNodeImplicitCommand implements AdminCommand { @Inject Nodes nodes; @Inject private CommandRunner cr; @Param(name="name", optional= true) String name; @Param(name="nodedir", optional = true) String nodedir; @Param(name="nodehost", primary = true) String nodehost; @Param(name = "installdir") String installdir;