Search in sources :

Example 61 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class CommandResourceMetaData method getRestRedirectPointToBean.

@SuppressWarnings("unchecked")
public static List<CommandResourceMetaData> getRestRedirectPointToBean(String beanName) {
    synchronized (restRedirects) {
        if (restRedirects.isEmpty()) {
            final ServiceLocator habitat = Globals.getDefaultHabitat();
            processConfigBeans(habitat);
            List<ActiveDescriptor<?>> iter = habitat.getDescriptors(BuilderHelper.createContractFilter(AdminCommand.class.getName()));
            for (ActiveDescriptor<?> ad : iter) {
                if (!(ad.getQualifiers().contains(RestEndpoints.class.getName()))) {
                    continue;
                }
                if (!ad.isReified()) {
                    try {
                        habitat.reifyDescriptor(ad);
                    } catch (MultiException me) {
                        // If we can't see the command, forget it
                        continue;
                    }
                }
                final Class<? extends AdminCommand> clazz = (Class<? extends AdminCommand>) ad.getImplementationClass();
                RestEndpoints endpoints = clazz.getAnnotation(RestEndpoints.class);
                if (endpoints != null) {
                    RestEndpoint[] list = endpoints.value();
                    if ((list != null) && (list.length > 0)) {
                        for (RestEndpoint endpoint : list) {
                            Service service = clazz.getAnnotation(Service.class);
                            String configBean = endpoint.configBean().getSimpleName();
                            CommandResourceMetaData metaData = new CommandResourceMetaData();
                            metaData.command = service.name();
                            metaData.httpMethod = endpoint.opType().name();
                            metaData.resourcePath = endpoint.path().isEmpty() ? service.name() : endpoint.path();
                            metaData.displayName = endpoint.description().isEmpty() ? metaData.resourcePath : endpoint.description();
                            metaData.commandParams = new ParameterMetaData[endpoint.params().length];
                            int index = 0;
                            for (RestParam param : endpoint.params()) {
                                ParameterMetaData currentParam = new ParameterMetaData();
                                metaData.commandParams[index] = currentParam;
                                currentParam.name = param.name();
                                currentParam.value = param.value();
                                index++;
                            }
                            addCommandMetaData(configBean, metaData);
                        }
                    }
                }
            }
        }
    }
    return restRedirects.get(beanName);
}
Also used : ActiveDescriptor(org.glassfish.hk2.api.ActiveDescriptor) Service(org.jvnet.hk2.annotations.Service) RestEndpoints(org.glassfish.api.admin.RestEndpoints) RestEndpoint(org.glassfish.api.admin.RestEndpoint) RestEndpoint(org.glassfish.api.admin.RestEndpoint) RestParam(org.glassfish.api.admin.RestParam) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) AdminCommand(org.glassfish.api.admin.AdminCommand) MultiException(org.glassfish.hk2.api.MultiException)

Example 62 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class HttpServicePropertiesUpgrade method execute.

public void execute(AdminCommandContext context) {
    for (Config config : configs.getConfig()) {
        HttpService service = config.getHttpService();
        if (service == null)
            continue;
        boolean done = false;
        try {
            final List<Property> properties = service.getProperty();
            final Iterator<Property> iterator = properties.iterator();
            while (!done && iterator.hasNext()) {
                final Property property = iterator.next();
                String name = property.getName();
                if ("accessLoggingEnabled".equals(name) || "accessLogBufferSize".equals(name) || "accessLogWriteInterval".equals(name) || "sso-enabled".equals(name)) {
                    done = true;
                    upgrade(context, property, service);
                }
            }
        } catch (TransactionFailure tf) {
            ConfigApiLoggerInfo.getLogger().log(Level.SEVERE, ConfigApiLoggerInfo.ERR_UPGRADE_HTTP_SVC_PROPS, tf);
            throw new RuntimeException(tf);
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) HttpService(com.sun.enterprise.config.serverbeans.HttpService) Property(org.jvnet.hk2.config.types.Property)

Aggregations

TransactionFailure (org.jvnet.hk2.config.TransactionFailure)25 PropertyVetoException (java.beans.PropertyVetoException)21 ActionReport (org.glassfish.api.ActionReport)16 Property (org.jvnet.hk2.config.types.Property)16 Config (com.sun.enterprise.config.serverbeans.Config)14 ArrayList (java.util.ArrayList)8 File (java.io.File)7 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 HashMap (java.util.HashMap)5 Properties (java.util.Properties)5 Service (org.jvnet.hk2.annotations.Service)5 Resources (com.sun.enterprise.config.serverbeans.Resources)4 List (java.util.List)4 Test (org.junit.Test)4 UnprocessedChangeEvent (org.jvnet.hk2.config.UnprocessedChangeEvent)4 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)4 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Domain (com.sun.enterprise.config.serverbeans.Domain)3 HttpService (com.sun.enterprise.config.serverbeans.HttpService)3 Resource (com.sun.enterprise.config.serverbeans.Resource)3