Package nexj.core.runtime

Examples of nexj.core.runtime.InvocationContext


   /**
    * @see nexj.core.tools.ContextREPL#initializeContext()
    */
   protected Context initializeContext()
   {
      InvocationContext context = (InvocationContext)Repository.getMetadata().getComponent("System.InvocationContext")
         .getInstance(null);

      context.setAudited(false);
      context.initialize((m_sUser == null) ? null : new SimplePrincipal(m_sUser));
      context.setLocale(Locale.getDefault());
      context.getUnitOfWork().commit();

      ThreadContextHolder.setContext(context);

      assert context.getMachine() != null;

      return context;
   }
View Full Code Here


      InputStream in = URLUtil.openStream(new URL(URLUtil.toURL(sInputURL)));
      Writer out = // for requested DataSources
         IOUtil.openBufferedWriter((URLUtil.isURL(sOutputURL)) ?
            new File(new URI(sOutputURL)) : new File(sOutputURL), XMLUtil.ENCODING);
      Set dataSourceSet = null;
      InvocationContext context =
         (InvocationContext)metadata.getComponent("System.InvocationContext").getInstance(null);

      context.initialize(null);
      context.setLocale(Locale.getDefault());
      context.setProtected(false);
      context.setSecure(false);
      context.setPartitioned(false);

      if (sDataSources != null && !"*".equals(sDataSources))
      {
         dataSourceSet = new HashHolder();

View Full Code Here

   /**
    * @see nexj.core.persistence.sql.SQLConnectionFactory#getConnection(nexj.core.persistence.sql.SQLAdapter)
    */
   public Connection getConnection(SQLAdapter adapter) throws SQLException
   {
      InvocationContext context = (adapter == null) ? null : adapter.getInvocationContext();

      return ((SQLConnectionFactory)((RelationalDatabaseFragment)m_database
            .getFragment((context == null) ? null : context.getUnitOfWork().getFragmentName()))
            .getConnectionFactory().getInstance(context)).getConnection(adapter);
   }
View Full Code Here

    * @param sDataSource The data source name.
    * @return false if a SQL connection could not be obtained
    */
   public static void testConnection(Metadata metadata, String sDataSource) throws SQLException
   {
      InvocationContext context = null;
      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);
         context.setPartitioned(false);

         for (Iterator itr = db.getFragmentIterator(); itr.hasNext();)
         {
            Object o = itr.next();

            if (o instanceof RelationalDatabaseFragment)
            {
               ((SQLConnectionFactory)((RelationalDatabaseFragment)o).getConnectionFactory().getInstance(context))
                  .getConnection(null).close();
            }
         }
      }
      finally
      {
         if (context != null)
         {
            context.complete(false);
         }

         ThreadContextHolder.setContext(contextSaved);
      }
   }
View Full Code Here

      Writer writer = null;
     
      try
      {
         StringWriter sw = new StringWriter(4096);
         new SOAPMarshaller(new InvocationContext(
            new XMLMetadata("", null, null, null, null))).serialize(obj, sw);

         String str = XMLUtil.formatXML(sw.toString());
         StringBuffer buf = new StringBuffer(4096);
         boolean bGenerate = StringUtil.parseBoolean(SysUtil.getConfigProperties().getProperty(REF_GENERATE_PROPERTY, "false"));
View Full Code Here

   protected void setUp() throws Exception
   {
      super.setUp();

      m_metadata = Repository.getMetadata();
      m_context = new InvocationContext(m_metadata);
      m_parser = new SchemeParser(m_context.getMachine().getGlobalEnvironment());
      m_compiler = new Compiler();

      try
      {
View Full Code Here

public class XMLUnmarshallerTest extends TestCase
{
   public void testTransferObject() throws MarshallerException, IOException
   {
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      Metaclass metaclass = Repository.getMetadata().findMetaclass("User");
      StringReader reader = new StringReader(
         "<User xmlns=\"" + XML.NS_URI_TNS + "\">" +
         "<fullName>fullname</fullName>" +
         "<names>name1</names><names>name2</names><names>name3</names>" +
View Full Code Here

      assertEquals("name3", ((List)list).get(2));
   }

   public void testDynamicChangeRequest() throws MarshallerException, IOException
   {
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      SchemeParser parser = new SchemeParser(new InvocationContext(Repository.getMetadata())
         .getMachine().getGlobalEnvironment());
      StringReader reader = new StringReader("<Change-Request xmlns=\"" + XML.NS_URI_TNS
         + "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><objects x" + "si:type=\"User\"><"
         + XML.BASE_PREFIX + "oid>10e8359492f25f4be49109b9979e684ff3</" + XML.BASE_PREFIX
         + "oid><" + XML.BASE_PREFIX + "event>welcome</" + XML.BASE_PREFIX
View Full Code Here

      assertNull(changeRequest.getMetaclass());
   }
  
   public void testDynamicReadRequest() throws MarshallerException, IOException
   {
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      SchemeParser parser = new SchemeParser(new InvocationContext(Repository.getMetadata())
         .getMachine().getGlobalEnvironment());
      StringReader reader = new StringReader("<Read-Request xmlns=\"" + XML.NS_URI_TNS + "\">"
         + "<class>User-test</class><attributes>(fullName)</attributes>"
         + "<where></where><orderBy></orderBy><count>8</count><offset>0</offset></Read-Request>");
      XMLReadRequest readRequest = (XMLReadRequest)unmarshaller.deserialize(reader);
View Full Code Here

      assertNull(readRequest.getMetaclass());
   }
  
   public void testDynamicRestrictedChangeRequest() throws MarshallerException, IOException
   {
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      SchemeParser parser = new SchemeParser(new InvocationContext(Repository.getMetadata())
         .getMachine().getGlobalEnvironment());
      StringReader reader = new StringReader("<User-Change-Request xmlns=\"" + XML.NS_URI_TNS
         + "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><objects x" + "si:type=\"User\"><"
         + XML.BASE_PREFIX + "oid>10e8359492f25f4be49109b9979e684ff3</" + XML.BASE_PREFIX
         + "oid><" + XML.BASE_PREFIX + "event>welcome</" + XML.BASE_PREFIX
View Full Code Here

TOP

Related Classes of nexj.core.runtime.InvocationContext

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.