@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 @PerLookup 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.getExtensionByType(LbConfigs.class).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)); } } }
/** * This class will weed out and duplicate implementations of anything populated into the * locator. This service must be put into the ServiceLocator prior to populating from the * inhabitant files, and hence is not annotated with @Service * * @author jwells * @deprecated Use DuplicatePostProcessor instead */ @PerLookup public class ContextDuplicatePostProcessor extends DuplicatePostProcessor implements PopulatorPostProcessor { }
@Service @PerLookup 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.getExtensionByType(LbConfigs.class).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)); } } }
/** * This class will weed out and duplicate implementations of anything populated into the * locator. This service must be put into the ServiceLocator prior to populating from the * inhabitant files, and hence is not annotated with @Service * * @author jwells * @deprecated Use DuplicatePostProcessor instead */ @PerLookup public class ContextDuplicatePostProcessor extends DuplicatePostProcessor implements PopulatorPostProcessor { }
@Service(name="test-upgrade", metadata="mode=debug") @PerLookup public class V2ToV3ConfigUpgradeTester implements AdminCommand, AdminCommandSecurity.AccessCheckProvider { @Inject ServiceLocator habitat; @Inject V2ToV3ConfigUpgrade up; @Override public Collection<? extends AccessCheck> getAccessChecks() { final Collection<AccessCheck> accessChecks = new ArrayList<AccessCheck>(); for (JavaConfig jc : up.getJavaConfigs()) { accessChecks.add(new AccessCheck(jc, "update", true /* isFailureFatal */)); } return accessChecks; } @Override public void execute(AdminCommandContext context) { up.postConstruct(); String msg = "Testing upgrade!"; ActionReport report = context.getActionReport(); report.setActionExitCode(ExitCode.SUCCESS); report.setMessage(msg); } }
@PerLookup @Override public Subject provide() { return SecurityUtils.getSubject(); } }
@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;
@Override @PerLookup public XMLInputFactory provide() { // In JDK 1.6, StAX is part of JRE, so we use no argument variant of // newInstance(), where as on JDK 1.5, we use two argument version of // newInstance() so that we can pass the classloader that loads // XMLInputFactory to load the factory, otherwise by default StAX uses // Thread's context class loader to locate the factory. See: // https://glassfish.dev.java.net/issues/show_bug.cgi?id=6428 return XMLInputFactory.class.getClassLoader() == null ? XMLInputFactory.newInstance() : XMLInputFactory.newInstance(XMLInputFactory.class.getName(), XMLInputFactory.class.getClassLoader()); }
@Service(name = "list-nodes-config") @PerLookup @CommandLock(CommandLock.LockType.NONE) @I18n("list.nodes.config.command") @RestEndpoints({ @RestEndpoint(configBean=Domain.class, opType=RestEndpoint.OpType.GET, public class ListNodesConfigCommand implements AdminCommand{ @Inject Servers servers; @Inject private Nodes nodes; @Param(optional = true, defaultValue = "false", name="long", shortName="l") private boolean long_opt; @Param(optional = true) private boolean terse;
@Rank(Integer.MIN_VALUE) @PerLookup @Override public SecureRandom provide() { return new SecureRandom(); }
@Service(name = "rollback-transaction") @TargetType({CommandTarget.DAS,CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTERED_INSTANCE}) @ExecuteOn(RuntimeType.INSTANCE) @PerLookup @I18n("rollback.transaction") public class RollbackTransaction implements AdminCommand { private static StringManager localStrings = StringManager.getManager(RollbackTransaction.class); @Param(optional = true) String target = SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME; @Param(name = "transaction_id") String txnId; @Inject JavaEETransactionManager transactionMgr;