Package nexj.core.meta

Examples of nexj.core.meta.Component


      Context contextSaved = ThreadContextHolder.getContext();

      try
      {
         DataSource db = metadata.getDataSource(sDataSource);
         Component comp = metadata.findComponent("System.InvocationContext");
         context = (comp != null) ? (InvocationContext)comp.getInstance(null) : new InvocationContext(metadata);

         context.initialize(null);
         context.setLocale(Locale.getDefault());
         context.setProtected(false);
         context.setSecure(false);
View Full Code Here


      RelationalSchema schema = new RelationalSchema();
      RelationalDatabase ds = new RelationalDatabase(null);
      DataSourceType dsType = new DataSourceType(null);
      Table table = new Table(schema);
      Column column = new Column("testColumn", table);
      Component converter = new Component(null, NullConverter.class, Component.SINGLETON);

      converter.addPrimitivePropertyInitializer("type", Primitive.TIMESTAMP);
      converter.addPrimitivePropertyInitializer("value", "1800-01-01 00:00:00");
      column.setType(Primitive.TIMESTAMP); // something that's not a String
      column.setNullable(false);
      column.setConverter(converter);
      table.setName("TestTable");
      table.addColumn(column);
View Full Code Here

      };
      SQLSchemaManager manager = m_adapter.createSchemaManager();
      RelationalSchemaUpgrade upgradeVersion;

      ds.setAdapter(valid);
      ds.setComponent(new Component("Component"));
      ds.setSchema(schema);
      ds.setType(new DataSourceType("DataSourceType"));
      ds.getType().setMetadata(metadata);
      ds.getType().addAdapter(ds.getAdapter());
      ds.getType().addAdapter(invalid);
