@@ -127,13 +125,14 @@ public interface CacheManager {
*/
boolean removeCache(String cacheName);
- /**
- * This method will return a UserTransaction.
- *
- * @return the UserTransaction.
- * @throws UnsupportedOperationException if JTA is not supported
- */
- UserTransaction getUserTransaction();
+ // TODO javax.transaction package is no longer available. Need to find a way to add this back
+// /**
+// * This method will return a UserTransaction.
+// *
+// * @return the UserTransaction.
+// * @throws UnsupportedOperationException if JTA is not supported
+// */
+// UserTransaction getUserTransaction();
/**
* Indicates whether a optional feature is supported by this CacheManager.
diff --git a/core/javax.cache/src/main/java/org/wso2/carbon/caching/impl/CarbonCacheManager.java b/core/javax.cache/src/main/java/org/wso2/carbon/caching/impl/CarbonCacheManager.java
index 66329c8344e..14f27cf9ddc 100644
--- a/core/javax.cache/src/main/java/org/wso2/carbon/caching/impl/CarbonCacheManager.java
+++ b/core/javax.cache/src/main/java/org/wso2/carbon/caching/impl/CarbonCacheManager.java
@@ -17,16 +17,10 @@
*/
package org.wso2.carbon.caching.impl;
-import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-import javax.cache.Cache;
-import javax.cache.CacheBuilder;
-import javax.cache.CacheException;
-import javax.cache.CacheManager;
-import javax.cache.OptionalFeature;
-import javax.cache.Status;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@@ -34,6 +28,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.cache.Cache;
+import javax.cache.CacheBuilder;
+import javax.cache.CacheException;
+import javax.cache.CacheManager;
+import javax.cache.OptionalFeature;
+import javax.cache.Status;
+
import static org.wso2.carbon.caching.impl.CachingConstants.ILLEGAL_STATE_EXCEPTION_MESSAGE;
/**
@@ -202,13 +203,13 @@ boolean removeLocalCaches() {
return this.caches.isEmpty();
}
- @Override
- public javax.transaction.UserTransaction getUserTransaction() {
- Util.checkAccess(ownerTenantDomain, ownerTenantId);
- checkStatusStarted();
- touch();
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
+// @Override
+// public javax.transaction.UserTransaction getUserTransaction() {
+// Util.checkAccess(ownerTenantDomain, ownerTenantId);
+// checkStatusStarted();
+// touch();
+// return null; //To change body of implemented methods use File | Settings | File Templates.
+// }
@Override
public boolean isSupported(OptionalFeature optionalFeature) {
diff --git a/core/org.wso2.carbon.application.deployer/pom.xml b/core/org.wso2.carbon.application.deployer/pom.xml
index 7dce129c359..aa0b8a7bea8 100644
--- a/core/org.wso2.carbon.application.deployer/pom.xml
+++ b/core/org.wso2.carbon.application.deployer/pom.xml
@@ -37,7 +37,7 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
+ org.eclipse.platformorg.eclipse.osgi.services
diff --git a/core/org.wso2.carbon.base/pom.xml b/core/org.wso2.carbon.base/pom.xml
index f328247c892..26e1401246c 100644
--- a/core/org.wso2.carbon.base/pom.xml
+++ b/core/org.wso2.carbon.base/pom.xml
@@ -36,7 +36,6 @@
org.apache.felixmaven-bundle-plugin
-
true
@@ -48,7 +47,7 @@
org.wso2.carbon.base.*; version="1.0.0"
- javax.activation.*;version="[0.0.0, 1.0.0)",
+ javax.activation.*;version="[1.0.0, 2.0.0)",
javax.servlet; version="${imp.pkg.version.javax.servlet}",
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
org.wso2.securevault.*,
@@ -59,6 +58,9 @@
*;resolution:=optional
+
+ osgi.service;objectClass=org.wso2.carbon.base.api.ServerConfigurationService
+
@@ -67,12 +69,19 @@
maven-surefire-plugintrue
+
+ --add-opens=java.base/java.lang=ALL-UNNAMED
+ --add-opens=java.base/java.util=ALL-UNNAMED
+ org.wso2.org.ops4j.pax.logging:pax-logging-apiorg.apache.logging.log4j.jul.LogManager
+
+ src/test/resources/testng.xml
+
@@ -118,6 +127,7 @@
org.eclipse.equinoxjavax.servlet
+
org.wso2.orbit.xercesxercesImpl
diff --git a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/ServerConfiguration.java b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/ServerConfiguration.java
index 5066d157711..5048ee00799 100644
--- a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/ServerConfiguration.java
+++ b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/ServerConfiguration.java
@@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.SecurityManager;
+import org.osgi.service.component.annotations.Component;
import org.w3c.dom.Element;
import org.wso2.carbon.base.api.ServerConfigurationService;
import org.wso2.carbon.securevault.SecretManagerInitializer;
@@ -55,6 +56,7 @@
* This class stores the configuration of the Carbon Server.
*/
@SuppressWarnings("unused")
+//@Component(service = ServerConfigurationService.class)
public class ServerConfiguration implements ServerConfigurationService {
/**
diff --git a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/api/ServerConfigurationService.java b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/api/ServerConfigurationService.java
index 195c0a88faf..122c0351b96 100644
--- a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/api/ServerConfigurationService.java
+++ b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/api/ServerConfigurationService.java
@@ -1,5 +1,6 @@
package org.wso2.carbon.base.api;
+import org.osgi.service.component.annotations.Component;
import org.w3c.dom.Element;
public interface ServerConfigurationService {
diff --git a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/internal/CarbonBaseActivator.java b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/internal/CarbonBaseActivator.java
index 6d1cec0bbb3..cd53af91503 100644
--- a/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/internal/CarbonBaseActivator.java
+++ b/core/org.wso2.carbon.base/src/main/java/org/wso2/carbon/base/internal/CarbonBaseActivator.java
@@ -22,16 +22,19 @@
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import org.wso2.carbon.base.CarbonBaseConstants;
import org.wso2.carbon.base.CarbonBaseUtils;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.base.ServerConfigurationException;
import org.wso2.carbon.base.api.ServerConfigurationService;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
import javax.servlet.ServletException;
-import java.io.*;
/**
* Activator of the {@link org.wso2.carbon.base} bundle
@@ -52,7 +55,6 @@ public void start(BundleContext bundleContext) throws Exception {
System.setProperty("portOffset", portOffset);
//register carbon server confg as an OSGi service
registration = bundleContext.registerService(ServerConfigurationService.class.getName(), carbonServerConfiguration, null);
-
}
@Override
diff --git a/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/CarbonBaseUtilsTest.java b/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/CarbonBaseUtilsTest.java
index 2f0937898cb..2d2a5729106 100644
--- a/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/CarbonBaseUtilsTest.java
+++ b/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/CarbonBaseUtilsTest.java
@@ -50,7 +50,7 @@ public void setSecurityManager() {
String resourcePath = resourceURL.getPath();
resourcePath = resourcePath + "policy-test.policy";
System.setProperty("java.security.policy", resourcePath);
- System.setSecurityManager(new SecurityManager());
+// System.setSecurityManager(new SecurityManager());
}
}
diff --git a/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/ServerConfigurationTest.java b/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/ServerConfigurationTest.java
index 9ee214c727e..f2abc748d79 100644
--- a/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/ServerConfigurationTest.java
+++ b/core/org.wso2.carbon.base/src/test/java/org/wso2/carbon/base/ServerConfigurationTest.java
@@ -54,6 +54,7 @@ public void createInstance() throws ServerConfigurationException, NoSuchFieldExc
IllegalAccessException {
assertFalse(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized"));
InputStream inputStream = readFile("carbon.xml");
+ //TODO carbon.home is not set
ServerConfiguration.getInstance().forceInit(inputStream);
assertTrue(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized"));
}
diff --git a/core/org.wso2.carbon.base/src/test/resources/testng.xml b/core/org.wso2.carbon.base/src/test/resources/testng.xml
new file mode 100644
index 00000000000..10e44e3d88c
--- /dev/null
+++ b/core/org.wso2.carbon.base/src/test/resources/testng.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/org.wso2.carbon.bootstrap/src/main/java/org/wso2/carbon/bootstrap/CarbonSecurityManager.java b/core/org.wso2.carbon.bootstrap/src/main/java/org/wso2/carbon/bootstrap/CarbonSecurityManager.java
index d1f2977fb74..6cbc8bf2a55 100644
--- a/core/org.wso2.carbon.bootstrap/src/main/java/org/wso2/carbon/bootstrap/CarbonSecurityManager.java
+++ b/core/org.wso2.carbon.bootstrap/src/main/java/org/wso2/carbon/bootstrap/CarbonSecurityManager.java
@@ -18,11 +18,6 @@
package org.wso2.carbon.bootstrap;
-import sun.security.util.SecurityConstants;
-
-import java.security.AccessControlContext;
-import java.security.AccessControlException;
-import java.security.Policy;
import java.util.ArrayList;
import java.util.List;
@@ -32,7 +27,11 @@
*/
public class CarbonSecurityManager extends SecurityManager {
- private List deniedProperties = new ArrayList();
+ private List deniedProperties = new ArrayList<>();
+
+ //TODO check this later sun.security.util is not exported
+ public static final RuntimePermission MODIFY_THREADGROUP_PERMISSION =
+ new RuntimePermission("modifyThreadGroup");
public CarbonSecurityManager() {
super();
@@ -86,7 +85,7 @@ public void checkAccess(ThreadGroup g) {
throw new NullPointerException("thread group can't be null");
}
- checkPermission(SecurityConstants.MODIFY_THREADGROUP_PERMISSION);
+ checkPermission(MODIFY_THREADGROUP_PERMISSION);
}
/**
@@ -100,7 +99,7 @@ public void checkAccess(Thread t) {
throw new NullPointerException("thread can't be null");
}
- checkPermission(SecurityConstants.MODIFY_THREADGROUP_PERMISSION);
+ checkPermission(MODIFY_THREADGROUP_PERMISSION);
}
diff --git a/core/org.wso2.carbon.coordination.core/pom.xml b/core/org.wso2.carbon.coordination.core/pom.xml
index 4b5e8d67aec..2cf851c594e 100644
--- a/core/org.wso2.carbon.coordination.core/pom.xml
+++ b/core/org.wso2.carbon.coordination.core/pom.xml
@@ -89,7 +89,6 @@
org.apache.felixmaven-bundle-plugin
- 1.4.0true
diff --git a/core/org.wso2.carbon.core.common/pom.xml b/core/org.wso2.carbon.core.common/pom.xml
index 5d97a971f69..5ed7f20e712 100644
--- a/core/org.wso2.carbon.core.common/pom.xml
+++ b/core/org.wso2.carbon.core.common/pom.xml
@@ -57,7 +57,7 @@
!org.wso2.carbon.core.common.*,
- javax.activation.*;version="[0.0.0, 1.0.0)"
+ javax.activation.*;version="[1.0.0, 2.0.0)"
diff --git a/core/org.wso2.carbon.core.services/pom.xml b/core/org.wso2.carbon.core.services/pom.xml
index f169c43d0dd..d50a1c2aa74 100644
--- a/core/org.wso2.carbon.core.services/pom.xml
+++ b/core/org.wso2.carbon.core.services/pom.xml
@@ -37,7 +37,11 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
+ org.eclipse.equinox
+ javax.servlet
+
+
+ org.eclipse.platformorg.eclipse.osgi.services
diff --git a/core/org.wso2.carbon.core/pom.xml b/core/org.wso2.carbon.core/pom.xml
index 28e5fb1a9a6..cae1c1bf6e9 100644
--- a/core/org.wso2.carbon.core/pom.xml
+++ b/core/org.wso2.carbon.core/pom.xml
@@ -37,13 +37,24 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
- org.eclipse.osgi.services
+ org.eclipse.equinox
+ javax.servlet
+ ${version.equinox.javax.servlet}
- org.eclipse.equinox
- org.eclipse.equinox.http.helper
+ org.eclipse.platform
+ org.eclipse.osgi.services
+
+
+ org.eclipse.jetty.toolchain
+ jetty-servlet
+
+
+
+
+
+
junitjunit
@@ -243,6 +254,9 @@
naming-factory|naming-resources|commons-collections;scope=compile|runtime;inline=false
+
+ osgi.service;objectClass=org.wso2.carbon.utils.ConfigurationContextService
+ true*
@@ -269,6 +283,9 @@
org.apache.logging.log4j.jul.LogManager
+
+ src/test/resources/testng.xml
+
diff --git a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java
index f9d5dc02b1d..acf0dcdcc81 100644
--- a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java
+++ b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java
@@ -36,19 +36,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.eclipse.equinox.http.helper.FilterServletAdaptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
+import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.base.CarbonBaseConstants;
import org.wso2.carbon.base.CarbonContextHolderBase;
import org.wso2.carbon.base.api.ServerConfigurationService;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.CarbonAxisConfigurator;
import org.wso2.carbon.core.CarbonConfigurationContextFactory;
import org.wso2.carbon.core.CarbonThreadCleanup;
@@ -61,10 +63,9 @@
import org.wso2.carbon.core.deployment.RegistryBasedRepositoryUpdater;
import org.wso2.carbon.core.internal.CarbonCoreDataHolder;
import org.wso2.carbon.core.internal.CarbonCoreServiceComponent;
-import org.wso2.carbon.core.multitenancy.GenericArtifactUnloader;
import org.wso2.carbon.core.internal.HTTPGetProcessorListener;
+import org.wso2.carbon.core.multitenancy.GenericArtifactUnloader;
import org.wso2.carbon.core.multitenancy.MultitenantServerManager;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils;
import org.wso2.carbon.core.security.CarbonJMXAuthenticator;
import org.wso2.carbon.core.transports.CarbonServlet;
@@ -92,8 +93,6 @@
import org.wso2.carbon.utils.deployment.GhostDeployerUtils;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-import javax.servlet.Filter;
-import javax.servlet.ServletException;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -102,6 +101,7 @@
import java.util.Date;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -116,6 +116,10 @@
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
import static org.apache.axis2.transport.TransportListener.HOST_ADDRESS;
/**
@@ -487,9 +491,10 @@ private void initializeCarbon() {
}
HttpService httpService = CarbonCoreDataHolder.getInstance().getHttpService();
+ // TODO might want to do this differently
HttpContext defaultHttpContext = httpService.createDefaultHttpContext();
- registerCarbonServlet(httpService, defaultHttpContext);
+ registerCarbonServlet(defaultHttpContext);
RealmService realmService = CarbonCoreDataHolder.getInstance().getRealmService();
UserRealm teannt0Realm = realmService.getBootstrapRealm();
@@ -539,8 +544,8 @@ private void initializeCarbon() {
}
}
- private void registerCarbonServlet(HttpService httpService, HttpContext defaultHttpContext)
- throws ServletException, NamespaceException, InvalidSyntaxException {
+ private void registerCarbonServlet(HttpContext defaultHttpContext) throws InvalidSyntaxException {
+
if (!"false".equals(serverConfig.getFirstProperty("RequireCarbonServlet"))) {
CarbonServlet carbonServlet = new CarbonServlet(serverConfigContext);
String servicePath = "/services";
@@ -552,11 +557,30 @@ private void registerCarbonServlet(HttpService httpService, HttpContext defaultH
servicePath = "/" + servicePath;
}
ServiceReference filterServiceReference = bundleContext.getServiceReference(Filter.class.getName());
+
+ Dictionary resourceProps = new Hashtable<>();
+ resourceProps.put("osgi.http.whiteboard.context.name", "serviceContext");
+ resourceProps.put("osgi.http.whiteboard.context.path", servicePath);
+ resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, servicePath + "/*");
+ ServiceRegistration servletContextHelperServiceRegistration =
+ bundleContext.registerService(ServletContextHelper.class, (ServletContextHelper) defaultHttpContext,
+ resourceProps);
+ CarbonCoreDataHolder.getInstance().addServiceRegistration(servletContextHelperServiceRegistration);
+
+ Dictionary carbonServletProperties = new Hashtable<>();
+ carbonServletProperties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/*");
+ carbonServletProperties.put("osgi.http.whiteboard.context.select", "(osgi.http.whiteboard.context.name=serviceContext)");
+ ServiceRegistration servletServiceRegistration =
+ bundleContext.registerService(Servlet.class, carbonServlet, carbonServletProperties);
+ CarbonCoreDataHolder.getInstance().addServiceRegistration(servletServiceRegistration);
+
if (filterServiceReference != null) {
Filter filter = (Filter) bundleContext.getService(filterServiceReference);
- httpService.registerServlet(servicePath, new FilterServletAdaptor(filter, null, carbonServlet), null, defaultHttpContext);
- } else {
- httpService.registerServlet(servicePath, carbonServlet, null, defaultHttpContext);
+ Dictionary props = new Hashtable<>();
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, servicePath);
+ ServiceRegistration filterServiceRegistration =
+ bundleContext.registerService(Filter.class, filter, props);
+ CarbonCoreDataHolder.getInstance().addServiceRegistration(filterServiceRegistration);
}
HTTPGetProcessorListener getProcessorListener =
new HTTPGetProcessorListener(carbonServlet, bundleContext);
@@ -941,17 +965,8 @@ public void stop() throws Exception {
((Map) property).clear();
}
- // un-registering the carbonServlet
- String servicePath = "/services"; // default path
- String path = serverConfigContext.getServicePath();
- if (path != null) {
- servicePath = path.trim();
- }
- if (!servicePath.startsWith("/")) {
- servicePath = "/" + servicePath;
- }
try {
- CarbonCoreDataHolder.getInstance().getHttpService().unregister(servicePath);
+ CarbonCoreDataHolder.getInstance().unregisterServiceRegistrations();
} catch (Exception e) {
log.error("Failed to Un-register Servlets ", e);
}
diff --git a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreActivator.java b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreActivator.java
index b03544e24df..5fa6e49043e 100644
--- a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreActivator.java
+++ b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreActivator.java
@@ -79,9 +79,9 @@ public void start(BundleContext context) throws Exception {
provider = (Provider) (Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider")).
getDeclaredConstructor().newInstance();
- } else if (providerName.equals(ServerConstants.JCE_PROVIDER_BCFIPS)) {
- provider = (Provider) (Class.forName("org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider")).
- getDeclaredConstructor().newInstance();
+// } else if (providerName.equals(ServerConstants.JCE_PROVIDER_BCFIPS)) {
+// provider = (Provider) (Class.forName("org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider")).
+// getDeclaredConstructor().newInstance();
} else {
throw new NoSuchProviderException("Configured JCE provider is not supported.");
diff --git a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreDataHolder.java b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreDataHolder.java
index 00c1e8272b3..86cb2276f7c 100644
--- a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreDataHolder.java
+++ b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/internal/CarbonCoreDataHolder.java
@@ -20,7 +20,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpService;
+import org.osgi.service.http.context.ServletContextHelper;
import org.wso2.carbon.base.api.ServerConfigurationService;
import org.wso2.carbon.crypto.api.CryptoService;
import org.wso2.carbon.registry.core.service.RegistryService;
@@ -47,6 +49,8 @@ public class CarbonCoreDataHolder {
private ServerConfigurationService serverConfigurationService;
private TenantRegistryLoader tenantRegistryLoader;
+ private List> serviceRegistrations = new ArrayList<>();
+
private List coordinatedActivities = new ArrayList() ;
private CryptoService cryptoService;
@@ -166,4 +170,16 @@ public CryptoService getCryptoService() {
return cryptoService;
}
+
+ public void addServiceRegistration(ServiceRegistration> serviceRegistration) {
+
+ serviceRegistrations.add(serviceRegistration);
+ }
+
+ public void unregisterServiceRegistrations() {
+
+ for (ServiceRegistration> serviceRegistration : serviceRegistrations) {
+ serviceRegistration.unregister();
+ }
+ }
}
diff --git a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/transports/CarbonServlet.java b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/transports/CarbonServlet.java
index d322bb36a45..c9471794ffe 100644
--- a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/transports/CarbonServlet.java
+++ b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/transports/CarbonServlet.java
@@ -83,15 +83,21 @@ public void init(ServletConfig config) throws ServletException {
configContext.setProperty("GETRequestProcessorMap", getRequestProcessors);
initParams();
String isMeteringEnabledStr = ServerConfiguration.getInstance().getFirstProperty("EnableMetering");
- if(isMeteringEnabledStr!=null){
+ if (isMeteringEnabledStr != null) {
isMeteringEnabled = Boolean.parseBoolean(isMeteringEnabledStr);
}
- if(isMeteringEnabled){
+ if (isMeteringEnabled) {
requestDataPersister = new RequestDataPersisterTask();
new Thread(requestDataPersister).start();
requestDataPersisterScheduler.scheduleWithFixedDelay(requestDataPersister, 5,
5, TimeUnit.SECONDS);
}
+ contextRoot = this.configContext.getContextRoot();
+ }
+
+ public ServletConfig getServletConfig() {
+
+ return servletConfig;
}
private void populateGetRequestProcessors() throws ServletException {
diff --git a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/SignatureUtil.java b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/SignatureUtil.java
index 24c0e948346..5ca30f3962a 100644
--- a/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/SignatureUtil.java
+++ b/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/SignatureUtil.java
@@ -53,9 +53,10 @@ public static void init() throws Exception {
provider = (Provider) (Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider")).
getDeclaredConstructor().newInstance();
- } else if (providerName.equals(ServerConstants.JCE_PROVIDER_BCFIPS)) {
- provider = (Provider) (Class.forName("org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider")).
- getDeclaredConstructor().newInstance();
+ //TODO check why this is not working
+// } else if (providerName.equals(ServerConstants.JCE_PROVIDER_BCFIPS)) {
+// provider = (Provider) (Class.forName("org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider")).
+// getDeclaredConstructor().newInstance();
} else {
throw new NoSuchProviderException("Configured JCE provider is not supported.");
diff --git a/core/org.wso2.carbon.http.bridge/pom.xml b/core/org.wso2.carbon.http.bridge/pom.xml
index 2ee399631e9..32872a15763 100644
--- a/core/org.wso2.carbon.http.bridge/pom.xml
+++ b/core/org.wso2.carbon.http.bridge/pom.xml
@@ -54,7 +54,7 @@
org.wso2.carbon.bridge
- org.eclipse.equinox
+ org.eclipse.platformorg.eclipse.equinox.http.servlet
diff --git a/core/org.wso2.carbon.ndatasource.common/pom.xml b/core/org.wso2.carbon.ndatasource.common/pom.xml
index ad373b2b03f..2e39bc3621b 100644
--- a/core/org.wso2.carbon.ndatasource.common/pom.xml
+++ b/core/org.wso2.carbon.ndatasource.common/pom.xml
@@ -47,7 +47,10 @@
org.wso2.carbon.ndatasource.common.*
- *
+
+
+ org.apache.commons.logging;version="[1.2,2)"
+
diff --git a/core/org.wso2.carbon.osgi.security/pom.xml b/core/org.wso2.carbon.osgi.security/pom.xml
index 8d9a8b97867..c3571f5e079 100644
--- a/core/org.wso2.carbon.osgi.security/pom.xml
+++ b/core/org.wso2.carbon.osgi.security/pom.xml
@@ -39,13 +39,13 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
+ org.eclipse.platformorg.eclipse.osgi.services
-
- org.eclipse.equinox
- org.eclipse.equinox.http.helper
-
+
+
+
+
junitjunit
diff --git a/core/org.wso2.carbon.pax-logging-log4j2-plugins/pom.xml b/core/org.wso2.carbon.pax-logging-log4j2-plugins/pom.xml
index 7e68cacfcdd..ebcf375cf16 100644
--- a/core/org.wso2.carbon.pax-logging-log4j2-plugins/pom.xml
+++ b/core/org.wso2.carbon.pax-logging-log4j2-plugins/pom.xml
@@ -63,16 +63,6 @@
mockito-coretest
-
- org.powermock
- powermock-module-testng
- test
-
-
- org.powermock
- powermock-api-mockito2
- test
- org.apache.logging.log4jlog4j-jul
diff --git a/core/org.wso2.carbon.pax-logging-log4j2-plugins/src/test/java/org/wso2/carbon/log4j2/plugins/AppNameConverterTest.java b/core/org.wso2.carbon.pax-logging-log4j2-plugins/src/test/java/org/wso2/carbon/log4j2/plugins/AppNameConverterTest.java
index dcb711f4345..a6ce6895308 100644
--- a/core/org.wso2.carbon.pax-logging-log4j2-plugins/src/test/java/org/wso2/carbon/log4j2/plugins/AppNameConverterTest.java
+++ b/core/org.wso2.carbon.pax-logging-log4j2-plugins/src/test/java/org/wso2/carbon/log4j2/plugins/AppNameConverterTest.java
@@ -21,19 +21,15 @@
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.SimpleMessage;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.testng.PowerMockTestCase;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.wso2.carbon.utils.logging.handler.TenantDomainSetter;
import static org.testng.Assert.assertEquals;
/**
* Tests AppNameConverter class.
*/
-@PrepareForTest(TenantDomainSetter.class)
-public class AppNameConverterTest extends PowerMockTestCase {
+public class AppNameConverterTest {
private AppNameConverter appNameConverter;
private LogEvent logEvent;
diff --git a/core/org.wso2.carbon.registry.api/pom.xml b/core/org.wso2.carbon.registry.api/pom.xml
index fbdb83b80a4..784e4641f3a 100644
--- a/core/org.wso2.carbon.registry.api/pom.xml
+++ b/core/org.wso2.carbon.registry.api/pom.xml
@@ -46,6 +46,9 @@
!javax.servlet.http,
org.wso2.carbon.registry.api.*;version=1.0.1,
+
+ !*
+
diff --git a/core/org.wso2.carbon.registry.core/pom.xml b/core/org.wso2.carbon.registry.core/pom.xml
index 5ae65db2e7f..37a81f17421 100644
--- a/core/org.wso2.carbon.registry.core/pom.xml
+++ b/core/org.wso2.carbon.registry.core/pom.xml
@@ -54,7 +54,7 @@
org.wso2.carbon.user.*,
org.wso2.carbon.utils.*,
!javax.xml.namespace,
- javax.activation.*;version="[0.0.0, 1.0.0)",
+ javax.activation.*;version="[1.0.0, 2.0.0)",
org.apache.abdera.*; version="${imp.pkg.version.abdera}",
javax.xml.namespace; version=0.0.0,
javax.servlet; version="${imp.pkg.version.javax.servlet}",
@@ -68,6 +68,11 @@
*;resolution:=optional
*
+
+ osgi.service;objectClass=org.wso2.carbon.registry.core.service.RegistryService,
+ osgi.service;objectClass=org.wso2.carbon.registry.api.RegistryService,
+ osgi.service;objectClass=org.wso2.carbon.registry.core.service.TenantRegistryLoader
+
acegi-security;scope=compile|runtime;inline=false
@@ -102,7 +107,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-0
@@ -126,7 +132,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-1
@@ -150,7 +157,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-2
@@ -174,7 +182,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-3
@@ -198,7 +207,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-4
@@ -226,7 +236,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-5
@@ -254,7 +265,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-6
@@ -282,7 +294,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-7
@@ -310,7 +323,8 @@
false
- pertest
+ 1
+ false-enableassertionsfalse${project.build.directory}/surefire-reports-8
@@ -376,9 +390,14 @@
annotations
- org.wso2.eclipse.osgi
+ org.eclipse.platformorg.eclipse.osgi.services
+
+
+
+
+
junitjunit
diff --git a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java
index d4cc7baa286..40a620805a2 100644
--- a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java
+++ b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java
@@ -19,6 +19,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.annotations.Component;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.RegistryConstants;
@@ -42,6 +43,7 @@
* to create remote registry instances for user sessions. The class acts in a manner that is similar
* to an {@link EmbeddedRegistryService}.
*/
+//@Component(service = RegistryService.class)
public class RemoteRegistryService implements RegistryService {
private static final Log log = LogFactory.getLog(RemoteRegistryService.class);
diff --git a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java
index da4a63516e4..dc38fd42161 100644
--- a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java
+++ b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java
@@ -18,6 +18,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.annotations.Component;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.registry.core.RegistryConstants;
import org.wso2.carbon.registry.core.clustering.NodeGroupLock;
@@ -25,7 +26,6 @@
import org.wso2.carbon.registry.core.config.RegistryContext;
import org.wso2.carbon.registry.core.dataaccess.DataAccessManager;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.internal.RegistryCoreServiceComponent;
import org.wso2.carbon.registry.core.jdbc.dataaccess.JDBCDataAccessManager;
import org.wso2.carbon.registry.core.jdbc.realm.RegistryRealm;
import org.wso2.carbon.registry.core.jdbc.utils.Transaction;
@@ -35,7 +35,6 @@
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.UserRealm;
import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.user.core.util.UserCoreUtil;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
@@ -71,6 +70,7 @@
* @see EmbeddedRegistry
* @see UserRegistry
*/
+//@Component(service = RegistryService.class)
public class EmbeddedRegistryService implements RegistryService {
private static final Log log = LogFactory.getLog(EmbeddedRegistryService.class);
diff --git a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java
index 27552d76c1f..cb2c9de1a3f 100644
--- a/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java
+++ b/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java
@@ -16,9 +16,11 @@
package org.wso2.carbon.registry.core.jdbc;
+import org.osgi.service.component.annotations.Component;
import org.wso2.carbon.registry.core.config.RegistryContext;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService;
+import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.api.RealmConfiguration;
import org.wso2.carbon.user.core.service.RealmService;
@@ -28,6 +30,7 @@
* This is an extension to the {@link EmbeddedRegistryService} which is tailored to expose {@link
* InMemoryEmbeddedRegistry} instances as OSGi services.
*/
+//@Component(service = RegistryService.class)
public class InMemoryEmbeddedRegistryService extends EmbeddedRegistryService {
private RealmService realmService;
diff --git a/core/org.wso2.carbon.registry.core/src/test/resources/testng.xml b/core/org.wso2.carbon.registry.core/src/test/resources/testng.xml
new file mode 100644
index 00000000000..9e60b4c8c4c
--- /dev/null
+++ b/core/org.wso2.carbon.registry.core/src/test/resources/testng.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/org.wso2.carbon.registry.xboot/pom.xml b/core/org.wso2.carbon.registry.xboot/pom.xml
index 7f7237307c3..e69de29bb2d 100644
--- a/core/org.wso2.carbon.registry.xboot/pom.xml
+++ b/core/org.wso2.carbon.registry.xboot/pom.xml
@@ -1,37 +0,0 @@
-
-
-
-
-
-
- org.wso2.carbon
- carbon-kernel
- 4.10.16-SNAPSHOT
- ../pom.xml
-
-
- 4.0.0
- org.wso2.carbon.registry.xboot
- jar
- WSO2 Carbon - Xbootclasspath library for Registry Kernel
- Xboot library which handle the SQL Connection API differences in JDK 5 and JDK 6
- http://wso2.org
-
-
-
-
-
diff --git a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/NClob.java b/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/NClob.java
deleted file mode 100644
index 7571e44674a..00000000000
--- a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/NClob.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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 java.sql;
-
-/**
- * Dummy implementation of NClob in JDK6
- */
-public interface NClob {
-}
diff --git a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/RowId.java b/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/RowId.java
deleted file mode 100644
index bd125b8bc40..00000000000
--- a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/RowId.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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 java.sql;
-
-/**
- * Dummy implementation of RowId in JDK6
- */
-public interface RowId {
-}
diff --git a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/SQLXML.java b/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/SQLXML.java
deleted file mode 100644
index 0947067d332..00000000000
--- a/core/org.wso2.carbon.registry.xboot/src/main/java/java/sql/SQLXML.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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 java.sql;
-
-/**
- * Dummy implementation of SQLXML in JDK6
- */
-public interface SQLXML {
-}
diff --git a/core/org.wso2.carbon.securevault/pom.xml b/core/org.wso2.carbon.securevault/pom.xml
index 6ba92beac08..f3fbc8fb820 100644
--- a/core/org.wso2.carbon.securevault/pom.xml
+++ b/core/org.wso2.carbon.securevault/pom.xml
@@ -36,7 +36,7 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
+ org.eclipse.platformorg.eclipse.osgi.services
@@ -86,6 +86,9 @@
*;resolution:=optional
*
+
+ osgi.service;objectClass=org.wso2.carbon.securevault.SecretCallbackHandlerService
+
diff --git a/core/org.wso2.carbon.server.admin.common/pom.xml b/core/org.wso2.carbon.server.admin.common/pom.xml
index 97d44a9ba94..ea5389bd049 100644
--- a/core/org.wso2.carbon.server.admin.common/pom.xml
+++ b/core/org.wso2.carbon.server.admin.common/pom.xml
@@ -55,6 +55,9 @@
org.wso2.carbon.server.admin.common.*
+
+ !*
+
diff --git a/core/org.wso2.carbon.tomcat.ext/pom.xml b/core/org.wso2.carbon.tomcat.ext/pom.xml
index 06f533caccd..abe300e130b 100644
--- a/core/org.wso2.carbon.tomcat.ext/pom.xml
+++ b/core/org.wso2.carbon.tomcat.ext/pom.xml
@@ -36,7 +36,7 @@
org.eclipse.osgi
- org.wso2.eclipse.equinox
+ org.eclipse.platformorg.eclipse.equinox.common
@@ -91,16 +91,6 @@
mockito-coretest
-
- org.powermock
- powermock-api-mockito2
- test
-
-
- org.powermock
- powermock-module-testng
- test
- org.osgiorg.osgi.service.component.annotations
diff --git a/core/org.wso2.carbon.tomcat/pom.xml b/core/org.wso2.carbon.tomcat/pom.xml
index 56425c14214..735d0b3b5a7 100644
--- a/core/org.wso2.carbon.tomcat/pom.xml
+++ b/core/org.wso2.carbon.tomcat/pom.xml
@@ -36,11 +36,11 @@
org.eclipse.osgi
- org.eclipse.equinox
+ org.eclipse.platformorg.eclipse.equinox.http.servlet
- org.wso2.eclipse.equinox
+ org.eclipse.platformorg.eclipse.equinox.common
@@ -119,6 +119,9 @@
*;resolution:=optional
*
+
+ osgi.service;objectClass=org.wso2.carbon.tomcat.api.CarbonTomcatService
+
diff --git a/core/org.wso2.carbon.ui/pom.xml b/core/org.wso2.carbon.ui/pom.xml
index 690e17b431f..e123a3d4b0f 100644
--- a/core/org.wso2.carbon.ui/pom.xml
+++ b/core/org.wso2.carbon.ui/pom.xml
@@ -37,21 +37,32 @@
org.eclipse.osgi
- org.wso2.eclipse.osgi
+ org.eclipse.equinox
+ javax.servlet
+ ${version.equinox.javax.servlet}
+
+
+ org.eclipse.platformorg.eclipse.osgi.services
+
+
+ org.eclipse.jetty.toolchain
+ jetty-servlet
+
+ org.apache.ws.commons.axiom.wso2axiom
- org.apache.tiles.wso2
+ org.wso2.orbit.org.apache.tilestiles-jsp
-
- org.apache.tiles
- tiles-jsp
-
+
+
+
+
commons-digestercommons-digester
@@ -62,6 +73,17 @@
+
+
+
+
+
+
+
+
+
+
+
org.wso2.carbonorg.wso2.carbon.core
@@ -111,7 +133,7 @@
axis2
- org.eclipse.equinox
+ org.eclipse.platformorg.eclipse.equinox.http.servlet
@@ -146,10 +168,6 @@
-
- org.eclipse.equinox
- javax.servlet
- commons-lang.wso2commons-lang
@@ -222,8 +240,7 @@
javax.servlet.http; version="${imp.pkg.version.javax.servlet}",
javax.servlet.jsp; version="${imp.pkg.version.javax.servlet.jsp}"
javax.servlet.jsp.tagext; version="${imp.pkg.version.javax.servlet.jsp}",
- org.eclipse.equinox.http.helper,
- org.apache.tiles.*;version="2.0.5",
+ org.apache.tiles.*;version="3.0.7",
org.wso2.carbon.registry.core.service,
org.owasp.csrfguard.tag.*; version="${orbit.version.csrfguard}",
org.owasp.encoder.*;version="${owasp.encoder.wso2.imp.pkg.version}",
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/BundleEntryHttpContext.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/BundleEntryHttpContext.java
new file mode 100644
index 00000000000..db6bb09e365
--- /dev/null
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/BundleEntryHttpContext.java
@@ -0,0 +1,114 @@
+package org.wso2.carbon.ui;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.context.ServletContextHelper;
+
+public class BundleEntryHttpContext extends ServletContextHelper implements HttpContext {
+ private Bundle bundle;
+ private String bundlePath;
+
+ public BundleEntryHttpContext(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ public BundleEntryHttpContext(Bundle b, String bundlePath) {
+ this(b);
+ if (bundlePath != null) {
+ if (bundlePath.endsWith("/")) {
+ bundlePath = bundlePath.substring(0, bundlePath.length() - 1);
+ }
+
+ if (bundlePath.length() == 0) {
+ bundlePath = null;
+ }
+ }
+
+ this.bundlePath = bundlePath;
+ }
+
+ public String getMimeType(String arg0) {
+ return null;
+ }
+
+ public boolean handleSecurity(HttpServletRequest arg0, HttpServletResponse arg1) throws IOException {
+ return true;
+ }
+
+ public URL getResource(String resourceName) {
+ if (this.bundlePath != null) {
+ resourceName = this.bundlePath + resourceName;
+ }
+
+ int lastSlash = resourceName.lastIndexOf(47);
+ if (lastSlash == -1) {
+ return null;
+ } else {
+ String path = resourceName.substring(0, lastSlash);
+ if (path.length() == 0) {
+ path = "/";
+ }
+
+ String file = this.sanitizeEntryName(resourceName.substring(lastSlash + 1));
+ Enumeration entryPaths = this.bundle.findEntries(path, file, false);
+ return entryPaths != null && entryPaths.hasMoreElements() ? (URL)entryPaths.nextElement() : null;
+ }
+ }
+
+ private String sanitizeEntryName(String name) {
+ StringBuffer buffer = null;
+
+ for(int i = 0; i < name.length(); ++i) {
+ char c = name.charAt(i);
+ switch (c) {
+ case '*':
+ case '\\':
+ if (buffer == null) {
+ buffer = new StringBuffer(name.length() + 16);
+ buffer.append(name.substring(0, i));
+ }
+
+ buffer.append('\\').append(c);
+ break;
+ default:
+ if (buffer != null) {
+ buffer.append(c);
+ }
+ }
+ }
+
+ return buffer == null ? name : buffer.toString();
+ }
+
+ public Set getResourcePaths(String path) {
+ if (this.bundlePath != null) {
+ path = this.bundlePath + path;
+ }
+
+ Enumeration entryPaths = this.bundle.findEntries(path, (String)null, false);
+ if (entryPaths == null) {
+ return null;
+ } else {
+ Set result = new HashSet();
+
+ while(entryPaths.hasMoreElements()) {
+ URL entryURL = (URL)entryPaths.nextElement();
+ String entryPath = entryURL.getFile();
+ if (this.bundlePath == null) {
+ result.add(entryPath);
+ } else {
+ result.add(entryPath.substring(this.bundlePath.length()));
+ }
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonSecuredHttpContext.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonSecuredHttpContext.java
index d5996633341..b28032c82ff 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonSecuredHttpContext.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonSecuredHttpContext.java
@@ -280,9 +280,9 @@ public boolean handleSecurity(HttpServletRequest request, HttpServletResponse re
}
if (request.getSession().isNew()) {
if (skipLoginPage) {
- response.sendRedirect(contextPath + "/carbon/admin/login_action.jsp");
+ response.sendRedirect(contextPath + "/admin/login_action.jsp");
} else {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp");
+ response.sendRedirect(contextPath + "/admin/login.jsp");
}
return false;
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonUILoginUtil.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonUILoginUtil.java
index b1bc03a1620..f4063779ae6 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonUILoginUtil.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CarbonUILoginUtil.java
@@ -161,9 +161,9 @@ protected static boolean saveOriginalUrl(CarbonUIAuthenticator authenticator,
}
} else {
if (skipLoginPage) {
- response.sendRedirect(contextPath + "/carbon/admin/login_action.jsp");
+ response.sendRedirect(contextPath + "/admin/login_action.jsp");
} else {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp");
+ response.sendRedirect(contextPath + "/admin/login.jsp");
}
}
@@ -460,7 +460,7 @@ protected static boolean handleLogin(CarbonUIAuthenticator authenticator,
response.addCookie(rmeCookie);
}
} catch (Exception e) {
- response.sendRedirect(contextPath + indexPageURL
+ response.sendRedirect(indexPageURL
+ (indexPageURL.indexOf('?') == -1 ? "?" : "&") + "loginStatus=false");
if (log.isDebugEnabled()) {
log.debug("Security check failed for login request for " + userName);
@@ -479,7 +479,7 @@ protected static boolean handleLogin(CarbonUIAuthenticator authenticator,
indexPageURL = indexPageURL.substring(5);
}
- response.sendRedirect(contextPath + indexPageURL
+ response.sendRedirect(indexPageURL
+ (indexPageURL.indexOf('?') == -1 ? "?" : "&") + "loginStatus=true");
}
@@ -497,14 +497,14 @@ protected static boolean handleLogin(CarbonUIAuthenticator authenticator,
if (isLoginFailureReasonEnabled()) {
if (e.getCause().getMessage().contains(ACCOUNT_LOCK_ERROR_CODE) || e.getCause().getMessage()
.contains(ACCOUNT_LOCK_ERROR_MESSAGE)) {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp?loginStatus=false&errorCode=error" +
+ response.sendRedirect(contextPath + "/admin/login.jsp?loginStatus=false&errorCode=error" +
".code.17003");
return false;
} else if (e.getCause().getMessage().contains(USER_NOT_FOUND_ERROR_CODE)) {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp?loginStatus=false&errorCode=error.code.17001");
+ response.sendRedirect(contextPath + "/admin/login.jsp?loginStatus=false&errorCode=error.code.17001");
return false;
} else if (e.getCause().getMessage().contains(INVALID_CREDENTIALS_ERROR_CODE)) {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp?loginStatus=false&errorCode=error.code.17002");
+ response.sendRedirect(contextPath + "/admin/login.jsp?loginStatus=false&errorCode=error.code.17002");
return false;
}
}
@@ -512,7 +512,7 @@ protected static boolean handleLogin(CarbonUIAuthenticator authenticator,
response.sendRedirect(httpLogin + "?loginStatus=false");
return false;
} else {
- response.sendRedirect(contextPath + "/carbon/admin/login.jsp?loginStatus=false");
+ response.sendRedirect(contextPath + "/admin/login.jsp?loginStatus=false");
return false;
}
} catch (Exception e1) {
@@ -644,7 +644,7 @@ protected static boolean escapeTenantWebAppRequests(boolean authenticated,
// a tenant requesting login.jsp while not being authenticated
// redirecting the tenant login page request to the root /carbon/admin/login.jsp
// instead of tenant-aware login page
- response.sendRedirect(context + "/carbon/admin/login.jsp");
+ response.sendRedirect(context + "/admin/login.jsp");
log.debug("Redirecting to /carbon/admin/login.jsp");
return false;
}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/ContextPathServletAdaptor.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/ContextPathServletAdaptor.java
new file mode 100644
index 00000000000..d2764e23b75
--- /dev/null
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/ContextPathServletAdaptor.java
@@ -0,0 +1,382 @@
+package org.wso2.carbon.ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+public class ContextPathServletAdaptor implements Servlet {
+ private Servlet delegate;
+ String contextPath;
+
+ public ContextPathServletAdaptor(Servlet delegate, String contextPath) {
+ this.delegate = delegate;
+ this.contextPath = contextPath != null && !contextPath.equals("/") ? contextPath : "";
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.delegate.init(new ContextPathServletAdaptor.ServletConfigAdaptor(config));
+ }
+
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ this.delegate.service(new ContextPathServletAdaptor.HttpServletRequestAdaptor((HttpServletRequest)request), response);
+ }
+
+ public void destroy() {
+ this.delegate.destroy();
+ }
+
+ public ServletConfig getServletConfig() {
+ return this.delegate.getServletConfig();
+ }
+
+ public String getServletInfo() {
+ return this.delegate.getServletInfo();
+ }
+
+ private class RequestDispatcherAdaptor implements RequestDispatcher {
+ private RequestDispatcher requestDispatcher;
+
+ public RequestDispatcherAdaptor(RequestDispatcher requestDispatcher) {
+ this.requestDispatcher = requestDispatcher;
+ }
+
+ public void forward(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+ if (req instanceof ContextPathServletAdaptor.HttpServletRequestAdaptor) {
+ req = ((ContextPathServletAdaptor.HttpServletRequestAdaptor)req).getRequest();
+ }
+
+ this.requestDispatcher.forward(req, resp);
+ }
+
+ public void include(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+ if (req instanceof ContextPathServletAdaptor.HttpServletRequestAdaptor) {
+ req = ((ContextPathServletAdaptor.HttpServletRequestAdaptor)req).getRequest();
+ }
+
+ this.requestDispatcher.include(req, resp);
+ }
+ }
+
+ private class HttpServletRequestAdaptor extends HttpServletRequestWrapper {
+ static final String INCLUDE_REQUEST_URI_ATTRIBUTE = "javax.servlet.include.request_uri";
+ static final String INCLUDE_CONTEXT_PATH_ATTRIBUTE = "javax.servlet.include.context_path";
+ static final String INCLUDE_SERVLET_PATH_ATTRIBUTE = "javax.servlet.include.servlet_path";
+ static final String INCLUDE_PATH_INFO_ATTRIBUTE = "javax.servlet.include.path_info";
+ private boolean isRequestDispatcherInclude;
+
+ public HttpServletRequestAdaptor(HttpServletRequest req) {
+ super(req);
+ this.isRequestDispatcherInclude = req.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null;
+ }
+
+ public String getServletPath() {
+ if (this.isRequestDispatcherInclude) {
+ return super.getServletPath();
+ } else {
+ String fullPath = super.getServletPath();
+ return fullPath.substring(
+ ContextPathServletAdaptor.this.contextPath.length());
+ }
+ }
+
+ public String getContextPath() {
+ return this.isRequestDispatcherInclude ? super.getContextPath() : super.getContextPath() + ContextPathServletAdaptor.this.contextPath;
+ }
+
+ public Object getAttribute(String attributeName) {
+ if (this.isRequestDispatcherInclude) {
+ String servletPath;
+ if (attributeName.equals(INCLUDE_CONTEXT_PATH_ATTRIBUTE)) {
+ servletPath = (String)super.getAttribute(INCLUDE_CONTEXT_PATH_ATTRIBUTE);
+ if (servletPath != null && !servletPath.equals("/")) {
+ return servletPath + ContextPathServletAdaptor.this.contextPath;
+ }
+
+ return ContextPathServletAdaptor.this.contextPath;
+ }
+
+ if (attributeName.equals(INCLUDE_SERVLET_PATH_ATTRIBUTE)) {
+ servletPath = (String)super.getAttribute(INCLUDE_SERVLET_PATH_ATTRIBUTE);
+ return servletPath.substring(
+ ContextPathServletAdaptor.this.contextPath.length());
+ }
+ }
+
+ return super.getAttribute(attributeName);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ return ContextPathServletAdaptor.this.new RequestDispatcherAdaptor(super.getRequestDispatcher(
+ ContextPathServletAdaptor.this.contextPath + arg0));
+ }
+ }
+
+ private class ServletContextAdaptor implements ServletContext {
+ private ServletContext delegate;
+
+ public ServletContextAdaptor(ServletContext delegate) {
+ this.delegate = delegate;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return ContextPathServletAdaptor.this.contextPath.equals("/") ? ContextPathServletAdaptor.this.new RequestDispatcherAdaptor(this.delegate.getRequestDispatcher(path)) : ContextPathServletAdaptor.this.new RequestDispatcherAdaptor(this.delegate.getRequestDispatcher(
+ ContextPathServletAdaptor.this.contextPath + path));
+ }
+
+ public URL getResource(String name) throws MalformedURLException {
+ return this.delegate.getResource(name);
+ }
+
+ public InputStream getResourceAsStream(String name) {
+ return this.delegate.getResourceAsStream(name);
+ }
+
+ public Set getResourcePaths(String name) {
+ return this.delegate.getResourcePaths(name);
+ }
+
+ public Object getAttribute(String arg0) {
+ return this.delegate.getAttribute(arg0);
+ }
+
+ public Enumeration getAttributeNames() {
+ return this.delegate.getAttributeNames();
+ }
+
+ public ServletContext getContext(String arg0) {
+ return this.delegate.getContext(arg0);
+ }
+
+ public String getInitParameter(String arg0) {
+ return this.delegate.getInitParameter(arg0);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return this.delegate.getInitParameterNames();
+ }
+
+ public boolean setInitParameter(String s, String s1) {
+ return this.delegate.setInitParameter(s, s1);
+ }
+
+ public int getMajorVersion() {
+ return this.delegate.getMajorVersion();
+ }
+
+ public String getMimeType(String arg0) {
+ return this.delegate.getMimeType(arg0);
+ }
+
+ public int getMinorVersion() {
+ return this.delegate.getMinorVersion();
+ }
+
+ public int getEffectiveMajorVersion() {
+ return this.delegate.getEffectiveMajorVersion();
+ }
+
+ public int getEffectiveMinorVersion() {
+ return this.delegate.getEffectiveMinorVersion();
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0) {
+ return ContextPathServletAdaptor.this.new RequestDispatcherAdaptor(this.delegate.getNamedDispatcher(arg0));
+ }
+
+ public String getRealPath(String arg0) {
+ return this.delegate.getRealPath(arg0);
+ }
+
+ public String getServerInfo() {
+ return this.delegate.getServerInfo();
+ }
+
+ /** @deprecated */
+ public Servlet getServlet(String arg0) throws ServletException {
+ return this.delegate.getServlet(arg0);
+ }
+
+ public String getServletContextName() {
+ return this.delegate.getServletContextName();
+ }
+
+ public ServletRegistration.Dynamic addServlet(String s, String s1) {
+ return this.delegate.addServlet(s, s1);
+ }
+
+ public ServletRegistration.Dynamic addServlet(String s, Servlet servlet) {
+ return this.delegate.addServlet(s, servlet);
+ }
+
+ public ServletRegistration.Dynamic addServlet(String s, Class extends Servlet> aClass) {
+ return this.delegate.addServlet(s, aClass);
+ }
+
+ public T createServlet(Class tClass) throws ServletException {
+ return this.delegate.createServlet(tClass);
+ }
+
+ public ServletRegistration getServletRegistration(String s) {
+ return this.delegate.getServletRegistration(s);
+ }
+
+ public Map getServletRegistrations() {
+ return this.delegate.getServletRegistrations();
+ }
+
+ public FilterRegistration.Dynamic addFilter(String s, String s1) {
+ return this.delegate.addFilter(s, s1);
+ }
+
+ public FilterRegistration.Dynamic addFilter(String s, Filter filter) {
+ return this.delegate.addFilter(s, filter);
+ }
+
+ public FilterRegistration.Dynamic addFilter(String s, Class extends Filter> aClass) {
+ return this.delegate.addFilter(s, aClass);
+ }
+
+ public T createFilter(Class tClass) throws ServletException {
+ return this.delegate.createFilter(tClass);
+ }
+
+ public FilterRegistration getFilterRegistration(String s) {
+ return this.delegate.getFilterRegistration(s);
+ }
+
+ public Map getFilterRegistrations() {
+ return this.delegate.getFilterRegistrations();
+ }
+
+ public SessionCookieConfig getSessionCookieConfig() {
+ return this.delegate.getSessionCookieConfig();
+ }
+
+ public void setSessionTrackingModes(Set sessionTrackingModes) throws IllegalStateException, IllegalArgumentException {
+ this.delegate.setSessionTrackingModes(sessionTrackingModes);
+ }
+
+ public Set getDefaultSessionTrackingModes() {
+ return this.delegate.getDefaultSessionTrackingModes();
+ }
+
+ public Set getEffectiveSessionTrackingModes() {
+ return this.delegate.getEffectiveSessionTrackingModes();
+ }
+
+ public void addListener(Class extends EventListener> aClass) {
+ this.delegate.addListener(aClass);
+ }
+
+ public void addListener(String s) {
+ this.delegate.addListener(s);
+ }
+
+ public void addListener(T t) {
+ this.delegate.addListener(t);
+ }
+
+ public T createListener(Class tClass) throws ServletException {
+ return this.delegate.createListener(tClass);
+ }
+
+ public void declareRoles(String... strings) {
+ this.delegate.declareRoles(strings);
+ }
+
+ public ClassLoader getClassLoader() {
+ return this.delegate.getClassLoader();
+ }
+
+ public JspConfigDescriptor getJspConfigDescriptor() {
+ return this.delegate.getJspConfigDescriptor();
+ }
+
+ /** @deprecated */
+ public Enumeration getServletNames() {
+ return this.delegate.getServletNames();
+ }
+
+ /** @deprecated */
+ public Enumeration getServlets() {
+ return this.delegate.getServlets();
+ }
+
+ /** @deprecated */
+ public void log(Exception arg0, String arg1) {
+ this.delegate.log(arg0, arg1);
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ this.delegate.log(arg0, arg1);
+ }
+
+ public void log(String arg0) {
+ this.delegate.log(arg0);
+ }
+
+ public void removeAttribute(String arg0) {
+ this.delegate.removeAttribute(arg0);
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ this.delegate.setAttribute(arg0, arg1);
+ }
+
+ public String getContextPath() {
+ try {
+ Method getContextPathMethod = this.delegate.getClass().getMethod("getContextPath", (Class[])null);
+ return (String)getContextPathMethod.invoke(this.delegate, (Object[])null);
+ } catch (Exception var2) {
+ return null;
+ }
+ }
+ }
+
+ private class ServletConfigAdaptor implements ServletConfig {
+ private ServletConfig config;
+ private ServletContext context;
+
+ public ServletConfigAdaptor(ServletConfig config) {
+ this.config = config;
+ this.context = ContextPathServletAdaptor.this.new ServletContextAdaptor(config.getServletContext());
+ }
+
+ public String getInitParameter(String arg0) {
+ return this.config.getInitParameter(arg0);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return this.config.getInitParameterNames();
+ }
+
+ public ServletContext getServletContext() {
+ return this.context;
+ }
+
+ public String getServletName() {
+ return this.config.getServletName();
+ }
+ }
+}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializer.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializer.java
new file mode 100644
index 00000000000..c6bc9a57895
--- /dev/null
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializer.java
@@ -0,0 +1,26 @@
+package org.wso2.carbon.ui;
+
+import org.apache.tiles.factory.AbstractTilesContainerFactory;
+import org.apache.tiles.factory.BasicTilesContainerFactory;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.servlet.ServletApplicationContext;
+import org.apache.tiles.startup.AbstractTilesInitializer;
+import org.apache.tiles.startup.TilesInitializer;
+import org.apache.tiles.web.startup.AbstractTilesListener;
+
+import javax.servlet.ServletContext;
+
+public class CustomTilesInitializer extends AbstractTilesInitializer {
+
+ @Override
+ protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext applicationContext) {
+
+ return new BasicTilesContainerFactory();
+ }
+
+ @Override
+ protected ApplicationContext createTilesApplicationContext(ApplicationContext context) {
+
+ return new ServletApplicationContext((ServletContext) context.getContext());
+ }
+}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializerListener.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializerListener.java
new file mode 100644
index 00000000000..b68c4ac5887
--- /dev/null
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/CustomTilesInitializerListener.java
@@ -0,0 +1,66 @@
+package org.wso2.carbon.ui;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import org.apache.tiles.factory.BasicTilesContainerFactory;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.servlet.ServletApplicationContext;
+import org.apache.tiles.request.servlet.wildcard.WildcardServletApplicationContext;
+import org.apache.tiles.startup.TilesInitializer;
+import org.apache.tiles.startup.AbstractTilesInitializer;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.request.servlet.ServletUtil;
+import org.apache.tiles.web.startup.AbstractTilesListener;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+@Component(
+ service = ServletContextListener.class,
+ property = {
+ HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER + "=true",
+ HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=tilesContext)"
+ }
+)
+public class CustomTilesInitializerListener extends AbstractTilesListener {
+
+ @Override
+ protected TilesInitializer createTilesInitializer() {
+
+ return new CustomTilesInitializer();
+ }
+
+// @Override
+// public void contextInitialized(ServletContextEvent sce) {
+// ServletApplicationContext application = new ServletApplicationContext(sce.getServletContext());
+// TilesInitializer initializer = new AbstractTilesInitializer() {
+// @Override
+// protected ApplicationContext createTilesApplicationContext(ApplicationContext context) {
+// return new ServletApplicationContext((ServletContext)context.getContext());
+// }
+//
+//// @Override
+//// protected ApplicationContext createApplicationContext(Object context) {
+//// return new ServletApplicationContext((javax.servlet.ServletContext) context);
+//// }
+//
+// @Override
+// protected BasicTilesContainerFactory createContainerFactory(ApplicationContext context) {
+// return new BasicTilesContainerFactory();
+// }
+// };
+//// TilesContainer container = initializer.createContainer(application);
+//// ServletUtil.setContainer(sce.getServletContext(), container);
+//
+// initializer.initialize(application);
+//// ServletUtil.setContainer(sce.getServletContext(), container);
+// }
+//
+// @Override
+// public void contextDestroyed(ServletContextEvent sce) {
+// // Clean up resources if necessary
+// }
+
+
+}
+
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/DefaultComponentEntryHttpContext.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/DefaultComponentEntryHttpContext.java
index db7d1999876..b58c3dcfd58 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/DefaultComponentEntryHttpContext.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/DefaultComponentEntryHttpContext.java
@@ -15,7 +15,6 @@
*/
package org.wso2.carbon.ui;
-import org.eclipse.equinox.http.helper.BundleEntryHttpContext;
import org.osgi.framework.Bundle;
import java.net.MalformedURLException;
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/FilterServletAdaptor.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/FilterServletAdaptor.java
new file mode 100644
index 00000000000..c546293a100
--- /dev/null
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/FilterServletAdaptor.java
@@ -0,0 +1,89 @@
+package org.wso2.carbon.ui;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Properties;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class FilterServletAdaptor implements Servlet {
+ ServletConfig config;
+ Servlet delegate;
+ Filter filter;
+ Properties filterInitParameters;
+ private FilterChain filterChain;
+
+ public FilterServletAdaptor(Filter filter, Properties filterInitParameters, Servlet delegate) {
+ this.delegate = delegate;
+ this.filter = filter;
+ this.filterInitParameters = filterInitParameters == null ? new Properties() : filterInitParameters;
+ this.filterChain = new FilterServletAdaptor.FilterChainImpl();
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.config = config;
+ this.filter.init(new FilterServletAdaptor.FilterConfigImpl());
+ this.delegate.init(config);
+ }
+
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ this.filter.doFilter(request, response, this.filterChain);
+ }
+
+ public void destroy() {
+ this.delegate.destroy();
+ this.filter.destroy();
+ this.config = null;
+ }
+
+ public ServletConfig getServletConfig() {
+ return this.config;
+ }
+
+ public String getServletInfo() {
+ return "";
+ }
+
+ class FilterConfigImpl implements FilterConfig {
+ FilterConfigImpl() {
+ }
+
+ public String getFilterName() {
+ String filterName = FilterServletAdaptor.this.filterInitParameters.getProperty("filter-name");
+ if (filterName == null) {
+ filterName = FilterServletAdaptor.this.filter.getClass().getName();
+ }
+
+ return filterName;
+ }
+
+ public String getInitParameter(String name) {
+ return FilterServletAdaptor.this.filterInitParameters.getProperty(name);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return FilterServletAdaptor.this.filterInitParameters.propertyNames();
+ }
+
+ public ServletContext getServletContext() {
+ return FilterServletAdaptor.this.config.getServletContext();
+ }
+ }
+
+ public class FilterChainImpl implements FilterChain {
+ public FilterChainImpl() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+ FilterServletAdaptor.this.delegate.service(request, response);
+ }
+ }
+}
+
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/JspServlet.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/JspServlet.java
index f8376f97b28..bb3fd058571 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/JspServlet.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/JspServlet.java
@@ -195,6 +195,7 @@ public void destroy() {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException,
IOException {
+
String pathInfo = request.getPathInfo();
if (pathInfo != null && pathInfo.startsWith("/WEB-INF/")) { //$NON-NLS-1$
response.sendError(HttpServletResponse.SC_NOT_FOUND);
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/SecuredComponentEntryHttpContext.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/SecuredComponentEntryHttpContext.java
index ca5b2af9f20..c441980904a 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/SecuredComponentEntryHttpContext.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/SecuredComponentEntryHttpContext.java
@@ -20,7 +20,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.equinox.http.helper.BundleEntryHttpContext;
import org.osgi.framework.Bundle;
import org.wso2.carbon.registry.core.Registry;
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/TilesJspServlet.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/TilesJspServlet.java
index 0b6773e6576..0b1b4708c08 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/TilesJspServlet.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/TilesJspServlet.java
@@ -19,6 +19,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.AttributeContext;
+import org.apache.tiles.request.reflect.ClassUtil;
+import org.apache.tiles.web.util.AttributeContextMutator;
+import org.apache.tiles.web.util.TilesDispatchServlet;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.wso2.carbon.ui.action.ActionHelper;
@@ -35,16 +39,42 @@ public class TilesJspServlet extends JspServlet {
private static final long serialVersionUID = 1L;
private static Log log = LogFactory.getLog(TilesJspServlet.class);
+ public static final String CONTAINER_KEY_INIT_PARAMETER =
+ "org.apache.tiles.web.util.TilesDispatchServlet.CONTAINER_KEY";
+
+ private String containerKey;
+ private AttributeContextMutator mutator;
+
public TilesJspServlet(Bundle bundle, UIResourceRegistry uiResourceRegistry) {
super(bundle, uiResourceRegistry);
}
+ //TODO check if this is needed
+ @Override
+ public void init() throws ServletException {
+ super.init();
+
+ containerKey = getServletConfig().getInitParameter(CONTAINER_KEY_INIT_PARAMETER);
+
+ String temp = getInitParameter("mutator");
+ if (temp != null) {
+ try {
+ mutator = (AttributeContextMutator) ClassUtil.instantiate(temp);
+ } catch (Exception e) {
+ throw new ServletException("Unable to instantiate specified context mutator.", e);
+ }
+ } else {
+ mutator = new DefaultMutator();
+ }
+ }
+
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
+
String actionUrl = request.getRequestURI();
//This is the layout page defined in
- //"/org.wso2.carbon.component/src/main/resources/web/WEB-INF/tiles/main_defs.xml"
+ //"/org.wso2.carbon.component/src/main/resources/web/WEB-INF/tiles/tiles.xml"
//Need to serve http requests other than to tiles body page,
//using the normal OSGi way
@@ -73,10 +103,10 @@ public void service(HttpServletRequest request, HttpServletResponse response)
}
}
-
if ((actionUrl.lastIndexOf("/admin/layout/template.jsp") > -1)
|| actionUrl.lastIndexOf("ajaxprocessor.jsp") > -1
- || actionUrl.indexOf("gadgets/js") > -1) {
+ || actionUrl.indexOf("gadgets/js") > -1
+ || "INCLUDE".equals(request.getDispatcherType().toString())) {
super.service(request, response);
} else if (actionUrl.startsWith("/carbon/registry/web/resources/foo/bar")) {
//TODO : consider the renamed ROOT war scenario
@@ -104,4 +134,67 @@ public void service(HttpServletRequest request, HttpServletResponse response)
}
}
}
+
+ class DefaultMutator implements AttributeContextMutator {
+
+ /** {@inheritDoc} */
+ public void mutate(AttributeContext context, javax.servlet.ServletRequest request) {
+ // noop;
+ }
+ }
+
+ protected static final String canonicalURI(String s) {
+ if (s == null) {
+ return null;
+ } else {
+ StringBuilder result = new StringBuilder();
+ int len = s.length();
+ int pos = 0;
+
+ while(pos < len) {
+ char c = s.charAt(pos);
+ if (isPathSeparator(c)) {
+ while(pos + 1 < len && isPathSeparator(s.charAt(pos + 1))) {
+ ++pos;
+ }
+
+ if (pos + 1 < len && s.charAt(pos + 1) == '.') {
+ if (pos + 2 >= len) {
+ break;
+ }
+
+ switch (s.charAt(pos + 2)) {
+ case '.':
+ if (pos + 3 < len && isPathSeparator(s.charAt(pos + 3))) {
+ pos += 3;
+
+ int separatorPos;
+ for(separatorPos = result.length() - 1; separatorPos >= 0 && !isPathSeparator(result.charAt(separatorPos)); --separatorPos) {
+ }
+
+ if (separatorPos >= 0) {
+ result.setLength(separatorPos);
+ }
+ continue;
+ }
+ break;
+ case '/':
+ case '\\':
+ pos += 2;
+ continue;
+ }
+ }
+ }
+
+ result.append(c);
+ ++pos;
+ }
+
+ return result.toString();
+ }
+ }
+
+ protected static final boolean isPathSeparator(char c) {
+ return c == '/' || c == '\\';
+ }
}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/UIResourceRegistry.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/UIResourceRegistry.java
index 232b908e894..d8a24759522 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/UIResourceRegistry.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/UIResourceRegistry.java
@@ -63,7 +63,7 @@ public void initialize(BundleContext bundleContext) {
}
public URL getUIResource(String path) {
- URL url = defaultUIResourceProvider.getUIResource(path);
+ URL url = defaultUIResourceProvider.getUIResource(canonicalURI(path));
if (url == null) {
for (UIResourceProvider resourceProvider : resourceProviderSet) {
url = resourceProvider.getUIResource(path);
@@ -104,4 +104,59 @@ public void serviceChanged(ServiceEvent serviceEvent) {
resourceProviderSet.remove(uiResourceProvider);
}
}
+
+ protected static final String canonicalURI(String s) {
+ if (s == null) {
+ return null;
+ } else {
+ StringBuilder result = new StringBuilder();
+ int len = s.length();
+ int pos = 0;
+
+ while(pos < len) {
+ char c = s.charAt(pos);
+ if (isPathSeparator(c)) {
+ while(pos + 1 < len && isPathSeparator(s.charAt(pos + 1))) {
+ ++pos;
+ }
+
+ if (pos + 1 < len && s.charAt(pos + 1) == '.') {
+ if (pos + 2 >= len) {
+ break;
+ }
+
+ switch (s.charAt(pos + 2)) {
+ case '.':
+ if (pos + 3 < len && isPathSeparator(s.charAt(pos + 3))) {
+ pos += 3;
+
+ int separatorPos;
+ for(separatorPos = result.length() - 1; separatorPos >= 0 && !isPathSeparator(result.charAt(separatorPos)); --separatorPos) {
+ }
+
+ if (separatorPos >= 0) {
+ result.setLength(separatorPos);
+ }
+ continue;
+ }
+ break;
+ case '/':
+ case '\\':
+ pos += 2;
+ continue;
+ }
+ }
+ }
+
+ result.append(c);
+ ++pos;
+ }
+
+ return result.toString();
+ }
+ }
+
+ protected static final boolean isPathSeparator(char c) {
+ return c == '/' || c == '\\';
+ }
}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/action/ActionHelper.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/action/ActionHelper.java
index 99d3455b230..79f355a948d 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/action/ActionHelper.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/action/ActionHelper.java
@@ -21,7 +21,12 @@
import org.apache.tiles.AttributeContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.servlet.ServletRequest;
+import org.apache.tiles.request.servlet.ServletUtil;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -40,21 +45,25 @@ public class ActionHelper {
*/
public static void render(String actionUrl, HttpServletRequest request,
HttpServletResponse response) throws Exception {
- TilesContainer container = TilesAccess.getContainer(
- request.getSession().getServletContext());
- if(log.isDebugEnabled()){
- log.debug("Rendering tiles main.layout with page : "+actionUrl+"("+request.getSession().getId()+")");
+
+ ServletContext servletContext = request.getSession().getServletContext();
+ ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
+ TilesContainer container = TilesAccess.getContainer(applicationContext);
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Rendering tiles main.layout with page : " + actionUrl + "(" + request.getSession().getId() + ")");
}
- AttributeContext attributeContext = container.startContext(request, response);
+ Request requestContext = new ServletRequest(container.getApplicationContext(), request, response);
+ AttributeContext attributeContext = container.startContext(requestContext);
Attribute attr = new Attribute(actionUrl);
attributeContext.putAttribute("body", attr);
try {
- container.render("main.layout", request, response);
- container.endContext(request, response);
+ container.render("main.layout", requestContext);
+ container.endContext(requestContext);
} catch (Exception e) {
if (log.isDebugEnabled()) { // Intentionally logged at debug level
log.debug("Error occurred while rendering." +
- " We generally see this 'harmless' exception on WebLogic. Hiding it.", e);
+ " We generally see this 'harmless' exception on WebLogic. Hiding it.", e);
}
}
}
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/deployment/UIBundleDeployer.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/deployment/UIBundleDeployer.java
index 0394aada225..4675d974825 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/deployment/UIBundleDeployer.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/deployment/UIBundleDeployer.java
@@ -17,8 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.equinox.http.helper.ContextPathServletAdaptor;
-import org.eclipse.equinox.http.helper.FilterServletAdaptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
@@ -30,11 +28,14 @@
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.osgi.util.tracker.ServiceTracker;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.CarbonException;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.ui.BundleBasedUIResourceProvider;
+import org.wso2.carbon.ui.ContextPathServletAdaptor;
+import org.wso2.carbon.ui.FilterServletAdaptor;
import org.wso2.carbon.ui.deployment.beans.CarbonUIDefinitions;
import org.wso2.carbon.ui.deployment.beans.Component;
import org.wso2.carbon.ui.deployment.beans.CustomUIDefenitions;
@@ -44,9 +45,6 @@
import org.wso2.carbon.ui.transports.fileupload.FileUploadExecutorManager;
import org.wso2.carbon.ui.util.UIResourceProvider;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
@@ -55,6 +53,10 @@
import java.util.Iterator;
import java.util.List;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
public class UIBundleDeployer implements SynchronousBundleListener {
private static Log log = LogFactory.getLog(UIBundleDeployer.class);
@@ -425,6 +427,18 @@ public void registerServlet(Servlet servlet, String urlPattern, Dictionary param
httpService.registerServlet(urlPattern,
new FilterServletAdaptor(associatedFilter, null, adaptedJspServlet), params, httpContext);
}
+// Dictionary properties = new Hashtable<>();
+// properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, urlPattern);
+// for (Enumeration enm = params.keys(); enm.hasMoreElements();) {
+// String key = (String) enm.nextElement();
+// properties.put("servlet.init." + key, params.get(key));
+// }
+// CarbonUIServiceComponent.getBundleContext().registerService(Servlet.class, servlet, properties);
+// if (associatedFilter != null) {
+// Dictionary props = new Hashtable<>();
+// props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, urlPattern);
+// CarbonUIServiceComponent.getBundleContext().registerService(Filter.class, associatedFilter, props);
+// }
if (servletAttrs != null) {
for (Enumeration enm = servletAttrs.keys(); enm.hasMoreElements();) {
String key = (String) enm.nextElement();
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/internal/CarbonUIServiceComponent.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/internal/CarbonUIServiceComponent.java
index 1b657fc3d14..23d26441786 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/internal/CarbonUIServiceComponent.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/internal/CarbonUIServiceComponent.java
@@ -25,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.InstanceManager;
-import org.eclipse.equinox.http.helper.ContextPathServletAdaptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -38,6 +37,8 @@
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
+import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.url.URLConstants;
import org.osgi.service.url.URLStreamHandlerService;
@@ -52,6 +53,7 @@
import org.wso2.carbon.ui.CarbonSecuredHttpContext;
import org.wso2.carbon.ui.CarbonUIAuthenticator;
import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.ui.ContextPathServletAdaptor;
import org.wso2.carbon.ui.DefaultCarbonAuthenticator;
import org.wso2.carbon.ui.TextJavascriptHandler;
import org.wso2.carbon.ui.TilesJspServlet;
@@ -68,13 +70,6 @@
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.ConfigurationContextService;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.ContentHandler;
@@ -90,6 +85,14 @@
import java.util.Map;
import java.util.StringTokenizer;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
import static org.wso2.carbon.CarbonConstants.PRODUCT_XML;
import static org.wso2.carbon.CarbonConstants.PRODUCT_XML_PROPERTIES;
import static org.wso2.carbon.CarbonConstants.PRODUCT_XML_PROPERTY;
@@ -108,8 +111,7 @@ public class CarbonUIServiceComponent {
private static ServerConfigurationService serverConfiguration;
private static RealmService realmService;
private static CarbonTomcatService carbonTomcatService;
- private static List authenticationExtenders =
- new LinkedList();
+ private static List authenticationExtenders = new LinkedList<>();
private BundleContext bundleContext;
@@ -230,15 +232,6 @@ public void start(BundleContext context) throws Exception {
final HttpService httpService = getHttpService();
- Dictionary initparams = new Hashtable();
- initparams.put("servlet-name", "TilesServlet");
- initparams.put("definitions-config", "/WEB-INF/tiles/main_defs.xml");
- initparams.put("org.apache.tiles.context.TilesContextFactory",
- "org.apache.tiles.context.enhanced.EnhancedContextFactory");
- initparams.put("org.apache.tiles.factory.TilesContainerFactory.MUTABLE", "true");
- initparams.put("org.apache.tiles.definition.DefinitionsFactory",
- "org.wso2.carbon.tiles.CarbonUrlDefinitionsFactory");
-
String webContext = "carbon"; // The subcontext for the Carbon Mgt Console
String serverURL = CarbonUIUtil.getServerURL(serverConfig);
@@ -262,6 +255,9 @@ public void start(BundleContext context) throws Exception {
//Registering filedownload servlet
Servlet fileDownloadServlet = new ContextPathServletAdaptor(new FileDownloadServlet(
context, getConfigurationContextService()), "/filedownload");
+// Dictionary fileDownloadServletProperties = new Hashtable<>();
+// fileDownloadServletProperties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/filedownload");
+// context.registerService(Servlet.class, fileDownloadServlet, fileDownloadServletProperties);
httpService.registerServlet("/filedownload", fileDownloadServlet, null, commonContext);
fileDownloadServlet.getServletConfig().getServletContext().setAttribute(
CarbonConstants.SERVER_URL, serverURL);
@@ -279,6 +275,9 @@ public void start(BundleContext context) throws Exception {
}
httpService.registerServlet("/fileupload", fileUploadServlet, null, commonContext);
+// Dictionary fileUploadServletProperties = new Hashtable<>();
+// fileUploadServletProperties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/fileupload");
+// context.registerService(Servlet.class, fileUploadServlet, fileUploadServletProperties);
fileUploadServlet.getServletConfig().getServletContext().setAttribute(
CarbonConstants.SERVER_URL, serverURL);
fileUploadServlet.getServletConfig().getServletContext().setAttribute(
@@ -287,30 +286,44 @@ public void start(BundleContext context) throws Exception {
uiBundleDeployer.deploy(bundleContext, commonContext);
context.addBundleListener(uiBundleDeployer);
- httpService.registerServlet("/", new org.apache.tiles.web.startup.TilesServlet(),
- initparams,
- commonContext);
- httpService.registerResources("/" + webContext, "/", commonContext);
-
- adaptedJspServlet = new ContextPathServletAdaptor(
- new TilesJspServlet(context.getBundle(), uiResourceRegistry), "/" + webContext);
+ Dictionary props = new Hashtable<>();
+ props.put("osgi.http.whiteboard.context.name", "tilesContext");
+ props.put("osgi.http.whiteboard.context.path", "/carbon");
- Dictionary carbonInitparams = new Hashtable();
- carbonInitparams.put("strictQuoteEscaping", "false");
- httpService.registerServlet("/" + webContext + "/*.jsp", adaptedJspServlet, carbonInitparams, commonContext);
-
- ServletContext jspServletContext =
- adaptedJspServlet.getServletConfig().getServletContext();
-
- jspServletContext.setAttribute(
- InstanceManager.class.getName(), getTomcatInstanceManager());
+ context.registerService(ServletContextHelper.class, (ServletContextHelper) commonContext, props);
+ HttpContext resourceContext =
+ new CarbonSecuredHttpContext(context.getBundle(), "/web", uiResourceRegistry, registry);
+ Dictionary resourceProps = new Hashtable<>();
+ resourceProps.put("osgi.http.whiteboard.context.name", "resourceContext");
+ resourceProps.put("osgi.http.whiteboard.context.path", "/carbon");
+ resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/" + webContext + "/*");
+ context.registerService(ServletContextHelper.class, (ServletContextHelper) resourceContext, resourceProps);
+ Dictionary properties = new Hashtable<>();
+ properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/*");
+ properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/");
+ properties.put("osgi.http.whiteboard.context.select", "(osgi.http.whiteboard.context.name=resourceContext)");
+ properties.put("osgi.http.whiteboard.context.httpservice", true);
+
+ // Replacement for httpService.registerResources with whiteboard
+ bundleContext.registerService(String.class, "resource", properties);
+
+ adaptedJspServlet = new TilesJspServlet(context.getBundle(), uiResourceRegistry);
+
+ Dictionary carbonInitparams = new Hashtable<>();
+ carbonInitparams.put("servlet.init.strictQuoteEscaping", "false");
+ carbonInitparams.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/*.jsp");
+ carbonInitparams.put("osgi.http.whiteboard.context.select", "(osgi.http.whiteboard.context.name=tilesContext)");
+ context.registerService(Servlet.class, adaptedJspServlet, carbonInitparams);
+
+ ServletContext jspServletContext = adaptedJspServlet.getServletConfig().getServletContext();
+
+ jspServletContext.setAttribute(InstanceManager.class.getName(), getTomcatInstanceManager());
jspServletContext.setAttribute("registry", registryService);
-
jspServletContext.setAttribute(CarbonConstants.SERVER_CONFIGURATION, serverConfig);
jspServletContext.setAttribute(CarbonConstants.CLIENT_CONFIGURATION_CONTEXT, clientConfigContext);
//If the UI is running on local transport mode, then we use the server-side config context.
- if(isLocalTransportMode) {
+ if (isLocalTransportMode) {
jspServletContext.setAttribute(CarbonConstants.CONFIGURATION_CONTEXT, serverConfigContext);
} else {
jspServletContext.setAttribute(CarbonConstants.CONFIGURATION_CONTEXT, clientConfigContext);
@@ -328,6 +341,7 @@ public void start(BundleContext context) throws Exception {
.setAttribute(CustomUIDefenitions.CUSTOM_UI_DEFENITIONS, customUIDefenitions);
// Registering jspServletContext as a service so that UI components can use it
+ // TODO why do we need to register this again?
bundleContext.registerService(ServletContext.class.getName(), jspServletContext, null);
//saving bundle context for future reference within CarbonUI Generation
diff --git a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/util/UIResourceProvider.java b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/util/UIResourceProvider.java
index fafb0815672..55f1be6075b 100644
--- a/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/util/UIResourceProvider.java
+++ b/core/org.wso2.carbon.ui/src/main/java/org/wso2/carbon/ui/util/UIResourceProvider.java
@@ -45,11 +45,11 @@ public interface UIResourceProvider {
* /WEB_INF
* /WEB-INF/web.xml
* /WEB-INF/tiles
- * /WEB-INF/tiles/main_defs.xml
+ * /WEB-INF/tiles/tiles.xml
*
* getResourcePaths("/") returns {"/welcome.html", "/WEB_INF"}.
* getResourcePaths("/WEB_INF/") returns {"/WEB-INF/web.xml", "/WEB-INF/tiles/"}.
- * getResourcePaths("/WEB-INF/tiles/") returns {"/WEB-INF/tiles/main_defs.xml"}.
+ * getResourcePaths("/WEB-INF/tiles/") returns {"/WEB-INF/tiles/tiles.xml"}.
*
* @param path partial path used to match the resources, which must start with a /
* @return a Set containing the directory listing, or null if there are no resources whose path begins with the
diff --git a/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tiles/main_defs.xml b/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tiles.xml
similarity index 100%
rename from core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tiles/main_defs.xml
rename to core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tiles.xml
diff --git a/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tlds/tiles-jsp.tld b/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tlds/tiles-jsp.tld
index 5250bb20799..effdb62e203 100644
--- a/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tlds/tiles-jsp.tld
+++ b/core/org.wso2.carbon.ui/src/main/resources/web/WEB-INF/tlds/tiles-jsp.tld
@@ -1,801 +1,921 @@
-
-
-
- 2.0
- 1.2
- tiles
- http://tiles.apache.org/tags-tiles
+
+
+
- This tag library provides Tiles tags.
+
+ 1.2
+ tiles
+ http://tiles.apache.org/tags-tiles
- insertTemplate
- org.apache.tiles.jsp.taglib.InsertTemplateTag
- JSP
- Insert a template.
-
Insert a template with the possibility to pass
- parameters (called attributes).
- A template can be seen as a procedure that can take parameters or attributes.
- <tiles:insertTemplate> allows to define these attributes
- and pass them to the inserted jsp page, called template.
- Attributes are defined using nested tag <tiles:put> or
- <tiles:putList>.
+
+ Insert a template.
+
+
+ Insert a template with the possibility to pass parameters (called
+ attributes). A template can be seen as a procedure that can take parameters
+ or attributes. <tiles:insertTemplate> allows to define
+ these attributes and pass them to the inserted jsp page, called template.
+ Attributes are defined using nested tag
+ <tiles:putAttribute> or
+ <tiles:putListAttribute>.
+
+
+ You must specify template attribute, for inserting a template
+
+ insertTemplate
+ org.apache.tiles.jsp.taglib.InsertTemplateTag
+ scriptless
+
+
+ templatetruetrue
+ java.lang.String
+
+
- A string representing the URI of a template (for example, a JSP
- page).
-
+
+ templateType
+ false
+ true
+ java.lang.String
- flush
- false
- false
- boolean
- True or false. If true, current page out stream is flushed
- before insertion.
+
-
-
- ignore
+ templateExpressionfalsetrue
- boolean
+ java.lang.String
+
+
- If this attribute is set to true, and the attribute specified by the
- name does not exist, simply return without writing anything. The
- default value is false, which will cause a runtime exception to be
- thrown.
+
-
- rolefalsetrue
+ java.lang.String
+
+
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
+
+ preparer
+ false
+ true
+ java.lang.String
-
- preparer
+
+ true, the response will be flushed after the insert.
+ ]]>
+
+ flushfalsetrue
-
- The fully qualified class name of the preparer.
-
+ boolean
- insertDefinition
- org.apache.tiles.jsp.taglib.InsertDefinitionTag
- JSP
- Insert a definition.
-
Insert a definition with the possibility to override and specify
- parameters (called attributes).
- A definition can be seen as a (partially or totally) filled template that
- can override or complete attribute values.
- <tiles:insertDefinition> allows to define these attributes
- and pass them to the inserted jsp page, called template.
- Attributes are defined using nested tag <tiles:put> or
- <tiles:putList>.
+
+ Insert a definition.
+
+
+ Insert a definition with the possibility to override and specify parameters
+ (called attributes). A definition can be seen as a (partially or totally)
+ filled template that can override or complete attribute values.
+ <tiles:insertDefinition> allows to define these attributes
+ and pass them to the inserted jsp page, called template. Attributes are
+ defined using nested tag <tiles:putAttribute> or
+ <tiles:putListAttribute>.
+
+
+ You must specify name tag attribute, for inserting a definition
+ from definitions factory.
+
+
+ Example :
-
You must specify name tag attribute, for inserting a definition from
- definitions factory.
]]>
+ insertDefinition
+ org.apache.tiles.jsp.taglib.InsertDefinitionTag
+ scriptless
+
+
+ nametruetrue
+ java.lang.String
+
+
- Name of the definition to insert.
+
+ template
+ false
+ true
+ java.lang.String
- flush
- false
- false
- boolean
- True or false. If true, current page out stream is flushed
- before insertion.
+
-
-
- ignore
+ templateTypefalsetrue
- boolean
+ java.lang.String
+
+
- If this attribute is set to true, and the attribute specified by the
- name does not exist, simply return without writing anything. The
- default value is false, which will cause a runtime exception to be
- thrown.
+
+ templateExpression
+ false
+ true
+ java.lang.String
+
+
+ rolefalsetrue
+ java.lang.String
+
+
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
+
+ preparer
+ false
+ true
+ java.lang.String
-
- preparer
+
+ true, the response will be flushed after the insert.
+ ]]>
+
+ flushfalsetrue
-
- The fully qualified class name of preparer.
-
+ boolean
- insertAttribute
- org.apache.tiles.jsp.taglib.InsertAttributeTag
- JSP
- Inserts the value of an attribute into the page.
-
This tag can be flexibly used to insert the value of an attribute into a page.
- As in other usages in Tiles, every attribute can be determined to have a "type",
- either set explicitly when it was defined, or "computed". If the type is not explicit, then
- if the attribute value is a valid definition, it will be inserted as such. Otherwise,
- if it begins with a "/" character, it will be treated as a "template". Finally, if it
- has not otherwise been assigned a type, it will be treated as a String and included without
- any special handling.
-
-
Example :
-
-
-
-
-
+
+ Declare a list that will be pass as an attribute.
+
+
+ Declare a list that will be pass as an attribute . List elements are added
+ using the tag 'addAttribute' or 'addListAttribute'. This tag can only be used
+ inside 'insertTemplate', 'insertDefinition' or 'definition' tag.
+
]]>
+ addListAttribute
+ org.apache.tiles.jsp.taglib.AddListAttributeTag
+ scriptless
- name
- false
- true
- Name of the attribute to insert. This attribute will be ignored if
- the value attribute is specified.
+
+ role
+ false
+ true
+ java.lang.String
+
+
+
+
+ Import attribute(s) in specified context.
+
+
+ Import attribute(s) to requested scope. Attribute name and scope are
+ optional. If not specified, all attributes are imported in page scope. Once
+ imported, an attribute can be used as any other beans from jsp contexts.
+
+ ]]>
+
+ importAttribute
+ org.apache.tiles.jsp.taglib.ImportAttributeTag
+ empty
- value
+
+ null, all the attributes will be imported.
+ ]]>
+
+ namefalsetrue
- java.lang.Object
+ java.lang.String
+
+
- Attribute object to render directly. If it specified, the name
- attribute will be ignored.
+ null, the import will go in page scope.
]]>
+ scope
+ false
+ true
+ java.lang.String
- flush
- false
- false
- boolean
- True or false. If true, current page out stream is flushed
- before insertion.
+ name. If
+ null, the value of name will be used.
]]>
+ toName
+ false
+ true
+ java.lang.String
+
+ true, if the attribute is not present, the
+ problem will be ignored.
+ ]]>
+ ignorefalsetrueboolean
-
+
+
+
+
If this attribute is set to true, and the attribute specified by the
- name does not exist, simply return without writing anything. The
- default value is false, which will cause a runtime exception to be
- thrown.
+
+ Declare a list that will be pass as attribute to tile.
+
+
+ Declare a list that will be pass as attribute to tile. List elements are
+ added using the tags 'addAttribute' or 'addListAttribute'. This tag can only
+ be used inside 'insertTemplate', 'insertDefinition', 'definition' tags.
+
+ ]]>
+
+ putListAttribute
+ org.apache.tiles.jsp.taglib.PutListAttributeTag
+ scriptless
+
+
+
+ name
+ true
+ true
+ java.lang.String
+
+
+ rolefalsetrue
+ java.lang.String
+
+
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
+ true, the list attribute will use, as first elements, the
+ list contained in the list attribute, put with the same name, of the containing definition.
]]>
+ inherit
+ false
+ true
+ boolean
- preparer
+
+ true the attribute will be cascaded to all nested attributes.
+ ]]>
+
+ cascadefalsetrue
-
- The fully qualified name of the preparer.
-
+ boolean
- definition
- org.apache.tiles.jsp.taglib.definition.DefinitionTag
- JSPCreate a definition at runtime.
-
-
Create a new definition at runtime.
- Newly created definition will be available across the entire request.
-
]]>
-
+
+ Create a definition at runtime.
+
+
+ Create a new definition at runtime. Newly created definition will be
+ available across the entire request.
+
+ ]]>
+
+ definition
+ org.apache.tiles.jsp.taglib.DefinitionTag
+ scriptless
- name
- true
- true
- Specifies the name under which the newly created definition bean
- will be saved.
+
+ name
+ false
+ true
+ java.lang.String
+
+
+ templatefalsetrue
+ java.lang.String
+
+
- A string representing the URI of a template
- (a JSP page).
+
-
- rolefalsetrue
+ java.lang.String
+
+
- Role to check before inserting this definition. If role is not
- defined for current user, definition is not inserted. Checking is
- done at insert time, not during definition process.
+
-
- extendsfalsetrue
+ java.lang.String
+
+
- Name of a parent definition that is used to initialize this new
- definition. Parent definition is searched in definitions factory.
+
-
- preparerfalsetrue
-
- Specifies the preparer name to use. The specified preparer will
- be executed before rendering this newly created definition.
- ]]>
-
+ java.lang.String
- putAttribute
- org.apache.tiles.jsp.taglib.PutAttributeTag
- JSP
- Put an attribute in enclosing attribute container tag.
-
- Enclosing attribute container tag can be :
-
-
<initContainer>
-
<definition>
-
<insertAttribute>
-
<insertDefinition>
-
<putListAttribute>
-
- (or any other tag which implements the {@link PutAttributeTagParent} interface.
- Exception is thrown if no appropriate tag can be found.
-
Put tag can have following atributes :
-
-
name : Name of the attribute
-
value : value to put as attribute
-
type : value type. Only valid if value is a String and is set by
- value="something" or by a bean.
- Possible type are : string (value is used as direct string),
- template (value is used as a page url to insert),
- definition (value is used as a definition name to insert)
-
direct : Specify if value is to be used as a direct string or as a
- page url to insert. This is another way to specify the type. It only apply
- if value is set as a string, and type is not present.
-
beanName : Name of a bean used for setting value. Only valid if value is not set.
- If property is specified, value come from bean's property. Otherwise, bean
- itself is used for value.
-
beanProperty : Name of the property used for retrieving value.
-
beanScope : Scope containing bean.
-
role : Role to check when 'insert' will be called. If enclosing tag is
- <insert>, role is checked immediately. If enclosing tag is
- <definition>, role will be checked when this definition will be
- inserted.
-
-
Value can also come from tag body. Tag body is taken into account only if
- value is not set by one of the tag attributes. In this case Attribute type is
- "string", unless tag body define another type.
+
+ setCurrentContainer
+ org.apache.tiles.jsp.taglib.SetCurrentContainerTag
+ empty
- name
- true
- true
- Name of the attribute.
+ null, the default one will be used.
]]>
-
-
- value
+ containerKeyfalsetrue
- java.lang.Object
-
+ java.lang.String
+
+
+
+
Attribute value. Could be a String or an Object.
- Value can come from a direct assignment (value="aValue") or from a bean.
- One of 'value' 'content' or 'beanName' must be present.
+
+ Inserts the value of an attribute into the page.
+
+
+ This tag can be flexibly used to insert the value of an attribute into a
+ page. As in other usages in Tiles, every attribute can be determined to have
+ a "type", either set explicitly when it was defined, or "computed". If the
+ type is not explicit, then if the attribute value is a valid definition, it
+ will be inserted as such. Otherwise, if it begins with a "/" character, it
+ will be treated as a "template". Finally, if it has not otherwise been
+ assigned a type, it will be treated as a String and included without any
+ special handling.
+
+ ]]>
+
+ insertAttribute
+ org.apache.tiles.jsp.taglib.InsertAttributeTag
+ scriptless
+
+
+ true, if an exception happens during
+ rendering, of if the attribute is null, the problem will be ignored.
]]>
+ ignore
+ false
+ true
+ boolean
- type
- false
- false
- Specify content type: string, template or definition.
-
-
String : Content is printed directly.
-
template : Content is included from specified URL. Value is used as an URL.
-
definition : Value is the name of a definition defined in factory (xml file). Definition will be searched
- in the inserted tile, in a <tiles:insert attribute="attributeName"> tag, where 'attributeName'
- is the name used for this tag.
-
+
+ preparer
+ false
+ true
+ java.lang.String
+
+
+ rolefalsetrue
+ java.lang.String
+
+
-
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
-
+
+ defaultValue
+ false
+ true
+ java.lang.Object
-
-
- putListAttribute
- org.apache.tiles.jsp.taglib.PutListAttributeTag
- JSP
-
- Declare a list that will be pass as attribute to tile.
-
-
Declare a list that will be pass as attribute to tile.
- List elements are added using the tag 'add'.
- This tag can only be used inside 'insert' or 'definition' tag.
- ]]>
-
- name
- true
- true
- Name of the list.
+
-
-
-
- addAttribute
-
- org.apache.tiles.jsp.taglib.AddAttributeTag
- JSP
-
- Add an element to the surrounding list.
- Equivalent to 'put', but for list element.
-
-
Add an element to the surrounding list.
- This tag can only be used inside putList tag.
- Value can come from a direct assignment (value="aValue") or from a bean.
- One of 'value' or 'beanName' must be present.
- ]]>
-
-
- value
+ defaultValueRolefalsetrue
- java.lang.Object
+ java.lang.String
+
+
- Attribute value. Can be a String or Object.
+
-
+
+ defaultValueType
+ false
+ true
+ java.lang.String
- type
- false
- false
- Specify content type: string, template or definition.
-
-
String : Content is printed directly.
-
template : Content is included from specified URL. Value is used as an URL.
-
definition : Value denote a definition defined in factory (xml file). Definition will be searched
- in the inserted tile, in a <insert attribute="attributeName"> tag, where 'attributeName'
- is the name used for this tag.
-
+
+ name
+ false
+ true
+ java.lang.String
- role
+
+
+
+ valuefalsetrue
+ org.apache.tiles.Attribute
+
+
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
-
The role isn't taken into account if <add>
- tag is used in a definition.
+ true, the response will be flushed after the insert.
]]>
+ flush
+ false
+ true
+ boolean
- addListAttribute
- org.apache.tiles.jsp.taglib.AddListAttributeTag
- JSP
-
- Declare a list that will be pass as attribute to tile.
-
-
Declare a list that will be pass as attribute to tile.
- List elements are added using the tag 'add'.
- This tag can only be used inside 'insert' or 'definition' tag.
- ]]>
-
-
-
- getAsString
- org.apache.tiles.jsp.taglib.GetAsStringTag
- empty
-
- Render the value of the specified template attribute to the current JspWriter
-
-
-
Retrieve the value of the specified template attribute
- property, and render it to the current JspWriter as a String.
- The usual toString() conversions is applied on found value.
-
Throw a JSPException if named value is not found.
+
+ Add an element to the surrounding list. Equivalent to 'putAttribute',
+ but for list element.
+
+
+
+ Add an element to the surrounding list. This tag can only be used inside
+ 'putListAttribute' or 'addListAttribute' tags. Value can come from a direct
+ assignment (value="aValue")
+
]]>
+ addAttribute
+ org.apache.tiles.jsp.taglib.AddAttributeTag
+ scriptless
- name
- true
- true
- Attribute name.
+
-
-
- ignore
+ valuefalsetrue
- boolean
+ java.lang.Object
+
+
-
- If this attribute is set to true, and the attribute specified by the name
- does not exist, simply return without writing anything. The default value is false, which will
- cause a runtime exception to be thrown.
-
+
+ expression
+ false
+ true
+ java.lang.String
+
+
+ rolefalsetrue
+ java.lang.String
+
+
-
- If the user is in the specified role, the tag is taken into account;
- otherwise, the tag is ignored (skipped).
-
+
+ type
+ false
+ true
+ java.lang.String
- useAttribute
- org.apache.tiles.jsp.taglib.UseAttributeTag
- org.apache.tiles.jsp.taglib.UseAttributeTag$Tei
- empty
- Use attribute value inside page.
-
Declare a Java variable, and an attribute in the specified scope,
- using tile attribute value.
-
Java variable and attribute will have the name specified by 'id',
- or the original name if not specified.
+
+ Put an attribute in enclosing attribute container tag.
+
+
+ Enclosing attribute container tag can be :
+
+
<initContainer>
+
<definition>
+
<insertAttribute>
+
<insertDefinition>
+
<putListAttribute>
+
+ (or any other tag which implements the PutAttributeTagParent
+ interface. Exception is thrown if no appropriate tag can be found.
+
+
+ Put tag can have following atributes :
+
+
name : Name of the attribute
+
value : value to put as attribute
+
type : value type. Possible type are : string (value is used as direct
+ string), template (value is used as a page url to insert), definition (value
+ is used as a definition name to insert), object (value is used as it is)
+
role : Role to check when 'insertAttribute' will be called.
+
+
+
+ Value can also come from tag body. Tag body is taken into account only if
+ value is not set by one of the tag attributes. In this case Attribute type is
+ "string", unless tag body define another type.
+
]]>
+ putAttribute
+ org.apache.tiles.jsp.taglib.PutAttributeTag
+ scriptless
- id
- false
- true
- Declared attribute and variable name.
+
+ name
+ true
+ true
+ java.lang.String
- classname
- false
- true
- Class of the declared variable.
+
+ value
+ false
+ true
+ java.lang.Object
- scope
- false
- false
- Scope of the declared attribute. Default to 'page'.
+
+ expression
+ false
+ true
+ java.lang.String
- name
- true
- true
- Tile's attribute name.
+
+ role
+ false
+ true
+ java.lang.String
- ignore
+
+
+
+ typefalsetrue
- boolean
+ java.lang.String
+
+
-
- If this attribute is set to true, and the attribute specified by the name
- does not exist, simply return without error. The default value is false, which will
- cause a runtime exception to be thrown.
-
+ true the attribute will be cascaded to all nested attributes.
]]>
+ cascade
+ false
+ true
+ boolean
- importAttribute
- org.apache.tiles.jsp.taglib.ImportAttributeTag
- empty
- Import Tile's attribute in specified context.
-
Import attribute from tile to requested scope.
- Attribute name and scope are optional. If not specified, all tile
- attributes are imported in page scope.
- Once imported, an attribute can be used as any other beans from jsp
- contexts.
+
+ Render the value of the specified template attribute to the current
+ Writer
+
+
+
+ Retrieve the value of the specified template attribute property, and render
+ it to the current Writer as a String. The usual toString() conversions is
+ applied on found value.
+
]]>
+ getAsString
+ org.apache.tiles.jsp.taglib.GetAsStringTag
+ scriptless
- name
+
+ true, if an exception happens during
+ rendering, of if the attribute is null, the problem will be ignored.
+ ]]>
+
+ ignorefalsetrue
+ boolean
+
+
- Tile's attribute name. If not specified, all attributes are
- imported.
+
+ preparer
+ false
+ true
+ java.lang.String
- toName
+
+
+
+ rolefalsetrue
+ java.lang.String
+
+
- Name of the destination attribute. If not specified, the name will
- be the same as specified in name attribute
+
+ defaultValue
+ false
+ true
+ java.lang.Object
- scope
- false
- false
- Scope into which attribute is imported. Default to page.
+
+ defaultValueRole
+ false
+ true
+ java.lang.String
- ignore
+
+
+
+ defaultValueTypefalsetrue
- boolean
+ java.lang.String
+
+
- If this attribute is set to true, and the attribute specified by
- the name does not exist, simply return without error. The default
- value is false, which will cause a runtime exception to be thrown.
+
+ name
+ true
+ true
+ java.lang.String
-
-
- initContainer
- org.apache.tiles.jsp.taglib.definition.InitContainerTag
- JSP
-
- Initialize the TilesContainer.
-
- In order to use the Tiles system, a TilesContainer must be instantiated.
- This initialization is generally done by the TilesListener (or perhaps the
- TilesServlet or TilesFilter).
-
-
- If the intialization needs to be dynamic, you can initialize the container using
- this tag. Realize however, that this tag MUST be executed prior to invoking
- any other definitions. Additionally, the initilization may only be done once,
- and any subsequent invocations will be ignored.
-