Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.Attribute


                    attribute = name;
                }
                if (StringUtil.notEmpty(bean) && StringUtil.notEmpty(attribute)) {
                    property.put("annotations", gatherReferencedAttributes(bean, attribute));
                }
                Attribute attr = method.getAnnotation(Attribute.class);
                if (attr != null) {
                    property.put("defaultValue", attr.defaultValue());
                }
                Class<?> type = isGetter
                        ? method.getReturnType()
                        : method.getParameterTypes()[0];
                property.put("type", type);
View Full Code Here


            Resource res = (Resource) configBean;
            return res.getIdentity();
        }
        Method[] methods = configBeanType.getMethods();
        for (Method method : methods) {
            Attribute attributeAnnotation = method.getAnnotation(Attribute.class);
            if ((attributeAnnotation != null) && attributeAnnotation.key()) {
                return (String) method.invoke(configBean);
            }
        }
        return null;
    }
View Full Code Here

                        break;
                    } catch (Exception ex) {
                        RestLogging.restLogger.log(Level.SEVERE, null, ex);
                    }
                } else if (Attribute.class.isAssignableFrom(annotation.getClass())) {
                    Attribute attr = (Attribute)annotation;
                    defval = attr.defaultValue();
                    break;
                }
            }
        }
        return defval;
View Full Code Here

        // System.out.println(" root "+ root );
        Dom dom1 = Dom.unwrap(entity);
        Dom root = dom1.document.getRoot();
        document = dom1.document;

        ConfigModel rootModel = root.model;


        //+ Domain domain = Domain.class.cast(RestService.getHabitat().getComponent(Domain.class.getName(), ""));
        try {
            generateSingle(rootModel);
View Full Code Here

                System.out.println("proxy.getElement(a).isCollection() " + a);
            } else {
                ConfigModel.Node node = (ConfigModel.Node) prop;
                //String childbeanName = getBeanName(a);

                ConfigModel childModel = node.getModel();

                String getterName = getBeanName(a);

                System.out.println("Model.targetTypeName" + model.targetTypeName);
                System.out.println("newModel.targetTypeName" + childModel.targetTypeName);
                System.out.println("ConfigModel.Node node isCollection=" + prop.isCollection());
                System.out.println("ConfigModel.Node node isLeaf=" + prop.isLeaf());
                System.out.println("ConfigModel.Node node xlmname=" + prop.xmlName());
                if (childModel.targetTypeName.endsWith("Named")) {
                    a = "application";
                    getterName = "Applications";
                    try {
                        Class<?> subType = childModel.classLoaderHolder.get().loadClass(childModel.targetTypeName); ///  a shoulf be the typename


                        List<ConfigModel> lcm = document.getAllModelsImplementing(subType);
                        if (lcm != null) {
                            for (ConfigModel childmodel : lcm) {
                                System.out.println("***childmodel.targetTypeName" + childmodel.targetTypeName);
                                if (childmodel.targetTypeName.equals("com.sun.enterprise.config.serverbeans.Application")) {
                                    childModel = childmodel;
                                }
                            }
                        }
                    } catch (Exception e) {
                        Logger.getLogger(GeneratorResource.class.getName()).log(Level.SEVERE, e.getMessage());
                    }


                }

                String childbeanName = childModel.targetTypeName.substring(childModel.targetTypeName.lastIndexOf(".") + 1,
                        childModel.targetTypeName.length());

                if (!childModel.targetTypeName.endsWith("Resource")) {
                    String prefix = "";
                    if (prop.isCollection()) {
                        prefix = "List";
                    }

                    if (a.equals("*")) {
                        getterName = childbeanName + "s";
                    }

                    out.write("\t@Path(\"" + childModel.getTagName() + "/\")\n");
                    out.write("\tpublic " + prefix + childbeanName + "Resource get" + childbeanName + "Resource() {\n");

                    out.write("\t\t" + prefix + childbeanName + "Resource resource = resourceContext.getResource(" + prefix + childbeanName + "Resource.class);\n");
                    out.write("\t\tresource.setEntity(getEntity().get" + getterName + "() );\n");
                    out.write("\t\treturn resource;\n");
View Full Code Here

    private void initialize() throws Exception {
        //System.getProperties().put("com.sun.grizzly.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
        theDomain = domain;
        theMonitoringRegistry = monitoringRegistry;
        ConfigSupport cs =
                RestService.habitat.getComponent(ConfigSupport.class);
        configSupport = cs;
    }
View Full Code Here


        //        DomDocument dodo = RestService.getHabitat().getComponent(DomDocument.class);
        //        Dom root = dodo.getRoot();
        // System.out.println(" root "+ root );
        Dom dom1 = Dom.unwrap(entity);
        Dom root = dom1.document.getRoot();
        document = dom1.document;

        ConfigModel rootModel = root.model;

View Full Code Here

                try {
                    boolean wasAdded = ports.add(Integer.parseInt(val));

                    if (!wasAdded) //TODO unit test
                        throw new TransactionFailure(Strings.get("PortUtils.duplicate_port", val, server.getName()));
                }
                catch(TransactionFailure tf) {
                    // don't re-wrap the same Exception type!
                    throw tf;
                }
                catch (Exception e) {  //TODO unit test
                    throw new TransactionFailure(Strings.get("PortUtils.non_int_port", val, server.getName()));
                }
            }
        }
        checkForLegalPorts(ports, server.getName());
    }
View Full Code Here

     * @return a message if error, nu8ll means A-OK
     */
    private static void checkForLegalPorts(Set<Integer> ports, String serverName) throws TransactionFailure {
        for (int port : ports)
            if (!NetUtils.isPortValid(port))
                throw new TransactionFailure(Strings.get("PortUtils.illegal_port_number", port, serverName, MAX_PORT));
    }
View Full Code Here

    private int convertPortStr(final String port)
            throws TransactionFailure {
        try {
            return Integer.parseInt(port);
        } catch (Exception e) {
            throw new TransactionFailure(
                    strings.get("InvalidPortNumber", port));
        }
    }
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.config.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.