svn commit: r819067 [2/3] - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/ entity/src/META-INF/services/ entity/src/org/ofbiz/entity/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r819067 [2/3] - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/ entity/src/META-INF/services/ entity/src/org/ofbiz/entity/

adrianc
Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/Delegator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=819067&view=auto
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (added)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java Fri Sep 25 23:36:13 2009
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.entity;
+
+import org.ofbiz.base.util.Factory;
+
+public interface DelegatorFactory extends Factory<Delegator> {}

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java?rev=819067&view=auto
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java (added)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java Fri Sep 25 23:36:13 2009
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.entity;
+
+import org.ofbiz.base.util.Debug;
+
+public class DelegatorFactoryImpl implements DelegatorFactory {
+
+    public static final String module = DelegatorFactoryImpl.class.getName();
+
+    public Delegator getInstance(Object obj) {
+        String delegatorName = null;
+        try {
+            delegatorName = (String) obj;
+        } catch (Exception e) {}
+        if (delegatorName == null) {
+            delegatorName = "default";
+            Debug.logWarning(new Exception("Location where getting delegator with null name"), "Got a getGenericDelegator call with a null delegatorName, assuming default for the name.", module);
+        }
+        GenericDelegator delegator = GenericDelegator.delegatorCache.get(delegatorName);
+        if (delegator == null) {
+            synchronized (GenericDelegator.delegatorCache) {
+                // must check if null again as one of the blocked threads can still enter
+                delegator = GenericDelegator.delegatorCache.get(delegatorName);
+                if (delegator == null) {
+                    if (Debug.infoOn()) Debug.logInfo("Creating new delegator [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", module);
+                    //Debug.logInfo(new Exception(), "Showing stack where new delegator is being created...", module);
+                    try {
+                        delegator = new GenericDelegator(delegatorName);
+                    } catch (GenericEntityException e) {
+                        Debug.logError(e, "Error creating delegator", module);
+                    }
+                    if (delegator != null) {
+                        GenericDelegator.delegatorCache.put(delegatorName, delegator);
+                    } else {
+                        Debug.logError("Could not create delegator with name " + delegatorName + ", constructor failed (got null value) not sure why/how.", module);
+                    }
+                }
+            }
+        }
+        return delegator;
+    }
+    
+}

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain