You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/01/08 20:41:33 UTC
svn commit: r732803 [8/17] - in
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
./ annotation/ component/ component/ejb/ component/jms/ component/xml/
config/ container/ context/ context/type/ decorator/ decorator/xml/ de...
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableField.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject;
@@ -35,70 +32,70 @@
*/
public class InjectableField extends AbstractInjectable
{
- protected Field field;
- protected Object instance;
+ protected Field field;
+ protected Object instance;
- public InjectableField(Field field, Object instance, AbstractComponent<?> owner)
- {
- super(owner);
- this.field = field;
- this.instance = instance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.webbeans.inject.Injectable#doInjection()
- */
- public Object doInjection()
- {
- Type type = field.getGenericType();
-
- Annotation[] annots = field.getAnnotations();
-
- annots = AnnotationUtil.getBindingAnnotations(annots);
-
- try
- {
- if (annots.length == 0)
- {
- annots = new Annotation[1];
- annots[0] = new CurrentLiteral();
- }
-
- if (!ClassUtil.isPublic(field.getModifiers()))
- {
- field.setAccessible(true);
- }
-
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
-
- checkParametrizedTypeForInjectionPoint(pt);
- args = new Type[1];
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- } else
- {
- clazz = (Class<?>) type;
- }
-
- if(!field.isAccessible())
- {
- field.setAccessible(true);
- }
-
- field.set(instance, inject(clazz, args, annots));
-
- } catch (Exception e)
- {
- throw new WebBeansException(e);
- }
+ public InjectableField(Field field, Object instance, AbstractComponent<?> owner)
+ {
+ super(owner);
+ this.field = field;
+ this.instance = instance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.inject.Injectable#doInjection()
+ */
+ public Object doInjection()
+ {
+ Type type = field.getGenericType();
+
+ Annotation[] annots = field.getAnnotations();
+
+ annots = AnnotationUtil.getBindingAnnotations(annots);
+
+ try
+ {
+ if (annots.length == 0)
+ {
+ annots = new Annotation[1];
+ annots[0] = new CurrentLiteral();
+ }
+
+ if (!ClassUtil.isPublic(field.getModifiers()))
+ {
+ field.setAccessible(true);
+ }
+
+ Type[] args = new Type[0];
+ Class<?> clazz = null;
+ if (type instanceof ParameterizedType)
+ {
+ ParameterizedType pt = (ParameterizedType) type;
+
+ checkParametrizedTypeForInjectionPoint(pt);
+ args = new Type[1];
+ args = pt.getActualTypeArguments();
+
+ clazz = (Class<?>) pt.getRawType();
+ } else
+ {
+ clazz = (Class<?>) type;
+ }
+
+ if (!field.isAccessible())
+ {
+ field.setAccessible(true);
+ }
+
+ field.set(instance, inject(clazz, args, annots));
+
+ } catch (Exception e)
+ {
+ throw new WebBeansException(e);
+ }
- return null;
- }
+ return null;
+ }
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject;
@@ -32,86 +29,84 @@
@SuppressWarnings("unchecked")
public class InjectableMethods<T> extends AbstractInjectable
{
- /** Injectable method */
- protected Method m;
+ /** Injectable method */
+ protected Method m;
- /** Component instance that owns the method */
- protected Object instance;
+ /** Component instance that owns the method */
+ protected Object instance;
- /**
- * Constructs new instance.
- *
- * @param m
- * injectable method
- * @param instance
- * component instance
- */
- public InjectableMethods(Method m, Object instance, AbstractComponent<?> owner)
- {
- super(owner);
- this.m = m;
- this.instance = instance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.webbeans.inject.Injectable#doInjection()
- */
- public T doInjection()
- {
- Type[] types = m.getGenericParameterTypes();
- Annotation[][] annots = m.getParameterAnnotations();
- List<Object> list = new ArrayList<Object>();
- if (types.length > 0)
- {
- int i = 0;
- for (Type type : types)
- {
- Annotation[] annot = annots[i];
- if (annot.length == 0)
- {
- annot = new Annotation[1];
- annot[0] = new CurrentLiteral();
- }
-
- Type[] args = new Type[0];
- Class<?> clazz = null;
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pt = (ParameterizedType) type;
-
- checkParametrizedTypeForInjectionPoint(pt);
- args = new Type[1];
- args = pt.getActualTypeArguments();
-
- clazz = (Class<?>) pt.getRawType();
- } else
- {
- clazz = (Class<?>) type;
- }
-
- list.add(inject(clazz, args, AnnotationUtil.getBindingAnnotations(annot)));
-
- i++;
-
- }
-
- }
-
- try
- {
- if (!ClassUtil.isPublic(m.getModifiers()))
- {
- m.setAccessible(true);
- }
-
- return (T) m.invoke(instance, list.toArray());
-
- } catch (Exception e)
- {
- throw new WebBeansException(e);
- }
- }
+ /**
+ * Constructs new instance.
+ *
+ * @param m injectable method
+ * @param instance component instance
+ */
+ public InjectableMethods(Method m, Object instance, AbstractComponent<?> owner)
+ {
+ super(owner);
+ this.m = m;
+ this.instance = instance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.inject.Injectable#doInjection()
+ */
+ public T doInjection()
+ {
+ Type[] types = m.getGenericParameterTypes();
+ Annotation[][] annots = m.getParameterAnnotations();
+ List<Object> list = new ArrayList<Object>();
+ if (types.length > 0)
+ {
+ int i = 0;
+ for (Type type : types)
+ {
+ Annotation[] annot = annots[i];
+ if (annot.length == 0)
+ {
+ annot = new Annotation[1];
+ annot[0] = new CurrentLiteral();
+ }
+
+ Type[] args = new Type[0];
+ Class<?> clazz = null;
+ if (type instanceof ParameterizedType)
+ {
+ ParameterizedType pt = (ParameterizedType) type;
+
+ checkParametrizedTypeForInjectionPoint(pt);
+ args = new Type[1];
+ args = pt.getActualTypeArguments();
+
+ clazz = (Class<?>) pt.getRawType();
+ } else
+ {
+ clazz = (Class<?>) type;
+ }
+
+ list.add(inject(clazz, args, AnnotationUtil.getBindingAnnotations(annot)));
+
+ i++;
+
+ }
+
+ }
+
+ try
+ {
+ if (!ClassUtil.isPublic(m.getModifiers()))
+ {
+ m.setAccessible(true);
+ }
+
+ return (T) m.invoke(instance, list.toArray());
+
+ } catch (Exception e)
+ {
+ throw new WebBeansException(e);
+ }
+ }
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableConstructor.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject.xml;
@@ -30,73 +27,76 @@
public class XMLInjectableConstructor<T> extends InjectableConstructor<T>
{
- private Constructor<T> constructor;
-
- private List<XMLInjectionPointModel> injectionPointModelList = new ArrayList<XMLInjectionPointModel>();
-
-
- public XMLInjectableConstructor(Constructor<T> constructor, AbstractComponent<?> owner)
- {
- super(constructor,owner);
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.webbeans.inject.InjectableConstructor#doInjection()
- */
- @Override
- @SuppressWarnings("unchecked")
- public T doInjection()
- {
- T instance = null;
- List<Object> list = new ArrayList<Object>();
-
- Iterator<XMLInjectionPointModel> it = this.injectionPointModelList.iterator();
- while(it.hasNext())
- {
- XMLInjectionPointModel model = it.next();
- Annotation[] anns = new Annotation[model.getBindingTypes().size()];
- anns = model.getBindingTypes().toArray(anns);
-
- list.add(inject(model.getInjectionClassType(), model.getActualTypeArguments(),anns));
- }
-
- try
- {
- if (!EJBUtil.isEJBSessionClass(con.getDeclaringClass()))
- {
- instance = con.newInstance(list.toArray());
-
-// if(getInjectionOwnerComponent().getScopeType().equals(Dependent.class))
-// {
-//
-// }
-// else
-// {
-// instance = (T) JavassistProxyFactory.createNewProxyInstance(con.getDeclaringClass(), con.getParameterTypes(), list.toArray(), getInjectionOwnerComponent());
-// }
- }
-
- } catch (Throwable e)
- {
- e.printStackTrace();
- throw new WebBeansException(e);
- }
-
- return instance;
- }
-
- /**
- * @return the constructor
- */
- public Constructor<T> getConstructor()
- {
- return constructor;
- }
-
- public void addInjectionPointModel(XMLInjectionPointModel model)
- {
- Asserts.assertNotNull(model, "model parameter can not be null");
- this.injectionPointModelList.add(model);
- }
+ private Constructor<T> constructor;
+
+ private List<XMLInjectionPointModel> injectionPointModelList = new ArrayList<XMLInjectionPointModel>();
+
+ public XMLInjectableConstructor(Constructor<T> constructor, AbstractComponent<?> owner)
+ {
+ super(constructor, owner);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.inject.InjectableConstructor#doInjection()
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public T doInjection()
+ {
+ T instance = null;
+ List<Object> list = new ArrayList<Object>();
+
+ Iterator<XMLInjectionPointModel> it = this.injectionPointModelList.iterator();
+ while (it.hasNext())
+ {
+ XMLInjectionPointModel model = it.next();
+ Annotation[] anns = new Annotation[model.getBindingTypes().size()];
+ anns = model.getBindingTypes().toArray(anns);
+
+ list.add(inject(model.getInjectionClassType(), model.getActualTypeArguments(), anns));
+ }
+
+ try
+ {
+ if (!EJBUtil.isEJBSessionClass(con.getDeclaringClass()))
+ {
+ instance = con.newInstance(list.toArray());
+
+ // if(getInjectionOwnerComponent().getScopeType().equals(Dependent.class))
+ // {
+ //
+ // }
+ // else
+ // {
+ // instance = (T)
+ // JavassistProxyFactory.createNewProxyInstance(con.getDeclaringClass(),
+ // con.getParameterTypes(), list.toArray(),
+ // getInjectionOwnerComponent());
+ // }
+ }
+
+ } catch (Throwable e)
+ {
+ e.printStackTrace();
+ throw new WebBeansException(e);
+ }
+
+ return instance;
+ }
+
+ /**
+ * @return the constructor
+ */
+ public Constructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ public void addInjectionPointModel(XMLInjectionPointModel model)
+ {
+ Asserts.assertNotNull(model, "model parameter can not be null");
+ this.injectionPointModelList.add(model);
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableField.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject.xml;
@@ -25,38 +22,39 @@
public class XMLInjectableField extends InjectableField
{
- private XMLInjectionPointModel injectionPointModel = null;
+ private XMLInjectionPointModel injectionPointModel = null;
- public XMLInjectableField(Field field, Object instance, AbstractComponent<?> owner, XMLInjectionPointModel model)
- {
- super(field, instance, owner);
- this.injectionPointModel = model;
- }
-
- /* (non-Javadoc)
- * @see org.apache.webbeans.inject.InjectableField#doInjection()
- */
- @Override
- public Object doInjection()
- {
- Annotation[] anns = new Annotation[this.injectionPointModel.getBindingTypes().size()];
- anns = this.injectionPointModel.getBindingTypes().toArray(anns);
-
- try
- {
- if(!field.isAccessible())
- {
- field.setAccessible(true);
- }
-
- field.set(instance, inject(this.injectionPointModel.getInjectionClassType(), this.injectionPointModel.getActualTypeArguments(), anns));
-
- }catch(Exception e)
- {
- throw new WebBeansException(e);
- }
-
-
- return null;
- }
+ public XMLInjectableField(Field field, Object instance, AbstractComponent<?> owner, XMLInjectionPointModel model)
+ {
+ super(field, instance, owner);
+ this.injectionPointModel = model;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.inject.InjectableField#doInjection()
+ */
+ @Override
+ public Object doInjection()
+ {
+ Annotation[] anns = new Annotation[this.injectionPointModel.getBindingTypes().size()];
+ anns = this.injectionPointModel.getBindingTypes().toArray(anns);
+
+ try
+ {
+ if (!field.isAccessible())
+ {
+ field.setAccessible(true);
+ }
+
+ field.set(instance, inject(this.injectionPointModel.getInjectionClassType(), this.injectionPointModel.getActualTypeArguments(), anns));
+
+ } catch (Exception e)
+ {
+ throw new WebBeansException(e);
+ }
+
+ return null;
+ }
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectableMethods.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject.xml;
@@ -28,47 +25,49 @@
public class XMLInjectableMethods<T> extends InjectableMethods<T>
{
- private List<XMLInjectionPointModel> injectionPointModelList = new ArrayList<XMLInjectionPointModel>();
-
- public XMLInjectableMethods(Method m, Object instance, AbstractComponent<?> owner, List<XMLInjectionPointModel> injectionPointModelList)
- {
- super(m, instance, owner);
- this.injectionPointModelList = injectionPointModelList;
- }
-
- /* (non-Javadoc)
- * @see org.apache.webbeans.inject.InjectableMethods#doInjection()
- */
- @Override
- @SuppressWarnings("unchecked")
- public T doInjection()
- {
- List<Object> list = new ArrayList<Object>();
-
- Iterator<XMLInjectionPointModel> it = this.injectionPointModelList.iterator();
- while(it.hasNext())
- {
- XMLInjectionPointModel model = it.next();
- Annotation[] anns = new Annotation[model.getBindingTypes().size()];
- anns = model.getBindingTypes().toArray(anns);
-
- list.add(inject(model.getInjectionClassType(), model.getActualTypeArguments(),anns));
- }
-
- try
- {
- if (!ClassUtil.isPublic(m.getModifiers()))
- {
- m.setAccessible(true);
- }
-
- return (T) m.invoke(instance, list.toArray());
-
- } catch (Throwable e)
- {
- // no-op
- e.printStackTrace();
- }
- return null;
- }
+ private List<XMLInjectionPointModel> injectionPointModelList = new ArrayList<XMLInjectionPointModel>();
+
+ public XMLInjectableMethods(Method m, Object instance, AbstractComponent<?> owner, List<XMLInjectionPointModel> injectionPointModelList)
+ {
+ super(m, instance, owner);
+ this.injectionPointModelList = injectionPointModelList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.inject.InjectableMethods#doInjection()
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public T doInjection()
+ {
+ List<Object> list = new ArrayList<Object>();
+
+ Iterator<XMLInjectionPointModel> it = this.injectionPointModelList.iterator();
+ while (it.hasNext())
+ {
+ XMLInjectionPointModel model = it.next();
+ Annotation[] anns = new Annotation[model.getBindingTypes().size()];
+ anns = model.getBindingTypes().toArray(anns);
+
+ list.add(inject(model.getInjectionClassType(), model.getActualTypeArguments(), anns));
+ }
+
+ try
+ {
+ if (!ClassUtil.isPublic(m.getModifiers()))
+ {
+ m.setAccessible(true);
+ }
+
+ return (T) m.invoke(instance, list.toArray());
+
+ } catch (Throwable e)
+ {
+ // no-op
+ e.printStackTrace();
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectionPointModel.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectionPointModel.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectionPointModel.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/xml/XMLInjectionPointModel.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.inject.xml;
@@ -26,165 +23,167 @@
import org.apache.webbeans.util.ClassUtil;
/**
- * Defines the model that is related with injection point decleration.
- * Each injection point decleration defined in the XML file defines
- * the injection point API type and Binding type annotations.
- *
+ * Defines the model that is related with injection point decleration. Each
+ * injection point decleration defined in the XML file defines the injection
+ * point API type and Binding type annotations.
* <p>
- * If injection point is a parametrized type, actual type arguments
- * are defined in the XML file. See specification for further details.
+ * If injection point is a parametrized type, actual type arguments are defined
+ * in the XML file. See specification for further details.
* </p>
*
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
public class XMLInjectionPointModel
-{
- /**Injection point raw/actual class type*/
- private Class<?> injectionClassType;
-
- /**This injection point is parametrized*/
- private boolean parametrized;
-
- /**Actual type arguments defined in the XML*/
- private Type[] actualTypeArguments = new Type[0];
-
- /**Injection point binding types*/
- private Set<Annotation> bindingTypes = new HashSet<Annotation>();
-
- /**This injection model is array*/
- private boolean array;
-
-
- public XMLInjectionPointModel(Class<?> arrayElementType)
- {
- this.array = true;
- this.injectionClassType = arrayElementType;
- }
-
- /**
- * Creates new injection point model.
- *
- * @param injectionClassType injection point class type
- * @param actualTypeArguments injection point actual type arguments
- */
- public XMLInjectionPointModel(Class<?> injectionClassType, Type[] actualTypeArguments)
- {
- this.injectionClassType = injectionClassType;
-
- if(actualTypeArguments != null && actualTypeArguments.length > 0)
- {
- this.actualTypeArguments = actualTypeArguments;
- }
-
- if(ClassUtil.isParametrized(this.injectionClassType))
- {
- this.parametrized = true;
- }
- }
-
- /**
- * Add new binding type annotation to the injection point.
- *
- * @param bindingType new binding type annotation
- */
- public void addBindingType(Annotation bindingType)
- {
- this.bindingTypes.add(bindingType);
- }
-
- /**
- * Gets injection point class type.
- *
- * @return the injectionClassType
- */
- public Class<?> getInjectionClassType()
- {
- return injectionClassType;
- }
-
- /**
- * Returns the injection point is parametrized type.
- *
- * @return the parametrized
- */
- public boolean isParametrized()
- {
- return parametrized;
- }
-
- /**
- * Gets actual type arguments.
- *
- * @return the actualTypeArguments
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
- * Gets unmodifiable binding types of the injection point.
- *
- * @return the bindingTypes
- */
- public Set<Annotation> getBindingTypes()
- {
- return Collections.unmodifiableSet(this.bindingTypes);
- }
-
- /**
- * @return the array
- */
- public boolean isArray()
- {
- return array;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + Arrays.hashCode(actualTypeArguments);
- result = prime * result + ((bindingTypes == null) ? 0 : bindingTypes.hashCode());
- result = prime * result + ((injectionClassType == null) ? 0 : injectionClassType.hashCode());
- result = prime * result + (parametrized ? 1231 : 1237);
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final XMLInjectionPointModel other = (XMLInjectionPointModel) obj;
- if (!Arrays.equals(actualTypeArguments, other.actualTypeArguments))
- return false;
- if (bindingTypes == null)
- {
- if (other.bindingTypes != null)
- return false;
- } else if (!bindingTypes.equals(other.bindingTypes))
- return false;
- if (injectionClassType == null)
- {
- if (other.injectionClassType != null)
- return false;
- } else if (!injectionClassType.equals(other.injectionClassType))
- return false;
- if (parametrized != other.parametrized)
- return false;
- return true;
- }
+{
+ /** Injection point raw/actual class type */
+ private Class<?> injectionClassType;
+
+ /** This injection point is parametrized */
+ private boolean parametrized;
+
+ /** Actual type arguments defined in the XML */
+ private Type[] actualTypeArguments = new Type[0];
+
+ /** Injection point binding types */
+ private Set<Annotation> bindingTypes = new HashSet<Annotation>();
+
+ /** This injection model is array */
+ private boolean array;
+
+ public XMLInjectionPointModel(Class<?> arrayElementType)
+ {
+ this.array = true;
+ this.injectionClassType = arrayElementType;
+ }
+
+ /**
+ * Creates new injection point model.
+ *
+ * @param injectionClassType injection point class type
+ * @param actualTypeArguments injection point actual type arguments
+ */
+ public XMLInjectionPointModel(Class<?> injectionClassType, Type[] actualTypeArguments)
+ {
+ this.injectionClassType = injectionClassType;
+
+ if (actualTypeArguments != null && actualTypeArguments.length > 0)
+ {
+ this.actualTypeArguments = actualTypeArguments;
+ }
+
+ if (ClassUtil.isParametrized(this.injectionClassType))
+ {
+ this.parametrized = true;
+ }
+ }
+
+ /**
+ * Add new binding type annotation to the injection point.
+ *
+ * @param bindingType new binding type annotation
+ */
+ public void addBindingType(Annotation bindingType)
+ {
+ this.bindingTypes.add(bindingType);
+ }
+
+ /**
+ * Gets injection point class type.
+ *
+ * @return the injectionClassType
+ */
+ public Class<?> getInjectionClassType()
+ {
+ return injectionClassType;
+ }
+
+ /**
+ * Returns the injection point is parametrized type.
+ *
+ * @return the parametrized
+ */
+ public boolean isParametrized()
+ {
+ return parametrized;
+ }
+
+ /**
+ * Gets actual type arguments.
+ *
+ * @return the actualTypeArguments
+ */
+ public Type[] getActualTypeArguments()
+ {
+ return actualTypeArguments;
+ }
+
+ /**
+ * Gets unmodifiable binding types of the injection point.
+ *
+ * @return the bindingTypes
+ */
+ public Set<Annotation> getBindingTypes()
+ {
+ return Collections.unmodifiableSet(this.bindingTypes);
+ }
+
+ /**
+ * @return the array
+ */
+ public boolean isArray()
+ {
+ return array;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(actualTypeArguments);
+ result = prime * result + ((bindingTypes == null) ? 0 : bindingTypes.hashCode());
+ result = prime * result + ((injectionClassType == null) ? 0 : injectionClassType.hashCode());
+ result = prime * result + (parametrized ? 1231 : 1237);
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final XMLInjectionPointModel other = (XMLInjectionPointModel) obj;
+ if (!Arrays.equals(actualTypeArguments, other.actualTypeArguments))
+ return false;
+ if (bindingTypes == null)
+ {
+ if (other.bindingTypes != null)
+ return false;
+ } else if (!bindingTypes.equals(other.bindingTypes))
+ return false;
+ if (injectionClassType == null)
+ {
+ if (other.injectionClassType != null)
+ return false;
+ } else if (!injectionClassType.equals(other.injectionClassType))
+ return false;
+ if (parametrized != other.parametrized)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorComparator.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -25,25 +22,22 @@
public class InterceptorComparator implements Comparator<Interceptor>
{
- public int compare(Interceptor o1, Interceptor o2)
- {
- WebBeansInterceptor src = (WebBeansInterceptor) o1;
- WebBeansInterceptor target = (WebBeansInterceptor)o2;
-
-
- if(o1.equals(o2))
- {
- return 0;
- }
- else
- {
- Class<?> o1Clazz = src.getClazz();
- Class<?> o2Clazz = target.getClazz();
-
- return InterceptorsManager.getInstance().compare(o1Clazz, o2Clazz);
-
- }
- }
-
+ public int compare(Interceptor o1, Interceptor o2)
+ {
+ WebBeansInterceptor src = (WebBeansInterceptor) o1;
+ WebBeansInterceptor target = (WebBeansInterceptor) o2;
+
+ if (o1.equals(o2))
+ {
+ return 0;
+ } else
+ {
+ Class<?> o1Clazz = src.getClazz();
+ Class<?> o2Clazz = target.getClazz();
+
+ return InterceptorsManager.getInstance().compare(o1Clazz, o2Clazz);
+
+ }
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -28,121 +25,122 @@
import javax.webbeans.manager.Interceptor;
/**
- * Web Beans general interceptor API contract. There are two types of interceptor
- * definition in the Web Beans Container. These are;
- *
+ * Web Beans general interceptor API contract. There are two types of
+ * interceptor definition in the Web Beans Container. These are;
* <p>
* <ul>
* <li>EJB related interceptors with {@link Interceptors} annotation</li>
- * <li>WebBeans specific interceptor definition with using {@link InterceptorBindingType} and {@link Interceptor} </li>
+ * <li>WebBeans specific interceptor definition with using
+ * {@link InterceptorBindingType} and {@link Interceptor} </li>
* </ul>
* </p>
- *
* <p>
- * If the web beans is an EJB component, EJB container is responsible for calling
- * the EJB related interceptors, otherwise Web Beans container takes the responsibility.
- * In the both cases, Web Beans Container is responsible for calling web beans related inteceptors.
+ * If the web beans is an EJB component, EJB container is responsible for
+ * calling the EJB related interceptors, otherwise Web Beans container takes the
+ * responsibility. In the both cases, Web Beans Container is responsible for
+ * calling web beans related inteceptors.
* </p>
- *
+ *
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
public interface InterceptorData
{
- /**
- * Gets the list of {@link PostConstruct} annotated methods.
- *
- * @return the list of post-construct methods
- */
- public Method getPostConstruct();
-
- /**
- * Gets the list of {@link PreDestroy} annotated methods.
- *
- * @return the list of pre-destroy methods
- */
- public Method getPreDestroy();
-
- /**
- * Gets the list of {@link AroundInvoke} annotated methods.
- *
- * @return the list of around invoke methods
- */
- public Method getAroundInvoke();
-
-
- /**
- * Sets the interceptor method.
- *
- * @param m interceptor method
- * @param annotation annotation class
- */
- public void setInterceptor(Method m, Class<? extends Annotation> annotation);
-
- /**
- * Sets the source of the interceptor.
- *
- * @param definedInInterceptorClass defined in interceptor class
- */
- public void setDefinedInInterceptorClass(boolean definedInInterceptorClass);
-
- /**
- * Gets the interceptor instance.
- *
- * @return the interceptor instance
- */
- public Object getInterceptorInstance();
-
- /**
- * Sets the interceptor instance.
- *
- * @param instance interceptor instance
- */
- public void setInterceptorInstance(Object instance);
-
- /**
- * Checks the interceptor is defined at the method level.
- *
- * @return inteceptor defined in method
- */
- public boolean isDefinedInMethod();
-
- /**
- * Sets true if interceptor is defined at the method, false ow.
- *
- * @param definedInMethod defined in method flag
- */
- public void setDefinedInMethod(boolean definedInMethod);
-
- /**
- * Gets the interceptor annotated method.
- *
- * @return the method
- */
- public Method getAnnotatedMethod();
-
- /**
- * Sets the interceptor annotated method.
- *
- * @param annotatedMethod interceptor annotated method.
- */
- public void setAnnotatedMethod(Method annotatedMethod);
-
- /**
- * Checks whether the interceptor is defined at the interceptor class.
- *
- * @return true if inteceptor is defined at the interceptor class
- */
- public boolean isDefinedInInterceptorClass();
-
- /**
- * Checks whether interceptor is configured with webbeans interceptor definition or not.
- *
- * @return true if interceptor is configured with webbeans interceptor definition
- */
- public boolean isDefinedWithWebBeansInterceptor();
-
- public void setWebBeansInterceptor(Interceptor webBeansInterceptor);
-
- public Interceptor getWebBeansInterceptor();
+ /**
+ * Gets the list of {@link PostConstruct} annotated methods.
+ *
+ * @return the list of post-construct methods
+ */
+ public Method getPostConstruct();
+
+ /**
+ * Gets the list of {@link PreDestroy} annotated methods.
+ *
+ * @return the list of pre-destroy methods
+ */
+ public Method getPreDestroy();
+
+ /**
+ * Gets the list of {@link AroundInvoke} annotated methods.
+ *
+ * @return the list of around invoke methods
+ */
+ public Method getAroundInvoke();
+
+ /**
+ * Sets the interceptor method.
+ *
+ * @param m interceptor method
+ * @param annotation annotation class
+ */
+ public void setInterceptor(Method m, Class<? extends Annotation> annotation);
+
+ /**
+ * Sets the source of the interceptor.
+ *
+ * @param definedInInterceptorClass defined in interceptor class
+ */
+ public void setDefinedInInterceptorClass(boolean definedInInterceptorClass);
+
+ /**
+ * Gets the interceptor instance.
+ *
+ * @return the interceptor instance
+ */
+ public Object getInterceptorInstance();
+
+ /**
+ * Sets the interceptor instance.
+ *
+ * @param instance interceptor instance
+ */
+ public void setInterceptorInstance(Object instance);
+
+ /**
+ * Checks the interceptor is defined at the method level.
+ *
+ * @return inteceptor defined in method
+ */
+ public boolean isDefinedInMethod();
+
+ /**
+ * Sets true if interceptor is defined at the method, false ow.
+ *
+ * @param definedInMethod defined in method flag
+ */
+ public void setDefinedInMethod(boolean definedInMethod);
+
+ /**
+ * Gets the interceptor annotated method.
+ *
+ * @return the method
+ */
+ public Method getAnnotatedMethod();
+
+ /**
+ * Sets the interceptor annotated method.
+ *
+ * @param annotatedMethod interceptor annotated method.
+ */
+ public void setAnnotatedMethod(Method annotatedMethod);
+
+ /**
+ * Checks whether the interceptor is defined at the interceptor class.
+ *
+ * @return true if inteceptor is defined at the interceptor class
+ */
+ public boolean isDefinedInInterceptorClass();
+
+ /**
+ * Checks whether interceptor is configured with webbeans interceptor
+ * definition or not.
+ *
+ * @return true if interceptor is configured with webbeans interceptor
+ * definition
+ */
+ public boolean isDefinedWithWebBeansInterceptor();
+
+ public void setWebBeansInterceptor(Interceptor webBeansInterceptor);
+
+ public Interceptor getWebBeansInterceptor();
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataComparator.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -23,45 +20,42 @@
public class InterceptorDataComparator implements Comparator<InterceptorData>
{
- /* (non-Javadoc)
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(InterceptorData o1, InterceptorData o2)
- {
- if(o1.equals(o2))
- {
- return 0;
- }
- else
- {
- WebBeansInterceptor interceptorFirst = (WebBeansInterceptor)o1.getWebBeansInterceptor();
- WebBeansInterceptor interceptorSecond = (WebBeansInterceptor)o2.getWebBeansInterceptor();
-
- if(interceptorFirst == null && interceptorSecond == null)
- {
- return 0;
- }
-
- if(interceptorFirst == null)
- {
-
- return 1;
- }
- else if(interceptorSecond == null)
- {
- return -1;
- }
- else
- {
- Class<?> o1Clazz = interceptorFirst.getClazz();
- Class<?> o2Clazz = interceptorSecond.getClazz();
-
- return InterceptorsManager.getInstance().compare(o1Clazz, o2Clazz);
- }
-
- }
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(InterceptorData o1, InterceptorData o2)
+ {
+ if (o1.equals(o2))
+ {
+ return 0;
+ } else
+ {
+ WebBeansInterceptor interceptorFirst = (WebBeansInterceptor) o1.getWebBeansInterceptor();
+ WebBeansInterceptor interceptorSecond = (WebBeansInterceptor) o2.getWebBeansInterceptor();
+
+ if (interceptorFirst == null && interceptorSecond == null)
+ {
+ return 0;
+ }
+
+ if (interceptorFirst == null)
+ {
+
+ return 1;
+ } else if (interceptorSecond == null)
+ {
+ return -1;
+ } else
+ {
+ Class<?> o1Clazz = interceptorFirst.getClazz();
+ Class<?> o2Clazz = interceptorSecond.getClazz();
+ return InterceptorsManager.getInstance().compare(o1Clazz, o2Clazz);
+ }
+
+ }
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -25,216 +22,231 @@
import javax.webbeans.manager.Interceptor;
/**
- * Abstract implementation of the {@link InterceptorData} api
- * contract.
- *
+ * Abstract implementation of the {@link InterceptorData} api contract.
+ *
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
-public class InterceptorDataImpl implements InterceptorData
+public class InterceptorDataImpl implements InterceptorData
{
- /**Around invokes method*/
- private Method aroundInvoke = null;
-
- /**Post construct methods*/
- private Method postConstruct = null;
-
- /**Predestroy Method*/
- private Method preDestroy = null;
-
- private Interceptor webBeansInterceptor;
-
- /**Instance of the method*/
- private Object interceptorInstance;
-
- /**Defined in the interceptor or bean*/
- private boolean definedInInterceptorClass;
-
- /**Whether the interceptor class is defined in the method*/
- private boolean definedInMethod;
-
- /**If defined in method true, then this method holds the interceptor annotated method*/
- private Method annotatedMethod;
-
- /**Defined with webbeans specific interceptor*/
- private boolean isDefinedWithWebBeansInterceptor;
-
-
- public InterceptorDataImpl(boolean isDefinedWithWebBeansInterceptor)
- {
- this.isDefinedWithWebBeansInterceptor = isDefinedWithWebBeansInterceptor;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#setInterceptor(java.lang.reflect.Method, java.lang.Class)
- */
- public void setInterceptor(Method m, Class<? extends Annotation> annotation)
- {
- if(annotation.equals(AroundInvoke.class))
- {
- setAroundInvoke(m);
- }
- else if(annotation.equals(PostConstruct.class))
- {
- setPostConstruct(m);
- }
- else if(annotation.equals(PreDestroy.class))
- {
- setPreDestroy(m);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#addAroundInvoke(java.lang.reflect.Method)
- */
- protected void setAroundInvoke(Method m)
- {
- this.aroundInvoke = m;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#addPostConstruct(java.lang.reflect.Method)
- */
- protected void setPostConstruct(Method m)
- {
- this.postConstruct = m;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#addPreDestroy(java.lang.reflect.Method)
- */
- protected void setPreDestroy(Method m)
- {
- this.preDestroy = m;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#getPostConstruct()
- */
- public Method getPostConstruct()
- {
- return this.postConstruct;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#getPreDestroy()
- */
- public Method getPreDestroy()
- {
- return this.preDestroy;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#getAroundInvoke()
- */
- public Method getAroundInvoke()
- {
- return this.aroundInvoke;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#getInterceptorInstance()
- */
- public Object getInterceptorInstance()
- {
- return interceptorInstance;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#setInterceptorInstance(java.lang.Object)
- */
- public void setInterceptorInstance(Object interceptorInstance)
- {
- this.interceptorInstance = interceptorInstance;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#isDefinedInInterceptorClass()
- */
- public boolean isDefinedInInterceptorClass()
- {
- return definedInInterceptorClass;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#setDefinedInInterceptorClass(boolean)
- */
- public void setDefinedInInterceptorClass(boolean definedInInterceptorClass)
- {
- this.definedInInterceptorClass = definedInInterceptorClass;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#isDefinedInMethod()
- */
- public boolean isDefinedInMethod()
- {
- return definedInMethod;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#setDefinedInMethod(boolean)
- */
- public void setDefinedInMethod(boolean definedInMethod)
- {
- this.definedInMethod = definedInMethod;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#getAnnotatedMethod()
- */
- public Method getAnnotatedMethod()
- {
- return annotatedMethod;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#setAnnotatedMethod(java.lang.reflect.Method)
- */
- public void setAnnotatedMethod(Method annotatedMethod)
- {
- this.annotatedMethod = annotatedMethod;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.webbeans.intercept.InterceptorData#isDefinedWithWebBeansInterceptor()
- */
- public boolean isDefinedWithWebBeansInterceptor()
- {
- return isDefinedWithWebBeansInterceptor;
- }
-
- /**
- * @return the webBeansInterceptor
- */
- public Interceptor getWebBeansInterceptor()
- {
- return webBeansInterceptor;
- }
-
- /**
- * @param webBeansInterceptor the webBeansInterceptor to set
- */
- public void setWebBeansInterceptor(Interceptor webBeansInterceptor)
- {
- this.webBeansInterceptor = webBeansInterceptor;
- }
+ /** Around invokes method */
+ private Method aroundInvoke = null;
+
+ /** Post construct methods */
+ private Method postConstruct = null;
+
+ /** Predestroy Method */
+ private Method preDestroy = null;
+
+ private Interceptor webBeansInterceptor;
+
+ /** Instance of the method */
+ private Object interceptorInstance;
+
+ /** Defined in the interceptor or bean */
+ private boolean definedInInterceptorClass;
+
+ /** Whether the interceptor class is defined in the method */
+ private boolean definedInMethod;
+
+ /**
+ * If defined in method true, then this method holds the interceptor
+ * annotated method
+ */
+ private Method annotatedMethod;
+
+ /** Defined with webbeans specific interceptor */
+ private boolean isDefinedWithWebBeansInterceptor;
+
+ public InterceptorDataImpl(boolean isDefinedWithWebBeansInterceptor)
+ {
+ this.isDefinedWithWebBeansInterceptor = isDefinedWithWebBeansInterceptor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#setInterceptor(java.lang.reflect.Method,
+ * java.lang.Class)
+ */
+ public void setInterceptor(Method m, Class<? extends Annotation> annotation)
+ {
+ if (annotation.equals(AroundInvoke.class))
+ {
+ setAroundInvoke(m);
+ } else if (annotation.equals(PostConstruct.class))
+ {
+ setPostConstruct(m);
+ } else if (annotation.equals(PreDestroy.class))
+ {
+ setPreDestroy(m);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#addAroundInvoke(java.lang.reflect.Method)
+ */
+ protected void setAroundInvoke(Method m)
+ {
+ this.aroundInvoke = m;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#addPostConstruct(java.lang.reflect.Method)
+ */
+ protected void setPostConstruct(Method m)
+ {
+ this.postConstruct = m;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#addPreDestroy(java.lang.reflect.Method)
+ */
+ protected void setPreDestroy(Method m)
+ {
+ this.preDestroy = m;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#getPostConstruct()
+ */
+ public Method getPostConstruct()
+ {
+ return this.postConstruct;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#getPreDestroy()
+ */
+ public Method getPreDestroy()
+ {
+ return this.preDestroy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#getAroundInvoke()
+ */
+ public Method getAroundInvoke()
+ {
+ return this.aroundInvoke;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#getInterceptorInstance()
+ */
+ public Object getInterceptorInstance()
+ {
+ return interceptorInstance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#setInterceptorInstance(java.lang.Object)
+ */
+ public void setInterceptorInstance(Object interceptorInstance)
+ {
+ this.interceptorInstance = interceptorInstance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#isDefinedInInterceptorClass()
+ */
+ public boolean isDefinedInInterceptorClass()
+ {
+ return definedInInterceptorClass;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#setDefinedInInterceptorClass(boolean)
+ */
+ public void setDefinedInInterceptorClass(boolean definedInInterceptorClass)
+ {
+ this.definedInInterceptorClass = definedInInterceptorClass;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#isDefinedInMethod()
+ */
+ public boolean isDefinedInMethod()
+ {
+ return definedInMethod;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#setDefinedInMethod(boolean)
+ */
+ public void setDefinedInMethod(boolean definedInMethod)
+ {
+ this.definedInMethod = definedInMethod;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#getAnnotatedMethod()
+ */
+ public Method getAnnotatedMethod()
+ {
+ return annotatedMethod;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#setAnnotatedMethod(java.lang.reflect.Method)
+ */
+ public void setAnnotatedMethod(Method annotatedMethod)
+ {
+ this.annotatedMethod = annotatedMethod;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.webbeans.intercept.InterceptorData#isDefinedWithWebBeansInterceptor()
+ */
+ public boolean isDefinedWithWebBeansInterceptor()
+ {
+ return isDefinedWithWebBeansInterceptor;
+ }
+
+ /**
+ * @return the webBeansInterceptor
+ */
+ public Interceptor getWebBeansInterceptor()
+ {
+ return webBeansInterceptor;
+ }
+
+ /**
+ * @param webBeansInterceptor the webBeansInterceptor to set
+ */
+ public void setWebBeansInterceptor(Interceptor webBeansInterceptor)
+ {
+ this.webBeansInterceptor = webBeansInterceptor;
+ }
-
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -38,234 +35,221 @@
public class InterceptorHandler implements MethodHandler
{
- private static WebBeansLogger logger = WebBeansLogger.getLogger(InterceptorHandler.class);
-
- private AbstractComponent<?> component = null;
-
- private Method calledMethod = null;
-
- private boolean isSameDecMethod = false;
-
- public InterceptorHandler(AbstractComponent<?> component)
- {
- this.component = component;
- }
-
- public Object invoke(Object instance, Method method, Method proceed, Object[] arguments) throws Throwable
- {
- Context webbeansContext = ManagerImpl.getManager().getContext(component.getScopeType());
- Object webbeansInstance = webbeansContext.get(this.component, true);
-
- if(!ClassUtil.isObjectMethod(method.getName()) && InterceptorUtil.isWebBeansBusinessMethod(method))
- {
- if(this.calledMethod == null)
- {
- this.calledMethod = method;
- }
- else if(this.calledMethod.equals(method))
- {
- this.isSameDecMethod = true;
- }
- else
- {
- this.calledMethod = method;
- this.isSameDecMethod = false;
- }
-
- //Run around invoke chain
- List<InterceptorData> stack = component.getInterceptorStack();
-
- Collections.sort(stack, new InterceptorDataComparator());
-
- filterEJBInterceptorStackList(stack, method);
- filterWebBeansInterceptorStackList(stack, method);
-
- if(WebBeansUtil.isContainsInterceptorMethod(stack, InterceptorType.AROUND_INVOKE))
- {
- callAroundInvokes(instance, proceed, arguments,WebBeansUtil.getInterceptorMethods(stack, InterceptorType.AROUND_INVOKE));
- }
-
- List<Object> decorators = component.getDecoratorStack();
- callDecorators(decorators, method, arguments);
-
- }
-
- if(!method.isAccessible())
- {
- method.setAccessible(true);
- }
-
- return method.invoke(webbeansInstance, arguments);
- }
-
- private void callDecorators(List<Object> decorators, Method method, Object[] arguments)
- {
-
- Iterator<Object> itDec = decorators.iterator();
- while(itDec.hasNext())
- {
- Object decorator = itDec.next();
- try
- {
- Method decMethod = decorator.getClass().getMethod(method.getName(), method.getParameterTypes());
-
- if(decMethod != null)
- {
- if(!this.isSameDecMethod)
- {
- if(!decMethod.isAccessible())
- {
- decMethod.setAccessible(true);
- }
-
- decMethod.invoke(decorator, arguments);
- }
- }
-
- } catch (SecurityException e)
- {
- logger.error("Method security access violation for method " + method.getName() + " for decorator class : " + decorator.getClass().getName());
- throw new WebBeansException(e);
-
- } catch (NoSuchMethodException e)
- {
- continue;
- }
- catch(InvocationTargetException e)
- {
- logger.error("Exception in calling method " + method.getName() + " for decorator class : " + decorator.getClass().getName() + ". Look log for target checked exception.", e.getTargetException());
- throw new WebBeansException(e);
- }
- catch(IllegalAccessException e)
- {
- logger.error("Method illegal access for method " + method.getName() + " for decorator class : " + decorator.getClass().getName());
- throw new WebBeansException(e);
- }
-
- }
- }
-
- private <T> void callAroundInvokes(Object instance, Method proceed, Object[] arguments, List<InterceptorData> stack) throws Exception
- {
- InvocationContextImpl impl = new InvocationContextImpl(instance,proceed,arguments,stack,InterceptorType.AROUND_INVOKE);
-
- impl.proceed();
-
- }
-
- private void filterEJBInterceptorStackList(List<InterceptorData> stack, Method method)
- {
- boolean isMethodAnnotatedWithInterceptorClass = false;
- boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
-
- if(AnnotationUtil.isMethodHasAnnotation(method, Interceptors.class))
- isMethodAnnotatedWithInterceptorClass = true;
-
- if(AnnotationUtil.isMethodHasAnnotation(method, ExcludeClassInterceptors.class))
- isMethodAnnotatedWithExcludeInterceptorClass = true;
-
-
- Iterator<InterceptorData> it = stack.iterator();
- while(it.hasNext())
- {
- InterceptorData data = it.next();
- if(isMethodAnnotatedWithInterceptorClass)
- {
- if(isMethodAnnotatedWithExcludeInterceptorClass)
- {
- if(!data.isDefinedInMethod() && data.isDefinedInInterceptorClass())
- {
- it.remove();
- }
- else if(data.isDefinedInMethod())
- {
- if(!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- else
- {
- if(data.isDefinedInMethod())
- {
- if(!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- }
- else
- {
- if(data.isDefinedInMethod())
- {
- it.remove();
- }
- }
-
- }
-
- }
-
- private void filterWebBeansInterceptorStackList(List<InterceptorData> stack, Method method)
- {
- boolean isMethodAnnotatedWithInterceptorClass = false;
- boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
-
- if(AnnotationUtil.isInterceptorBindingMetaAnnotationExist(method.getDeclaredAnnotations()))
- {
- isMethodAnnotatedWithInterceptorClass = true;
- }
-
- if(AnnotationUtil.isMethodHasAnnotation(method, ExcludeClassInterceptors.class))
- {
- isMethodAnnotatedWithExcludeInterceptorClass = true;
- }
-
-
- Iterator<InterceptorData> it = stack.iterator();
- while(it.hasNext())
- {
- InterceptorData data = it.next();
- if(isMethodAnnotatedWithInterceptorClass)
- {
- if(isMethodAnnotatedWithExcludeInterceptorClass)
- {
- if(!data.isDefinedInMethod() && data.isDefinedInInterceptorClass() && data.isDefinedWithWebBeansInterceptor())
- {
- it.remove();
- }
- else if(data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- if(!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- else
- {
- if(data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- if(!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- }
- else
- {
- if(data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- it.remove();
- }
- }
-
- }
-
- }
-
+ private static WebBeansLogger logger = WebBeansLogger.getLogger(InterceptorHandler.class);
+
+ private AbstractComponent<?> component = null;
+
+ private Method calledMethod = null;
+
+ private boolean isSameDecMethod = false;
+
+ public InterceptorHandler(AbstractComponent<?> component)
+ {
+ this.component = component;
+ }
+
+ public Object invoke(Object instance, Method method, Method proceed, Object[] arguments) throws Throwable
+ {
+ Context webbeansContext = ManagerImpl.getManager().getContext(component.getScopeType());
+ Object webbeansInstance = webbeansContext.get(this.component, true);
+
+ if (!ClassUtil.isObjectMethod(method.getName()) && InterceptorUtil.isWebBeansBusinessMethod(method))
+ {
+ if (this.calledMethod == null)
+ {
+ this.calledMethod = method;
+ } else if (this.calledMethod.equals(method))
+ {
+ this.isSameDecMethod = true;
+ } else
+ {
+ this.calledMethod = method;
+ this.isSameDecMethod = false;
+ }
+
+ // Run around invoke chain
+ List<InterceptorData> stack = component.getInterceptorStack();
+
+ Collections.sort(stack, new InterceptorDataComparator());
+
+ filterEJBInterceptorStackList(stack, method);
+ filterWebBeansInterceptorStackList(stack, method);
+
+ if (WebBeansUtil.isContainsInterceptorMethod(stack, InterceptorType.AROUND_INVOKE))
+ {
+ callAroundInvokes(instance, proceed, arguments, WebBeansUtil.getInterceptorMethods(stack, InterceptorType.AROUND_INVOKE));
+ }
+
+ List<Object> decorators = component.getDecoratorStack();
+ callDecorators(decorators, method, arguments);
+
+ }
+
+ if (!method.isAccessible())
+ {
+ method.setAccessible(true);
+ }
+
+ return method.invoke(webbeansInstance, arguments);
+ }
+
+ private void callDecorators(List<Object> decorators, Method method, Object[] arguments)
+ {
+
+ Iterator<Object> itDec = decorators.iterator();
+ while (itDec.hasNext())
+ {
+ Object decorator = itDec.next();
+ try
+ {
+ Method decMethod = decorator.getClass().getMethod(method.getName(), method.getParameterTypes());
+
+ if (decMethod != null)
+ {
+ if (!this.isSameDecMethod)
+ {
+ if (!decMethod.isAccessible())
+ {
+ decMethod.setAccessible(true);
+ }
+
+ decMethod.invoke(decorator, arguments);
+ }
+ }
+
+ } catch (SecurityException e)
+ {
+ logger.error("Method security access violation for method " + method.getName() + " for decorator class : " + decorator.getClass().getName());
+ throw new WebBeansException(e);
+
+ } catch (NoSuchMethodException e)
+ {
+ continue;
+ } catch (InvocationTargetException e)
+ {
+ logger.error("Exception in calling method " + method.getName() + " for decorator class : " + decorator.getClass().getName() + ". Look log for target checked exception.", e.getTargetException());
+ throw new WebBeansException(e);
+ } catch (IllegalAccessException e)
+ {
+ logger.error("Method illegal access for method " + method.getName() + " for decorator class : " + decorator.getClass().getName());
+ throw new WebBeansException(e);
+ }
+
+ }
+ }
+
+ private <T> void callAroundInvokes(Object instance, Method proceed, Object[] arguments, List<InterceptorData> stack) throws Exception
+ {
+ InvocationContextImpl impl = new InvocationContextImpl(instance, proceed, arguments, stack, InterceptorType.AROUND_INVOKE);
+
+ impl.proceed();
+
+ }
+
+ private void filterEJBInterceptorStackList(List<InterceptorData> stack, Method method)
+ {
+ boolean isMethodAnnotatedWithInterceptorClass = false;
+ boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
+
+ if (AnnotationUtil.isMethodHasAnnotation(method, Interceptors.class))
+ isMethodAnnotatedWithInterceptorClass = true;
+
+ if (AnnotationUtil.isMethodHasAnnotation(method, ExcludeClassInterceptors.class))
+ isMethodAnnotatedWithExcludeInterceptorClass = true;
+
+ Iterator<InterceptorData> it = stack.iterator();
+ while (it.hasNext())
+ {
+ InterceptorData data = it.next();
+ if (isMethodAnnotatedWithInterceptorClass)
+ {
+ if (isMethodAnnotatedWithExcludeInterceptorClass)
+ {
+ if (!data.isDefinedInMethod() && data.isDefinedInInterceptorClass())
+ {
+ it.remove();
+ } else if (data.isDefinedInMethod())
+ {
+ if (!data.getAnnotatedMethod().equals(method))
+ {
+ it.remove();
+ }
+ }
+ } else
+ {
+ if (data.isDefinedInMethod())
+ {
+ if (!data.getAnnotatedMethod().equals(method))
+ {
+ it.remove();
+ }
+ }
+ }
+ } else
+ {
+ if (data.isDefinedInMethod())
+ {
+ it.remove();
+ }
+ }
+
+ }
+
+ }
+
+ private void filterWebBeansInterceptorStackList(List<InterceptorData> stack, Method method)
+ {
+ boolean isMethodAnnotatedWithInterceptorClass = false;
+ boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
+
+ if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(method.getDeclaredAnnotations()))
+ {
+ isMethodAnnotatedWithInterceptorClass = true;
+ }
+
+ if (AnnotationUtil.isMethodHasAnnotation(method, ExcludeClassInterceptors.class))
+ {
+ isMethodAnnotatedWithExcludeInterceptorClass = true;
+ }
+
+ Iterator<InterceptorData> it = stack.iterator();
+ while (it.hasNext())
+ {
+ InterceptorData data = it.next();
+ if (isMethodAnnotatedWithInterceptorClass)
+ {
+ if (isMethodAnnotatedWithExcludeInterceptorClass)
+ {
+ if (!data.isDefinedInMethod() && data.isDefinedInInterceptorClass() && data.isDefinedWithWebBeansInterceptor())
+ {
+ it.remove();
+ } else if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
+ {
+ if (!data.getAnnotatedMethod().equals(method))
+ {
+ it.remove();
+ }
+ }
+ } else
+ {
+ if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
+ {
+ if (!data.getAnnotatedMethod().equals(method))
+ {
+ it.remove();
+ }
+ }
+ }
+ } else
+ {
+ if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
+ {
+ it.remove();
+ }
+ }
+
+ }
+
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * 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.
+ * 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.
*/
package org.apache.webbeans.intercept;
@@ -21,47 +18,37 @@
import org.apache.webbeans.exception.WebBeansException;
/**
- * Type of the interceptors. Defines in the EJB specification and
- * common annotations.
+ * Type of the interceptors. Defines in the EJB specification and common
+ * annotations.
*
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
public enum InterceptorType
{
- AROUND_INVOKE,
- POST_CONSTRUCT,
- PRE_DESTROY,
- PRE_PASSIVATE,
- POST_ACTIVATE;
+ AROUND_INVOKE, POST_CONSTRUCT, PRE_DESTROY, PRE_PASSIVATE, POST_ACTIVATE;
-
- public static InterceptorType getType(InterceptionType type)
- {
- if(type.equals(InterceptionType.AROUND_INVOKE))
- {
- return AROUND_INVOKE;
- }
- else if(type.equals(InterceptionType.POST_CONSTRUCT))
- {
- return POST_CONSTRUCT;
- }
- else if(type.equals(InterceptionType.PRE_DESTROY))
- {
- return PRE_DESTROY;
- }
- else if(type.equals(InterceptionType.PRE_PASSIVATE))
- {
- return PRE_PASSIVATE;
- }
- else if(type.equals(InterceptionType.POST_ACTIVATE))
- {
- return POST_ACTIVATE;
- }
- else
- {
- throw new WebBeansException("Undefined interceptor type!");
- }
+ public static InterceptorType getType(InterceptionType type)
+ {
+ if (type.equals(InterceptionType.AROUND_INVOKE))
+ {
+ return AROUND_INVOKE;
+ } else if (type.equals(InterceptionType.POST_CONSTRUCT))
+ {
+ return POST_CONSTRUCT;
+ } else if (type.equals(InterceptionType.PRE_DESTROY))
+ {
+ return PRE_DESTROY;
+ } else if (type.equals(InterceptionType.PRE_PASSIVATE))
+ {
+ return PRE_PASSIVATE;
+ } else if (type.equals(InterceptionType.POST_ACTIVATE))
+ {
+ return POST_ACTIVATE;
+ } else
+ {
+ throw new WebBeansException("Undefined interceptor type!");
+ }
- }
+ }
}
\ No newline at end of file