Package org.jboss.metadata

Examples of org.jboss.metadata.EjbLocalRefMetaData


      // Bind Local EJB references
      {
         Iterator i = beanMetaData.getEjbLocalReferences();
         while (i.hasNext())
         {
            EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
            String refName = ref.getName();
            log.debug("Binding an EJBLocalReference " + ref.getName());

            if (ref.getLink() != null)
            {
               // Internal link
               log.debug("Binding " + refName + " to bean source: " + ref.getLink());

               String jndiName = ref.getJndiName();

               Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
            }
            else
            {
               // Bind the bean level ejb-local-ref/local-jndi-name
               if (ref.getJndiName() == null)
               {
                  throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml");
               }
               Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
            }
         }
      }

      // Bind service references
      {
         ClassLoader loader = unit.getClassLoader();
         UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
         Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences();
         if (serviceReferences != null)
         {
            while (serviceReferences.hasNext())
            {
               ServiceReferenceMetaData sref = serviceReferences.next();
               String refName = sref.getServiceRefName();
               new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
            }
         }
      }

      // Bind resource references
      {
         Iterator i = beanMetaData.getResourceReferences();

         // let's play guess the cast game ;)  New metadata should fix this.
         ApplicationMetaData application = beanMetaData.getApplicationMetaData();

         while (i.hasNext())
         {
            ResourceRefMetaData ref = (ResourceRefMetaData)i.next();

            String resourceName = ref.getResourceName();
            String finalName = application.getResourceByName(resourceName);
            String resType = ref.getType();
            // If there was no resource-manager specified then an immeadiate
            // jndi-name or res-url name should have been given
            if (finalName == null)
               finalName = ref.getJndiName();

            if (finalName == null && resType.equals("java.net.URL") == false)
            {
               // the application assembler did not provide a resource manager
               // if the type is javax.sql.Datasoure use the default one

               if (ref.getType().equals("javax.sql.DataSource"))
               {
                  // Go through JNDI and look for DataSource - use the first one
                  Context dsCtx = new InitialContext();
                  try
                  {
                     // Check if it is available in JNDI
                     dsCtx.lookup("java:/DefaultDS");
                     finalName = "java:/DefaultDS";
                  }
                  catch (Exception e)
                  {
                     log.debug("failed to lookup DefaultDS; ignoring", e);
                  }
                  finally
                  {
                     dsCtx.close();
                  }
               }

               // Default failed? Warn user and move on
               // POTENTIALLY DANGEROUS: should this be a critical error?
               if (finalName == null)
               {
                  log.warn("No resource manager found for " + ref.getResourceName());
                  continue;
               }
            }

            if (resType.equals("java.net.URL"))
            {
               // URL bindings
               if (ref.getResURL() != null)
               {
                  // The URL string was given by the res-url
                  log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL());
                  URL resURL = new URL(ref.getResURL());
                  Util.bind(envCtx, ref.getRefName(), resURL);
               }
               else
               {
                  log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
                  Object bind = null;
                  if (ref.getJndiName() != null)
                  {
                     // Was the url given as a jndi-name reference to link to it
                     bind = new LinkRef(finalName);
                  }
                  else
                  {
                     // The url string was given via a resource-name mapping
                     bind = new URL(finalName);
                  }
                  Util.bind(envCtx, ref.getRefName(), bind);
               }
            }
            else
            {
               // Resource Manager bindings, should validate the type...
               log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName);
               Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
            }
         }
      }

      // Bind resource env references
      {
         Iterator i = beanMetaData.getResourceEnvReferences();
         while (i.hasNext())
         {
            ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next();
            String encName = resRef.getRefName();
            String jndiName = resRef.getJndiName();
            // Should validate the type...
            log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName);
            Util.bind(envCtx, encName, new LinkRef(jndiName));
         }
      }

      // Bind message destination references
      {
         Iterator i = beanMetaData.getMessageDestinationReferences();

         while (i.hasNext())
         {
            MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();

            String refName = ref.getRefName();
            String jndiName = ref.getJNDIName();
            String link = ref.getLink();
            if (link != null)
            {
               if (jndiName == null)
               {
                  MessageDestinationMetaData messageDestination = getMessageDestination(link);
View Full Code Here


   {
      assertNotNull(ejbLocalRefs);
      int count = 1;
      while (ejbLocalRefs.hasNext())
      {
         EjbLocalRefMetaData ejbLocalRef = ejbLocalRefs.next();
         String pref = prefix + "EjbLocalRef" + count;
         assertEquals(pref + "Name", ejbLocalRef.getName());
         if (full)
         {
            if (count == 1)
               assertEquals("Session", ejbLocalRef.getType());
            else
               assertEquals("Entity", ejbLocalRef.getType());
            assertEquals(pref + "LocalHome", ejbLocalRef.getLocalHome());
            assertEquals(pref + "Local", ejbLocalRef.getLocal());
            assertEquals(pref + "EjbLink", ejbLocalRef.getLink());
         }
         assertJndiName(pref, full, ejbLocalRef.getJndiName(), mode);
         ++count;
      }
      assertEquals(size + 1, count);
   }
View Full Code Here

      // Bind Local EJB references
      {
         Iterator i = beanMetaData.getEjbLocalReferences();
         while (i.hasNext())
         {
            EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
            String refName = ref.getName();
            log.debug("Binding an EJBLocalReference " + ref.getName());

            if (ref.getLink() != null)
            {
               // Internal link
               log.debug("Binding " + refName + " to bean source: " + ref.getLink());

               String jndiName = ref.getJndiName();

               Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
            }
            else
            {
               // Bind the bean level ejb-local-ref/local-jndi-name
               if (ref.getJndiName() == null)
               {
                  throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml");
               }
               Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
            }
         }
      }

      // Bind service references
      {
         ClassLoader loader = unit.getClassLoader();
         UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
         Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences();
         if (serviceReferences != null)
         {
            while (serviceReferences.hasNext())
            {
               ServiceReferenceMetaData sref = serviceReferences.next();
               String refName = sref.getServiceRefName();
               new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
            }
         }
      }

      // Bind resource references
      {
         Iterator i = beanMetaData.getResourceReferences();

         // let's play guess the cast game ;)  New metadata should fix this.
         ApplicationMetaData application = beanMetaData.getApplicationMetaData();

         while (i.hasNext())
         {
            ResourceRefMetaData ref = (ResourceRefMetaData)i.next();

            String resourceName = ref.getResourceName();
            String finalName = application.getResourceByName(resourceName);
            String resType = ref.getType();
            // If there was no resource-manager specified then an immeadiate
            // jndi-name or res-url name should have been given
            if (finalName == null)
               finalName = ref.getJndiName();

            if (finalName == null && resType.equals("java.net.URL") == false)
            {
               // the application assembler did not provide a resource manager
               // if the type is javax.sql.Datasoure use the default one

               if (ref.getType().equals("javax.sql.DataSource"))
               {
                  // Go through JNDI and look for DataSource - use the first one
                  Context dsCtx = new InitialContext();
                  try
                  {
                     // Check if it is available in JNDI
                     dsCtx.lookup("java:/DefaultDS");
                     finalName = "java:/DefaultDS";
                  }
                  catch (Exception e)
                  {
                     log.debug("failed to lookup DefaultDS; ignoring", e);
                  }
                  finally
                  {
                     dsCtx.close();
                  }
               }

               // Default failed? Warn user and move on
               // POTENTIALLY DANGEROUS: should this be a critical error?
               if (finalName == null)
               {
                  log.warn("No resource manager found for " + ref.getResourceName());
                  continue;
               }
            }

            if (resType.equals("java.net.URL"))
            {
               // URL bindings
               if (ref.getResURL() != null)
               {
                  // The URL string was given by the res-url
                  log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL());
                  URL resURL = new URL(ref.getResURL());
                  Util.bind(envCtx, ref.getRefName(), resURL);
               }
               else
               {
                  log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
                  Object bind = null;
                  if (ref.getJndiName() != null)
                  {
                     // Was the url given as a jndi-name reference to link to it
                     bind = new LinkRef(finalName);
                  }
                  else
                  {
                     // The url string was given via a resource-name mapping
                     bind = new URL(finalName);
                  }
                  Util.bind(envCtx, ref.getRefName(), bind);
               }
            }
            else
            {
               // Resource Manager bindings, should validate the type...
               log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName);
               Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
            }
         }
      }

      // Bind resource env references
      {
         Iterator i = beanMetaData.getResourceEnvReferences();
         while (i.hasNext())
         {
            ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next();
            String encName = resRef.getRefName();
            String jndiName = resRef.getJndiName();
            // Should validate the type...
            log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName);
            Util.bind(envCtx, encName, new LinkRef(jndiName));
         }
      }

      // Bind message destination references
      {
         Iterator i = beanMetaData.getMessageDestinationReferences();

         while (i.hasNext())
         {
            MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();

            String refName = ref.getRefName();
            String jndiName = ref.getJNDIName();
            String link = ref.getLink();
            if (link != null)
            {
               if (jndiName == null)
               {
                  MessageDestinationMetaData messageDestination = getMessageDestination(link);
View Full Code Here

/*      */     }
/*      */
/* 1246 */     Iterator i = beanMetaData.getEjbLocalReferences();
/* 1247 */     while (i.hasNext())
/*      */     {
/* 1249 */       EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next();
/* 1250 */       String refName = ref.getName();
/* 1251 */       this.log.debug("Binding an EJBLocalReference " + ref.getName());
/*      */
/* 1253 */       if (ref.getLink() != null)
/*      */       {
/* 1256 */         this.log.debug("Binding " + refName + " to bean source: " + ref.getLink());
/*      */
/* 1258 */         String jndiName = ref.getJndiName();
/*      */
/* 1260 */         Util.bind(envCtx, ref.getName(), new LinkRef(jndiName));
/*      */       }
/*      */       else
/*      */       {
/* 1265 */         if (ref.getJndiName() == null)
/*      */         {
/* 1267 */           throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml");
/*      */         }
/* 1269 */         Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName()));
/*      */       }
/*      */
/*      */     }
/*      */
/* 1276 */     ClassLoader loader = this.unit.getClassLoader();
/* 1277 */     UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(this.unit.getRoot());
/* 1278 */     Iterator serviceReferences = beanMetaData.getServiceReferences();
/* 1279 */     if (serviceReferences != null)
/*      */     {
/* 1281 */       while (serviceReferences.hasNext())
/*      */       {
/* 1283 */         ServiceReferenceMetaData sref = (ServiceReferenceMetaData)serviceReferences.next();
/* 1284 */         String refName = sref.getServiceRefName();
/* 1285 */         new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
/*      */       }
/*      */
/*      */     }
/*      */
/* 1292 */     Iterator i = beanMetaData.getResourceReferences();
/*      */
/* 1295 */     ApplicationMetaData application = beanMetaData.getApplicationMetaData();
/*      */
/* 1297 */     while (i.hasNext())
/*      */     {
/* 1299 */       ResourceRefMetaData ref = (ResourceRefMetaData)i.next();
/*      */
/* 1301 */       String resourceName = ref.getResourceName();
/* 1302 */       String finalName = application.getResourceByName(resourceName);
/* 1303 */       String resType = ref.getType();
/*      */
/* 1306 */       if (finalName == null) {
/* 1307 */         finalName = ref.getJndiName();
/*      */       }
/* 1309 */       if ((finalName == null) && (!resType.equals("java.net.URL")))
/*      */       {
/* 1314 */         if (ref.getType().equals("javax.sql.DataSource"))
/*      */         {
/* 1317 */           Context dsCtx = new InitialContext();
/*      */           try
/*      */           {
/* 1321 */             dsCtx.lookup("java:/DefaultDS");
/* 1322 */             finalName = "java:/DefaultDS";
/*      */           }
/*      */           catch (Exception e)
/*      */           {
/* 1326 */             this.log.debug("failed to lookup DefaultDS; ignoring", e);
/*      */           }
/*      */           finally
/*      */           {
/* 1330 */             dsCtx.close();
/*      */           }
/*      */
/*      */         }
/*      */
/* 1336 */         if (finalName == null)
/*      */         {
/* 1338 */           this.log.warn("No resource manager found for " + ref.getResourceName());
/* 1339 */           continue;
/*      */         }
/*      */       }
/*      */
/* 1343 */       if (resType.equals("java.net.URL"))
/*      */       {
/* 1346 */         if (ref.getResURL() != null)
/*      */         {
/* 1349 */           this.log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL());
/* 1350 */           URL resURL = new URL(ref.getResURL());
/* 1351 */           Util.bind(envCtx, ref.getRefName(), resURL);
/*      */         }
/*      */         else
/*      */         {
/* 1355 */           this.log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName);
/* 1356 */           Object bind = null;
/* 1357 */           if (ref.getJndiName() != null)
/*      */           {
/* 1360 */             bind = new LinkRef(finalName);
/*      */           }
/*      */           else
/*      */           {
/* 1365 */             bind = new URL(finalName);
/*      */           }
/* 1367 */           Util.bind(envCtx, ref.getRefName(), bind);
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/* 1373 */         this.log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName);
/* 1374 */         Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName));
/*      */       }
/*      */
/*      */     }
/*      */
/* 1381 */     Iterator i = beanMetaData.getResourceEnvReferences();
/* 1382 */     while (i.hasNext())
/*      */     {
/* 1384 */       ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next();
/* 1385 */       String encName = resRef.getRefName();
/* 1386 */       String jndiName = resRef.getJndiName();
/*      */
/* 1388 */       this.log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName);
/* 1389 */       Util.bind(envCtx, encName, new LinkRef(jndiName));
/*      */     }
/*      */
/* 1395 */     Iterator i = beanMetaData.getMessageDestinationReferences();
/*      */
/* 1397 */     while (i.hasNext())
/*      */     {
/* 1399 */       MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next();
/*      */
/* 1401 */       String refName = ref.getRefName();
/* 1402 */       String jndiName = ref.getJNDIName();
/* 1403 */       String link = ref.getLink();
/* 1404 */       if (link != null)
/*      */       {
/* 1406 */         if (jndiName == null)
/*      */         {
/* 1408 */           MessageDestinationMetaData messageDestination = getMessageDestination(link);
View Full Code Here

TOP

Related Classes of org.jboss.metadata.EjbLocalRefMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.