Author: richard.opalka(a)jboss.com
Date: 2009-05-05 05:33:28 -0400 (Tue, 05 May 2009)
New Revision: 9953
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/ReferenceResolver.java
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionMetaData.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionsMetaData.java
Log:
[JBWS-2634] extending SPI
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionMetaData.java
===================================================================
---
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionMetaData.java 2009-05-04
08:09:01 UTC (rev 9952)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionMetaData.java 2009-05-05
09:33:28 UTC (rev 9953)
@@ -25,7 +25,7 @@
* An injection target specifies a class and a name within
* that class into which a resource should be injected.
*
- * @author ropalka(a)redhat.com
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
*/
public final class InjectionMetaData
{
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionsMetaData.java
===================================================================
---
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionsMetaData.java 2009-05-04
08:09:01 UTC (rev 9952)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/InjectionsMetaData.java 2009-05-05
09:33:28 UTC (rev 9953)
@@ -21,16 +21,18 @@
*/
package org.jboss.wsf.spi.metadata.injection;
+import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.Collection;
import java.util.LinkedList;
+import java.util.Map;
import javax.naming.Context;
/**
* Injections metadata container.
*
- * @author ropalka(a)redhat.com
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
*/
public final class InjectionsMetaData
{
@@ -46,6 +48,11 @@
private final Collection<InjectionMetaData> injections;
/**
+ * Reference resolvers.
+ */
+ private final Map<Class<? extends Annotation>, ReferenceResolver>
referenceResolvers;
+
+ /**
* JNDI context.
*/
private final Context ctx;
@@ -56,14 +63,17 @@
* @param injections injection definitions list
* @param ctx JNDI context
*/
- public InjectionsMetaData(Collection<InjectionMetaData> injections, Context
ctx)
+ public InjectionsMetaData(Collection<InjectionMetaData> injections,
Map<Class<? extends Annotation>, ReferenceResolver> referenceResolvers,
Context ctx)
{
super();
if (injections == null)
throw new IllegalArgumentException("injections metadata list cannot be
null");
+ if ((referenceResolvers == null) || (referenceResolvers.size() == 0))
+ throw new IllegalArgumentException("reference resolvers list cannot be null
or empty collection");
this.injections = injections;
+ this.referenceResolvers = referenceResolvers;
this.ctx = ctx;
}
@@ -111,4 +121,21 @@
return (retVal == null) ? EMPTY_LIST : retVal;
}
+ /**
+ * Returns reference resolver for annotation.
+ *
+ * @param annotation to find resolver for
+ * @return reference resolver
+ */
+ public ReferenceResolver getResolver(final Class<? extends Annotation>
annotation)
+ {
+ final ReferenceResolver resolver = this.referenceResolvers.get(annotation);
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("No registered reference resolver for:
" + annotation.getClass());
+ }
+
+ return resolver;
+ }
+
}
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/ReferenceResolver.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/ReferenceResolver.java
(rev 0)
+++
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/injection/ReferenceResolver.java 2009-05-05
09:33:28 UTC (rev 9953)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.metadata.injection;
+
+import java.lang.reflect.AccessibleObject;
+
+/**
+ * JNDI reference resolver.
+ *
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ */
+public interface ReferenceResolver
+{
+
+ /**
+ * Resolves JNDI name.
+ *
+ * @param accessibleObject object
+ * @return JNDI name.
+ */
+ String resolve(AccessibleObject accessibleObject);
+
+ /**
+ * Returns <b>true</b> if can resolve, <b>false</b>
otherwise.
+ *
+ * @param accessibleObject object
+ * @return true if can resolve, false otherwise
+ */
+ boolean canResolve(AccessibleObject accessibleObject);
+
+}