factory

Custom FaceletFactory in JSF 2.2 / Alternatives for virtual host facelets

。_饼干妹妹 提交于 2019-12-18 08:56:22
问题 Since Mojarra/JSF 2.2. it is not possible anymore to provide a custom FaceletFactory using a web.xml context parameter: <context-param> <param-name>com.sun.faces.faceletFactory</param-name> <param-value>my.faces.overrides.MyFaceletFactory</param-value> </context-param> My application provides some CMS features, including virtual host support to serve different pages (facelets) based on the currently requested domain. So http://www.domain1.com/index.xhtml returns different content than http:/

Effective Java By Joshua Bloch: Item1 - Static Factory Method

余生长醉 提交于 2019-12-17 21:52:37
问题 I am reading the Effective Java by Joshua Bloch and I have question about Item1 Static Factory Method . Quote[Bloch, p.7] Interfaces cant have static methods, so by convention, static factory methods for an interface named Type are put in non-instantiable class named Types. For example, the Java Collections Framework, provide unmodifiable collections, synchronized collections, and the like. Nearly all of these implementations are export via static factory methods in one noninstantiable class

C# task factory timeout

耗尽温柔 提交于 2019-12-17 18:54:58
问题 I have to execute a long process operation in a thread and continue by returning the result to a function. Here is my code : Task<ProductEventArgs>.Factory.StartNew(() => { try { // long operation which return new ProductEventArgs with a list of product } catch (Exception e) { return new ProductEventArgs() { E = e }; } }).ContinueWith((x) => handleResult(x.Result), TaskScheduler.FromCurrentSynchronizationContext()); The problem is actually I don't have a timeout. I want to put a timer in

What does java:comp/env/ do?

人盡茶涼 提交于 2019-12-17 07:59:54
问题 I just spent too much time of my day trying to figure out some errors when hooking up some JNDI factory bean. The problem turned out to be that instead of this... <bean id="someId" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/loc"/> </bean> I had actually written this... <bean id="someId" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jdbc/loc"/> </bean> I infer that the java:comp/env/

Pass arguments to Constructor in VBA

橙三吉。 提交于 2019-12-17 02:54:33
问题 How can you construct objects passing arguments directly to your own classes? Something like this: Dim this_employee as Employee Set this_employee = new Employee(name:="Johnny", age:=69) Not being able to do this is very annoying, and you end up with dirty solutions to work this around. 回答1: Here's a little trick I'm using lately and brings good results. I would like to share with those who have to fight often with VBA. 1.- Implement a public initiation subroutine in each of your custom

What is the basic difference between the Factory and Abstract Factory Design Patterns? [closed]

可紊 提交于 2019-12-17 02:07:33
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . What is the basic difference between the Factory and Abstract Factory Patterns? 回答1: With the Factory pattern, you produce instances of implementations ( Apple , Banana , Cherry , etc.) of a particular interface -- say, IFruit . With the Abstract Factory pattern, you provide a way

Spring FactoryBean

北城余情 提交于 2019-12-14 03:43:04
问题 I'm trying to grasp Spring's FactoryBean and I've had and issue. Could you please see my sources below and answer. It's my app context: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www

How to create a generic template based factory?

萝らか妹 提交于 2019-12-14 03:07:24
问题 I am using c++98. I want to create a generic factory which is template based, and the creator can take no parameter to create the target object, or one parameter. /*<class.h> begins #ifndef INCLUDED_CLASS #define INCLUDED_CLASS #include <iostream> #include <boost/shared_ptr.hpp> class A { public: A() { _a = 27; } void print() const { std::cout << "A is " << _a << "." << std::endl; } protected: int _a; }; typedef boost::shared_ptr<A> APtr; class AA : public A { public: void print() const { std

Caching objects built with multiple parameters

南笙酒味 提交于 2019-12-14 03:01:25
问题 I have a factory that creates objects of class MyClass , returning already generated ones when they exist. As I have the creation method ( getOrCreateMyClass ) taking multiple parameters, which is the best way to use a Map to store and retrieve the objects? My current solution is the following, but it doesn't sound too clear to me. I use the hashCode method (slightly modified) of class MyClass to build an int based on the parameters of class MyClass, and I use it as the key of the Map. import

Unity to Resolve By Name

老子叫甜甜 提交于 2019-12-13 18:25:58
问题 I'm trying to get Unity to be my factory in a factory pattern, hence return different implementations of an Interface depending upon the named instance. I have the following code public static class Factory { private static readonly IUnityContainer container; static Factory() { container = new UnityContainer(); container .AddNewExtension<EnterpriseLibraryCoreExtension>() .AddNewExtension<Interception>() .RegisterType<IInterceptionBehavior, LoggingBehaviour>() //register the implemantation1