Пример #1
0
 /**
  * Initialize the initial context with the values of the passed properties.
  *
  * @param \AppserverIo\Properties\PropertiesInterface $properties The configuration properties
  */
 public function __construct(PropertiesInterface $properties = null)
 {
     // initialize the default properties if no ones has been passed
     if ($properties == null) {
         // initialize the default properties
         $properties = new Properties();
         foreach ($this->defaultProperties as $key => $value) {
             $properties->setProperty($key, $value);
         }
     }
     // inject the properties
     $this->injectProperties($properties);
     // create a factory for the lexer we use to parse the JNDI style bean names
     $factory = new UsingPregReplace(new LexerDataGenerator());
     // create the lexer instance and inject it
     $this->injectLexer($factory->createLexer(array('php' => InitialContext::T_SCHEME, 'global\\/([a-zA-Z0-9_-]+)' => InitialContext::T_GLOBAL_SCOPE, 'app' => InitialContext::T_APPLICATION_SCOPE, '\\:' => InitialContext::T_COLON, '\\/' => InitialContext::T_SEPARATOR, 'local|remote' => InitialContext::T_INTERFACE, '\\w+' => InitialContext::T_CLASS)));
 }
 /**
  * Initializes the connection.
  *
  * @param string                                      $appName    Name of the webapp using this client connection
  * @param \AppserverIo\Properties\PropertiesInterface $properties The properties containing the connection parameters
  */
 public function __construct($appName = '', PropertiesInterface $properties = null)
 {
     // set the application name
     $this->appName = $appName;
     // initialize the message queue parser and the session
     $this->parser = new MessageQueueParser();
     $this->sessions = new \ArrayObject();
     // initialize the default properties if no ones has been passed
     if ($properties == null) {
         // initialize the default properties
         $properties = new Properties();
         foreach ($this->defaultProperties as $key => $value) {
             $properties->setProperty($key, $value);
         }
     }
     // inject the properties
     $this->injectProperties($properties);
 }
 /**
  * Checks if the resource identifier will be initialized propertly
  * from a URL with global scope and remote interface.
  *
  * @return void
  */
 public function testWithDefaultPropertiesPopulatedWithGlobalScopeAndRemoteInterface()
 {
     // create default properties
     $defaultProperties = new Properties();
     $defaultProperties->setProperty('indexFile', InitialContextTest::INDEX_FILE);
     $defaultProperties->setProperty('contextName', InitialContextTest::CONTEXT_NAME);
     $defaultProperties->setProperty('transport', InitialContextTest::TRANSPORT);
     // create the initial context initialized with the default properties
     $this->initialContext->injectProperties($defaultProperties);
     // populate the identifier with the data of the passed URL
     $resourceIdentifier = $this->initialContext->prepareResourceIdentifier(InitialContextTest::IDENTIFIER_GLOBAL_REMOTE);
     // check the data from the resource identifier
     $this->assertSame(InitialContextTest::INDEX_FILE, $resourceIdentifier->getIndexFile());
     $this->assertSame(InitialContextTest::CLASS_NAME, $resourceIdentifier->getClassName());
     $this->assertSame(InitialContextTest::CONTEXT_NAME, $resourceIdentifier->getContextName());
     $this->assertSame(InitialContextTest::TRANSPORT, $resourceIdentifier->getTransport());
     $this->assertSame(EnterpriseBeanResourceIdentifier::REMOTE_INTERFACE, $resourceIdentifier->getInterface());
 }
Пример #4
0
 /**
  * Test the replaceProperties() method.
  *
  * @return void
  */
 public function testReplaceProperties()
 {
     // initialize the properties
     $properties = new Properties();
     $properties->setProperty('foo.bar', $propertyValue = 'foo.bar');
     // try to replace the variables in the node value's value
     $this->nodeValue->replaceProperties($properties);
     // assert that the property has been replaced
     $this->assertSame(str_replace('${foo.bar}', $propertyValue, $this->constructorValue), $this->nodeValue->getValue());
 }