Examples of ObjectRecipe


Examples of org.apache.xbean.recipe.ObjectRecipe

                Integer index = attributeIndex.get(argumentName);
                GBeanAttribute attribute = attributes[index];
                cstrTypes[i] = attribute.getType();
            }
        }
        ObjectRecipe objectRecipe = new ObjectRecipe(type, cstrNames.toArray(new String[0]), cstrTypes);
        objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);

        // set the initial attribute values
        Map<String, Object> dataAttributes = gbeanData.getAttributes();
        for (GAttributeInfo attributeInfo : beanInfo.getAttributes()) {
            Integer integer = attributeIndex.get(attributeInfo.getName());
            GBeanAttribute attribute = attributes[integer];
            String attributeName = attribute.getName();
            if (attribute.isPersistent() || attribute.isDynamic()) {
                Object attributeValue = dataAttributes.get(attributeName);
                if (null != attributeValue) {
                    attribute.setPersistentValue(attributeValue);
                }
                if (attribute.isPersistent() && null != attributeValue && !attribute.isDynamic()) {
                    objectRecipe.setProperty(attributeName, attribute.getPersistentValue());
                }
            } else if (attribute.isSpecial() && (attribute.isWritable() || cstrNames.contains(attributeName))) {
                objectRecipe.setProperty(attributeName, attribute.getPersistentValue());
            }
        }
       
        return objectRecipe;
    }
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

                loginContext = ContextManager.login(realmName, callbackHandler);
                clientSubject = loginContext.getSubject();
            }
            ContextManager.setCallers(clientSubject, clientSubject);
            Class mainClass = classLoader.loadClass(mainClassName);
            ObjectRecipe objectRecipe = new ObjectRecipe(mainClass);
            objectRecipe.allow(Option.FIELD_INJECTION);
            objectRecipe.allow(Option.PRIVATE_PROPERTIES);
            objectRecipe.allow(Option.STATIC_PROPERTIES);
            List<Injection> injections = new ArrayList<Injection>();
            while (mainClass != null && mainClass != Object.class) {
                List<Injection> perClass = holder.getInjections(mainClass.getName());
                if (perClass != null) {
                    injections.addAll(perClass);
                }
                mainClass = mainClass.getSuperclass();
            }
            if (injections != null) {
                List<NamingException> problems = new ArrayList<NamingException>();
                for (Injection injection : injections) {
                    String jndiName = injection.getJndiName();
                    try {
                        Object object = componentContext.lookup(jndiName);
                        objectRecipe.setProperty(injection.getTargetName(), object);
                    } catch (NamingException e) {
                        log.info("Injection problem for jndiName: " + jndiName, e);
                        problems.add(e);
                    }
                }
                if (!problems.isEmpty()) {
                    //TODO fix the problems with trying to lookup resource refs from the client.
//                    throw new Exception("Some objects to be injected were not found in jndi: " + problems);
                    log.error("Some objects to be injected were not found in jndi: " + problems);
                }
            }
            Class clazz = objectRecipe.setStaticProperties();
            if (holder.getPostConstruct() != null) {
                Holder.apply(null, clazz, holder.getPostConstruct());
            }

            if (clientSubject == null) {
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

                Integer index = attributeIndex.get(argumentName);
                GBeanAttribute attribute = attributes[index];
                cstrTypes[i] = attribute.getType();
            }
        }
        ObjectRecipe objectRecipe = new ObjectRecipe(type, cstrNames.toArray(new String[0]), cstrTypes);
        objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);

        // set the initial attribute values
        Map<String, Object> dataAttributes = gbeanData.getAttributes();
        for (GAttributeInfo attributeInfo : beanInfo.getAttributes()) {
            Integer integer = attributeIndex.get(attributeInfo.getName());
            GBeanAttribute attribute = attributes[integer];
            String attributeName = attribute.getName();
            if (attribute.isPersistent() || attribute.isDynamic()) {
                Object attributeValue = dataAttributes.get(attributeName);
                if (null != attributeValue) {
                    attribute.setPersistentValue(attributeValue);
                }
                if (attribute.isPersistent() && null != attributeValue && !attribute.isDynamic()) {
                    objectRecipe.setProperty(attributeName, attribute.getPersistentValue());
                }
            } else if (attribute.isSpecial() && (attribute.isWritable() || cstrNames.contains(attributeName))) {
                objectRecipe.setProperty(attributeName, attribute.getPersistentValue());
            }
        }

        return objectRecipe;
    }
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

                && (postConstruct == null || postConstruct.isEmpty())
                && (preDestroy == null || preDestroy.isEmpty());
    }

    public Object newInstance(String className, ClassLoader classLoader, Context context) throws IllegalAccessException, InstantiationException {
        ObjectRecipe objectRecipe = new ObjectRecipe(className);
        objectRecipe.allow(Option.FIELD_INJECTION);
        objectRecipe.allow(Option.PRIVATE_PROPERTIES);
        Class<?> clazz;
        try {
            clazz = classLoader.loadClass(className);
        } catch (ClassNotFoundException e) {
            throw (InstantiationException)new InstantiationException("Can't load class " + className + " in classloader: " + classLoader).initCause(e);
        }
        List<NamingException> problems = new ArrayList<NamingException>();
        while (clazz != Object.class) {
            addInjections(clazz.getName(), context, objectRecipe, problems);
            clazz = clazz.getSuperclass();
        }
        if (!problems.isEmpty()) {
            throw new InstantiationException("Some objects to be injected were not found in jndi: " + problems);
        }
        Object result;
        try {
            result = objectRecipe.create(classLoader);
        } catch (ConstructionException e) {
            throw (InstantiationException)new InstantiationException("Could not construct object").initCause(e);
        }
        // TODO we likely don't want to create a new one each time -- investigate the destroy() method
        OWBInjector beanInjector = new OWBInjector();
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

        for (Map.Entry<QName, String> entry: otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            properties.put(name, entry.getValue());
        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        Engine engine = (Engine) recipe.create(cl);
//        Class<? extends Engine> engineClass = cl.loadClass(className).asSubclass(Engine.class);
//        Engine engine = engineClass.newInstance();
//        engine.setName(name);
//        engine.setDefaultHost(defaultHost);
//        engine.setJvmRoute(jvmRoute);
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

        Map<String, Object> properties = new HashMap<String, Object>();
        for (Map.Entry<QName, String> entry: otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            properties.put(name, entry.getValue());
        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        Server instance = (Server) recipe.create(cl);
        instance.setPort(port);
        instance.setShutdown(shutdown);

        for (ListenerType listenerType : getListener()) {
            LifecycleListener listener = listenerType.getLifecycleListener(cl);
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

        properties.put("name", getName());
        for (Map.Entry<QName, String> entry: otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            properties.put(name, entry.getValue());
        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        Service service = (Service) recipe.create(cl);
        for (ExecutorType executorType: getExecutor()) {
            Executor executor = executorType.getExecutor(cl, kernel);
            service.addExecutor(executor);
            TomcatServerGBean.executors.put(executor.getName(), executor);
        }
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

        // other properties
        if (dataSourceDescription.getProperties() != null) {
            properties.putAll(dataSourceDescription.getProperties());
        }
                                                   
        ObjectRecipe recipe = new ObjectRecipe(clazz, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
           
        Object instance = recipe.create();
           
        Map<String, Object> unset = recipe.getUnsetProperties();
        if (unset != null && !unset.isEmpty()) {
            log.warn("Some DataSource properties were not set {}", unset);
        }
           
        return instance;
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

        }
        for (Map.Entry<QName, String> entry : otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            properties.put(name, entry.getValue());
        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        Host host = (Host) recipe.create(cl);

        for (ListenerType listenerType : getListener()) {
            LifecycleListener listener = listenerType.getLifecycleListener(cl);
            host.addLifecycleListener(listener);
        }
View Full Code Here

Examples of org.apache.xbean.recipe.ObjectRecipe

            properties.put(X_POWERED_BY, getXpoweredBy());
        }
        if (isUseIPVHosts() != null) {
            properties.put(USE_IPVHOSTS, isUseIPVHosts());
        }
        ObjectRecipe recipe = new ObjectRecipe(className, properties);
        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
        recipe.setConstructorArgTypes(new Class[] { String.class });
        recipe.setConstructorArgNames(new String[] { "protocol" });
        Connector connector = (Connector) recipe.create(cl);
        boolean executorSupported = !connector.getProtocolHandlerClassName().equals("org.apache.jk.server.JkCoyoteHandler");
        for (Map.Entry<QName, String> entry : otherAttributes.entrySet()) {
            String name = entry.getKey().getLocalPart();
            String value = entry.getValue();
            if (executorSupported && "executor".equals(name)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.