You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2010/12/10 10:14:43 UTC
svn commit: r1044245 [3/6] - in /ofbiz/branches/jquery: ./
applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/
applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/
applications/accounting/webapp/accounting/fin...
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Relation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLDelete.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLIndex.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLInsert.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLPlan.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLSelect.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLStatement.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLUpdate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SQLView.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SelectGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SelectPlan.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/SetField.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/StaticValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/StringValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Table.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/TableName.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Unioned.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/UpdatePlan.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Value.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ViewPlan.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/test/ConditionsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/test/Recorder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/test/SQLTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/test/SelectTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/test/ValuesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/start/src/org/ofbiz/base/start/Instrumenter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/start/src/org/ofbiz/base/start/InstrumenterWorker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/testtools/src/org/ofbiz/testtools/TestListContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java Fri Dec 10 09:14:36 2010
@@ -1,66 +1,66 @@
-/*******************************************************************************
- * 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.commons.vfs;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.impl.StandardFileSystemManager;
-import org.ofbiz.base.container.Container;
-import org.ofbiz.base.container.ContainerException;
-import org.ofbiz.base.util.UtilMisc;
-import org.webslinger.commons.vfs.VFSUtil;
-
-public class CommonsVfsContainer implements Container {
- private static StandardFileSystemManager sfsm;
-
- public void init(String[] args, String configFile) throws ContainerException {
- }
-
- public boolean start() throws ContainerException {
- try {
- StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
- FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
- sfsm.setBaseFile(currentDir);
- CommonsVfsContainer.sfsm = sfsm;
- } catch (FileSystemException e) {
- throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
- } catch (MalformedURLException e) {
- throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
- }
- return true;
- }
-
- public void stop() throws ContainerException {
- sfsm.close();
- sfsm = null;
- }
-
- public static FileObject resolveFile(String uri) throws IOException {
- return sfsm.resolveFile(uri);
- }
-
- public static FileSystemManager getFileSystemManager() {
- return sfsm;
- }
-}
+/*******************************************************************************
+ * 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.commons.vfs;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.impl.StandardFileSystemManager;
+import org.ofbiz.base.container.Container;
+import org.ofbiz.base.container.ContainerException;
+import org.ofbiz.base.util.UtilMisc;
+import org.webslinger.commons.vfs.VFSUtil;
+
+public class CommonsVfsContainer implements Container {
+ private static StandardFileSystemManager sfsm;
+
+ public void init(String[] args, String configFile) throws ContainerException {
+ }
+
+ public boolean start() throws ContainerException {
+ try {
+ StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
+ FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
+ sfsm.setBaseFile(currentDir);
+ CommonsVfsContainer.sfsm = sfsm;
+ } catch (FileSystemException e) {
+ throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
+ } catch (MalformedURLException e) {
+ throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
+ }
+ return true;
+ }
+
+ public void stop() throws ContainerException {
+ sfsm.close();
+ sfsm = null;
+ }
+
+ public static FileObject resolveFile(String uri) throws IOException {
+ return sfsm.resolveFile(uri);
+ }
+
+ public static FileSystemManager getFileSystemManager() {
+ return sfsm;
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java Fri Dec 10 09:14:36 2010
@@ -1,58 +1,58 @@
-/*******************************************************************************
- * 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.commons.vfs.ofbiz;
-
-import java.net.URL;
-import java.util.Collection;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.provider.AbstractFileProvider;
-import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
-import org.ofbiz.base.location.FlexibleLocation;
-import org.ofbiz.base.util.UtilMisc;
-import org.webslinger.commons.vfs.VFSUtil;
-
-public class OfbizComponentProvider extends AbstractFileProvider {
- public Collection<?> getCapabilities() {
- return DefaultLocalFileProvider.capabilities;
- }
-
- public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
- try {
- //name = name.replaceAll("^ofbiz-component://", "");
- int nameLength = name.length();
- int componentNameStart = 16;
- while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
- if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
- int componentNameEnd = componentNameStart;
- while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
- if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
- int restStart = componentNameEnd;
- while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
- if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
- String componentName = name.substring(componentNameStart, componentNameEnd);
- URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
- FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
- return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(restStart)).getURL().toString(), properties);
- } catch (Exception e) {
- throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
- }
- }
-}
+/*******************************************************************************
+ * 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.commons.vfs.ofbiz;
+
+import java.net.URL;
+import java.util.Collection;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.AbstractFileProvider;
+import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
+import org.ofbiz.base.location.FlexibleLocation;
+import org.ofbiz.base.util.UtilMisc;
+import org.webslinger.commons.vfs.VFSUtil;
+
+public class OfbizComponentProvider extends AbstractFileProvider {
+ public Collection<?> getCapabilities() {
+ return DefaultLocalFileProvider.capabilities;
+ }
+
+ public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
+ try {
+ //name = name.replaceAll("^ofbiz-component://", "");
+ int nameLength = name.length();
+ int componentNameStart = 16;
+ while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
+ if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
+ int componentNameEnd = componentNameStart;
+ while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
+ if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
+ int restStart = componentNameEnd;
+ while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
+ if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
+ String componentName = name.substring(componentNameStart, componentNameEnd);
+ URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
+ FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
+ return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(restStart)).getURL().toString(), properties);
+ } catch (Exception e) {
+ throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
+ }
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java Fri Dec 10 09:14:36 2010
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * 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.commons.vfs.ofbiz;
-
-import java.net.URL;
-import java.util.Collection;
-
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.provider.AbstractFileProvider;
-import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
-
-import org.ofbiz.base.location.FlexibleLocation;
-import org.ofbiz.base.util.UtilMisc;
-
-import org.webslinger.commons.vfs.VFSUtil;
-
-public class OfbizHomeProvider extends AbstractFileProvider {
- public Collection<?> getCapabilities() {
- return DefaultLocalFileProvider.capabilities;
- }
-
- public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
- //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
- try {
- URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
- FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
- return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
- } catch (Exception e) {
- throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
- }
- }
-}
+/*******************************************************************************
+ * 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.commons.vfs.ofbiz;
+
+import java.net.URL;
+import java.util.Collection;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.AbstractFileProvider;
+import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
+
+import org.ofbiz.base.location.FlexibleLocation;
+import org.ofbiz.base.util.UtilMisc;
+
+import org.webslinger.commons.vfs.VFSUtil;
+
+public class OfbizHomeProvider extends AbstractFileProvider {
+ public Collection<?> getCapabilities() {
+ return DefaultLocalFileProvider.capabilities;
+ }
+
+ public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
+ //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
+ try {
+ URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
+ FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
+ return VFSUtil.toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
+ } catch (Exception e) {
+ throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
+ }
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java Fri Dec 10 09:14:36 2010
@@ -1,73 +1,73 @@
-/*******************************************************************************
- * 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.webslinger;
-
-import java.util.Iterator;
-import java.util.Locale;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.ObjectType;
-import org.ofbiz.base.util.UtilHttp;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.model.ModelEntity;
-import org.ofbiz.entity.model.ModelField;
-import org.ofbiz.entity.model.ModelFieldType;
-
-public class EntityHttpUtil {
- public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
- return makeValidValue(entityName, false, request);
- }
-
- public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws GeneralException {
- if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest) request);
- throw new IllegalArgumentException("Not an HttpServletRequest");
- }
-
- public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
- return makeValidValue(entityName, false, request);
- }
-
- public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws GeneralException {
- Delegator delegator = (Delegator) request.getAttribute("delegator");
- GenericValue value = delegator.makeValue(entityName);
- ModelEntity model = value.getModelEntity();
- Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
- Locale locale = UtilHttp.getLocale(request);
- while (it.hasNext()) {
- ModelField field = it.next();
- String fieldName = field.getName();
- String parameterValue = request.getParameter(fieldName);
- Object fieldValue;
- if (parameterValue == null) {
- fieldValue = null;
- } else {
- ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
- String wantedType = fieldType.getJavaType();
- fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
- }
- value.put(fieldName, fieldValue);
- }
- return value;
- }
-}
-
+/*******************************************************************************
+ * 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.webslinger;
+
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelField;
+import org.ofbiz.entity.model.ModelFieldType;
+
+public class EntityHttpUtil {
+ public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
+ return makeValidValue(entityName, false, request);
+ }
+
+ public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws GeneralException {
+ if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest) request);
+ throw new IllegalArgumentException("Not an HttpServletRequest");
+ }
+
+ public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
+ return makeValidValue(entityName, false, request);
+ }
+
+ public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws GeneralException {
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+ GenericValue value = delegator.makeValue(entityName);
+ ModelEntity model = value.getModelEntity();
+ Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
+ Locale locale = UtilHttp.getLocale(request);
+ while (it.hasNext()) {
+ ModelField field = it.next();
+ String fieldName = field.getName();
+ String parameterValue = request.getParameter(fieldName);
+ Object fieldValue;
+ if (parameterValue == null) {
+ fieldValue = null;
+ } else {
+ ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
+ String wantedType = fieldType.getJavaType();
+ fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
+ }
+ value.put(fieldName, fieldValue);
+ }
+ return value;
+ }
+}
+
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/EntityTransactionUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java Fri Dec 10 09:14:36 2010
@@ -1,118 +1,118 @@
-/*******************************************************************************
- * 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.webslinger;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericPK;
-import org.ofbiz.entity.GenericValue;
-import org.webslinger.cache.ConcurrentCache;
-import org.webslinger.concurrent.ExecutionPool;
-
-public class StatsUpdater {
- private static final Updater UPDATER = new Updater();
-
- public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields, Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
- GenericPK pk = delegator.makePK(entityName, keyFields);
- Map<String, Long> value = UPDATER.getValue(pk);
- synchronized (value) {
- for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
- Long oldValue = value.get(entry.getKey());
- if (oldValue != null) {
- value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
- } else {
- value.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
-
- private static final class Updater implements Callable<Void> {
- protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class, "entities", null));
- protected ScheduledFuture<Void> future;
-
- protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
- synchronized (this) {
- if (future == null || future.isDone()) {
- future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
- }
- }
- try {
- return entities.get().get(pk);
- } catch (RuntimeException e) {
- throw e;
- } catch (GenericEntityException e) {
- throw e;
- } catch (Exception e) {
- throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
- }
- }
-
- public Void call() {
- EntityHolder oldEntities;
- EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
- do {
- oldEntities = entities.get();
- } while (!entities.compareAndSet(oldEntities, newEntities));
- synchronized (Updater.class) {
- for (GenericPK pk: oldEntities.keys()) {
- try {
- Map<String, Long> add = oldEntities.get(pk);
- GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
- if (existing == null) {
- existing = pk.getDelegator().create(pk.getEntityName(), pk);
- }
- for (Map.Entry<String, Long> entry: add.entrySet()) {
- Long value = entry.getValue();
- Long oldValue = existing.getLong(entry.getKey());
- if (oldValue != null) {
- existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
- } else {
- existing.put(entry.getKey(), value);
- }
- }
- existing.store();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- return null;
- }
- }
-
- private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
- protected EntityHolder(Class<?> owner, String field, String label) {
- super(owner, field, label, HARD);
- }
-
- @Override
- protected Map<String, Long> createValue(GenericPK pk) throws Exception {
- return new HashMap<String, Long>();
- }
- }
-}
+/*******************************************************************************
+ * 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.webslinger;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericPK;
+import org.ofbiz.entity.GenericValue;
+import org.webslinger.cache.ConcurrentCache;
+import org.webslinger.concurrent.ExecutionPool;
+
+public class StatsUpdater {
+ private static final Updater UPDATER = new Updater();
+
+ public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields, Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
+ GenericPK pk = delegator.makePK(entityName, keyFields);
+ Map<String, Long> value = UPDATER.getValue(pk);
+ synchronized (value) {
+ for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
+ Long oldValue = value.get(entry.getKey());
+ if (oldValue != null) {
+ value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
+ } else {
+ value.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ }
+
+ private static final class Updater implements Callable<Void> {
+ protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class, "entities", null));
+ protected ScheduledFuture<Void> future;
+
+ protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
+ synchronized (this) {
+ if (future == null || future.isDone()) {
+ future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
+ }
+ }
+ try {
+ return entities.get().get(pk);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (GenericEntityException e) {
+ throw e;
+ } catch (Exception e) {
+ throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
+ }
+ }
+
+ public Void call() {
+ EntityHolder oldEntities;
+ EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
+ do {
+ oldEntities = entities.get();
+ } while (!entities.compareAndSet(oldEntities, newEntities));
+ synchronized (Updater.class) {
+ for (GenericPK pk: oldEntities.keys()) {
+ try {
+ Map<String, Long> add = oldEntities.get(pk);
+ GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
+ if (existing == null) {
+ existing = pk.getDelegator().create(pk.getEntityName(), pk);
+ }
+ for (Map.Entry<String, Long> entry: add.entrySet()) {
+ Long value = entry.getValue();
+ Long oldValue = existing.getLong(entry.getKey());
+ if (oldValue != null) {
+ existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
+ } else {
+ existing.put(entry.getKey(), value);
+ }
+ }
+ existing.store();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
+ protected EntityHolder(Class<?> owner, String field, String label) {
+ super(owner, field, label, HARD);
+ }
+
+ @Override
+ protected Map<String, Long> createValue(GenericPK pk) throws Exception {
+ return new HashMap<String, Long>();
+ }
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerBSFServiceEngine.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerCatalinaContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java Fri Dec 10 09:14:36 2010
@@ -1,216 +1,216 @@
-/*******************************************************************************
- * 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.webslinger;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.DelegatorFactory;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.cache.Cache;
-import org.ofbiz.entity.util.EntityUtil;
-import org.ofbiz.security.SecurityFactory;
-import org.ofbiz.security.authz.AuthorizationFactory;
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.GenericDispatcher;
-import org.ofbiz.service.ServiceDispatcher;
-import org.webslinger.AbstractMappingWebslingerServletContextFactory;
-import org.webslinger.WebslingerServletContext;
-import org.webslinger.collections.CollectionUtil;
-import org.webslinger.lang.ObjectUtil;
-
-public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
- protected ServletContext servletContext;
- protected Delegator delegator;
- protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
-
- public void init(ServletConfig config) throws ServletException, IOException {
- System.err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
- servletContext = config.getServletContext();
- String delegatorName = servletContext.getInitParameter("entityDelegatorName");
- delegator = DelegatorFactory.getDelegator(delegatorName);
- String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
- if (readerFiles != null) {
- for (String reader: CollectionUtil.split(readerFiles, ";")) {
- URL url = config.getServletContext().getResource(reader);
- if (url != null) globalReaderURLs.add(url);
- }
- }
- super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
- }
-
- @Override
- protected Layout[] getStartLayouts() throws Exception {
- ArrayList<Layout> layouts = new ArrayList<Layout>();
- try {
- for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
- layouts.add(new OfbizLayout(value));
- }
- } catch (GenericEntityException e) {
- }
- return layouts.toArray(new Layout[layouts.size()]);
- }
-
- @Override
- public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
- request.setAttribute("servletContext", context);
- Object delegator = context.getAttribute("delegator");
- Object dispatcher = context.getAttribute("dispatcher");
- Object authz = context.getAttribute("authz");
- Object security = context.getAttribute("security");
- request.setAttribute("delegator", delegator);
- request.setAttribute("dispatcher", dispatcher);
- request.setAttribute("authz", authz);
- request.setAttribute("security", security);
- // FIXME!!! These next two are a hack until proper fake/wrapped session support is done in webslinger
- servletContext.setAttribute("delegator", delegator);
- servletContext.setAttribute("dispatcher", dispatcher);
- servletContext.setAttribute("authz", authz);
- servletContext.setAttribute("security", security);
- }
-
- @Override
- protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
- OfbizLayout ofbizLayout = (OfbizLayout) layout;
- Delegator delegator = null;
- delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
- context.setAttribute("delegator", delegator);
- context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator, globalReaderURLs));
- context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
- context.setAttribute("security", SecurityFactory.getInstance(delegator));
- }
-
- protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
- protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator, List<URL> globalReaderURLs) throws IOException {
- ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
- String readerFiles = context.getInitParameter("serviceReaderUrls");
- if (readerFiles != null) {
- for (String reader: CollectionUtil.split(readerFiles, ";")) {
- URL url = context.getResource(reader);
- if (url != null) readerURLs.add(url);
- }
- }
- System.err.println(readerURLs);
- this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
- };
- ClassLoader loader = null;
- try {
- loader = Thread.currentThread().getContextClassLoader();
- } catch (SecurityException e) {
- loader = WebslingerContextMapper.class.getClassLoader();
- }
- DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
- init(name, delegator, dc);
- }
- }
-
- @Override
- protected Set<String> getSuffixes() throws Exception {
- Cache cache = delegator.getCache();
- Set<String> suffixes;
- synchronized (WebslingerContextMapper.class) {
- suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
- if (suffixes == null) {
- suffixes = new HashSet<String>();
- for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
- suffixes.add(value.getString("hostSuffix"));
- }
- cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
- }
- }
- return suffixes;
- }
-
- @Override
- protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
- GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
- if (layout == null) return null;
- return new OfbizLayout(layout);
- }
-
- protected class OfbizLayout implements Layout {
- private final String contextPath;
- private final String id;
- private final String target;
- private final String[] bases;
- private final int hashCode;
- protected final String delegatorName;
- protected final String dispatcherName;
-
- protected OfbizLayout(GenericValue server) throws GenericEntityException {
- contextPath = server.getString("contextPath");
- id = server.getString("webslingerServerId");
- target = server.getString("target");
- List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
- bases = new String[baseValues.size()];
- for (int i = 0; i < bases.length; i++) {
- GenericValue baseValue = baseValues.get(i);
- bases[i] = baseValue.getString("baseName");
- }
- delegatorName = server.getString("delegatorName");
- dispatcherName = server.getString("dispatcherName");
- hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
- }
-
- public String getContextPath() {
- return contextPath;
- }
-
- public String getId() {
- return id;
- }
-
- public String getTarget() {
- return target;
- }
-
- public String[] getBases() {
- return bases;
- }
-
- @Override
- public int hashCode() {
- return hashCode;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof OfbizLayout)) return false;
- OfbizLayout other = (OfbizLayout) o;
- if (!contextPath.equals(other.contextPath)) return false;
- if (!target.equals(other.target)) return false;
- if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
- return Arrays.equals(bases, other.bases);
- }
- }
-}
+/*******************************************************************************
+ * 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.webslinger;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.DelegatorFactory;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.cache.Cache;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.security.SecurityFactory;
+import org.ofbiz.security.authz.AuthorizationFactory;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.ServiceDispatcher;
+import org.webslinger.AbstractMappingWebslingerServletContextFactory;
+import org.webslinger.WebslingerServletContext;
+import org.webslinger.collections.CollectionUtil;
+import org.webslinger.lang.ObjectUtil;
+
+public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
+ protected ServletContext servletContext;
+ protected Delegator delegator;
+ protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
+
+ public void init(ServletConfig config) throws ServletException, IOException {
+ System.err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
+ servletContext = config.getServletContext();
+ String delegatorName = servletContext.getInitParameter("entityDelegatorName");
+ delegator = DelegatorFactory.getDelegator(delegatorName);
+ String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
+ if (readerFiles != null) {
+ for (String reader: CollectionUtil.split(readerFiles, ";")) {
+ URL url = config.getServletContext().getResource(reader);
+ if (url != null) globalReaderURLs.add(url);
+ }
+ }
+ super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
+ }
+
+ @Override
+ protected Layout[] getStartLayouts() throws Exception {
+ ArrayList<Layout> layouts = new ArrayList<Layout>();
+ try {
+ for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
+ layouts.add(new OfbizLayout(value));
+ }
+ } catch (GenericEntityException e) {
+ }
+ return layouts.toArray(new Layout[layouts.size()]);
+ }
+
+ @Override
+ public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
+ request.setAttribute("servletContext", context);
+ Object delegator = context.getAttribute("delegator");
+ Object dispatcher = context.getAttribute("dispatcher");
+ Object authz = context.getAttribute("authz");
+ Object security = context.getAttribute("security");
+ request.setAttribute("delegator", delegator);
+ request.setAttribute("dispatcher", dispatcher);
+ request.setAttribute("authz", authz);
+ request.setAttribute("security", security);
+ // FIXME!!! These next two are a hack until proper fake/wrapped session support is done in webslinger
+ servletContext.setAttribute("delegator", delegator);
+ servletContext.setAttribute("dispatcher", dispatcher);
+ servletContext.setAttribute("authz", authz);
+ servletContext.setAttribute("security", security);
+ }
+
+ @Override
+ protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
+ OfbizLayout ofbizLayout = (OfbizLayout) layout;
+ Delegator delegator = null;
+ delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
+ context.setAttribute("delegator", delegator);
+ context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator, globalReaderURLs));
+ context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
+ context.setAttribute("security", SecurityFactory.getInstance(delegator));
+ }
+
+ protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
+ protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator, List<URL> globalReaderURLs) throws IOException {
+ ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
+ String readerFiles = context.getInitParameter("serviceReaderUrls");
+ if (readerFiles != null) {
+ for (String reader: CollectionUtil.split(readerFiles, ";")) {
+ URL url = context.getResource(reader);
+ if (url != null) readerURLs.add(url);
+ }
+ }
+ System.err.println(readerURLs);
+ this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
+ };
+ ClassLoader loader = null;
+ try {
+ loader = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException e) {
+ loader = WebslingerContextMapper.class.getClassLoader();
+ }
+ DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
+ init(name, delegator, dc);
+ }
+ }
+
+ @Override
+ protected Set<String> getSuffixes() throws Exception {
+ Cache cache = delegator.getCache();
+ Set<String> suffixes;
+ synchronized (WebslingerContextMapper.class) {
+ suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
+ if (suffixes == null) {
+ suffixes = new HashSet<String>();
+ for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
+ suffixes.add(value.getString("hostSuffix"));
+ }
+ cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
+ }
+ }
+ return suffixes;
+ }
+
+ @Override
+ protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
+ GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
+ if (layout == null) return null;
+ return new OfbizLayout(layout);
+ }
+
+ protected class OfbizLayout implements Layout {
+ private final String contextPath;
+ private final String id;
+ private final String target;
+ private final String[] bases;
+ private final int hashCode;
+ protected final String delegatorName;
+ protected final String dispatcherName;
+
+ protected OfbizLayout(GenericValue server) throws GenericEntityException {
+ contextPath = server.getString("contextPath");
+ id = server.getString("webslingerServerId");
+ target = server.getString("target");
+ List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
+ bases = new String[baseValues.size()];
+ for (int i = 0; i < bases.length; i++) {
+ GenericValue baseValue = baseValues.get(i);
+ bases[i] = baseValue.getString("baseName");
+ }
+ delegatorName = server.getString("delegatorName");
+ dispatcherName = server.getString("dispatcherName");
+ hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public String[] getBases() {
+ return bases;
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof OfbizLayout)) return false;
+ OfbizLayout other = (OfbizLayout) o;
+ if (!contextPath.equals(other.contextPath)) return false;
+ if (!target.equals(other.target)) return false;
+ if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
+ return Arrays.equals(bases, other.bases);
+ }
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=1044245&r1=1044244&r2=1044245&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java (original)
+++ ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java Fri Dec 10 09:14:36 2010
@@ -1,59 +1,59 @@
-/*******************************************************************************
- * 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.webslinger;
-
-import java.util.Map;
-
-import org.ofbiz.base.util.UtilGenerics;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.util.EntityUtil;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.ModelService;
-import org.ofbiz.service.ServiceDispatcher;
-import org.ofbiz.service.engine.GenericAsyncEngine;
-import org.webslinger.WebslingerServletContext;
-
-public class WebslingerServerEngine extends GenericAsyncEngine {
- public WebslingerServerEngine(ServiceDispatcher dispatcher) {
- super(dispatcher);
- }
-
- @Override
- public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
- runSync(localName, modelService, context);
- }
-
- @Override
- public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
- Delegator delegator = dispatcher.getDelegator();
- try {
- GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("webslingerServerId", modelService.location)));
- if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" + modelService.location + ")");
- return UtilGenerics.checkMap(WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080, modelService.invoke, context));
- } catch (RuntimeException e) {
- throw e;
- } catch (GenericServiceException e) {
- throw e;
- } catch (Exception e) {
- throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
- }
- }
-}
+/*******************************************************************************
+ * 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.webslinger;
+
+import java.util.Map;
+
+import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceDispatcher;
+import org.ofbiz.service.engine.GenericAsyncEngine;
+import org.webslinger.WebslingerServletContext;
+
+public class WebslingerServerEngine extends GenericAsyncEngine {
+ public WebslingerServerEngine(ServiceDispatcher dispatcher) {
+ super(dispatcher);
+ }
+
+ @Override
+ public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
+ runSync(localName, modelService, context);
+ }
+
+ @Override
+ public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws GenericServiceException {
+ Delegator delegator = dispatcher.getDelegator();
+ try {
+ GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("webslingerServerId", modelService.location)));
+ if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" + modelService.location + ")");
+ return UtilGenerics.checkMap(WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080, modelService.invoke, context));
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (GenericServiceException e) {
+ throw e;
+ } catch (Exception e) {
+ throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
+ }
+ }
+}
Propchange: ofbiz/branches/jquery/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java
------------------------------------------------------------------------------
svn:eol-style = native