use of org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef in project tomee by apache.
the class BuiltInEnvironmentEntries method add.
private void add(final JndiConsumer jndi, final DeploymentModule module, final DeploymentModule app, final boolean defaults) {
// Standard names
add(jndi.getEnvEntryMap(), new EnvEntry().name("java:module/ModuleName").value(module.getModuleId()).type(String.class));
add(jndi.getEnvEntryMap(), new EnvEntry().name("java:app/AppName").value(app.getModuleId()).type(String.class));
// Standard References to built-in objects
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/BeanManager").type(BeanManager.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/Validator").type(Validator.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/ValidatorFactory").type(ValidatorFactory.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionManager").type(TransactionManager.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionSynchronizationRegistry").type(TransactionSynchronizationRegistry.class));
if (defaults) {
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedExecutorService").type(ManagedExecutorService.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedScheduledExecutorService").type(ManagedScheduledExecutorService.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedThreadFactory").type(ManagedThreadFactory.class));
add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultContextService").type(ContextService.class));
try {
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
contextClassLoader.loadClass("org.apache.activemq.ActiveMQSslConnectionFactory");
final ResourceEnvRef ref = new ResourceEnvRef().name("java:comp/DefaultJMSConnectionFactory").type(contextClassLoader.loadClass("javax.jms.ConnectionFactory"));
add(jndi.getResourceEnvRefMap(), ref);
} catch (final ClassNotFoundException | NoClassDefFoundError notThere) {
// no-op
}
}
// OpenEJB specific feature
add(jndi.getEnvEntryMap(), new EnvEntry().name("java:comp/ComponentName").value(jndi.getJndiConsumerName()).type(String.class));
}
use of org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef in project tomee by apache.
the class ApplyOpenejbJar method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final Map<String, EjbDeployment> ejbDeployments = ejbModule.getOpenejbJar().getDeploymentsByEjbName();
for (final EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) {
// Get the OpenEJB deployment from openejb-jar.xml
final EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
enterpriseBean.setId(ejbDeployment.getDeploymentId());
for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
{
ref.setMappedName(resourceLink.getResId());
}
}
for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
{
ref.setMappedName(resourceLink.getResId());
}
}
for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
if (resourceLink != null && resourceLink.getResId() != null) /* don't overwrite with null */
{
ref.setMappedName(resourceLink.getResId());
}
}
for (final EjbRef ref : enterpriseBean.getEjbRef()) {
final EjbLink ejbLink = ejbDeployment.getEjbLink(ref.getName());
if (ejbLink != null && ejbLink.getDeployentId() != null) /* don't overwrite with null */
{
ref.setMappedName(ejbLink.getDeployentId());
}
}
for (final EjbLocalRef ref : enterpriseBean.getEjbLocalRef()) {
final EjbLink ejbLink = ejbDeployment.getEjbLink(ref.getName());
if (ejbLink != null && ejbLink.getDeployentId() != null) /* don't overwrite with null */
{
ref.setMappedName(ejbLink.getDeployentId());
}
}
}
}
return appModule;
}
use of org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef in project tomee by apache.
the class DebuggableVmHackery method pruneRefs.
private void pruneRefs(final JndiConsumer bean, final EjbDeployment ejbDeployment) {
for (final ResourceRef ref : copy(bean.getResourceRef())) {
if (ref.getResType().startsWith("javax.jms.")) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
ejbDeployment.getResourceLink().remove(resourceLink);
bean.getResourceRef().remove(ref);
}
}
for (final ResourceEnvRef ref : bean.getResourceEnvRef()) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
ejbDeployment.getResourceLink().remove(resourceLink);
}
bean.getResourceEnvRef().clear();
for (final MessageDestinationRef ref : bean.getMessageDestinationRef()) {
final ResourceLink resourceLink = ejbDeployment.getResourceLink(ref.getName());
ejbDeployment.getResourceLink().remove(resourceLink);
}
bean.getMessageDestinationRef().clear();
bean.getPersistenceContextRef().clear();
bean.getPersistenceUnitRef().clear();
}
use of org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef in project tomee by apache.
the class GeronimoMappedName method mapReferences.
private void mapReferences(final EjbJar ejbJar) {
if (ejbJar == null) {
return;
}
for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
for (final EjbRef ref : enterpriseBean.getEjbRef()) {
// remap only corba references
final String mappedName = ref.getMappedName();
if (mappedName != null && (mappedName.startsWith("jndi:corbaloc") || mappedName.startsWith("jndi:corbaname"))) {
final String refName = ref.getEjbRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
if (null == mappedName && ref.getEjbRefName().equals("ejb/MEJB")) {
ref.setMappedName("mejb/ejb/mgmt/MEJB");
}
}
for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
final String refName = ref.getMessageDestinationRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
final String refName = ref.getPersistenceContextRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final PersistenceUnitRef ref : enterpriseBean.getPersistenceUnitRef()) {
final String refName = ref.getPersistenceUnitRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
final String refName = ref.getResRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
final String refName = ref.getResourceEnvRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
for (final ServiceRef ref : enterpriseBean.getServiceRef()) {
final String refName = ref.getServiceRefName();
ref.setMappedName(MAPPED_NAME_PREFIX + refName);
}
}
}
use of org.apache.openejb.jee.ResourceEnvRef$JAXB.readResourceEnvRef in project tomee by apache.
the class LegacyProcessor method process.
public static void process(final Class<?> clazz, final EnterpriseBean bean) {
if (bean instanceof SessionBean) {
final SessionBean sessionBean = (SessionBean) bean;
if (sessionBean.getSessionType() == STATEFUL && SessionSynchronization.class.isAssignableFrom(clazz)) {
try {
sessionBean.getAfterBegin().add(new LifecycleCallback(clazz.getMethod("afterBegin")));
sessionBean.getBeforeCompletion().add(new LifecycleCallback(clazz.getMethod("beforeCompletion")));
sessionBean.getAfterCompletion().add(new LifecycleCallback(clazz.getMethod("afterCompletion", boolean.class)));
} catch (final NoSuchMethodException e) {
// Ignore, should never happen
}
}
if (javax.ejb.SessionBean.class.isAssignableFrom(clazz)) {
final ResourceEnvRef ref = new ResourceEnvRef("javax.ejb.SessionBean/sessionContext", SessionContext.class);
final InjectionTarget target = new InjectionTarget();
target.setInjectionTargetClass(clazz);
target.setInjectionTargetName("sessionContext");
ref.getInjectionTarget().add(target);
sessionBean.getResourceEnvRef().add(ref);
}
}
if (bean instanceof MessageDrivenBean) {
final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
if (javax.ejb.MessageDrivenBean.class.isAssignableFrom(clazz)) {
final ResourceEnvRef ref = new ResourceEnvRef("javax.ejb.MessageDrivenBean/messageDrivenContext", MessageDrivenContext.class);
final InjectionTarget target = new InjectionTarget();
target.setInjectionTargetClass(clazz);
target.setInjectionTargetName("messageDrivenContext");
ref.getInjectionTarget().add(target);
messageDrivenBean.getResourceEnvRef().add(ref);
}
}
}
Aggregations