View Full Code Here

   public void loadConnection(Element element, final DataSource source, final XMLMetadataLoader loader)
   {
      final FileDataSource fileDS = (FileDataSource)source;
      final FileDataSourceFragment defaultFragment = (FileDataSourceFragment)fileDS.getDefaultFragment();

      final Component component = new Component(source.getName(), source.getAdapter().getClassObject(), Component.CONTEXT);

      fileDS.setComponent(component);
      component.setMetadata(loader.getMetadata());

      if (element != null)
      {
         //This loads the default fragment properties off the main FileStorageConnection node
         loadFragment(element, defaultFragment, false);

         //Load property overrides for each fragment off the fragment nodes
         XMLUtil.withFirstChildElement(element, "Fragments", false, new ElementHandler()
         {
            public void handleElement(Element fragmentsElement)
            {
               XMLUtil.forEachChildElement(fragmentsElement, "Fragment", getHelper().new ElementHandler("fragment")
               {
                  protected void handleElement(Element fragmentElement, String sName)
                  {
                     FileDataSourceFragment fragment = (FileDataSourceFragment)defaultFragment.clone();

                     fragment.setName(sName);
                     loadFragment(fragmentElement, fragment, true);
                     fileDS.addFragment(fragment);
                  }
               });
            }
         });

         if (!loader.isEnvironmentOnly())
         {
            loader.addEnvironmentFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
            {
               public void fixup()
               {
                  Component cf = null;

                  for (Iterator itr = fileDS.getFragmentIterator(); itr.hasNext(); )
                  {
                     FileDataSourceFragment fragment = (FileDataSourceFragment)itr.next();

                     if (J2EEUtil.isContained())
                     {
                        cf = new Component(source.getName() + ".ConnectionFactory" + fragment.getSuffix(),
                           loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.file.JNDIFileStorageConnectionFactory"),
                           Component.SINGLETON);

                        cf.addPrimitivePropertyInitializer("factoryName", J2EEUtil.JNDI_ENV_PREFIX + "fileStorage/" + fileDS.getName() + fragment.getSuffix());
                        cf.addPrimitivePropertyInitializer("dataSource", fileDS);
                     }
                     else
                     {
                        cf = new Component(source.getName() + ".ConnectionFactory" + fragment.getSuffix(),
                           loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.file.XAFileStorageConnectionFactory"),
                           Component.SINGLETON);

                        cf.addPrimitivePropertyInitializer("fragment", fragment);

                        final ComponentPropertyInitializer initializer = cf.addComponentPropertyInitializer("transactionManager", null);

                        loader.addComponentFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
                        {
                           public void fixup()
                           {
                              initializer.setInstanceComponent(loader.getMetadata().getComponent("System.TransactionManager"));
                           }
                        });
                     }

                     cf.setMetadata(loader.getMetadata());
                     fragment.setConnectionFactory(cf);
                     loader.addSingletonFixup(cf);
                  }

                  if (fileDS.getFragmentCount() > 1)
View Full Code Here

      OID oid = instance.getOID();
      VirtualWork work = getWork(uow, VirtualWork.CREATE, instance);

      if (oid == null)
      {
         Component keyGen = mapping.getKeyGenerator();

         if (keyGen != null)
         {
            oid = ((OIDGenerator)keyGen.getInstance(uow.getInvocationContext())).generateOID(instance, this);
         }
         else
         {
            // Compute OID from attribute values
            Object[] valueArray = null;
View Full Code Here

    */
   public void loadConnection(Element element, DataSource source, final XMLMetadataLoader loader)
   {
      final VirtualDataSource ds = (VirtualDataSource)source;
      final VirtualDataSourceFragment defaultFragment = (VirtualDataSourceFragment)ds.getDefaultFragment();
      Component adapter = new Component(ds.getName(), ds.getAdapter().getClassObject(), Component.CONTEXT);

      ds.setComponent(adapter);
      adapter.setMetadata(loader.getMetadata());

      if (element != null)
      {
         loadFragment(element, defaultFragment, loader);

         XMLUtil.withFirstChildElement(element, "Fragments", false, new ElementHandler()
         {
            public void handleElement(Element fragmentsElement)
            {
               XMLUtil.forEachChildElement(fragmentsElement, "Fragment", loader.getHelper().new ElementHandler("fragment")
               {
                  protected void handleElement(Element fragmentElement, String sName)
                  {
                     VirtualDataSourceFragment fragment = (VirtualDataSourceFragment)defaultFragment.clone(false);

                     fragment.setName(sName);
                     loadFragment(fragmentElement, fragment, loader);
                     ds.addFragment(fragment);
                  }
               });
            }
         });

         if (ds.getFragmentCount() > 1)
         {
            adapter.addPrimitivePropertyInitializer("fragmented", Boolean.TRUE);
         }
      }
      else
      {
         // Disable if no connection file entry.
View Full Code Here

   {
      final ObjectQueue msg = (ObjectQueue)channel;

      if (msg.isSendable())
      {
         Component component = new Component("ObjectSender." + channel.getName(), channel.getType().getSender(), Component.CONTEXT);
         loader.getMetadata().addComponent(component);
         msg.setSender(component);
         component.addPrimitivePropertyInitializer("channel", channel);
      }

      if (msg.isReceivable())
      {
         Component component = new Component("ObjectReceiver." + channel.getName(), channel.getType().getReceiver(), Component.SINGLETON);

         loader.addSingletonFixup(component);
         msg.setReceiver(component);
         component.setMetadata(loader.getMetadata());
         component.addPrimitivePropertyInitializer("channel", channel);

         final PrimitivePropertyInitializer dispatcherInitializer = component.addPrimitivePropertyInitializer("dispatcherComponent", null);

         loader.addComponentFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
         {
            public void fixup()
            {
View Full Code Here

         udp.setTOS(XMLUtil.getIntAttr(element, "tos", udp.getTOS()));
      }

      if (udp.isSendable())
      {
         Component component = new Component("UDPSender." + channel.getName(), channel.getType().getSender(), Component.SINGLETON);
         loader.getMetadata().addComponent(component);
         loader.addSingletonFixup(component);
         udp.setSender(component);
         component.addPrimitivePropertyInitializer("channel", channel);
      }

      if (udp.isReceivable())
      {
         Component component = new Component("UDPReceiver." + channel.getName(), channel.getType().getReceiver(), Component.SINGLETON);

         loader.addSingletonFixup(component);
         udp.setReceiver(component);
         component.setMetadata(loader.getMetadata());
         component.addPrimitivePropertyInitializer("channel", channel);

         final PrimitivePropertyInitializer initializer = component.addPrimitivePropertyInitializer("contextComponent", null);

         loader.addComponentFixup(new XMLMetadataHelper.ContextFixup(loader.getHelper())
         {
            public void fixup()
            {
View Full Code Here

               XMLUtil.withFirstChildElement(relationalMappingElement, "Hook", false, new ElementHandler()
               {
                  public void handleElement(Element componentElement)
                  {
                     final Component hook = new Component("<PersistenceHook:" + metaclass.getName() + ">");

                     m_loader.loadComponent(componentElement, hook);

                     if (!loader.isRuntimeExcluded())
                     {
View Full Code Here

      if (adapter == null)
      {
         return; // no RDBMS mapping defined for "optional" DataSource, hence no component required
      }

      final Component component =
         new Component(source.getName(), adapter.getClassObject(), Component.CONTEXT);

      component.setMetadata(loader.getMetadata());

      if (element != null)
      {
         XMLUtil.withFirstChildElement(element, "SQLHook", false, new ElementHandler()
         {
            public void handleElement(Element componentElement)
            {
               Component hook = new Component("<SQLHook:" + source.getName() + ">");

               m_loader.loadComponent(componentElement, hook);
               component.addComponentPropertyInitializer("SQLHook", hook);
            }
         });
      }

      db.setComponent(component);

      if (adapter.getVersion() != null)
      {
         component.addPrimitivePropertyInitializer("version", adapter.getVersion());
      }

      if (!db.isUnicode())
      {
         component.addPrimitivePropertyInitializer("unicode", Boolean.FALSE);
      }

      if (db.isLiteral())
      {
         component.addPrimitivePropertyInitializer("literal", Boolean.TRUE);
      }

      if (!loader.isEnvironmentOnly() && !loader.isValidatedOnly())
      {
         loader.addEnvironmentFixup(new ContextFixup(loader.getHelper())
         {
            public void fixup()
            {
               Component cf = null;

               for (Iterator fragmentItr = db.getFragmentIterator(); fragmentItr.hasNext();)
               {
                  RelationalDatabaseFragment fragment = (RelationalDatabaseFragment)fragmentItr.next();

                  if (J2EEUtil.isContained() && db.isEnabled())
                  {
                     cf = new Component(source.getName() + ".ConnectionFactory" + fragment.getSuffix(),
                        loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.sql.SQLJNDIConnectionFactory"),
                        Component.SINGLETON);

                     cf.addPrimitivePropertyInitializer("dataSource", db.getName() + fragment.getSuffix());
                  }
                  else
                  {
                     cf = new Component(source.getName() + ".ConnectionFactory" + fragment.getSuffix(),
                        loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.sql.SQLRAConnectionFactory"),
                        Component.SINGLETON);

                     SQLAdapter adapterInstance = (SQLAdapter)component.getInstance(null);

                     cf.addPrimitivePropertyInitializer("fragment", fragment);
                     cf.addPrimitivePropertyInitializer("initialSQL", adapterInstance.getInitialSQL());
                     cf.addPrimitivePropertyInitializer("testSQL", adapterInstance.getTestSQL());
                  }

                  cf.setMetadata(loader.getMetadata());
                  fragment.setConnectionFactory(cf);
                  loader.addSingletonFixup(cf);
               }

               if (db.getFragmentCount() > 1)
               {
                  cf = new Component(source.getName() + ".FragmentConnectionFactory",
                           loader.getHelper().getClassObject(SysUtil.PACKAGE + ".core.persistence.sql.SQLFragmentConnectionFactory"),
                     Component.SINGLETON);

                  cf.setMetadata(loader.getMetadata());
                  cf.addPrimitivePropertyInitializer("database", db);
                  component.addPrimitivePropertyInitializer("fragmented", Boolean.TRUE);
               }

               component.addComponentPropertyInitializer("connectionFactory", cf);
            }
View Full Code Here

TOP

Related Classes of nexj.core.meta.Component

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.