struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4518 Drops unused Struts object factory
Date Tue, 23 Jun 2015 10:27:58 GMT
Repository: struts
Updated Branches:
  refs/heads/master 52b478f59 -> c4f591018


WW-4518 Drops unused Struts object factory


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c4f59101
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c4f59101
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c4f59101

Branch: refs/heads/master
Commit: c4f5910188d65a061f9491a32633740e4368ae2b
Parents: 52b478f
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Jun 23 12:27:51 2015 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Jun 23 12:27:51 2015 +0200

----------------------------------------------------------------------
 .../factory/DefaultInterceptorFactory.java      |  13 ++-
 .../struts2/impl/StrutsObjectFactory.java       | 102 -------------------
 2 files changed, 9 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/c4f59101/core/src/main/java/com/opensymphony/xwork2/factory/DefaultInterceptorFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/factory/DefaultInterceptorFactory.java
b/core/src/main/java/com/opensymphony/xwork2/factory/DefaultInterceptorFactory.java
index 9f0195f..407aa35 100644
--- a/core/src/main/java/com/opensymphony/xwork2/factory/DefaultInterceptorFactory.java
+++ b/core/src/main/java/com/opensymphony/xwork2/factory/DefaultInterceptorFactory.java
@@ -39,11 +39,16 @@ public class DefaultInterceptorFactory implements InterceptorFactory {
 
         try {
             // interceptor instances are long-lived and used across user sessions, so don't
try to pass in any extra context
-            Interceptor interceptor = (Interceptor) objectFactory.buildBean(interceptorClassName,
null);
-            reflectionProvider.setProperties(params, interceptor);
-            interceptor.init();
+            Object o = objectFactory.buildBean(interceptorClassName, null);
+            reflectionProvider.setProperties(params, o);
 
-            return interceptor;
+            if (o instanceof Interceptor) {
+                Interceptor interceptor = (Interceptor) o;
+                interceptor.init();
+                return interceptor;
+            }
+
+            throw new ConfigurationException("Class [" + interceptorClassName + "] does not
implement Interceptor", interceptorConfig);
         } catch (InstantiationException e) {
             cause = e;
             message = "Unable to instantiate an instance of Interceptor class [" + interceptorClassName
+ "].";

http://git-wip-us.apache.org/repos/asf/struts/blob/c4f59101/core/src/main/java/org/apache/struts2/impl/StrutsObjectFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/impl/StrutsObjectFactory.java b/core/src/main/java/org/apache/struts2/impl/StrutsObjectFactory.java
deleted file mode 100644
index 528ee34..0000000
--- a/core/src/main/java/org/apache/struts2/impl/StrutsObjectFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// Copyright 2006 Google Inc. All Rights Reserved.
-
-package org.apache.struts2.impl;
-
-import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.config.entities.InterceptorConfig;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.interceptor.Interceptor;
-import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Instead of overriding the whole class a new {@link com.opensymphony.xwork2.factory.InterceptorFactory}
- * should be defined, thus should be solved in Struts 2.5
- *
- * @deprecated since version 2.3.16
- */
-@Deprecated
-public class StrutsObjectFactory extends ObjectFactory {
-
-    private ReflectionProvider reflectionProvider;
-
-    @Inject
-    public void setReflectionProvider(ReflectionProvider reflectionProvider) {
-        this.reflectionProvider = reflectionProvider;
-    }
-
-    public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map refParams)
-            throws ConfigurationException {
-        String className = interceptorConfig.getClassName();
-
-        Map<String, String> params = new HashMap<>();
-        Map typeParams = interceptorConfig.getParams();
-        if (typeParams != null && !typeParams.isEmpty())
-            params.putAll(typeParams);
-        if (refParams != null && !refParams.isEmpty())
-            params.putAll(refParams);
-
-        try {
-            // interceptor instances are long-lived and used across user sessions, so don't
try to pass in any extra
-            // context
-            Object o = buildBean(className, null);
-            reflectionProvider.setProperties(params, o);
-
-            if (o instanceof Interceptor) {
-                Interceptor interceptor = (Interceptor) o;
-                interceptor.init();
-                return interceptor;
-            }
-
-// This is for the new API:
-//            if (o instanceof org.apache.struts2.spi.Interceptor)
-//                return new InterceptorAdapter((org.apache.struts2.spi.Interceptor) o);
-
-            throw new ConfigurationException(
-                    "Class [" + className + "] does not implement Interceptor", interceptorConfig);
-        } catch (InstantiationException e) {
-            throw new ConfigurationException(
-                    "Unable to instantiate an instance of Interceptor class [" + className
+ "].",
-                    e, interceptorConfig);
-        } catch (IllegalAccessException e) {
-            throw new ConfigurationException(
-                    "IllegalAccessException while attempting to instantiate an instance of
Interceptor class ["
-                            + className + "].",
-                    e, interceptorConfig);
-        } catch (Exception e) {
-            throw new ConfigurationException(
-                    "Caught Exception while registering Interceptor class " + className,
-                    e, interceptorConfig);
-        } catch (NoClassDefFoundError e) {
-            throw new ConfigurationException(
-                    "Could not load class " + className
-                            + ". Perhaps it exists but certain dependencies are not available?",
-                    e, interceptorConfig);
-        }
-    }
-
-}


Mime
View raw message