Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3661 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
6 changed files
with
214 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed 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.jboss.webbeans.bean.ee; | ||
|
||
import org.jboss.webbeans.BeanManagerImpl; | ||
import org.jboss.webbeans.bean.AbstractClassBean; | ||
import org.jboss.webbeans.bean.ProducerField; | ||
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment; | ||
import org.jboss.webbeans.ejb.EJBApiAbstraction; | ||
import org.jboss.webbeans.introspector.WBField; | ||
import org.jboss.webbeans.persistence.PersistenceApiAbstraction; | ||
import org.jboss.webbeans.ws.WSApiAbstraction; | ||
|
||
/** | ||
* @author pmuir | ||
* | ||
*/ | ||
public class EEResourceProducerField<T> extends ProducerField<T> | ||
{ | ||
|
||
/** | ||
* Creates an EE resource producer field | ||
* | ||
* @param field The underlying method abstraction | ||
* @param declaringBean The declaring bean abstraction | ||
* @param manager the current manager | ||
* @return A producer field | ||
*/ | ||
public static <T> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager) | ||
{ | ||
return new EEResourceProducerField<T>(field, declaringBean, manager); | ||
} | ||
|
||
protected EEResourceProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager) | ||
{ | ||
super(field, declaringBean, manager); | ||
} | ||
|
||
@Override | ||
public void initialize(BeanDeployerEnvironment environment) | ||
{ | ||
if (!isInitialized()) | ||
{ | ||
super.initialize(environment); | ||
checkEEResource(); | ||
} | ||
} | ||
|
||
protected void checkEEResource() | ||
{ | ||
EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class); | ||
PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class); | ||
WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class); | ||
if (!(getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)) || getAnnotatedItem().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS)) | ||
{ | ||
throw new IllegalStateException("Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present " + getAnnotatedItem()); | ||
} | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed 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.jboss.webbeans.bean.ee; | ||
|
||
import javax.persistence.EntityManager; | ||
|
||
import org.jboss.webbeans.BeanManagerImpl; | ||
import org.jboss.webbeans.bean.AbstractClassBean; | ||
import org.jboss.webbeans.introspector.WBField; | ||
|
||
/** | ||
* @author pmuir | ||
* | ||
*/ | ||
public class PersistenceContextProducerField<T extends EntityManager> extends EEResourceProducerField<T> | ||
{ | ||
|
||
/** | ||
* Creates an EE resource producer field | ||
* | ||
* @param field The underlying method abstraction | ||
* @param declaringBean The declaring bean abstraction | ||
* @param manager the current manager | ||
* @return A producer field | ||
*/ | ||
public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager) | ||
{ | ||
return new PersistenceContextProducerField<T>(field, declaringBean, manager); | ||
} | ||
|
||
/** | ||
* @param field | ||
* @param declaringBean | ||
* @param manager | ||
*/ | ||
protected PersistenceContextProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager) | ||
{ | ||
super(field, declaringBean, manager); | ||
} | ||
|
||
public void dispose(T instance) | ||
{ | ||
instance.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed 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.jboss.webbeans.ws; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
import org.jboss.webbeans.bootstrap.api.Service; | ||
import org.jboss.webbeans.resources.spi.ResourceLoader; | ||
import org.jboss.webbeans.util.ApiAbstraction; | ||
|
||
public class WSApiAbstraction extends ApiAbstraction implements Service | ||
{ | ||
|
||
public final Class<? extends Annotation> WEB_SERVICE_REF_ANNOTATION_CLASS; | ||
|
||
/** | ||
* @param resourceLoader | ||
*/ | ||
public WSApiAbstraction(ResourceLoader resourceLoader) | ||
{ | ||
super(resourceLoader); | ||
WEB_SERVICE_REF_ANNOTATION_CLASS = annotationTypeForName("javax.xml.ws.WebServiceRef"); | ||
} | ||
|
||
public void cleanup() {} | ||
|
||
} |