You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/10/20 12:49:36 UTC
svn commit: r1186730 [16/22] - in /myfaces/commons/branches/jsf_20: examples/
examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/
examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/acces...
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/FilterRegistration.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/FilterRegistration.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/FilterRegistration.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/FilterRegistration.java Thu Oct 20 10:49:18 2011
@@ -1,33 +1,33 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
-
-import java.util.Collection;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public interface FilterRegistration extends Registration
-{
- Collection<String> getServletNameMappings();
-
- Collection<String> getUrlPatternMappings();
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public interface FilterRegistration extends Registration
+{
+ Collection<String> getServletNameMappings();
+
+ Collection<String> getUrlPatternMappings();
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/FilterRegistration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/Registration.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/Registration.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/Registration.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/Registration.java Thu Oct 20 10:49:18 2011
@@ -1,40 +1,40 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
-
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public interface Registration
-{
- /**
- *
- * @return the class name of filter or servlet this registered
- */
- String getClassName();
-
- /**
- *
- * @return name of filter or servlet this initialised
- */
- String getName();
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
+
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public interface Registration
+{
+ /**
+ *
+ * @return the class name of filter or servlet this registered
+ */
+ String getClassName();
+
+ /**
+ *
+ * @return name of filter or servlet this initialised
+ */
+ String getName();
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/Registration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/ServletRegistration.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/ServletRegistration.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/ServletRegistration.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/ServletRegistration.java Thu Oct 20 10:49:18 2011
@@ -1,31 +1,31 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
-
-import java.util.Collection;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public interface ServletRegistration extends Registration
-{
- Collection<String> getMappings();
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public interface ServletRegistration extends Registration
+{
+ Collection<String> getMappings();
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/ServletRegistration.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationImpl.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationImpl.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationImpl.java Thu Oct 20 10:49:18 2011
@@ -1,89 +1,89 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class FilterRegistrationImpl implements FilterRegistration
-{
-
- private final String name;
- private String className;
- private Set<String> servletNameMappings = new HashSet<String>();
- private Set<String> urlNameMappings = new HashSet<String>();
-
- public FilterRegistrationImpl(
- String name)
- {
- this.name = name;
- }
-
- public FilterRegistrationImpl(
- String name,
- String className)
- {
- this.name = name;
- this.className = className;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Collection<String> getServletNameMappings()
- {
- return Collections.unmodifiableCollection(servletNameMappings);
- }
-
- public Collection<String> getUrlPatternMappings()
- {
- return Collections.unmodifiableCollection(urlNameMappings);
- }
-
- public void addUrlNameMapping(String url)
- {
- urlNameMappings.add(url);
- }
-
- public void addServletNameMapping(String url)
- {
- servletNameMappings.add(url);
- }
-
- public void setClassName(String className)
- {
- this.className = className;
- }
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class FilterRegistrationImpl implements FilterRegistration
+{
+
+ private final String name;
+ private String className;
+ private Set<String> servletNameMappings = new HashSet<String>();
+ private Set<String> urlNameMappings = new HashSet<String>();
+
+ public FilterRegistrationImpl(
+ String name)
+ {
+ this.name = name;
+ }
+
+ public FilterRegistrationImpl(
+ String name,
+ String className)
+ {
+ this.name = name;
+ this.className = className;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Collection<String> getServletNameMappings()
+ {
+ return Collections.unmodifiableCollection(servletNameMappings);
+ }
+
+ public Collection<String> getUrlPatternMappings()
+ {
+ return Collections.unmodifiableCollection(urlNameMappings);
+ }
+
+ public void addUrlNameMapping(String url)
+ {
+ urlNameMappings.add(url);
+ }
+
+ public void addServletNameMapping(String url)
+ {
+ servletNameMappings.add(url);
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationWrapper.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationWrapper.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationWrapper.java Thu Oct 20 10:49:18 2011
@@ -1,64 +1,64 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
-
-import java.util.Collection;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class FilterRegistrationWrapper implements FilterRegistration
-{
- private javax.servlet.FilterRegistration delegate;
-
- public FilterRegistrationWrapper(javax.servlet.FilterRegistration delegate)
- {
- super();
- this.delegate = delegate;
- }
-
- public String getClassName()
- {
- return delegate.getClassName();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public Collection<String> getServletNameMappings()
- {
- return delegate.getServletNameMappings();
- }
-
- public Collection<String> getUrlPatternMappings()
- {
- return delegate.getUrlPatternMappings();
- }
-
- public Object getWrapped()
- {
- return delegate;
- }
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
+
+import java.util.Collection;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class FilterRegistrationWrapper implements FilterRegistration
+{
+ private javax.servlet.FilterRegistration delegate;
+
+ public FilterRegistrationWrapper(javax.servlet.FilterRegistration delegate)
+ {
+ super();
+ this.delegate = delegate;
+ }
+
+ public String getClassName()
+ {
+ return delegate.getClassName();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public Collection<String> getServletNameMappings()
+ {
+ return delegate.getServletNameMappings();
+ }
+
+ public Collection<String> getUrlPatternMappings()
+ {
+ return delegate.getUrlPatternMappings();
+ }
+
+ public Object getWrapped()
+ {
+ return delegate;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/FilterRegistrationWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationImpl.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationImpl.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationImpl.java Thu Oct 20 10:49:18 2011
@@ -1,79 +1,79 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class ServletRegistrationImpl implements ServletRegistration
-{
-
- private final String name;
- private String className;
- private Set<String> mappings = new HashSet<String>();
-
- public ServletRegistrationImpl(
- String name)
- {
- this.name = name;
- }
-
- public ServletRegistrationImpl(
- String name,
- String className)
- {
- this.name = name;
- this.className = className;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Collection<String> getMappings()
- {
- return Collections.unmodifiableCollection(mappings);
- }
-
- public void addMapping(String url)
- {
- mappings.add(url);
- }
-
- public void setClassName(String className)
- {
- this.className = className;
- }
-
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class ServletRegistrationImpl implements ServletRegistration
+{
+
+ private final String name;
+ private String className;
+ private Set<String> mappings = new HashSet<String>();
+
+ public ServletRegistrationImpl(
+ String name)
+ {
+ this.name = name;
+ }
+
+ public ServletRegistrationImpl(
+ String name,
+ String className)
+ {
+ this.name = name;
+ this.className = className;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Collection<String> getMappings()
+ {
+ return Collections.unmodifiableCollection(mappings);
+ }
+
+ public void addMapping(String url)
+ {
+ mappings.add(url);
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationWrapper.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationWrapper.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationWrapper.java Thu Oct 20 10:49:18 2011
@@ -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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
-
-import java.util.Collection;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class ServletRegistrationWrapper implements ServletRegistration
-{
- private javax.servlet.ServletRegistration delegate;
-
- public ServletRegistrationWrapper(javax.servlet.ServletRegistration delegate)
- {
- super();
- this.delegate = delegate;
- }
-
- public String getClassName()
- {
- return delegate.getClassName();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public Collection<String> getMappings()
- {
- return delegate.getMappings();
- }
-
- public Object getWrapped()
- {
- return delegate;
- }
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.element.impl;
+
+import java.util.Collection;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class ServletRegistrationWrapper implements ServletRegistration
+{
+ private javax.servlet.ServletRegistration delegate;
+
+ public ServletRegistrationWrapper(javax.servlet.ServletRegistration delegate)
+ {
+ super();
+ this.delegate = delegate;
+ }
+
+ public String getClassName()
+ {
+ return delegate.getClassName();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public Collection<String> getMappings()
+ {
+ return delegate.getMappings();
+ }
+
+ public Object getWrapped()
+ {
+ return delegate;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/element/impl/ServletRegistrationWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebConfigProviderImpl.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebConfigProviderImpl.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebConfigProviderImpl.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebConfigProviderImpl.java Thu Oct 20 10:49:18 2011
@@ -1,139 +1,139 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
-
-import java.io.IOException;
-import java.net.URL;
-
-import javax.faces.application.ProjectStage;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.WebConfigProvider;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.WebConfigProviderFactory;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
-import org.apache.myfaces.commons.util.WebConfigParamUtils;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class WebConfigProviderImpl extends WebConfigProvider
-{
- private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
-
- private static final String WEB_REGISTRATION_KEY = WebRegistration.class.getName();
-
- private static final String INIT_PARAM_CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
- private static final long INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT = 2;
-
- private long refreshPeriod = -1;
-
- private long parsingTime = -1;
-
- private Boolean servlet30Mode;
-
- public WebConfigProviderImpl()
- {
- }
-
- public WebRegistration getWebRegistration(FacesContext context)
- {
- WebRegistration webConfig = (WebRegistration)context.getExternalContext().getApplicationMap().get(WEB_REGISTRATION_KEY);
- if (webConfig == null)
- {
- init(context);
- webConfig = (WebRegistration)context.getExternalContext().getApplicationMap().get(WEB_REGISTRATION_KEY);
- }
- return webConfig;
- }
-
- public void init(FacesContext context)
- {
- if (servlet30Mode == null)
- {
- servlet30Mode = (context.getExternalContext().getContext() instanceof ServletContext && _ExternalSpecifications.isServlet30Available());
- }
- if (servlet30Mode)
- {
- ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
- context.getExternalContext().getApplicationMap().put(WEB_REGISTRATION_KEY, _Servlet30Utils.getWebRegistrationFromServlet30Api(servletContext));
- }
- else
- {
- //Load the information parsing web.xml
- context.getExternalContext().getApplicationMap().put(WEB_REGISTRATION_KEY, WebXmlConfigParser.getWebRegistrationFromParsedWebXml(context));
- }
- if (!context.isProjectStage(ProjectStage.Production))
- {
- long configRefreshPeriod = WebConfigParamUtils.getLongInitParameter(context.getExternalContext(),
- INIT_PARAM_CONFIG_REFRESH_PERIOD, INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT);
- parsingTime = System.currentTimeMillis();
- refreshPeriod = (configRefreshPeriod * 1000);
- }
- }
-
- public void update(FacesContext context)
- {
- if (servlet30Mode == null)
- {
- servlet30Mode = (context.getExternalContext().getContext() instanceof ServletContext && _ExternalSpecifications.isServlet30Available());
- }
- if (!servlet30Mode && !context.isProjectStage(ProjectStage.Production))
- {
- if (isOld(context.getExternalContext()))
- {
- init(context);
- }
- }
- }
-
- private boolean isOld(ExternalContext context)
- {
- if (refreshPeriod > 0) {
- long ttl = this.parsingTime + refreshPeriod;
- if (System.currentTimeMillis() > ttl) {
- long lastModified = getWebXmlLastModified(context);
- return lastModified == 0 || lastModified > ttl;
- }
- }
- return false;
- }
-
-
- private static long getWebXmlLastModified(ExternalContext context)
- {
- try {
- URL url = context.getResource(WEB_XML_PATH);
- if (url != null)
- return url.openConnection().getLastModified();
- } catch (IOException e) {
- Log log = LogFactory.getLog(WebConfigProviderFactory.class);
- if (log.isErrorEnabled())
- {
- log.error("Could not find web.xml in path " + WEB_XML_PATH);
- }
- }
- return 0L;
- }
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.faces.application.ProjectStage;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.WebConfigProvider;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.WebConfigProviderFactory;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
+import org.apache.myfaces.commons.util.WebConfigParamUtils;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class WebConfigProviderImpl extends WebConfigProvider
+{
+ private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
+
+ private static final String WEB_REGISTRATION_KEY = WebRegistration.class.getName();
+
+ private static final String INIT_PARAM_CONFIG_REFRESH_PERIOD = "org.apache.myfaces.CONFIG_REFRESH_PERIOD";
+ private static final long INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT = 2;
+
+ private long refreshPeriod = -1;
+
+ private long parsingTime = -1;
+
+ private Boolean servlet30Mode;
+
+ public WebConfigProviderImpl()
+ {
+ }
+
+ public WebRegistration getWebRegistration(FacesContext context)
+ {
+ WebRegistration webConfig = (WebRegistration)context.getExternalContext().getApplicationMap().get(WEB_REGISTRATION_KEY);
+ if (webConfig == null)
+ {
+ init(context);
+ webConfig = (WebRegistration)context.getExternalContext().getApplicationMap().get(WEB_REGISTRATION_KEY);
+ }
+ return webConfig;
+ }
+
+ public void init(FacesContext context)
+ {
+ if (servlet30Mode == null)
+ {
+ servlet30Mode = (context.getExternalContext().getContext() instanceof ServletContext && _ExternalSpecifications.isServlet30Available());
+ }
+ if (servlet30Mode)
+ {
+ ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
+ context.getExternalContext().getApplicationMap().put(WEB_REGISTRATION_KEY, _Servlet30Utils.getWebRegistrationFromServlet30Api(servletContext));
+ }
+ else
+ {
+ //Load the information parsing web.xml
+ context.getExternalContext().getApplicationMap().put(WEB_REGISTRATION_KEY, WebXmlConfigParser.getWebRegistrationFromParsedWebXml(context));
+ }
+ if (!context.isProjectStage(ProjectStage.Production))
+ {
+ long configRefreshPeriod = WebConfigParamUtils.getLongInitParameter(context.getExternalContext(),
+ INIT_PARAM_CONFIG_REFRESH_PERIOD, INIT_PARAM_CONFIG_REFRESH_PERIOD_DEFAULT);
+ parsingTime = System.currentTimeMillis();
+ refreshPeriod = (configRefreshPeriod * 1000);
+ }
+ }
+
+ public void update(FacesContext context)
+ {
+ if (servlet30Mode == null)
+ {
+ servlet30Mode = (context.getExternalContext().getContext() instanceof ServletContext && _ExternalSpecifications.isServlet30Available());
+ }
+ if (!servlet30Mode && !context.isProjectStage(ProjectStage.Production))
+ {
+ if (isOld(context.getExternalContext()))
+ {
+ init(context);
+ }
+ }
+ }
+
+ private boolean isOld(ExternalContext context)
+ {
+ if (refreshPeriod > 0) {
+ long ttl = this.parsingTime + refreshPeriod;
+ if (System.currentTimeMillis() > ttl) {
+ long lastModified = getWebXmlLastModified(context);
+ return lastModified == 0 || lastModified > ttl;
+ }
+ }
+ return false;
+ }
+
+
+ private static long getWebXmlLastModified(ExternalContext context)
+ {
+ try {
+ URL url = context.getResource(WEB_XML_PATH);
+ if (url != null)
+ return url.openConnection().getLastModified();
+ } catch (IOException e) {
+ Log log = LogFactory.getLog(WebConfigProviderFactory.class);
+ if (log.isErrorEnabled())
+ {
+ log.error("Could not find web.xml in path " + WEB_XML_PATH);
+ }
+ }
+ return 0L;
+ }
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebConfigProviderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebRegistrationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebRegistrationImpl.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebRegistrationImpl.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebRegistrationImpl.java Thu Oct 20 10:49:18 2011
@@ -1,67 +1,67 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public class WebRegistrationImpl extends WebRegistration
-{
-
- private Map<String, FilterRegistration> filterRegistrations = new HashMap<String, FilterRegistration>();
- private Map<String, ServletRegistration> servletRegistrations = new HashMap<String, ServletRegistration>();
-
- public WebRegistrationImpl()
- {
- }
-
- @Override
- public FilterRegistration getFilterRegistration(String filterName)
- {
- return filterRegistrations.get(filterName);
- }
-
- @Override
- public Map<String, FilterRegistration> getFilterRegistrations()
- {
- return filterRegistrations;
- }
-
- @Override
- public ServletRegistration getServletRegistration(String servletName)
- {
- return servletRegistrations.get(servletName);
- }
-
- @Override
- public Map<String, ServletRegistration> getServletRegistrations()
- {
- return servletRegistrations;
- }
-
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.FilterRegistration;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public class WebRegistrationImpl extends WebRegistration
+{
+
+ private Map<String, FilterRegistration> filterRegistrations = new HashMap<String, FilterRegistration>();
+ private Map<String, ServletRegistration> servletRegistrations = new HashMap<String, ServletRegistration>();
+
+ public WebRegistrationImpl()
+ {
+ }
+
+ @Override
+ public FilterRegistration getFilterRegistration(String filterName)
+ {
+ return filterRegistrations.get(filterName);
+ }
+
+ @Override
+ public Map<String, FilterRegistration> getFilterRegistrations()
+ {
+ return filterRegistrations;
+ }
+
+ @Override
+ public ServletRegistration getServletRegistration(String servletName)
+ {
+ return servletRegistrations.get(servletName);
+ }
+
+ @Override
+ public Map<String, ServletRegistration> getServletRegistrations()
+ {
+ return servletRegistrations;
+ }
+
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebRegistrationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/WebXmlConfigParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_ExternalSpecifications.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_ExternalSpecifications.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_ExternalSpecifications.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_ExternalSpecifications.java Thu Oct 20 10:49:18 2011
@@ -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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * <p>
- * Package-private utility class for determining which specifications are available
- * in the current process.
- * </p>
- *
- * @author Leonardo Uribe
- */
-final class _ExternalSpecifications
-{
-
- private static final Log log = LogFactory.getLog(_ExternalSpecifications.class);
-
- private static volatile Boolean servlet30Available;
-
- /**
- * This method determines if servlet 3.0 is present.
- *
- * @return true if servlet 3.0 is available, false otherwise.
- */
- public static boolean isServlet30Available()
- {
- if (servlet30Available == null)
- {
- try
- {
- servlet30Available = (Class.forName("javax.servlet.ServletRegistration") != null);
- }
- catch(Throwable t)
- {
- if (log.isTraceEnabled())
- {
- log.trace("Cannot load servlet 3.0 class (could be normal)", t);
- }
- servlet30Available = Boolean.FALSE;
- }
-
- log.info("MyFaces commons ResourceHandler Servlet 3.0 container support " + (servlet30Available ? "enabled" : "disabled"));
- }
- return servlet30Available;
- }
-
- /**
- * this class should not be instantiated.
- */
- private _ExternalSpecifications()
- {
- }
-
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * Package-private utility class for determining which specifications are available
+ * in the current process.
+ * </p>
+ *
+ * @author Leonardo Uribe
+ */
+final class _ExternalSpecifications
+{
+
+ private static final Log log = LogFactory.getLog(_ExternalSpecifications.class);
+
+ private static volatile Boolean servlet30Available;
+
+ /**
+ * This method determines if servlet 3.0 is present.
+ *
+ * @return true if servlet 3.0 is available, false otherwise.
+ */
+ public static boolean isServlet30Available()
+ {
+ if (servlet30Available == null)
+ {
+ try
+ {
+ servlet30Available = (Class.forName("javax.servlet.ServletRegistration") != null);
+ }
+ catch(Throwable t)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Cannot load servlet 3.0 class (could be normal)", t);
+ }
+ servlet30Available = Boolean.FALSE;
+ }
+
+ log.info("MyFaces commons ResourceHandler Servlet 3.0 container support " + (servlet30Available ? "enabled" : "disabled"));
+ }
+ return servlet30Available;
+ }
+
+ /**
+ * this class should not be instantiated.
+ */
+ private _ExternalSpecifications()
+ {
+ }
+
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_ExternalSpecifications.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_Servlet30Utils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_Servlet30Utils.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_Servlet30Utils.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_Servlet30Utils.java Thu Oct 20 10:49:18 2011
@@ -1,116 +1,116 @@
-/*
- * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.webapp.FacesServlet;
-import javax.servlet.FilterRegistration;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRegistration;
-
-import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.impl.FilterRegistrationWrapper;
-import org.apache.myfaces.commons.resourcehandler.webapp.config.element.impl.ServletRegistrationWrapper;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-final class _Servlet30Utils
-{
-
- public static WebRegistration getWebRegistrationFromServlet30Api(ServletContext servletContext)
- {
- WebRegistrationImpl provider = new WebRegistrationImpl();
- Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations();
- Map<String, ? extends FilterRegistration> filterRegistrations = servletContext.getFilterRegistrations();
- if (servletRegistrations != null && !servletRegistrations.isEmpty())
- {
- for (Map.Entry<String, ? extends ServletRegistration> entry : servletRegistrations.entrySet())
- {
- provider.getServletRegistrations().put(entry.getKey(),
- (org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration)
- new ServletRegistrationWrapper(entry.getValue()));
- }
- }
- if (filterRegistrations != null && !filterRegistrations.isEmpty())
- {
- for (Map.Entry<String, ? extends FilterRegistration> entry : filterRegistrations.entrySet())
- {
- provider.getFilterRegistrations().put(entry.getKey(), new FilterRegistrationWrapper(entry.getValue()));
- }
- }
- return provider;
- }
-
- public static String[] getFacesServletPrefixMappings(ServletContext servletContext)
- {
- Map<String, ? extends ServletRegistration> registrations = servletContext.getServletRegistrations();
- List<String> prefixMappings = null;
- if (registrations != null)
- {
- for (Map.Entry<String, ? extends ServletRegistration> entry : registrations.entrySet())
- {
- ServletRegistration registration = entry.getValue();
-
- if (FacesServlet.class.getName().equals(registration.getClassName()))
- {
- for (String urlPattern :entry.getValue().getMappings())
- {
- //look for prefix mapping
- String prefix;
- String extension = urlPattern != null && urlPattern.startsWith("*.") ? urlPattern.substring(urlPattern
- .indexOf('.')) : null;
- if (extension == null)
- {
- int index = urlPattern.indexOf("/*");
- if (index != -1)
- {
- prefix = urlPattern.substring(0, urlPattern.indexOf("/*"));
- }
- else
- {
- prefix = urlPattern;
- }
- }
- else
- {
- prefix = null;
- }
-
- if (prefix != null)
- {
- if (prefixMappings == null)
- {
- prefixMappings = new ArrayList<String>();
- }
- prefixMappings.add(prefix);
- }
- }
- }
- }
- }
- return prefixMappings == null ? new String[]{} : prefixMappings.toArray(new String[prefixMappings.size()]);
- }
-
-}
+/*
+ * 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.apache.myfaces.commons.resourcehandler.webapp.config.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.webapp.FacesServlet;
+import javax.servlet.FilterRegistration;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRegistration;
+
+import org.apache.myfaces.commons.resourcehandler.webapp.config.WebRegistration;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.impl.FilterRegistrationWrapper;
+import org.apache.myfaces.commons.resourcehandler.webapp.config.element.impl.ServletRegistrationWrapper;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+final class _Servlet30Utils
+{
+
+ public static WebRegistration getWebRegistrationFromServlet30Api(ServletContext servletContext)
+ {
+ WebRegistrationImpl provider = new WebRegistrationImpl();
+ Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations();
+ Map<String, ? extends FilterRegistration> filterRegistrations = servletContext.getFilterRegistrations();
+ if (servletRegistrations != null && !servletRegistrations.isEmpty())
+ {
+ for (Map.Entry<String, ? extends ServletRegistration> entry : servletRegistrations.entrySet())
+ {
+ provider.getServletRegistrations().put(entry.getKey(),
+ (org.apache.myfaces.commons.resourcehandler.webapp.config.element.ServletRegistration)
+ new ServletRegistrationWrapper(entry.getValue()));
+ }
+ }
+ if (filterRegistrations != null && !filterRegistrations.isEmpty())
+ {
+ for (Map.Entry<String, ? extends FilterRegistration> entry : filterRegistrations.entrySet())
+ {
+ provider.getFilterRegistrations().put(entry.getKey(), new FilterRegistrationWrapper(entry.getValue()));
+ }
+ }
+ return provider;
+ }
+
+ public static String[] getFacesServletPrefixMappings(ServletContext servletContext)
+ {
+ Map<String, ? extends ServletRegistration> registrations = servletContext.getServletRegistrations();
+ List<String> prefixMappings = null;
+ if (registrations != null)
+ {
+ for (Map.Entry<String, ? extends ServletRegistration> entry : registrations.entrySet())
+ {
+ ServletRegistration registration = entry.getValue();
+
+ if (FacesServlet.class.getName().equals(registration.getClassName()))
+ {
+ for (String urlPattern :entry.getValue().getMappings())
+ {
+ //look for prefix mapping
+ String prefix;
+ String extension = urlPattern != null && urlPattern.startsWith("*.") ? urlPattern.substring(urlPattern
+ .indexOf('.')) : null;
+ if (extension == null)
+ {
+ int index = urlPattern.indexOf("/*");
+ if (index != -1)
+ {
+ prefix = urlPattern.substring(0, urlPattern.indexOf("/*"));
+ }
+ else
+ {
+ prefix = urlPattern;
+ }
+ }
+ else
+ {
+ prefix = null;
+ }
+
+ if (prefix != null)
+ {
+ if (prefixMappings == null)
+ {
+ prefixMappings = new ArrayList<String>();
+ }
+ prefixMappings.add(prefix);
+ }
+ }
+ }
+ }
+ }
+ return prefixMappings == null ? new String[]{} : prefixMappings.toArray(new String[prefixMappings.size()]);
+ }
+
+}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/webapp/config/impl/_Servlet30Utils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/resources/META-INF/faces-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/site/apt/index.apt?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/site/apt/index.apt (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/site/apt/index.apt Thu Oct 20 10:49:18 2011
@@ -1,32 +1,32 @@
- ------
-Apache MyFaces Commons
- ------
-
-Apache MyFaces Commons Resource Handler for JSF 2.0
-
- The objective is have a common place where find utilities for create Resource Handler instances
- and a Extended ResourceHandler which has some useful features like:
-
- * GZIP compression and local cache in tmp dir.
-
- * i18n (supporting country code and language).
-
- * Prevent use #\{resource['...']\} on css files, using prefix mapping
-
- * Prefix mapping automatic detection
-
- * Override request path generation using EL expressions
-
- * Redirect library names to prevent duplicate usage against other JSF libraries.
-
- Just add this jar to your project and register on a WEB-INF/myfaces-resources-config.xml file or
- META-INF/myfaces-resources-config.xml the libraries that needs to be handled by the
- ExtendedResourceHandler. Look on the Web Context Parameter List for the available parameters.
-
-Documentation
-
- * {{{https://issues.apache.org/jira/browse/MFCOMMONS-33}MFCOMMONS-33}}
-
- * {{{./apidocs/index.html}Javadocs}}
-
- * {{{./webconfig.html}Web Context Parameter List}}
+ ------
+Apache MyFaces Commons
+ ------
+
+Apache MyFaces Commons Resource Handler for JSF 2.0
+
+ The objective is have a common place where find utilities for create Resource Handler instances
+ and a Extended ResourceHandler which has some useful features like:
+
+ * GZIP compression and local cache in tmp dir.
+
+ * i18n (supporting country code and language).
+
+ * Prevent use #\{resource['...']\} on css files, using prefix mapping
+
+ * Prefix mapping automatic detection
+
+ * Override request path generation using EL expressions
+
+ * Redirect library names to prevent duplicate usage against other JSF libraries.
+
+ Just add this jar to your project and register on a WEB-INF/myfaces-resources-config.xml file or
+ META-INF/myfaces-resources-config.xml the libraries that needs to be handled by the
+ ExtendedResourceHandler. Look on the Web Context Parameter List for the available parameters.
+
+Documentation
+
+ * {{{https://issues.apache.org/jira/browse/MFCOMMONS-33}MFCOMMONS-33}}
+
+ * {{{./apidocs/index.html}Javadocs}}
+
+ * {{{./webconfig.html}Web Context Parameter List}}
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/java/org/apache/myfaces/commons/resourcehandler/ResourceUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/META-INF/resources/my/library/resource.css
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/test/myfaces-resources-config.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/test/myfaces-resources-config.xml?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/test/myfaces-resources-config.xml (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/test/myfaces-resources-config.xml Thu Oct 20 10:49:18 2011
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<myfaces-resources-config>
- <!-- Mark this library to be handled by Extended Resource Handler -->
- <library>
- <library-name>libraryA</library-name>
- </library>
-
- <!-- Indicate this library has another name, so if libraryC is used,
- resources should be redirected to libraryC1 -->
- <library>
- <library-name>libraryC</library-name>
- <redirect-name>libraryC1</redirect-name>
- </library>
-
- <!-- Allow to customize the request path generated, to do things like
- take library resources from a Content Delivery Network (CDN) or just
- take it directly from an specified location. Note it is responsibility
- of the developer to configure it properly, and the resources should
- exists locally under the library name selected. -->
- <library>
- <library-name>libraryB</library-name>
- <request-path>http://someaddress.com/alternatePath/#{resourceName}</request-path>
- </library>
-</myfaces-resources-config>
+<?xml version="1.0" encoding="UTF-8"?>
+<myfaces-resources-config>
+ <!-- Mark this library to be handled by Extended Resource Handler -->
+ <library>
+ <library-name>libraryA</library-name>
+ </library>
+
+ <!-- Indicate this library has another name, so if libraryC is used,
+ resources should be redirected to libraryC1 -->
+ <library>
+ <library-name>libraryC</library-name>
+ <redirect-name>libraryC1</redirect-name>
+ </library>
+
+ <!-- Allow to customize the request path generated, to do things like
+ take library resources from a Content Delivery Network (CDN) or just
+ take it directly from an specified location. Note it is responsibility
+ of the developer to configure it properly, and the resources should
+ exists locally under the library name selected. -->
+ <library>
+ <library-name>libraryB</library-name>
+ <request-path>http://someaddress.com/alternatePath/#{resourceName}</request-path>
+ </library>
+</myfaces-resources-config>
Propchange: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/test/resources/test/myfaces-resources-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-utils/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-utils/pom.xml?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-utils/pom.xml (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-utils/pom.xml Thu Oct 20 10:49:18 2011
@@ -23,14 +23,12 @@
<version>1.0.3-SNAPSHOT</version>
</parent>
<artifactId>myfaces-commons-utils20</artifactId>
- <packaging>jar</packaging>
<name>Apache MyFaces Commons Utils</name>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
<executions>
<execution>
<goals>
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ArrayUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ArrayUtils.java?rev=1186730&r1=1186729&r2=1186730&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ArrayUtils.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ArrayUtils.java Thu Oct 20 10:49:18 2011
@@ -1,229 +1,229 @@
-/*
- * 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.apache.myfaces.commons.util;
-
-import java.lang.reflect.Array;
-
-/**
- * Utility class for managing arrays
- *
- * @since 1.0.1
- * @author Anton Koinov (latest modification by $Author: matzew $)
- * @version $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (mié, 18 jul 2007) $
- */
-public final class ArrayUtils
-{
- public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- //~ Constructors -------------------------------------------------------------------------------
-
- protected ArrayUtils()
- {
- // hide from public access
- }
-
- //~ Methods ------------------------------------------------------------------------------------
-
- private static Class commonClass(Class c1, Class c2)
- {
- if (c1 == c2)
- {
- return c1;
- }
-
- if ((c1 == Object.class) || c1.isAssignableFrom(c2))
- {
- return c1;
- }
-
- if (c2.isAssignableFrom(c1))
- {
- return c2;
- }
-
- if (c1.isPrimitive() || c2.isPrimitive())
- {
- // REVISIT: we could try to autoconvert to Object or something appropriate
- throw new IllegalArgumentException("incompatible types " + c1 + " and " + c2);
- }
-
- // REVISIT: we could try to find a common supper class or interface
- return Object.class;
- }
-
- /**
- * Concatenates two arrays into one. If arr1 is null or empty, returns arr2.
- * If arr2 is null or empty, returns arr1. May return null if both arrays are null,
- * or one is empty and the other null. <br>
- * The concatenated array has componentType which is compatible with both input arrays (or Object[])
- *
- * @param arr1 input array
- * @param arr2 input array
- *
- * @return Object the concatenated array, elements of arr1 first
- */
- public static Object concat(Object arr1, Object arr2)
- {
- int len1 = (arr1 == null) ? (-1) : Array.getLength(arr1);
-
- if (len1 <= 0)
- {
- return arr2;
- }
-
- int len2 = (arr2 == null) ? (-1) : Array.getLength(arr2);
-
- if (len2 <= 0)
- {
- return arr1;
- }
-
- Class commonComponentType =
- commonClass(arr1.getClass().getComponentType(), arr2.getClass().getComponentType());
- Object newArray = Array.newInstance(commonComponentType, len1 + len2);
- System.arraycopy(arr1, 0, newArray, 0, len1);
- System.arraycopy(arr2, 0, newArray, len1, len2);
-
- return newArray;
- }
-
- /**
- * Concatenates arrays into one. Any null or empty arrays are ignored.
- * If all arrays are null or empty, returns null.
- * Elements will be ordered in the order in which the arrays are supplied.
- *
- * @param arrs array of arrays
- * @return the concatenated array
- */
- public static Object concat(Object[] arrs)
- {
- int totalLen = 0;
- Class commonComponentType = null;
- for (int i = 0, len = arrs.length; i < len; i++)
- {
- // skip all null arrays
- if (arrs[i] == null)
- {
- continue;
- }
-
- int arrayLen = Array.getLength(arrs[i]);
-
- // skip all empty arrays
- if (arrayLen == 0)
- {
- continue;
- }
-
- totalLen += arrayLen;
-
- Class componentType = arrs[i].getClass().getComponentType();
- commonComponentType =
- (commonComponentType == null) ? componentType
- : commonClass(commonComponentType, componentType);
- }
-
- if (commonComponentType == null)
- {
- return null;
- }
-
- return concat(Array.newInstance(commonComponentType, totalLen), totalLen, arrs);
- }
-
- public static Object concat(Object toArray, int totalLen, Object[] arrs)
- {
- if (totalLen == 0)
- {
- // Should we allocate an empty array instead?
- return toArray;
- }
-
- if (totalLen > Array.getLength(toArray))
- {
- toArray = Array.newInstance(toArray.getClass().getComponentType(), totalLen);
- }
-
- for (int i = 0, len = arrs.length, offset = 0; i < len; i++)
- {
- final Object arr = arrs[i];
- if (arr != null)
- {
- int arrayLen = Array.getLength(arr);
- if (arrayLen > 0)
- {
- System.arraycopy(arr, 0, toArray, offset, arrayLen);
- offset += arrayLen;
- }
- }
- }
-
- return toArray;
- }
-
- public static Object concat(Object arr1, Object arr2, Object arr3)
- {
- return concat(new Object[] {arr1, arr2, arr3});
- }
-
- public static Object concat(Object arr1, Object arr2, Object arr3, Object arr4)
- {
- return concat(new Object[] {arr1, arr2, arr3, arr4});
- }
-
- public static Object concat(Object arr1, Object arr2, Object arr3, Object arr4, Object arr5)
- {
- return concat(new Object[] {arr1, arr2, arr3, arr4, arr5});
- }
-
- public static Object concatSameType(Object toArray, Object[] arrs)
- {
- int totalLen = 0;
- for (int i = 0, len = arrs.length; i < len; i++)
- {
- if (arrs[i] != null)
- {
- totalLen += Array.getLength(arrs[i]);
- }
- }
-
- return concat(toArray, totalLen, arrs);
- }
-
- public static boolean contains(Object[] array, Object value)
- {
- if (array == null || array.length == 0)
- {
- return false;
- }
-
- for (int i = 0; i < array.length; i++)
- {
- Object o = array[i];
- if ((o == null && value == null) ||
- (o != null && o.equals(value)))
- {
- return true;
- }
- }
-
- return false;
- }
-}
+/*
+ * 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.apache.myfaces.commons.util;
+
+import java.lang.reflect.Array;
+
+/**
+ * Utility class for managing arrays
+ *
+ * @since 1.0.1
+ * @author Anton Koinov (latest modification by $Author: matzew $)
+ * @version $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (mié, 18 jul 2007) $
+ */
+public final class ArrayUtils
+{
+ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ protected ArrayUtils()
+ {
+ // hide from public access
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ private static Class commonClass(Class c1, Class c2)
+ {
+ if (c1 == c2)
+ {
+ return c1;
+ }
+
+ if ((c1 == Object.class) || c1.isAssignableFrom(c2))
+ {
+ return c1;
+ }
+
+ if (c2.isAssignableFrom(c1))
+ {
+ return c2;
+ }
+
+ if (c1.isPrimitive() || c2.isPrimitive())
+ {
+ // REVISIT: we could try to autoconvert to Object or something appropriate
+ throw new IllegalArgumentException("incompatible types " + c1 + " and " + c2);
+ }
+
+ // REVISIT: we could try to find a common supper class or interface
+ return Object.class;
+ }
+
+ /**
+ * Concatenates two arrays into one. If arr1 is null or empty, returns arr2.
+ * If arr2 is null or empty, returns arr1. May return null if both arrays are null,
+ * or one is empty and the other null. <br>
+ * The concatenated array has componentType which is compatible with both input arrays (or Object[])
+ *
+ * @param arr1 input array
+ * @param arr2 input array
+ *
+ * @return Object the concatenated array, elements of arr1 first
+ */
+ public static Object concat(Object arr1, Object arr2)
+ {
+ int len1 = (arr1 == null) ? (-1) : Array.getLength(arr1);
+
+ if (len1 <= 0)
+ {
+ return arr2;
+ }
+
+ int len2 = (arr2 == null) ? (-1) : Array.getLength(arr2);
+
+ if (len2 <= 0)
+ {
+ return arr1;
+ }
+
+ Class commonComponentType =
+ commonClass(arr1.getClass().getComponentType(), arr2.getClass().getComponentType());
+ Object newArray = Array.newInstance(commonComponentType, len1 + len2);
+ System.arraycopy(arr1, 0, newArray, 0, len1);
+ System.arraycopy(arr2, 0, newArray, len1, len2);
+
+ return newArray;
+ }
+
+ /**
+ * Concatenates arrays into one. Any null or empty arrays are ignored.
+ * If all arrays are null or empty, returns null.
+ * Elements will be ordered in the order in which the arrays are supplied.
+ *
+ * @param arrs array of arrays
+ * @return the concatenated array
+ */
+ public static Object concat(Object[] arrs)
+ {
+ int totalLen = 0;
+ Class commonComponentType = null;
+ for (int i = 0, len = arrs.length; i < len; i++)
+ {
+ // skip all null arrays
+ if (arrs[i] == null)
+ {
+ continue;
+ }
+
+ int arrayLen = Array.getLength(arrs[i]);
+
+ // skip all empty arrays
+ if (arrayLen == 0)
+ {
+ continue;
+ }
+
+ totalLen += arrayLen;
+
+ Class componentType = arrs[i].getClass().getComponentType();
+ commonComponentType =
+ (commonComponentType == null) ? componentType
+ : commonClass(commonComponentType, componentType);
+ }
+
+ if (commonComponentType == null)
+ {
+ return null;
+ }
+
+ return concat(Array.newInstance(commonComponentType, totalLen), totalLen, arrs);
+ }
+
+ public static Object concat(Object toArray, int totalLen, Object[] arrs)
+ {
+ if (totalLen == 0)
+ {
+ // Should we allocate an empty array instead?
+ return toArray;
+ }
+
+ if (totalLen > Array.getLength(toArray))
+ {
+ toArray = Array.newInstance(toArray.getClass().getComponentType(), totalLen);
+ }
+
+ for (int i = 0, len = arrs.length, offset = 0; i < len; i++)
+ {
+ final Object arr = arrs[i];
+ if (arr != null)
+ {
+ int arrayLen = Array.getLength(arr);
+ if (arrayLen > 0)
+ {
+ System.arraycopy(arr, 0, toArray, offset, arrayLen);
+ offset += arrayLen;
+ }
+ }
+ }
+
+ return toArray;
+ }
+
+ public static Object concat(Object arr1, Object arr2, Object arr3)
+ {
+ return concat(new Object[] {arr1, arr2, arr3});
+ }
+
+ public static Object concat(Object arr1, Object arr2, Object arr3, Object arr4)
+ {
+ return concat(new Object[] {arr1, arr2, arr3, arr4});
+ }
+
+ public static Object concat(Object arr1, Object arr2, Object arr3, Object arr4, Object arr5)
+ {
+ return concat(new Object[] {arr1, arr2, arr3, arr4, arr5});
+ }
+
+ public static Object concatSameType(Object toArray, Object[] arrs)
+ {
+ int totalLen = 0;
+ for (int i = 0, len = arrs.length; i < len; i++)
+ {
+ if (arrs[i] != null)
+ {
+ totalLen += Array.getLength(arrs[i]);
+ }
+ }
+
+ return concat(toArray, totalLen, arrs);
+ }
+
+ public static boolean contains(Object[] array, Object value)
+ {
+ if (array == null || array.length == 0)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < array.length; i++)
+ {
+ Object o = array[i];
+ if ((o == null && value == null) ||
+ (o != null && o.equals(value)))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}