Package com.opensymphony.xwork2.inject

Examples of com.opensymphony.xwork2.inject.Factory


        final Settings settings = Settings.getInstance();
       
        loadSettings(props, settings);
       
        // Set default locale by lazily resolving the locale property as needed into a Locale object
        builder.factory(Locale.class, new Factory() {
            private Locale locale;

            public synchronized Object create(Context context) throws Exception {
                if (locale == null) {
                    String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
View Full Code Here


  protected void loadButAdd(final Class<?> type, final String name, final Object impl) {
    loadConfigurationProviders(new StubConfigurationProvider() {
      @Override
      public void register(ContainerBuilder builder, LocatableProperties props)
          throws ConfigurationException {
        builder.factory(type, name, new Factory() {
          public Object create(Context context) throws Exception {
            return impl;
          }

        }, Scope.SINGLETON);
View Full Code Here

        final Settings settings = Settings.getInstance();
       
        loadSettings(props, settings);
       
        // Set default locale by lazily resolving the locale property as needed into a Locale object
        builder.factory(Locale.class, new Factory() {
            private Locale locale;

            public synchronized Object create(Context context) throws Exception {
                if (locale == null) {
                    String loc = context.getContainer().getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
View Full Code Here

    protected void loadButAdd(final Class<?> type, final String name, final Object impl) {
        loadConfigurationProviders(new StubConfigurationProvider() {
            @Override
            public void register(ContainerBuilder builder,
                                 LocatableProperties props) throws ConfigurationException {
                builder.factory(type, name, new Factory() {
                    public Object create(Context context) throws Exception {
                        return impl;
                    }

                }, Scope.SINGLETON);
View Full Code Here

        loadConfigurationProviders(new StubConfigurationProvider() {
            @Override
            public void register(ContainerBuilder builder,
                    LocatableProperties props) throws ConfigurationException {
                builder.factory(ObjectTypeDeterminer.class, new Factory() {
                    public Object create(Context context) throws Exception {
                        return new MockObjectTypeDeterminer(null,Cat.class,null,allowAdditions);
                    }
                   
                });
View Full Code Here

        final MockObjectTypeDeterminer determiner = new MockObjectTypeDeterminer(Long.class,Bar.class,"id",true);
        loadConfigurationProviders(new StubConfigurationProvider() {
            @Override
            public void register(ContainerBuilder builder,
                    LocatableProperties props) throws ConfigurationException {
                builder.factory(ObjectTypeDeterminer.class, new Factory() {
                    public Object create(Context context) throws Exception {
                        return determiner;
                    }
                   
                }, Scope.SINGLETON);
View Full Code Here

        FilterDispatcher filterDispatcher = new FilterDispatcher() {
            @Override
            protected Dispatcher createDispatcher(FilterConfig cfg) {
                return new Dispatcher(cfg.getServletContext(), new HashMap()) {
                    Container cont = new ContainerBuilder()
                        .factory(ObjectFactory.class, new Factory() {
                            public Object create(Context context) throws Exception { return destroyedObjectFactory; }
                        })
                        .create(false);
                   
                    @Override
View Full Code Here

    public <T> T getInstance(Class<T> type) {
      try {
        T obj = type.newInstance();
        if (obj instanceof ObjectFactory) {
          ((ObjectFactory) obj).setReflectionProvider(new OgnlReflectionProvider() {

            @Override
            public void setProperties(Map<String, String> properties, Object o) {
            }
View Full Code Here

    if (messageKey == null || StringUtils.isBlank(messageKey) && StringUtils.isNotBlank(defaultValue)) {
      message = StringUtils.capitalize(defaultValue);
    }
    // the titleKey attribute is used
    else {
      OgnlValueStack stack = (OgnlValueStack) TagUtils.getStack(pageContext);
     
      for (Object o : stack.getRoot()) {
        if (o instanceof TextProvider) {
          TextProvider tp = (TextProvider) o;
          message = tp.getText(messageKey, UNDEFINED_KEY + messageKey + UNDEFINED_KEY);
          break;
        }
View Full Code Here

   */
  @Override
  public Locale resolveLocale(HttpServletRequest request) {

    Locale result = null;
    OgnlValueStack stack = (OgnlValueStack) ActionContext.getContext().getValueStack();

    for (Object o : stack.getRoot()) {
      if (o instanceof LocaleProvider) {
        LocaleProvider lp = (LocaleProvider) o;
        result = lp.getLocale();
        break;
      }
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.inject.Factory

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.