Hi Anjana,

I think we can do this. We can make environment the union of the environment
passed when creating the factory and the environment passed when creating
the context. Thereby, both your requirement and the requirements of existing
code would be satisfied. I think the spec does allow that. WDYT?

Thanks,
Senaka.

On Sat, Jul 9, 2011 at 4:02 PM, Senaka Fernando <sen...@wso2.com> wrote:

> Hi Anjana,
>
> On Sat, Jul 9, 2011 at 3:51 PM, Anjana Fernando <anj...@wso2.com> wrote:
>
>>
>>
>> On Sat, Jul 9, 2011 at 11:59 AM, Senaka Fernando <sen...@wso2.com> wrote:
>>
>>>
>>> So, I guess that says, it loads the properties from a resource file and
>>>> makes them readily available?, so they don't actually need to pass those
>>>> into InitialContext constructor explicitly. Anyways, we'll put that aside
>>>> for the moment.
>>>>
>>>
>>> Tried to locate the resource file inside the binary but never found one.
>>> Where did you find this?
>>>
>>
>> I was also just saying, so the container (e.g. an appserver) will
>> initialise those internally. I'm also not sure, how it works in our case. As
>> It has said, some of these properties are read from Java system properties
>> and environment variables.
>>
>
> Nothing will magically happen unless you write code to do it. So, if you
> could point me to some instructions on how you think this should happen,
> that would be great. AFAIU, there is no such way that this happens right now
> in Carbon since we don't have any application-specific JNDI properties right
> now.
>
>
>>
>>
>>>
>>> Not really, see the difference of the code what you've written (focusing
>>> on the sections in bold). If someone passed the environment when creating a
>>> new initial context, that would get replaced with the one you pass when
>>> creating the factory. Note that I applied the latest fix that you sent a few
>>> minutes ago, and it still remains the same.
>>>
>>
>> If someone passes in the environment, those values would be the values
>> that would be received by CarbonInitialJNDIContextFactory#getInitialContext.
>> Wont they? .. So it's not like I'm generating some other environment values
>> on my own, but those are the ones that are passed in externally, and they
>> will be the same values used later.
>>
>
> The code that you provided might work for your case, but it will definitely
> break code that has been written properly using new
> InitialContext(environment), since you are making a substitution inside the
> code. I highlighted this in my previous response in bold. Can you suggest a
> better way of doing that? Plus, it would be great if you could point to some
> documentation which justifies what you've done is correct. Because, AFAIU,
> this is just a hack to get another bug fixed, from what I see.
>
> Thanks,
> Senaka.
>
>
>> Cheers,
>> Anjana.
>>
>>
>>>
>>> +++++++++++++++++++++++++
>>>      private static class CarbonInitialJNDIContext implements
>>> EventDirContext, LdapContext {
>>>
>>>          private Context initialContext;
>>> +        private Hashtable<?, ?> environment;
>>>          private Map<String, Context> contextCache =
>>>                  Collections.synchronizedMap(new HashMap<String,
>>> Context>());
>>>          private static ContextCleanupTask contextCleanupTask;
>>> @@ -777,7 +778,8 @@
>>>
>>> "JNDI.Restrictions.AllTenants.UrlContexts.UrlContext.Scheme"));
>>>          }
>>>
>>> -        public CarbonInitialJNDIContext(Context initialContext) throws
>>> NamingException {
>>> +        public CarbonInitialJNDIContext(Hashtable<?, ?> environment,
>>> Context initialContext) throws NamingException {
>>> +            this.environment = environment;
>>>              this.initialContext = initialContext;
>>>          }
>>>
>>> @@ -815,7 +817,7 @@
>>>          private boolean isBaseContextRequested() {
>>>
>>>              try {
>>> *-                String baseContextRequested = (String)
>>> this.initialContext.getEnvironment().
>>> +                String baseContextRequested = (String)
>>> this.getEnvironment().*
>>>                          get(CarbonConstants.REQUEST_BASE_CONTEXT);
>>>                  if (baseContextRequested != null &&
>>> baseContextRequested.equals("true")) {
>>>                      return true;
>>> @@ -849,7 +851,7 @@
>>>                      } else {
>>>                          try {
>>>
>>>                              Context urlContext =
>>> NamingManager.getURLContext(scheme,
>>> *-                                    initialContext.getEnvironment());
>>> +                                    this.getEnvironment());*
>>>                              if (urlContext != null) {
>>>                                  contextCache.put(scheme, urlContext);
>>>                                  base = urlContext;
>>> @@ -1043,7 +1045,8 @@
>>>              if
>>> (isSubTenant(getCurrentCarbonContextHolder().getTenantId())) {
>>>                  throw new NamingException("Tenants cannot retrieve the
>>> environment.");
>>>              }
>>> *-            return getInitialContext().getEnvironment();
>>> +            //return getInitialContext().getEnvironment();
>>> +            return environment;*
>>>          }
>>> +++++++++++++++++++++++++
>>>
>>> Thanks,
>>> Senaka.
>>>
>>>
>>>> public Context getInitialContext(Hashtable<?, ?> h) throws
>>>> NamingException {
>>>>             return new CarbonInitialJNDIContext((Hashtable<?, ?>)
>>>> h.clone(),
>>>>                     factory.getInitialContext(h));
>>>>         }
>>>>
>>>> That's the modified method of mine, there it seems
>>>> "factory.getInitialContext(h)" changes "h". That's why I did a clone of it
>>>> and saved elsewhere (maybe we should also give a clone to the 2'nd
>>>> parameter, since he's the one changing it).
>>>>
>>>> [1]
>>>> http://download.oracle.com/javase/1.4.2/docs/api/javax/naming/spi/InitialContextFactory.html#getInitialContext%28java.util.Hashtable%29
>>>>
>>>> Cheers,
>>>> Anjana.
>>>>
>>>>
>>>>
>>>>>
>>>>> [1]
>>>>> http://download.oracle.com/javase/6/docs/api/javax/naming/InitialContext.html#InitialContext%28%29
>>>>> [2]
>>>>> http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#RESOURCEFILES
>>>>>
>>>>> Thanks,
>>>>> Senaka.
>>>>>
>>>>>>
>>>>>> Cheers,
>>>>>> Anjana.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Senaka.
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Jul 8, 2011 at 9:22 PM, Anjana Fernando <anj...@wso2.com>wrote:
>>>>>>>
>>>>>>>> Reminder, this issue should be fixed for the Stratos release. I've
>>>>>>>> created a JIRA here [1].
>>>>>>>>
>>>>>>>> [1] https://wso2.org/jira/browse/CARBON-10975
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Anjana.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Jul 3, 2011 at 4:33 PM, Anjana Fernando <anj...@wso2.com>wrote:
>>>>>>>>
>>>>>>>>> Hi Amila,
>>>>>>>>>
>>>>>>>>> On Sat, Jul 2, 2011 at 11:20 PM, Amila Jayasekara <ami...@wso2.com
>>>>>>>>> > wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Any idea, which call causes CarbonInitialJNDIContextFactory to
>>>>>>>>>> pass an
>>>>>>>>>> empty hash table ?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Passed the empty hashtable as in, a proper one is passed into the
>>>>>>>>> place at line 755 (in the code that's in svn). There it says
>>>>>>>>> "factory.getInitialContext(h)", and creates an InitialContext object, 
>>>>>>>>> that
>>>>>>>>> object in the construction somehow empties out the hashtable as given 
>>>>>>>>> as "h"
>>>>>>>>> here. Anyhow, the result is at line 852, the expression
>>>>>>>>> "initialContext.getEnvironment()" returns an empty Hashtable object.
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Anjana.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> AmilaJ
>>>>>>>>>>
>>>>>>>>>> >
>>>>>>>>>> > Another thing to note is, the ESB has the geronimo-jta lib. This
>>>>>>>>>> causes
>>>>>>>>>> > Atomikos to not to work properly, since the JDK also has these
>>>>>>>>>> libs, and you
>>>>>>>>>> > will ultimately get an ClassCastException. So I simply deleted
>>>>>>>>>> this jar and
>>>>>>>>>> > it worked without any issues.
>>>>>>>>>> >
>>>>>>>>>> > Cheers,
>>>>>>>>>> > Anjana.
>>>>>>>>>> >
>>>>>>>>>> > --
>>>>>>>>>> > Anjana Fernando
>>>>>>>>>> > Senior Software Engineer
>>>>>>>>>> > WSO2 Inc. | http://wso2.com
>>>>>>>>>> > lean . enterprise . middleware
>>>>>>>>>> >
>>>>>>>>>> > _______________________________________________
>>>>>>>>>> > Carbon-dev mailing list
>>>>>>>>>> > Carbon-dev@wso2.org
>>>>>>>>>> > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Carbon-dev mailing list
>>>>>>>>>> Carbon-dev@wso2.org
>>>>>>>>>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> *Anjana Fernando*
>>>>>>>>> Senior Software Engineer
>>>>>>>>> WSO2 Inc. | http://wso2.com
>>>>>>>>> lean . enterprise . middleware
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Anjana Fernando*
>>>>>>>> Senior Software Engineer
>>>>>>>> WSO2 Inc. | http://wso2.com
>>>>>>>> lean . enterprise . middleware
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Senaka Fernando*
>>>>>>> Product Manager - WSO2 Governance Registry;
>>>>>>> Associate Technical Lead; WSO2 Inc.; http://wso2.com*
>>>>>>> Member; Apache Software Foundation; http://apache.org
>>>>>>>
>>>>>>> E-mail: senaka AT wso2.com
>>>>>>> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
>>>>>>> Linked-In: http://linkedin.com/in/senakafernando
>>>>>>>
>>>>>>> *Lean . Enterprise . Middleware
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Anjana Fernando*
>>>>>> Senior Software Engineer
>>>>>> WSO2 Inc. | http://wso2.com
>>>>>> lean . enterprise . middleware
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Senaka Fernando*
>>>>> Product Manager - WSO2 Governance Registry;
>>>>> Associate Technical Lead; WSO2 Inc.; http://wso2.com*
>>>>> Member; Apache Software Foundation; http://apache.org
>>>>>
>>>>> E-mail: senaka AT wso2.com
>>>>> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
>>>>> Linked-In: http://linkedin.com/in/senakafernando
>>>>>
>>>>> *Lean . Enterprise . Middleware
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Anjana Fernando*
>>>> Senior Software Engineer
>>>> WSO2 Inc. | http://wso2.com
>>>> lean . enterprise . middleware
>>>>
>>>
>>>
>>>
>>>
>>> --
>>> *Senaka Fernando*
>>> Product Manager - WSO2 Governance Registry;
>>> Associate Technical Lead; WSO2 Inc.; http://wso2.com*
>>> Member; Apache Software Foundation; http://apache.org
>>>
>>> E-mail: senaka AT wso2.com
>>> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
>>> Linked-In: http://linkedin.com/in/senakafernando
>>>
>>> *Lean . Enterprise . Middleware
>>>
>>>
>>
>>
>> --
>> *Anjana Fernando*
>> Senior Software Engineer
>> WSO2 Inc. | http://wso2.com
>> lean . enterprise . middleware
>>
>
>
>
> --
> *Senaka Fernando*
> Product Manager - WSO2 Governance Registry;
> Associate Technical Lead; WSO2 Inc.; http://wso2.com*
> Member; Apache Software Foundation; http://apache.org
>
> E-mail: senaka AT wso2.com
> **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
> Linked-In: http://linkedin.com/in/senakafernando
>
> *Lean . Enterprise . Middleware
>
>


-- 
*Senaka Fernando*
Product Manager - WSO2 Governance Registry;
Associate Technical Lead; WSO2 Inc.; http://wso2.com*
Member; Apache Software Foundation; http://apache.org

E-mail: senaka AT wso2.com
**P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818
Linked-In: http://linkedin.com/in/senakafernando

*Lean . Enterprise . Middleware
_______________________________________________
Carbon-dev mailing list
Carbon-dev@wso2.org
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to