JBoss Portal SVN: r13519 - jbossexo/branches.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2009-07-06 11:57:02 -0400 (Mon, 06 Jul 2009)
New Revision: 13519
Removed:
jbossexo/branches/modules/
Log:
Oops, added to wrong directory location.
14 years, 11 months
JBoss Portal SVN: r13518 - jbossexo/branches/modules/portlet.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2009-07-06 11:32:54 -0400 (Mon, 06 Jul 2009)
New Revision: 13518
Added:
jbossexo/branches/modules/portlet/trunk/
Log:
Create branch for the portlet module integration (revision 13515)
Copied: jbossexo/branches/modules/portlet/trunk (from rev 13515, modules/portlet/trunk)
14 years, 11 months
JBoss Portal SVN: r13517 - jbossexo/branches/modules/web.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2009-07-06 11:29:19 -0400 (Mon, 06 Jul 2009)
New Revision: 13517
Added:
jbossexo/branches/modules/web/trunk/
Log:
Create branch for the web module integration (revision 13515)
Copied: jbossexo/branches/modules/web/trunk (from rev 13515, modules/web/trunk)
14 years, 11 months
JBoss Portal SVN: r13499 - in modules/authorization/trunk: agent/src/main/java/org/jboss/security/authz/agent/services and 13 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-07-05 07:12:20 -0400 (Sun, 05 Jul 2009)
New Revision: 13499
Added:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/EnforcementStateGenerator.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementContext.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementPoint.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/SecurityContextDataProcessor.java
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEnforcementGenerator.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/SecurityContextData.java
Removed:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
Modified:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java
modules/authorization/trunk/agent/src/main/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
modules/authorization/trunk/http-profile/pom.xml
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
modules/authorization/trunk/pom.xml
Log:
client side enforcement context generation
Added: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java (rev 0)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,106 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.SecurityContextData;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+class AnnotationProcessor
+{
+ static Object[] extractSecurityContextData(Object component) throws Exception
+ {
+ Object[] securityContextData = null;
+
+ List<Object> cour = new ArrayList<Object>();
+ Class targetClass = component.getClass();
+ do
+ {
+ Object[] local = extractSecurityContextData(component, targetClass);
+ if(local != null && local.length>0)
+ {
+ for(Object data: local)
+ {
+ cour.add(data);
+ }
+ }
+ targetClass = targetClass.getSuperclass();
+ }while(targetClass != null);
+
+ if(!cour.isEmpty())
+ {
+ securityContextData = cour.toArray();
+ }
+
+ return securityContextData;
+ }
+
+ static ComponentCategory findComponentCategory(Class targetClass)
+ {
+ Annotation component = targetClass.getAnnotation(Component.class);
+ if(component != null)
+ {
+ return ((Component)component).category();
+ }
+
+ return null;
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private static Object[] extractSecurityContextData(Object component, Class targetClass) throws Exception
+ {
+ Object[] securityContextData = null;
+
+ List<Object> cour = new ArrayList<Object>();
+ Field[] declaredFields = targetClass.getDeclaredFields();
+ if(declaredFields != null)
+ {
+ for(Field declaredField: declaredFields)
+ {
+ Annotation local = declaredField.getAnnotation(SecurityContextData.class);
+ if(local != null)
+ {
+ declaredField.setAccessible(true);
+ Object data = declaredField.get(component);
+ if(data != null)
+ {
+ cour.add(data);
+ }
+ }
+ }
+ }
+
+ if(!cour.isEmpty())
+ {
+ return cour.toArray();
+ }
+
+ return securityContextData;
+ }
+}
Added: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/EnforcementStateGenerator.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/EnforcementStateGenerator.java (rev 0)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/EnforcementStateGenerator.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,214 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.model.AbstractContextObject;
+import org.jboss.security.authz.model.Resource;
+import org.jboss.security.authz.model.Subject;
+import org.jboss.security.authz.model.Action;
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.components.subject.Identity;
+import org.jboss.security.authz.components.subject.Roles;
+
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+class EnforcementStateGenerator
+{
+ private static Logger log = Logger.getLogger(EnforcementStateGenerator.class);
+
+ AbstractContextObject[] generate(Object component)
+ {
+ try
+ {
+ AbstractContextObject[] enforcementState = null;
+
+ List<AbstractContextObject> cour = new ArrayList<AbstractContextObject>();
+
+ ComponentCategory componentCategory = AnnotationProcessor.findComponentCategory(component.getClass());
+
+ //Extract SecurityContextData for the component
+ Object[] securityContextData = AnnotationProcessor.extractSecurityContextData(component);
+
+ for(Object input: securityContextData)
+ {
+ if(Collection.class.isAssignableFrom(input.getClass()) || input.getClass().isArray())
+ {
+ if(input.getClass().isArray())
+ {
+ List<Object> local = new ArrayList<Object>();
+ int arrayLength = Array.getLength(input);
+ for(int i=0; i<arrayLength; i++)
+ {
+ local.add(Array.get(input, i));
+ }
+ input = SecurityContextDataProcessor.processEnforcementState(local);
+ }
+ else
+ {
+ input = SecurityContextDataProcessor.processEnforcementState((Collection)input);
+ }
+ }
+ else if(Map.class.isAssignableFrom(input.getClass()))
+ {
+ input = SecurityContextDataProcessor.processEnforcementState((Map)input);
+ }
+ else
+ {
+ input = input.toString();
+ }
+
+ //Create the appropriate Context Object
+ if(componentCategory.getAttributeCategory().equals(XACMLConstants.ATTRIBUTEID_RESOURCE_ID))
+ {
+ if(input instanceof String)
+ {
+ cour.add(this.generateURIBasedResource((String)input));
+ }
+ else if(input instanceof Map)
+ {
+ cour.add(this.generateCustomResource((Map<String, String>)input));
+ }
+ }
+ else if(componentCategory.getAttributeCategory().equals(XACMLConstants.ATTRIBUTEID_ACTION_ID))
+ {
+ cour.add(generateAction((String)input));
+ }
+ else if(componentCategory.getAttributeCategory().equals(XACMLConstants.ATTRIBUTEID_SUBJECT_ID))
+ {
+ //Note: Identity and Roles components are exposed to this component since these are part of the core set components shipped
+ //with the Framework
+ if(component instanceof Identity)
+ {
+ cour.add(generateIdentity(input.toString()));
+ }
+ else if(component instanceof Roles)
+ {
+ cour.add(this.generateRoles((Set<String>)input));
+ }
+ }
+ }
+
+ enforcementState = cour.toArray(new AbstractContextObject[0]);
+
+ return enforcementState;
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+
+ //TODO: implement proper exception handling
+ throw new RuntimeException(e);
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private Resource generateURIBasedResource(String uri)
+ {
+ Resource uriResource = new Resource();
+
+ Attribute attribute = new Attribute();
+ attribute.setUri(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
+ attribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
+ attribute.setValue(uri);
+ uriResource.addAttribute(attribute);
+
+ return uriResource;
+ }
+
+ private Resource generateCustomResource(Map<String, String> parameters)
+ {
+ Resource custom = new Resource();
+
+ Set<String> names = parameters.keySet();
+ for(String name: names)
+ {
+ String value = parameters.get(name);
+
+ Attribute customAttribute = new Attribute();
+ customAttribute.setUri(name);
+ customAttribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
+ customAttribute.setValue(value);
+ custom.addAttribute(customAttribute);
+ }
+
+ return custom;
+ }
+
+ private Action generateAction(String actionName)
+ {
+ Action action = new Action();
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
+ XMLSchemaConstants.DATATYPE_STRING,
+ actionName
+ );
+ action.addAttribute(attribute);
+
+ return action;
+ }
+
+ private Subject generateIdentity(String subjectName)
+ {
+ Subject subject = new Subject();
+
+ subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
+
+ Attribute attribute = new Attribute(
+ XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
+ XMLSchemaConstants.DATATYPE_STRING, subjectName);
+ subject.addAttribute(attribute);
+
+ return subject;
+ }
+
+ private Subject generateRoles(Set<String> roleNames)
+ {
+ Subject subject = new Subject();
+
+ subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
+
+ for(String name: roleNames)
+ {
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
+ XMLSchemaConstants.DATATYPE_STRING,
+ name
+ );
+ subject.addAttribute(attribute);
+ }
+
+ return subject;
+ }
+}
Added: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementContext.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementContext.java (rev 0)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementContext.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,59 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PolicyEnforcementContext implements Serializable
+{
+ private Map<String, Object> attributes;
+
+ public PolicyEnforcementContext()
+ {
+ this.attributes = new HashMap<String, Object>();
+ }
+
+ public Object getAttribute(String name)
+ {
+ return this.attributes.get(name);
+ }
+
+ public void setAttribute(String name, Object attribute)
+ {
+ this.attributes.put(name, attribute);
+ }
+
+ public void clear(String name)
+ {
+ this.attributes.remove(name);
+ }
+
+ public void clearAll()
+ {
+ this.attributes.clear();
+ }
+}
Added: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementPoint.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementPoint.java (rev 0)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/PolicyEnforcementPoint.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,33 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PolicyEnforcementPoint
+{
+ public void checkAccess(PolicyEnforcementContext enforcementContext)
+ {
+
+ }
+}
Added: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/SecurityContextDataProcessor.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/SecurityContextDataProcessor.java (rev 0)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/SecurityContextDataProcessor.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,65 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+class SecurityContextDataProcessor
+{
+ static Set<String> processEnforcementState(Collection input)
+ {
+ Set<String> enforcementState = new HashSet<String>();
+
+ if(input != null)
+ {
+ for(Object local: input)
+ {
+ enforcementState.add(local.toString());
+ }
+ }
+
+ return enforcementState;
+ }
+
+ static Map<String, String> processEnforcementState(Map input)
+ {
+ Map<String, String> enforcementState = new HashMap<String, String>();
+
+ if(input != null)
+ {
+ Set<Object> keys = input.keySet();
+ for(Object key: keys)
+ {
+ enforcementState.put(key.toString(), input.get(key).toString());
+ }
+ }
+
+ return enforcementState;
+ }
+}
Modified: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -31,7 +31,7 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentCategory;
import org.jboss.security.authz.component.ImpliedActions;
-import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.SecurityContextData;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.AttributeExpression;
@@ -126,7 +126,7 @@
Target target = new Target();
//Read the TargetUri
- Field targetField = this.findTargetField(this.targetComponent.getClass());
+ Field targetField = this.findSecurityContextDataField(this.targetComponent.getClass());
targetField.setAccessible(true);
Object targetUriObj = targetField.get(this.targetComponent);
@@ -196,14 +196,14 @@
return null;
}
- private Field findTargetField(Class targetClass)
+ private Field findSecurityContextDataField(Class targetClass)
{
Field[] declaredFields = targetClass.getDeclaredFields();
if(declaredFields != null)
{
for(Field declaredField: declaredFields)
{
- Annotation targetUri = declaredField.getAnnotation(TargetUri.class);
+ Annotation targetUri = declaredField.getAnnotation(SecurityContextData.class);
if(targetUri != null)
{
return declaredField;
@@ -214,7 +214,7 @@
//If I get here, query the super class
if(targetClass.getSuperclass() != null)
{
- return this.findTargetField(targetClass.getSuperclass());
+ return this.findSecurityContextDataField(targetClass.getSuperclass());
}
return null;
Modified: modules/authorization/trunk/agent/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- modules/authorization/trunk/agent/src/main/resources/META-INF/jboss-beans.xml 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/agent/src/main/resources/META-INF/jboss-beans.xml 2009-07-05 11:12:20 UTC (rev 13499)
@@ -4,5 +4,8 @@
xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
<bean name="/agent/PolicyComposer" class="org.jboss.security.authz.agent.services.PolicyComposer">
+ </bean>
+
+ <bean name="/agent/PolicyEnforcementPoint" class="org.jboss.security.authz.agent.services.PolicyEnforcementPoint">
</bean>
</deployment>
\ No newline at end of file
Added: modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEnforcementGenerator.java
===================================================================
--- modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEnforcementGenerator.java (rev 0)
+++ modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEnforcementGenerator.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,133 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.agent.services;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.model.Resource;
+import org.jboss.security.authz.model.Action;
+import org.jboss.security.authz.model.Subject;
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.model.AbstractContextObject;
+
+import org.jboss.security.authz.components.subject.Identity;
+import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.components.action.Manage;
+import org.jboss.security.authz.components.resource.URIResource;
+
+import org.jboss.security.authz.agent.Agent;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestEnforcementGenerator extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestEnforcementGenerator.class);
+
+ private EnforcementStateGenerator stateGenerator;
+
+ protected void setUp() throws Exception
+ {
+ Agent.bootstrap();
+ this.stateGenerator = new EnforcementStateGenerator();
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void testGenerateURIResource() throws Exception
+ {
+ //Setup the state of Components to be used for Enforcement State
+ URIResource uriResource = new URIResource();
+ uriResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+
+ AbstractContextObject[] contextState = this.stateGenerator.generate(uriResource);
+ Resource enforcementState = (Resource)contextState[0];
+
+ this.assertResource(enforcementState);
+ }
+
+ public void testGenerateAction() throws Exception
+ {
+ AbstractContextObject[] contextState = this.stateGenerator.generate(new Manage());
+ Action enforcementState = (Action)contextState[0];
+
+ this.assertAction(enforcementState);
+ }
+
+ public void testGenerateIdentity() throws Exception
+ {
+ Identity identity = new Identity();
+ identity.setName("blah(a)blah.com");
+
+ AbstractContextObject[] contextState = this.stateGenerator.generate(identity);
+ Subject enforcementState = (Subject)contextState[0];
+
+ this.assertSubject(enforcementState);
+ }
+
+ public void testGenerateRoles() throws Exception
+ {
+ Roles roles = new Roles();
+ roles.addName("admin");
+ roles.addName("user");
+
+ AbstractContextObject[] contextState = this.stateGenerator.generate(roles);
+ Subject enforcementState = (Subject)contextState[0];
+
+ this.assertSubject(enforcementState);
+ }
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void assertResource(Resource resource)
+ {
+ log.info("---------------------------------------------------------------");
+ for(Attribute attribute: resource.getAttributes())
+ {
+ log.info("Name="+attribute.getUri());
+ log.info("Value="+attribute.getValue());
+ log.info("---------------------------------------------------------------");
+ }
+ }
+
+ private void assertAction(Action action)
+ {
+ log.info("---------------------------------------------------------------");
+ for(Attribute attribute: action.getAttributes())
+ {
+ log.info("Name="+attribute.getUri());
+ log.info("Value="+attribute.getValue());
+ log.info("---------------------------------------------------------------");
+ }
+ }
+
+ private void assertSubject(Subject subject)
+ {
+ log.info("---------------------------------------------------------------");
+ for(Attribute attribute: subject.getAttributes())
+ {
+ log.info("Name="+attribute.getUri());
+ log.info("Value="+attribute.getValue());
+ log.info("---------------------------------------------------------------");
+ }
+ }
+}
Deleted: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -1,37 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.security.authz.component;
-
-import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-(a)Target(ElementType.FIELD)
-(a)Retention(RetentionPolicy.RUNTIME)
-public @interface LogicData
-{
-
-}
Added: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/SecurityContextData.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/SecurityContextData.java (rev 0)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/SecurityContextData.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface SecurityContextData
+{
+
+}
Deleted: modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
===================================================================
--- modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -1,37 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.security.authz.component;
-
-import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-(a)Target(ElementType.FIELD)
-(a)Retention(RetentionPolicy.RUNTIME)
-public @interface TargetUri
-{
-
-}
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -21,7 +21,7 @@
*/
package org.jboss.security.authz.components.action;
-import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.SecurityContextData;
/**
* Represents any Operation that can be performed on a Resource
@@ -30,7 +30,7 @@
*/
public abstract class Operation
{
- @TargetUri
+ @SecurityContextData
protected String name;
public Operation()
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -28,7 +28,7 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentType;
import org.jboss.security.authz.component.ComponentCategory;
-import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.SecurityContextData;
/**
* Represents any System Resource uniquely identified by a URI
@@ -47,7 +47,7 @@
/**
* The unique URI that identifies this resource
*/
- @TargetUri
+ @SecurityContextData
protected URI uri;
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -25,8 +25,7 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentType;
import org.jboss.security.authz.component.ComponentCategory;
-import org.jboss.security.authz.component.TargetUri;
-import org.jboss.security.authz.component.LogicData;
+import org.jboss.security.authz.component.SecurityContextData;
/**
* The Identity Policy Component represents the "Identity/User" that is Authenticated by the System
@@ -47,8 +46,7 @@
/**
* Unique id/name of the Identity
*/
- @TargetUri
- @LogicData
+ @SecurityContextData
private String name;
Modified: modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
===================================================================
--- modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -31,7 +31,7 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentType;
import org.jboss.security.authz.component.ComponentCategory;
-import org.jboss.security.authz.component.LogicData;
+import org.jboss.security.authz.component.SecurityContextData;
import org.jboss.security.authz.component.LogicExpression;
/**
@@ -84,7 +84,7 @@
/**
* Role Names
*/
- @LogicData
+ @SecurityContextData
private Set<String> names;
public Roles()
@@ -114,6 +114,11 @@
}
this.getNames().add(name);
}
+
+ public boolean isEmpty()
+ {
+ return this.getNames().isEmpty();
+ }
//------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
* Creates a Policy Rule suggesting the roles indicated by this object are permitted access to the 'Resource' designated in the Policy
Modified: modules/authorization/trunk/http-profile/pom.xml
===================================================================
--- modules/authorization/trunk/http-profile/pom.xml 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/pom.xml 2009-07-05 11:12:20 UTC (rev 13499)
@@ -23,6 +23,11 @@
<groupId>org.jboss.security.authz</groupId>
<artifactId>core-components-api</artifactId>
<version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>agent</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.security.authz</groupId>
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -28,7 +28,7 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentCategory;
import org.jboss.security.authz.component.ComponentType;
-import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.SecurityContextData;
import org.jboss.security.authz.components.resource.URIResource;
/**
@@ -45,12 +45,12 @@
type=ComponentType.TARGET,
category=ComponentCategory.RESOURCE
)
-public class HttpResource extends URIResource implements Cloneable
+public class HttpResource extends URIResource
{
/**
* The HTTP Parameters that are used to access this resource
*/
- @TargetUri
+ @SecurityContextData
private Map<String, String> parameters;
/**
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -38,11 +38,14 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import org.jboss.security.authz.model.Effect;
import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.authz.policy.server.plugin.XACMLPolicy;
import org.jboss.security.authz.policy.server.spi.PolicyConfig;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.http.component.action.Delete;
import org.jboss.security.authz.http.component.action.Get;
import org.jboss.security.authz.http.component.action.Head;
@@ -50,7 +53,10 @@
import org.jboss.security.authz.http.component.action.Post;
import org.jboss.security.authz.http.component.action.Put;
import org.jboss.security.authz.http.component.action.Trace;
-import org.jboss.security.authz.http.component.resource.HttpResource;
+import org.jboss.security.authz.components.action.Operation;
+import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.agent.services.CompositionContext;
+import org.jboss.security.authz.agent.services.PolicyComposer;
/**
@@ -61,6 +67,19 @@
{
private static Logger log = Logger.getLogger(HttpPolicyConfig.class);
+ private PolicyComposer policyComposer;
+
+
+ public PolicyComposer getPolicyComposer()
+ {
+ return policyComposer;
+ }
+
+ public void setPolicyComposer(PolicyComposer policyComposer)
+ {
+ this.policyComposer = policyComposer;
+ }
+
/**
* Configures the Policy instances that can be represented in system level XACML format. The easyDomainXml is a user friendly XML configuration that is within the context
* of the application tier being protected. For instance, to apply Access Control at the web tier, the XML configuration would consist of Resources and
@@ -83,21 +102,87 @@
NodeList securityConstraints = document.getElementsByTagName("security-constraint");
for(int i=0, length=securityConstraints.getLength(); i< length; i++)
- {
+ {
Element securityConstraint = (Element)securityConstraints.item(i);
- Element webResourceCollection = (Element)securityConstraint.getElementsByTagName("web-resource-collection").item(0);
- List<HttpResource> webResources = this.parseWebResources(webResourceCollection);
-
- if(webResources != null)
- {
- for(HttpResource policyResource: webResources)
- {
- //Parse role constraints
- this.parseRoles(policyResource, securityConstraint.getElementsByTagName("roles"));
-
- cour.add(new XACMLPolicy(GeneralTool.generateUniqueId(), policyResource.getPolicyMetaData()));
- }
- }
+
+ //Parse out information related to access control based on user roles
+ NodeList roleNodes = securityConstraint.getElementsByTagName("roles");
+ Roles allowRoles = new Roles();
+ Roles denyRoles = new Roles();
+ if(roleNodes != null)
+ {
+ for(int j=0; j<roleNodes.getLength(); j++)
+ {
+ boolean allow = true;
+ Element roles = (Element)roleNodes.item(j);
+
+ allow = Boolean.parseBoolean(roles.getAttribute("allow").trim());
+
+ NodeList roleNames = roles.getElementsByTagName("role-name");
+ if(roleNames != null)
+ {
+ for(int k=0; k<roleNames.getLength(); k++)
+ {
+ Element roleName = (Element)roleNames.item(k);
+ String role = roleName.getTextContent().trim();
+
+ if(allow)
+ {
+ allowRoles.addName(role);
+ }
+ else
+ {
+ denyRoles.addName(role);
+ }
+ }
+ }
+ }
+ }
+
+ //Parse out the resources and actions upon which the Policies must be created
+ Element webResourceCollection = (Element)securityConstraint.getElementsByTagName("web-resource-collection").item(0);
+ NodeList resources = webResourceCollection.getElementsByTagName("web-resource");
+ if (resources != null)
+ {
+ for (int j = 0; j < resources.getLength(); j++)
+ {
+ //SetUp the Http Resource
+ HttpResource policyResource = new HttpResource();
+ Element webResource = (Element) resources.item(j);
+ Element urlPattern = (Element) webResource
+ .getElementsByTagName("url-pattern").item(0);
+
+ policyResource.setUri(new URI(urlPattern
+ .getTextContent().trim()));
+ this.parseParameters(policyResource, webResource);
+
+ //Setup the Action Targets to be secured on this resource
+ List<Operation> secureActions = this.parseSecureWebActions(webResource);
+
+ if(secureActions != null)
+ {
+ //SetUp Policy Composition Context
+ CompositionContext context = new CompositionContext();
+ context.setPolicyTarget(policyResource);
+ for(Operation secureAction: secureActions)
+ {
+ if(!allowRoles.isEmpty())
+ {
+ context.addPolicyRule(Effect.PERMIT, secureAction, allowRoles, "allowExpression");
+ }
+
+ if(!denyRoles.isEmpty())
+ {
+ context.addPolicyRule(Effect.DENY, secureAction, denyRoles, "denyExpression");
+ }
+ }
+
+ //Generate the Policy
+ PolicyMetaData policyMetaData = this.policyComposer.compose(context);
+ cour.add(new XACMLPolicy(GeneralTool.generateUniqueId(), policyMetaData));
+ }
+ }
+ }
}
policies = cour.toArray(new Policy[0]);
@@ -120,41 +205,33 @@
}catch(IOException ioe){log.warn(this, ioe);}
}
}
- //XMLParsing----------------------------------------------------------------------------------------------------------------------------------------------------
- private List<HttpResource> parseWebResources(Element webResourceCollection) throws Exception
+ //XML Configuration Parsing----------------------------------------------------------------------------------------------------------------------------------------------------
+ private void parseParameters(HttpResource policyResource, Element webResource) throws Exception
{
- List<HttpResource> webResources = new ArrayList<HttpResource>();
-
- NodeList resources = webResourceCollection.getElementsByTagName("web-resource");
- if(resources != null)
- {
- for(int i=0; i<resources.getLength(); i++)
- {
- HttpResource policyResource = new HttpResource();
- Element webResource = (Element)resources.item(i);
- Element urlPattern = (Element)webResource.getElementsByTagName("url-pattern").item(0);
-
- policyResource.setUri(new URI(urlPattern.getTextContent().trim()));
- this.parseParameters(policyResource, webResource);
-
- List<HttpResource> methodResources = this.parseHttpMethods(policyResource, webResource);
- if(methodResources != null && !methodResources.isEmpty())
- {
- webResources.addAll(methodResources);
- }
- else
- {
- webResources.add(policyResource);
- }
- }
- }
-
- return webResources;
+ //Process Parameters
+ Element parameters = (Element)webResource.getElementsByTagName("parameters").item(0);
+ if(parameters != null)
+ {
+ NodeList params = parameters.getElementsByTagName("parameter");
+ if(params != null)
+ {
+ for(int i=0, length=params.getLength(); i<length; i++)
+ {
+ Element parameter = (Element)params.item(i);
+
+ String name = parameter.getAttribute("name").trim();
+ String value = parameter.getTextContent().trim();
+
+ policyResource.addParameter(name, value);
+ }
+ }
+ }
}
- private List<HttpResource> parseHttpMethods(HttpResource policyResource, Element webResource) throws Exception
+ private List<Operation> parseSecureWebActions(Element webResource) throws Exception
{
- List<HttpResource> webResources = new ArrayList<HttpResource>();
+ List<Operation> secureWebActions = new ArrayList<Operation>();
+
NodeList httpMethods = webResource.getElementsByTagName("http-method");
if(httpMethods != null)
{
@@ -162,95 +239,39 @@
{
Element httpMethodElem = (Element)httpMethods.item(i);
- String httpMethod = httpMethodElem.getTextContent();
- HttpResource methodResource = (HttpResource)policyResource.clone();
+ String httpMethod = httpMethodElem.getTextContent();
if(httpMethod.equalsIgnoreCase("get"))
{
- methodResource.setHttpMethod(new Get());
+ secureWebActions.add(new Get());
}
else if(httpMethod.equalsIgnoreCase("post"))
{
- methodResource.setHttpMethod(new Post());
+ secureWebActions.add(new Post());
}
else if(httpMethod.equalsIgnoreCase("put"))
{
- methodResource.setHttpMethod(new Put());
+ secureWebActions.add(new Put());
}
else if(httpMethod.equalsIgnoreCase("delete"))
{
- methodResource.setHttpMethod(new Delete());
+ secureWebActions.add(new Delete());
}
else if(httpMethod.equalsIgnoreCase("head"))
{
- methodResource.setHttpMethod(new Head());
+ secureWebActions.add(new Head());
}
else if(httpMethod.equalsIgnoreCase("options"))
{
- methodResource.setHttpMethod(new Options());
+ secureWebActions.add(new Options());
}
else if(httpMethod.equalsIgnoreCase("trace"))
{
- methodResource.setHttpMethod(new Trace());
- }
-
- webResources.add(methodResource);
+ secureWebActions.add(new Trace());
+ }
}
}
- return webResources;
- }
-
- private void parseParameters(HttpResource policyResource, Element webResource) throws Exception
- {
- //Process Parameters
- Element parameters = (Element)webResource.getElementsByTagName("parameters").item(0);
- if(parameters != null)
- {
- NodeList params = parameters.getElementsByTagName("parameter");
- if(params != null)
- {
- for(int i=0, length=params.getLength(); i<length; i++)
- {
- Element parameter = (Element)params.item(i);
-
- String name = parameter.getAttribute("name").trim();
- String value = parameter.getTextContent().trim();
-
- policyResource.addParameter(name, value);
- }
- }
- }
- }
-
- private void parseRoles(HttpResource policyResource, NodeList roleNodes) throws Exception
- {
- if(roleNodes != null)
- {
- for(int i=0; i<roleNodes.getLength(); i++)
- {
- boolean allow = true;
- Element roles = (Element)roleNodes.item(i);
-
- allow = Boolean.parseBoolean(roles.getAttribute("allow").trim());
-
- NodeList roleNames = roles.getElementsByTagName("role-name");
- if(roleNames != null)
- {
- for(int j=0; j<roleNames.getLength(); j++)
- {
- Element roleName = (Element)roleNames.item(j);
-
- if(allow)
- {
- policyResource.addAllowed(roleName.getTextContent().trim());
- }
- else
- {
- policyResource.addDenied(roleName.getTextContent().trim());
- }
- }
- }
- }
- }
- }
+
+ return secureWebActions;
+ }
}
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -205,7 +205,9 @@
String value = httpRequest.getParameter(name);
contextResource.addParameter(name, value);
}
-
+
+ //TODO: migrate to the new developer framework
+ /*
//Setup Resource context
authzRequest.addResource(contextResource.getResource());
@@ -243,7 +245,7 @@
//TODO: replace mock code with actual loading of Roles information of the authenticated user via the new Identity API
Roles roles = new Roles();
roles.addName(Roles.ANONYMOUS);
- authzRequest.addSubject(roles.getSubject());
+ authzRequest.addSubject(roles.getSubject());*/
return authzRequest;
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -29,7 +29,6 @@
import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.test.MockPolicy;
/**
@@ -39,7 +38,8 @@
{
private static Logger log = Logger.getLogger(TestHttpResource.class);
- public void testGetURLTargetNoParameters() throws Exception
+ //TODO: migrate to the new developer framework
+ /*public void testGetURLTargetNoParameters() throws Exception
{
HttpResource httpResource = new HttpResource();
httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
@@ -107,5 +107,5 @@
log.info("------------------------------------------------------------------");
log.info(policy.generateSystemPolicy());
- }
+ }*/
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -55,7 +55,8 @@
this.provisioner = (PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
}
- public void testMatchContextSuperset() throws Exception
+ //TODO: migrate to the new developer framework
+ /*public void testMatchContextSuperset() throws Exception
{
//SetUp HttpResource component to generate/store a policy
HttpResource policyResource = new HttpResource();
@@ -178,5 +179,5 @@
request.setAction(new Read().getAction());
return request;
- }
+ }*/
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -54,7 +54,8 @@
this.provisioner = (PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
}
- public void test() throws Exception
+ //TODO: migrate to the new developer framework
+ /*public void test() throws Exception
{
HttpResource policyResource = new HttpResource();
policyResource.setUri(new URI("/private/devspace/*"));
@@ -149,5 +150,5 @@
request.setAction(new Read().getAction());
return request;
- }
+ }*/
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -57,12 +57,13 @@
this.provisioner = (PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
}
- public void testRegex() throws Exception
+ //TODO: migrate to the new developer framework
+ /*public void testRegex() throws Exception
{
- /**
- * Rule = "/prefix/url/*" matches any URL starting with /prefix/url,
- * including prefix/url itself. It does not match /prefix/urlfoo because any slash must immediately follow url
- */
+ //
+ // Rule = "/prefix/url/*" matches any URL starting with /prefix/url,
+ // including prefix/url itself. It does not match /prefix/urlfoo because any slash must immediately follow url
+ //
String regex = "^/prefix/url$|^prefix/url$|^/prefix/url/.*|^prefix/url/.*";
//Should Match
@@ -150,5 +151,5 @@
request.setAction(new Read().getAction());
return request;
- }
+ }*/
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -62,7 +62,8 @@
{
}
- public void testNewPolicyEnforcement() throws Exception
+ //TODO: migrate to the new developer framework
+ /*public void testNewPolicyEnforcement() throws Exception
{
HttpResource httpResource = new HttpResource();
httpResource.setUri(new URI("/blah/index.html"));
@@ -126,5 +127,5 @@
request.setAction(new Read().getAction());
return request;
- }
+ }*/
}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-07-05 11:12:20 UTC (rev 13499)
@@ -29,6 +29,8 @@
import org.apache.log4j.Logger;
+import org.jboss.security.authz.agent.Agent;
+import org.jboss.security.authz.agent.services.PolicyComposer;
import org.jboss.security.authz.components.subject.Roles;
import org.jboss.security.authz.http.component.action.Get;
import org.jboss.security.authz.http.component.action.Post;
@@ -56,6 +58,7 @@
private PolicyEnforcementPoint enforcer;
private PolicyProvisioner provisioner;
+ private PolicyComposer policyComposer;
/**
*
@@ -63,13 +66,19 @@
protected void setUp() throws Exception
{
Server.bootstrap();
+ Agent.bootstrap();
+
this.enforcer = (PolicyEnforcementPoint)Server.lookup("/enforcement/localEnforcementPoint");
this.provisioner = (PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
+ this.policyComposer = (PolicyComposer)Agent.lookup("/agent/PolicyComposer");
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
+ //TODO: migrate to the new developer framework
public void testExecutiveFiles() throws Exception
{
PolicyConfig config = new HttpPolicyConfig();
+ ((HttpPolicyConfig)config).setPolicyComposer(this.policyComposer);
+
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("http-policy.xml");
Policy[] policies = config.configure(GeneralTool.readStream(is));
@@ -79,7 +88,7 @@
for(int i=0; i<policies.length; i++)
{
String xacmlPolicy = policies[i].generateSystemPolicy();
- this.provisioner.newPolicy(policies[i].getMetaData());
+ //this.provisioner.newPolicy(policies[i].getMetaData());
log.info("------------------------------------------------------");
log.info(xacmlPolicy);
@@ -89,7 +98,7 @@
is.close();
//Perform an Enforcement
- HttpResource incoming = new HttpResource();
+ /*HttpResource incoming = new HttpResource();
incoming.setUri(new URI("/private/executives/index.html"));
incoming.addParameter("id", "1234");
@@ -105,7 +114,7 @@
this.enforce(this.createGetRequest(incoming, new String[]{"manager"}), false);
//Anonymous is Not Allowed
- this.enforce(this.createGetRequest(incoming, new String[]{"anonymous"}), false);
+ this.enforce(this.createGetRequest(incoming, new String[]{"anonymous"}), false);*/
}
/*public void testBoardFiles() throws Exception
@@ -186,7 +195,7 @@
//Anonymous is Not Allowed
this.enforce(this.createGetRequest(incoming, new String[]{"anonymous"}), false);
- }*/
+ }
//-------------------------------------------------------------------------------------------------------------------------------------------------
private void enforce(Request request, boolean mustBePermitted) throws Exception
{
@@ -249,5 +258,5 @@
request.setAction(new Post().getAction());
return request;
- }
+ }*/
}
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-06-24 23:28:48 UTC (rev 13498)
+++ modules/authorization/trunk/pom.xml 2009-07-05 11:12:20 UTC (rev 13499)
@@ -14,8 +14,8 @@
<module>core-components-api</module>
<module>agent</module>
<module>policy-server</module>
+ <module>http-profile</module>
<!--
- <module>http-profile</module>
<module>portal-profile</module>
-->
</modules>
14 years, 11 months
JBoss Portal SVN: r13515 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/state.
by portal-commits@lists.jboss.org
Author: mputz
Date: 2009-07-02 15:54:12 -0400 (Thu, 02 Jul 2009)
New Revision: 13515
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
Log:
JBPORTAL-2389: moved session.flush() as the previous fix did not cover all cases
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2009-07-02 19:49:26 UTC (rev 13514)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2009-07-02 19:54:12 UTC (rev 13515)
@@ -195,7 +195,6 @@
//
context.entries.clear();
- session.flush();
for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();)
{
String key = (String)i.next();
@@ -206,6 +205,8 @@
//
session.update(context);
+
+ session.flush();
}
public void destroyState(String stateId) throws InvalidStateIdException, NoSuchStateException
14 years, 11 months
JBoss Portal SVN: r13514 - branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-60_JBEPP-95/core/src/main/org/jboss/portal/core/impl/portlet/state.
by portal-commits@lists.jboss.org
Author: mputz
Date: 2009-07-02 15:49:26 -0400 (Thu, 02 Jul 2009)
New Revision: 13514
Modified:
branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-60_JBEPP-95/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
Log:
JBEPP-95: moved session.flush() as it did not cover all scenarios previously
Modified: branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-60_JBEPP-95/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-60_JBEPP-95/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2009-07-02 11:28:54 UTC (rev 13513)
+++ branches/Enterprise_Portal_Platform_4_3_GA_JBEPP-60_JBEPP-95/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentPortletStatePersistenceManager.java 2009-07-02 19:49:26 UTC (rev 13514)
@@ -195,8 +195,6 @@
//
context.entries.clear();
- // fix for JBPORTAL-2389
- session.flush();
for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();)
{
String key = (String)i.next();
@@ -207,6 +205,10 @@
//
session.update(context);
+
+ // fix for JBPORTAL-2389
+ session.flush();
+
}
public void destroyState(String stateId) throws InvalidStateIdException, NoSuchStateException
14 years, 11 months
JBoss Portal SVN: r13513 - in modules/wsrp/trunk: core/src/main/java/org/jboss/portal/wsrp/consumer and 8 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-07-02 07:28:54 -0400 (Thu, 02 Jul 2009)
New Revision: 13513
Removed:
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJBossService.java
modules/wsrp/trunk/core/src/main/resources/portal-wsrp-sar/
Modified:
modules/wsrp/trunk/core/pom.xml
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/CachingServiceFactory.java
modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/servlet/ServletAccessService.java
modules/wsrp/trunk/service/pom.xml
modules/wsrp/trunk/test-support/src/main/java/org/jboss/portal/wsrp/framework/TestWSRPProducerImpl.java
modules/wsrp/trunk/wsrp1-rpc/pom.xml
Log:
- JBPORTAL-2186: More WSRP extraction
+ Added dependency on newly created jems module for now as too many functionality had to be imported otherwise.
+ Added AOPC plugin for ConsumerRegistryService.
+ Renamed service artifacts and use proper dependent artifacts.
+ Added dependencies in lib directory.
+ Cleaned up.
Modified: modules/wsrp/trunk/core/pom.xml
===================================================================
--- modules/wsrp/trunk/core/pom.xml 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/pom.xml 2009-07-02 11:28:54 UTC (rev 13513)
@@ -70,6 +70,11 @@
<artifactId>portlet-federation</artifactId>
<version>${version.portlet}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>jems</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
<!-- JBoss dependencies -->
<dependency>
@@ -87,6 +92,18 @@
<artifactId>jboss-system</artifactId>
<version>${version.jbossas}</version>
</dependency>
+ <!-- For JBoss AOP -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <!-- Services & Hibernate dependencies -->
+ <dependency>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>jems</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
<!-- other dependencies -->
@@ -101,11 +118,6 @@
<version>${version.slf4j}</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>${version.slf4j}</version>
- </dependency>
- <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
@@ -130,6 +142,16 @@
<build>
<finalName>portal-wsrp</finalName>
<sourceDirectory>src/main</sourceDirectory>
+
+ <resources>
+ <resource>
+ <directory>src/resources</directory>
+ <excludes>
+ <exclude>src/resources/**</exclude>
+ </excludes>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@@ -152,13 +174,41 @@
<descriptors>
<descriptor>src/assemble/portal-wsrp-client-jar.xml</descriptor>
<descriptor>src/assemble/portal-wsrp-war.xml</descriptor>
- <descriptor>src/assemble/portal-wsrp-sar.xml</descriptor>
<!--<descriptor>src/assemble/portal-wsrp-tests-jar.xml</descriptor>-->
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jbossaop-plugin</artifactId>
+ <version>1.0.0.GA</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <configuration>
+ <!-- if you want to include dependencies from the current module
+ (only needed if a class inherits a class thats not defined in this module
+ -->
+ <includeProjectDependency>true</includeProjectDependency>
+ <aoppaths>
+ <aoppath>src/main/resources/portal-wsrp-sar/wsrp-aop.xml</aoppath>
+ <!-- for a second jboss-aop.xml file
+ <aoppath>src/main/resources/jboss-aop.xml</aoppath>
+ -->
+ </aoppaths>
+ <includes>
+ <include>org/jboss/portal/wsrp/consumer/ConsumerRegistryService.class</include>
+ </includes>
+ </configuration>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -27,13 +27,13 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.federation.FederatedPortletInvoker;
import org.jboss.portal.portlet.federation.FederatingPortletInvoker;
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.api.SessionEventBroadcaster;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
import javax.naming.InitialContext;
import java.util.ArrayList;
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.portlet.InvokerUnavailableException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
@@ -64,7 +65,6 @@
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
import org.jboss.portal.wsrp.services.ServiceFactory;
import org.jboss.portal.wsrp.servlet.UserAccess;
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.producer;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvoker;
@@ -78,7 +79,6 @@
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerConfigurationService;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -26,6 +26,7 @@
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.mx.util.ObjectNameFactory;
import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.registration.RegistrationPolicyChangeListener;
import org.jboss.portal.registration.RegistrationPropertyChangeListener;
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
@@ -34,7 +35,6 @@
import org.jboss.portal.wsrp.producer.config.ProducerConfigurationProvider;
import org.jboss.portal.wsrp.producer.config.ProducerConfigurationService;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
import org.jboss.xb.binding.JBossXBException;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.ObjectModelProvider;
Deleted: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJBossService.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJBossService.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJBossService.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -1,87 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2009, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.services;
-
-import org.jboss.logging.Logger;
-import org.jboss.system.ServiceMBeanSupport;
-
-/**
- * TODO: REMOVE Legacy JBoss service integration helper. Will need to be removed once first extraction stage is
- * complete.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 8784 $
- */
-public class AbstractJBossService extends ServiceMBeanSupport
-{
-
- public AbstractJBossService()
- {
- }
-
- public AbstractJBossService(final Class type)
- {
- super(type);
- }
-
- public AbstractJBossService(final String category)
- {
- super(category);
- }
-
- public AbstractJBossService(final Logger log)
- {
- super(log);
- }
-
- public final int getState()
- {
- return super.getState();
- }
-
- public final String getStateString()
- {
- return super.getStateString();
- }
-
- public final void create() throws Exception
- {
- super.create();
- }
-
- public final void start() throws Exception
- {
- super.start();
- }
-
- public final void stop()
- {
- super.stop();
- }
-
- public final void destroy()
- {
- super.destroy();
- }
-}
\ No newline at end of file
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/AbstractJNDIServiceFactory.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -20,9 +20,11 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
+
package org.jboss.portal.wsrp.services;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/CachingServiceFactory.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/services/CachingServiceFactory.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -23,6 +23,8 @@
package org.jboss.portal.wsrp.services;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
import java.rmi.Remote;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Modified: modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/servlet/ServletAccessService.java
===================================================================
--- modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/servlet/ServletAccessService.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/core/src/main/java/org/jboss/portal/wsrp/servlet/ServletAccessService.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -20,9 +20,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
+
package org.jboss.portal.wsrp.servlet;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.management.ObjectName;
import java.lang.reflect.Proxy;
Modified: modules/wsrp/trunk/service/pom.xml
===================================================================
--- modules/wsrp/trunk/service/pom.xml 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/service/pom.xml 2009-07-02 11:28:54 UTC (rev 13513)
@@ -34,16 +34,8 @@
<packaging>jboss-sar</packaging>
<name>JBoss Portal WSRP Service</name>
- <!--<dependencies>
- <dependency>
- <groupId>org.jboss.portal.jopr</groupId>
- <artifactId>portal-management</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
--->
-
<build>
+ <finalName>portal-wsrp</finalName>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -59,10 +51,65 @@
<artifactItems>
<artifactItem>
<groupId>org.jboss.portal.wsrp</groupId>
+ <artifactId>wsrp1-rpc</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.wsrp</groupId>
<artifactId>wsrp-core</artifactId>
<version>${project.version}</version>
</artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.wsrp</groupId>
+ <artifactId>wsrp-core</artifactId>
+ <classifier>client</classifier>
+ <version>${project.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.wsrp</groupId>
+ <artifactId>wsrp-core</artifactId>
+ <type>war</type>
+ <classifier>server</classifier>
+ <version>${project.version}</version>
+ </artifactItem>
</artifactItems>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-portal-runtime-libs</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>${version.slf4j}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.registration</groupId>
+ <artifactId>registration-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.registration</groupId>
+ <artifactId>registration-impl</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>jems</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </artifactItem>
+ </artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
</configuration>
</execution>
Modified: modules/wsrp/trunk/test-support/src/main/java/org/jboss/portal/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
--- modules/wsrp/trunk/test-support/src/main/java/org/jboss/portal/wsrp/framework/TestWSRPProducerImpl.java 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/test-support/src/main/java/org/jboss/portal/wsrp/framework/TestWSRPProducerImpl.java 2009-07-02 11:28:54 UTC (rev 13513)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.framework;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
@@ -67,7 +68,6 @@
import org.jboss.portal.wsrp.producer.WSRPValidator;
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
-import org.jboss.portal.wsrp.services.AbstractJBossService;
import java.rmi.RemoteException;
Modified: modules/wsrp/trunk/wsrp1-rpc/pom.xml
===================================================================
--- modules/wsrp/trunk/wsrp1-rpc/pom.xml 2009-07-02 08:42:40 UTC (rev 13512)
+++ modules/wsrp/trunk/wsrp1-rpc/pom.xml 2009-07-02 11:28:54 UTC (rev 13513)
@@ -43,6 +43,7 @@
</dependencies>
<build>
+ <finalName>wsrp1-rpc</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
14 years, 11 months
JBoss Portal SVN: r13511 - in modules: jems and 21 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-07-01 12:12:36 -0400 (Wed, 01 Jul 2009)
New Revision: 13511
Added:
modules/jems/
modules/jems/trunk/
modules/jems/trunk/build/
modules/jems/trunk/build/licences/
modules/jems/trunk/build/licences/JBossEULA.txt
modules/jems/trunk/build/misc/
modules/jems/trunk/build/misc/codeguide.html
modules/jems/trunk/build/pom.xml
modules/jems/trunk/jems/
modules/jems/trunk/jems/pom.xml
modules/jems/trunk/jems/src/
modules/jems/trunk/jems/src/main/
modules/jems/trunk/jems/src/main/java/
modules/jems/trunk/jems/src/main/java/org/
modules/jems/trunk/jems/src/main/java/org/jboss/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JMX.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDI.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDIBinder.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/AbstractJBossService.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JBossServiceModelMBean.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JMXConstants.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifeCycleAdapter.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifecycleInvoker.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjection.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjector.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvoker.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvokerMBean.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ByteArrayBlob.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/CacheableBlobUserType.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ContextObject.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/DialectFactory.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/HibernateProvider.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProvider.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProviderMBean.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/MagicString.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ObjectContextualizer.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/OracleStringUserType.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/QNameUserType.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/StringWrapperUserType.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/TreeCacheProvider.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/
modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/ClassicService.java
modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/POJOService.java
modules/jems/trunk/jems/src/main/resources/
modules/jems/trunk/jems/src/main/resources/pojo-service-sar/
modules/jems/trunk/jems/src/main/resources/pojo-service-sar/META-INF/
modules/jems/trunk/jems/src/main/resources/pojo-service-sar/META-INF/jboss-service.xml
modules/jems/trunk/pom.xml
Log:
First import of mavenized JEMS support module. Note that pojo-service.sar is not currently built.
Added: modules/jems/trunk/build/licences/JBossEULA.txt
===================================================================
--- modules/jems/trunk/build/licences/JBossEULA.txt (rev 0)
+++ modules/jems/trunk/build/licences/JBossEULA.txt 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,106 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software
+Packages, regardless of the delivery mechanism. Each Software Package is a collective work
+under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to
+the user ("Client") a license to the applicable collective work(s) pursuant to the
+GNU Lesser General Public License v. 2.1 except for the following Software Packages:
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the
+GNU General Public License v.2;
+
+(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database,
+it may purchase a license from Sleepycat Software);
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1,
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various
+royalty-free patent licenses.
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1. The Software. "Software Packages" refer to the various software modules that are created and made available
+for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages
+may be comprised of hundreds of software components. The end user license agreement for each component is located in
+the component's source code. With the exception of certain image files identified in Section 2 below,
+the license terms for the components permit Client to copy, modify, and redistribute the component,
+in both source code and binary code forms. This agreement does not limit Client's rights under,
+or grant Client rights that supersede, the license terms of any particular component.
+
+2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright
+and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall
+remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates
+in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified.
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.
+
+3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular
+component, to the maximum extent permitted under applicable law, the Software Packages and the
+components are provided and licensed "as is" without warranty of any kind, expressed or implied,
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements
+or that the operation of the Software Packages will be entirely error free or appear precisely as described
+in the accompanying documentation. This warranty extends only to the party that purchases the Services
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
+
+4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies
+described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or
+refund the money paid by Client for the Software. To the maximum extent permitted by applicable law,
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential
+damages, including lost profits or lost savings arising out of the use or inability to use the Software,
+even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this
+Agreement during the twelve months preceding the action.
+
+5. Export Control. As required by U.S. law, Client represents and warrants that it:
+(a) understands that the Software Packages are subject to export controls under the
+U.S. Commerce Department's Export Administration Regulations ("EAR");
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity,
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government;
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by
+regulation or specific license;
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and
+address (including country) of each transferee;
+
+and (f) understands that countries other than the United States may restrict the import, use, or
+export of encryption products and that it shall be solely responsible for compliance with any such
+import, use, or export restrictions.
+
+6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages
+that are not part of the Software Packages and which Client must install separately. These third party
+programs are subject to their own license terms. The license terms either accompany the programs or
+can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable
+license terms for such programs, then Client may not install them. If Client wishes to install the programs
+on more than one system or transfer the programs to another party, then Client must contact the licensor
+of the programs.
+
+7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the
+enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the
+State of North Carolina and of the United States, without regard to any conflict of laws provisions,
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc. All rights reserved.
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
+All other trademarks are the property of their respective owners.
+
+ Page 1 of 1 18 October 2006
Added: modules/jems/trunk/build/misc/codeguide.html
===================================================================
--- modules/jems/trunk/build/misc/codeguide.html (rev 0)
+++ modules/jems/trunk/build/misc/codeguide.html 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,133 @@
+<html>
+
+<head>
+<style type="text/css">
+pre { border-style:solid; border-width:thin; padding:5px; background-color:#EEEEFF;}
+span.bad { text-decoration:line-through; }
+span.important { font-weight:bold; color:red; }
+</style>
+</head>
+
+<body>
+
+<h2>Coding Conventions</h2>
+
+<h3>Some more general guidelines</h3>
+<ul>
+<li>Fully qualified imports should be used, rather than importing x.y.*.</li>
+<li>Use newlines for opening braces, so that the top and bottom braces can be visually matched.</li>
+<li>Aid visual separation of logical steps by introducing newlines and appropriate comments above them.</li>
+</ul>
+
+
+<h3>A class that conforms to JBoss coding guidelines</h3>
+
+<pre>
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package x;
+
+// <span class="important">Explicit imports</span>
+import a.b.C1; // <span class="important">good</span>
+import a.b.C2;
+import a.b.C3;
+
+// <span class="important">Do not write</span>
+<span class="bad">import a.b.*;</span> // <span class="important">bad</span>
+
+// <span class="important">DO NOT USE "TAB" TO INDENT CODE USE *3* SPACES FOR PORTABILITY AMONG EDITORS</span>
+
+/**
+ * A description of this class.
+ *
+ * @see SomeRelatedClass.
+ *
+ * @version <tt>$Revision: 7755 $</tt>
+ * @author <a href="mailto:{email}">{full name}</a>
+ */
+public class X
+ extends Y
+ implements Z
+{
+ public void startService() throws Exception
+ {
+ // Use the newline for the opening bracket so we can match top
+ // and bottom bracket visually
+
+ Class cls = Class.forName(dataSourceClass);
+ vendorSource = (XADataSource)cls.newInstance();
+
+ // Jump a line between logically distinct <span class="important">steps</span> and add<
+ // line of comment to it
+ cls = vendorSource.getClass();
+
+ // Comment lines <span class="important">always</span> start with an uppercase
+ // except if it is the second line
+ if(properties != null)
+ {
+
+ try
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ for (Iterator i = props.entrySet().iterator(); i.hasNext();)
+ {
+
+ // Get the name and value for the attributes
+ Map.Entry entry = (Map.Entry) i.next();
+ String attributeName = (String) entry.getKey();
+ String attributeValue = (String) entry.getValue();
+
+ // Print the debug message
+ log.debug("Setting attribute '" + attributeName + "' to '" + attributeValue + "'");
+
+ // get the attribute
+ Method setAttribute =
+ cls.getMethod("set" + attributeName, new Class[] { String.class });
+
+ // And set the value
+ setAttribute.invoke(vendorSource, new Object[] { attributeValue });
+ }
+ }
+
+ <span class="bad">// this is a <span class="important">bad</span> comment line because it starts with a lower case</span>
+ vendorSource.getXAConnection().close();
+
+ // Bind in JNDI
+ bind(new InitialContext(), "java:/"+getPoolName(),
+ new Reference(vendorSource.getClass().getName(),
+ getClass().getName(), null));
+
+ // Block must always be delimited explicitely
+ if (0 == 0)
+ <span class="important">{</span>
+ System.out.println(true);
+ <span class="important">}</span>
+
+ }
+}
+</pre>
+</body>
+</html>
Property changes on: modules/jems/trunk/build/misc/codeguide.html
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/build/pom.xml
===================================================================
--- modules/jems/trunk/build/pom.xml (rev 0)
+++ modules/jems/trunk/build/pom.xml 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!--
+ This pom functions as a default configuration. The subproject
+ poms each inherit configuration from this one.
+
+ When adding version information for an artifact please do the following
+ - add a version property for the specific version
+ - add a dependency in the dependencyManagement section which refers to
+ the property
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal</groupId>
+ <artifactId>jboss-portal-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>JBoss Portal JEMS Support Parent</name>
+ <description>JBoss Portal JEMS Support</description>
+
+
+ <!--JBoss reporitories to be able to grab jboss-portal-parent pom-->
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+
+ <!--Sample additional plugin repository. This one is not needed if you don't use maven-antrun-extended-plugin
+ (used in module-c)-->
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net maven repository</id>
+ <url>http://download.java.net/maven/2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+</project>
Added: modules/jems/trunk/jems/pom.xml
===================================================================
--- modules/jems/trunk/jems/pom.xml (rev 0)
+++ modules/jems/trunk/jems/pom.xml 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,111 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jems</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal JEMS Support</name>
+
+ <properties>
+ <version.jbossas>4.2.3.GA</version.jbossas>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ <version>1.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.15</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>3.3.1.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jbosscache</artifactId>
+ <version>3.3.1.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbossha</artifactId>
+ <version>${version.jbossas}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>1.4.1.SP3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.beanshell</groupId>
+ <artifactId>bsh</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JMX.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JMX.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JMX.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,215 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as;
+
+import org.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.mx.util.ObjectNameConverter;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import java.util.Comparator;
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 13310 $
+ */
+public final class JMX
+{
+
+ private static final Logger log = Logger.getLogger(JMX.class);
+
+ public static ObjectName extend(ObjectName name, Properties keyProperties)
+ {
+ try
+ {
+ Hashtable table = name.getKeyPropertyList();
+ table.putAll(keyProperties);
+ return ObjectNameConverter.convert(name.getDomain(), table);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ log.error("", e);
+ throw new RuntimeException();
+ }
+ }
+
+ /** ObjectName comparator based on canonical name lexicography. */
+ public static Comparator OBJECT_NAME_COMPARATOR = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ ObjectName n1 = (ObjectName)o1;
+ ObjectName n2 = (ObjectName)o2;
+ return n1.getCanonicalName().compareTo(n2.getCanonicalName());
+ }
+ };
+
+ public static void safeUnregister(MBeanServer server, ObjectName name)
+ {
+ if (server != null)
+ {
+ if (name != null)
+ {
+ try
+ {
+ server.unregisterMBean(name);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.error("MBean " + name + " nto here");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ log.error("MBean threw an exception during unregistration", e.getTargetException());
+ }
+ }
+ else
+ {
+ log.error("Cannot unregister a null MBean");
+ }
+ }
+ else
+ {
+ log.error("Cannot unregister with a null MBeanServer");
+ }
+ }
+
+ /**
+ * Retrieves the MBeanProxy associated with the given class and name from the specified MBeanServer.
+ *
+ * @param expectedClass the expected class of the MBean's proxy
+ * @param name the MBean's ObjectName
+ * @param server the MBeanServer from which to retrieve the MBeanProxy
+ * @return a MBeanProxy for the specified MBean if it exists
+ * @throws RuntimeException if the MBean couldn't be retrieved
+ */
+ public static <T> T getMBeanProxy(Class<T> expectedClass, ObjectName name, MBeanServer server)
+ {
+ try
+ {
+ return expectedClass.cast(MBeanProxy.get(expectedClass, name, server));
+ }
+ catch (Exception e)
+ {
+ String message = "Couldn't retrieve '" + name.getCanonicalName() + "' MBean with class " + expectedClass.getName();
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ /**
+ * Retrieves the MBeanProxy associated with the given class and name from the JBoss microkernel as returned by
+ * <code>MBeanServerLocator.locateJBoss()</code>.
+ *
+ * @param expectedClass the expected class of the MBean's proxy
+ * @param name a String representation of the MBean's ObjectName
+ * @return a MBeanProxy for the specified MBean if it exists
+ * @throws IllegalArgumentException if the given name is not a valid ObjectName
+ * @throws RuntimeException if the MBean couldn't be retrieved
+ * @see #getMBeanProxy(Class, javax.management.ObjectName, javax.management.MBeanServer)
+ * @since 2.4
+ */
+ public static <T> T getMBeanProxy(Class<T> expectedClass, String name)
+ {
+ ObjectName objecName = createObjectName(name);
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ return getMBeanProxy(expectedClass, objecName, server);
+ }
+
+ private static ObjectName createObjectName(String name)
+ {
+ ObjectName objecName;
+ try
+ {
+ objecName = new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new IllegalArgumentException("'" + name + "' is not a valid ObjectName");
+ }
+ return objecName;
+ }
+
+ /**
+ * Checks whether the JBoss MBeanServer knows about an MBean with the specified name without having to retrieve a
+ * proxy to it.
+ *
+ * @param name a String representation of the MBean object name which registration status we're interested in
+ * @return <code>true</code> if the server knows of an MBean with the specified name, <code>false</code> otherwise.
+ */
+ public static boolean isRegistered(String name)
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ return server.isRegistered(createObjectName(name));
+ }
+
+ public static boolean addNotificationListener(
+ MBeanServer server,
+ ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object handback)
+ {
+ try
+ {
+ server.addNotificationListener(name, listener, filter, handback);
+ return true;
+ }
+ catch (InstanceNotFoundException e)
+ {
+ return false;
+ }
+ }
+
+ public static boolean removeNotificationListener(
+ MBeanServer server,
+ ObjectName name,
+ NotificationListener listener)
+ {
+ try
+ {
+ server.removeNotificationListener(name, listener);
+ return true;
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.error("Cannot remove notification listener", e);
+ return false;
+ }
+ catch (ListenerNotFoundException e)
+ {
+ log.error("Cannot remove notification listener", e);
+ return false;
+ }
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JMX.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDI.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDI.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDI.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as;
+
+import org.jboss.util.naming.NonSerializableFactory;
+
+import javax.naming.CompositeName;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * Various JNDI stuff.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JNDI
+{
+
+ /**
+ * Encapsulate JNDI binding operation into one single class, hidding non usefull JNDI complexity. It has been
+ * designed to fit with service life cycle.
+ * <p/>
+ * <code>
+ * <p/>
+ * private String jndiName; private JNDI.Binding jndiBinding;
+ * <p/>
+ * public void startService() throws Exception { ... if (this.jndiName != null) { jndiBinding = new
+ * JNDI.Binding(jndiName, this); jndiBinding.bind(); } ... }
+ * <p/>
+ * public void stopService() throws Exception { ... if (jndiBinding != null) { jndiBinding.unbind(); jndiBinding =
+ * null; } ... } </code>
+ */
+ public static class Binding
+ {
+
+ /** . */
+ private final String jndiName;
+
+ /** . */
+ private String unbindJNDIName;
+
+ /** . */
+ private Object o;
+
+ public Binding(String jndiName, Object o)
+ {
+ if (jndiName == null)
+ {
+ throw new IllegalArgumentException("No JNDI name provided");
+ }
+ if (o == null)
+ {
+ throw new IllegalArgumentException("No object to bind for JNDI name " + jndiName);
+ }
+ this.jndiName = jndiName;
+ this.o = o;
+ }
+
+ /**
+ * Attempt to perform binding.
+ *
+ * @throws NamingException on failure
+ */
+ public void bind() throws NamingException
+ {
+ NonSerializableFactory.rebind(new CompositeName(jndiName), o, true);
+ unbindJNDIName = jndiName;
+ }
+
+ /** Unbinds in a safe manner. */
+ public void unbind()
+ {
+ if (unbindJNDIName != null)
+ {
+ try
+ {
+ NonSerializableFactory.unbind(unbindJNDIName);
+ }
+ catch (NameNotFoundException ignore)
+ {
+ }
+ }
+ }
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDI.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDIBinder.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDIBinder.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/JNDIBinder.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * A service that binds an injected service to the JNDI registry.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JNDIBinder extends AbstractJBossService
+{
+
+ /** The jndi name. */
+ private String jndiName;
+
+ /** The injected service that will be bound. */
+ private Object targetObject;
+
+ /** The jndi binding object. */
+ private JNDI.Binding jndiBinding;
+
+ public String getJNDIName()
+ {
+ return jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Object getTargetObject()
+ {
+ return targetObject;
+ }
+
+ public void setTargetObject(Object targetObject)
+ {
+ this.targetObject = targetObject;
+ }
+
+ protected void createService() throws Exception
+ {
+ if (jndiName == null)
+ {
+ throw new IllegalStateException("No jndi name provided");
+ }
+ }
+
+ protected void startService() throws Exception
+ {
+ if (targetObject == null)
+ {
+ throw new IllegalStateException("No target object to bind");
+ }
+
+ //
+ log.debug("About to bind service" + targetObject + " to JNDI with name " + jndiName);
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ log.debug("Service" + targetObject + " bound to JNDI with name " + jndiName);
+ }
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ }
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/AbstractJBossService.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/AbstractJBossService.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/AbstractJBossService.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import org.jboss.logging.Logger;
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * JBoss service integration helper.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class AbstractJBossService extends ServiceMBeanSupport
+{
+
+ public AbstractJBossService()
+ {
+ }
+
+ public AbstractJBossService(final Class type)
+ {
+ super(type);
+ }
+
+ public AbstractJBossService(final String category)
+ {
+ super(category);
+ }
+
+ public AbstractJBossService(final Logger log)
+ {
+ super(log);
+ }
+
+ public final int getState()
+ {
+ return super.getState();
+ }
+
+ public final String getStateString()
+ {
+ return super.getStateString();
+ }
+
+ public final void create() throws Exception
+ {
+ super.create();
+ }
+
+ public final void start() throws Exception
+ {
+ super.start();
+ }
+
+ public final void stop()
+ {
+ super.stop();
+ }
+
+ public final void destroy()
+ {
+ super.destroy();
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/AbstractJBossService.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JBossServiceModelMBean.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JBossServiceModelMBean.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JBossServiceModelMBean.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,543 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import org.apache.log4j.Logger;
+import org.jboss.mx.interceptor.AbstractInterceptor;
+import org.jboss.mx.interceptor.Interceptor;
+import org.jboss.mx.modelmbean.ModelMBeanInvoker;
+import org.jboss.mx.server.Invocation;
+import org.jboss.mx.server.InvocationContext;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.portal.common.mx.JavaBeanModelMBeanBuilder;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.system.ServiceMBeanSupport;
+import org.w3c.dom.Element;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.modelmbean.ModelMBeanConstructorInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfoSupport;
+import javax.management.modelmbean.ModelMBeanNotificationInfo;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JBossServiceModelMBean extends ModelMBeanInvoker
+{
+
+ // Attributes ----------------------------------------------------
+
+ static
+ {
+ try
+ {
+ serviceMixinInfo = JavaBeanModelMBeanBuilder.build(ServiceMixin.class, Object.class);
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ /** . */
+ private static final ModelMBeanInfo serviceMixinInfo;
+
+ /** . */
+ private static final Logger log = Logger.getLogger(JBossServiceModelMBean.class);
+
+ /** . */
+ public static final String PORTAL_KERNEL_NO_PROXIES = "portal.kernel.no_proxies";
+
+ // Constructors --------------------------------------------------
+
+ /** . */
+ private final boolean replaceProxies;
+
+ /** . */
+ private final ServiceMixin serviceMixin;
+
+ /** . */
+ private final POJOInjector injector;
+
+ /** . */
+ private final boolean createExists;
+
+ /** . */
+ private final boolean startExists;
+
+ /** . */
+ private final boolean stopExists;
+
+ /** . */
+ private final boolean destroyExists;
+
+ /** . */
+ private final boolean getStateExists;
+
+ /** . */
+ private final boolean getStateStringExists;
+
+ /** . */
+ private final boolean getManagedResourceExists;
+
+ public JBossServiceModelMBean(Object resource) throws MBeanException
+ {
+ this(resource, null, null);
+ }
+
+ public JBossServiceModelMBean(Object resource, Element config, String version) throws MBeanException
+ {
+ try
+ {
+ setManagedResource(resource, "ObjectReference");
+
+ //
+ boolean pojo = !(resource instanceof ServiceMBeanSupport);
+
+ // Build
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(resource.getClass(), pojo ? Object.class : ServiceMBeanSupport.class);
+
+ //
+ this.replaceProxies = "true".equals(System.getProperty(PORTAL_KERNEL_NO_PROXIES, "true"));
+ this.injector = new POJOInjector();
+ this.serviceMixin = new ServiceMixin(resource);
+
+ //
+ List mmois = Tools.toList(info.getOperations());
+ List mmais = Tools.toList(info.getAttributes());
+
+ //
+ boolean createExists = false;
+ boolean startExists = false;
+ boolean stopExists = false;
+ boolean destroyExists = false;
+ boolean getStateExists = false;
+ boolean getStateStringExists = false;
+ boolean getManagedResourceExists = false;
+
+ //
+ for (int i = 0; i < mmois.size(); i++)
+ {
+ ModelMBeanOperationInfo mmoi = (ModelMBeanOperationInfo)mmois.get(i);
+ if (mmoi.getSignature().length == 0)
+ {
+ if (mmoi.getName().equals("create"))
+ {
+ createExists = true;
+ }
+ else if (mmoi.getName().equals("start"))
+ {
+ startExists = true;
+ }
+ else if (mmoi.getName().equals("stop"))
+ {
+ stopExists = true;
+ }
+ else if (mmoi.getName().equals("destroy"))
+ {
+ destroyExists = true;
+ }
+ else if (mmoi.getName().equals("getState"))
+ {
+ getStateExists = true;
+ }
+ else if (mmoi.getName().equals("getStateString"))
+ {
+ getStateStringExists = true;
+ }
+ else if (mmoi.getName().equals("getManagedResource"))
+ {
+ getManagedResourceExists = true;
+ }
+ }
+ }
+
+ //
+ this.createExists = createExists;
+ this.startExists = startExists;
+ this.stopExists = stopExists;
+ this.destroyExists = destroyExists;
+ this.getStateExists = getStateExists;
+ this.getStateStringExists = getStateStringExists;
+ this.getManagedResourceExists = getManagedResourceExists;
+
+ //
+ if (!createExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("create"));
+ }
+ if (!startExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("start"));
+ }
+ if (!stopExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("stop"));
+ }
+ if (!destroyExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("destroy"));
+ }
+ if (!getStateExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("getState"));
+ mmais.add(serviceMixinInfo.getAttribute("State"));
+ }
+ if (!getStateStringExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("getStateString"));
+ mmais.add(serviceMixinInfo.getAttribute("StateString"));
+ }
+ if (!getManagedResourceExists)
+ {
+ mmois.add(serviceMixinInfo.getOperation("getManagedResource"));
+ mmais.add(serviceMixinInfo.getAttribute("ManagedResource"));
+ }
+
+ //
+ info = new ModelMBeanInfoSupport(
+ info.getClassName(),
+ info.getDescription(),
+ (ModelMBeanAttributeInfo[])mmais.toArray(new ModelMBeanAttributeInfo[mmais.size()]),
+ (ModelMBeanConstructorInfo[])info.getConstructors(),
+ (ModelMBeanOperationInfo[])mmois.toArray(new ModelMBeanOperationInfo[mmois.size()]),
+ (ModelMBeanNotificationInfo[])info.getNotifications());
+
+ //
+ setModelMBeanInfo(info);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new MBeanException(e);
+ }
+ catch (InvalidTargetObjectTypeException e)
+ {
+ throw new MBeanException(e, "Unsupported resource type: " + resourceType);
+ }
+ catch (Exception e)
+ {
+ throw new MBeanException(e);
+ }
+ }
+
+ // ModelMBean implementation -------------------------------------
+
+ public boolean isSupportedResourceType(Object resource, String resourceType)
+ {
+ return "ObjectReference".equals(resourceType);
+ }
+
+ public MBeanInfo getMBeanInfo()
+ {
+ return info;
+ }
+
+ //
+
+ protected void initDispatchers()
+ {
+ super.initDispatchers();
+
+ //
+ for (Iterator i = attributeContextMap.values().iterator(); i.hasNext();)
+ {
+ InvocationContext ctx = (InvocationContext)i.next();
+ if ("State".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return new Integer(serviceMixin.getState());
+ }
+ });
+ }
+ else if ("StateString".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return serviceMixin.getStateString();
+ }
+ });
+ }
+ else if ("ManagedResource".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return serviceMixin.getManagedResource();
+ }
+ });
+ }
+ else if (replaceProxies)
+ {
+ // Retrieve original dispatcher
+ final Interceptor dispatcher = ctx.getDispatcher();
+
+ //
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ if (InvocationContext.OP_SETATTRIBUTE.equals(invocation.getType()))
+ {
+ Object value = invocation.getArgs()[0];
+ if (value != null && Proxy.isProxyClass(value.getClass()))
+ {
+ Object handler = Proxy.getInvocationHandler(value);
+ if (handler instanceof MBeanProxyExt)
+ {
+ MBeanProxyExt pojoHandler = (MBeanProxyExt)handler;
+ POJOInjection injection = new POJOInjection(pojoHandler, dispatcher, invocation);
+ injector.addInjection(injection);
+ }
+ else
+ {
+ dispatcher.invoke(invocation);
+ }
+ }
+ else
+ {
+ dispatcher.invoke(invocation);
+ }
+
+ //
+ return null;
+ }
+ else
+ {
+ return dispatcher.invoke(invocation);
+ }
+ }
+ });
+ }
+ }
+
+ //
+ for (Iterator i = operationContextMap.values().iterator(); i.hasNext();)
+ {
+ InvocationContext ctx = (InvocationContext)i.next();
+ if ("create".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ serviceMixin.create();
+ return null;
+ }
+ });
+ }
+ else if ("start".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ serviceMixin.start();
+ return null;
+ }
+ });
+ }
+ else if ("stop".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ serviceMixin.stop();
+ return null;
+ }
+ });
+ }
+ else if ("destroy".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ serviceMixin.destroy();
+ return null;
+ }
+ });
+ }
+ else if ("getState".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return new Integer(serviceMixin.getState());
+ }
+ });
+ }
+ else if ("getStateString".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return serviceMixin.getStateString();
+ }
+ });
+ }
+ else if ("getManagedResource".equals(ctx.getName()))
+ {
+ ctx.setDispatcher(new AbstractInterceptor()
+ {
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ return serviceMixin.getManagedResource();
+ }
+ });
+ }
+ }
+ }
+
+ private static class ServiceMixin extends ServiceMBeanSupport
+ {
+
+ /** . */
+ private final Object resource;
+
+ public ServiceMixin(Object resource)
+ {
+ this.resource = resource;
+ }
+
+ protected void createService() throws Exception
+ {
+ execute("create");
+ }
+
+ protected void startService() throws Exception
+ {
+ execute("start");
+ }
+
+ protected void stopService() throws Exception
+ {
+ execute("stop");
+ }
+
+ protected void destroyService() throws Exception
+ {
+ execute("destroy");
+ }
+
+ public Object getManagedResource()
+ {
+ return resource;
+ }
+
+ private void execute(String lifecycle) throws Exception
+ {
+ Method m = null;
+ try
+ {
+ m = resource.getClass().getMethod(lifecycle, new Class[0]);
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+
+ //
+ if (m != null)
+ {
+ try
+ {
+ m.invoke(resource, new Object[0]);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable t = e.getTargetException();
+ if (t instanceof Exception)
+ {
+ throw (Exception)t;
+ }
+ else if (t instanceof Error)
+ {
+ throw (Error)t;
+ }
+ else
+ {
+ throw new Error(t);
+ }
+ }
+ }
+ }
+ }
+
+ // MBeanRegistration implementation *********************************************************************************
+
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ name = super.preRegister(server, name);
+
+ //
+ server.addNotificationListener(JMXConstants.MBEAN_SERVER_DELEGATE, injector, null, null);
+
+ //
+ return name;
+ }
+
+ public void postRegister(Boolean done)
+ {
+ super.postRegister(done);
+ }
+
+ public void preDeregister() throws Exception
+ {
+ getServer().removeNotificationListener(JMXConstants.MBEAN_SERVER_DELEGATE, injector);
+
+ //
+ super.preDeregister();
+ }
+
+ public void postDeregister()
+ {
+ super.postDeregister();
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JBossServiceModelMBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JMXConstants.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JMXConstants.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/JMXConstants.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface JMXConstants
+{
+ /** The name of the server delegate. */
+ ObjectName MBEAN_SERVER_DELEGATE = ObjectNameFactory.create("JMImplementation:type=MBeanServerDelegate");
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifeCycleAdapter.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifeCycleAdapter.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifeCycleAdapter.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,238 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import org.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanProxyCreationException;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.portal.jems.as.JMX;
+import org.jboss.system.ServiceController;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.system.ServiceMBean;
+
+import javax.management.AttributeChangeNotification;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerNotification;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Adapts JBoss lifecycle event handling and multiplex event from different sources into one source.
+ * <p/>
+ * It requires an MBeanServer and a ServiceController plugged into the MBeanServer.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class LifeCycleAdapter
+{
+
+ /** The name of the server delegate. */
+ private static final ObjectName MBEAN_SERVER_DELEGATE = ObjectNameFactory.create("JMImplementation:type=MBeanServerDelegate");
+
+ /** The logger. */
+ protected Logger log;
+
+ /** The service controller name. */
+ protected ServiceControllerMBean controller;
+
+ /** The server. */
+ protected MBeanServer server;
+
+ /** The delegated listener. */
+ private Listener listener;
+
+ /** The watched mbeans. */
+ private Set watched;
+
+ /** Create the rule for the given server. */
+ public LifeCycleAdapter(MBeanServer server)
+ {
+ try
+ {
+ this.log = Logger.getLogger(getClass());
+ this.controller = (ServiceControllerMBean)MBeanProxy.get(ServiceControllerMBean.class, ServiceController.OBJECT_NAME, server);
+ this.server = server;
+ this.listener = new Listener();
+ this.watched = Collections.synchronizedSet(new HashSet());
+ }
+ catch (MBeanProxyCreationException ignored)
+ {
+ }
+ }
+
+ /**
+ * Start the adapter.
+ *
+ * @throws IllegalStateException if the service controller is missing
+ */
+ public void start() throws IllegalStateException
+ {
+ JMX.addNotificationListener(server, MBEAN_SERVER_DELEGATE, listener, listener, null);
+ if (!JMX.addNotificationListener(server, ServiceControllerMBean.OBJECT_NAME, listener, listener, null))
+ {
+ throw new IllegalStateException("The service controller is not here");
+ }
+ }
+
+ /** Stop the adapter */
+ public void stop()
+ {
+ JMX.removeNotificationListener(server, ServiceControllerMBean.OBJECT_NAME, listener);
+ JMX.removeNotificationListener(server, MBEAN_SERVER_DELEGATE, listener);
+ server = null;
+ watched.clear();
+ }
+
+ public void addStateListener(ObjectName name)
+ {
+ try
+ {
+ server.addNotificationListener(name, listener, listener, name);
+ watched.add(name);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot become a listener of " + name, e);
+ }
+ }
+
+ public void removeStateListener(ObjectName name)
+ {
+ try
+ {
+ server.removeNotificationListener(name, listener);
+ watched.remove(name);
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+// protected void registered(ObjectName name)
+// {
+// }
+//
+// protected void unregistered(ObjectName name)
+// {
+// }
+
+ protected void created(ObjectName name)
+ {
+ }
+
+ protected void starting(ObjectName name)
+ {
+ }
+
+ protected void started(ObjectName name)
+ {
+ }
+
+ protected void stopping(ObjectName name)
+ {
+ }
+
+ protected void stopped(ObjectName name)
+ {
+ }
+
+ protected void destroyed(ObjectName name)
+ {
+ }
+
+ private class Listener implements NotificationListener, NotificationFilter
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4049015398272819164L;
+
+ public boolean isNotificationEnabled(Notification notification)
+ {
+ return true;
+ }
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ String type = notification.getType();
+ if (type == MBeanServerNotification.REGISTRATION_NOTIFICATION)
+ {
+ MBeanServerNotification msn = (MBeanServerNotification)notification;
+ ObjectName name = msn.getMBeanName();
+ // registered(name);
+ }
+ else if (type == MBeanServerNotification.UNREGISTRATION_NOTIFICATION)
+ {
+ MBeanServerNotification msn = (MBeanServerNotification)notification;
+ ObjectName name = msn.getMBeanName();
+ // unregistered(name);
+ }
+ else if (type == AttributeChangeNotification.ATTRIBUTE_CHANGE)
+ {
+ AttributeChangeNotification acn = (AttributeChangeNotification)notification;
+ ObjectName name = (ObjectName)handback;
+ if ("State".equals(acn.getAttributeName()))
+ {
+ int state = ((Integer)acn.getNewValue()).intValue();
+ switch (state)
+ {
+ case ServiceMBean.STARTING:
+ starting(name);
+ break;
+ case ServiceMBean.STARTED:
+ started(name);
+ break;
+ case ServiceMBean.STOPPING:
+ stopping(name);
+ break;
+ case ServiceMBean.STOPPED:
+ stopped(name);
+ break;
+ default:
+ }
+ }
+ }
+ else if (type == ServiceMBean.CREATE_EVENT)
+ {
+ ObjectName name = (ObjectName)notification.getUserData();
+ if (watched.contains(name))
+ {
+ created(name);
+ }
+ }
+ else if (type == ServiceMBean.DESTROY_EVENT)
+ {
+ ObjectName name = (ObjectName)notification.getUserData();
+ if (watched.contains(name))
+ {
+ destroyed(name);
+ }
+ }
+ }
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifeCycleAdapter.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifecycleInvoker.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifecycleInvoker.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifecycleInvoker.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+/**
+ * A jmx method invoker based on the lifecycle.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class LifecycleInvoker extends AbstractJBossService
+{
+
+ /** . */
+ private ObjectName target;
+
+ /** . */
+ private String onCreate;
+
+ /** . */
+ private String onStart;
+
+ /** . */
+ private String onStop;
+
+ /** . */
+ private String onDestroy;
+
+ public ObjectName getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(ObjectName target)
+ {
+ this.target = target;
+ }
+
+ public String getOnCreate()
+ {
+ return onCreate;
+ }
+
+ public void setOnCreate(String onCreate)
+ {
+ this.onCreate = onCreate;
+ }
+
+ public String getOnStart()
+ {
+ return onStart;
+ }
+
+ public void setOnStart(String onStart)
+ {
+ this.onStart = onStart;
+ }
+
+ public String getOnStop()
+ {
+ return onStop;
+ }
+
+ public void setOnStop(String onStop)
+ {
+ this.onStop = onStop;
+ }
+
+ public String getOnDestroy()
+ {
+ return onDestroy;
+ }
+
+ public void setOnDestroy(String onDestroy)
+ {
+ this.onDestroy = onDestroy;
+ }
+
+ private void invoke(String methodName)
+ {
+ try
+ {
+ log.debug("About to invoke " + methodName + " on mbean " + target);
+ server.invoke(target, methodName, new Object[0], new String[0]);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.debug("The mbean " + target + " does not exist and " + methodName + " cannot be invoked");
+ }
+ catch (MBeanException e)
+ {
+ Throwable t = e.getCause();
+ log.error("The mbean " + target + " threw an exception during the invocation of the method " + methodName, t);
+ }
+ catch (ReflectionException e)
+ {
+ log.error("The mbean " + target + " invocation of method " + methodName, e);
+ }
+ }
+
+ protected void createService() throws Exception
+ {
+ if (onCreate != null)
+ {
+ invoke(onCreate);
+ }
+ }
+
+ protected void startService() throws Exception
+ {
+ if (onStart != null)
+ {
+ invoke(onStart);
+ }
+ }
+
+ protected void stopService() throws Exception
+ {
+ if (onStop != null)
+ {
+ invoke(onStop);
+ }
+ }
+
+ protected void destroyService() throws Exception
+ {
+ if (onDestroy != null)
+ {
+ invoke(onDestroy);
+ }
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/LifecycleInvoker.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjection.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjection.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjection.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import org.jboss.mx.interceptor.Interceptor;
+import org.jboss.mx.server.Invocation;
+import org.jboss.mx.server.registry.MBeanEntry;
+import org.jboss.mx.util.MBeanProxyExt;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class POJOInjection
+{
+
+ /** The dispatcher. */
+ private final Interceptor dispatcher;
+
+ /** The setter invocation. */
+ private final Invocation setter;
+
+ /** The mbean server. */
+ private final MBeanServer server;
+
+ /** The pojo object name. */
+ private final ObjectName pojoName;
+
+ /** The injection status. */
+ private boolean injected;
+
+ public POJOInjection(MBeanProxyExt pojoHandler, Interceptor dispatcher, Invocation setter)
+ {
+ this.dispatcher = dispatcher;
+ this.setter = setter;
+ this.server = pojoHandler.getMBeanProxyMBeanServer();
+ this.pojoName = pojoHandler.getMBeanProxyObjectName();
+ this.injected = false;
+ }
+
+ public ObjectName getPOJOName()
+ {
+ return pojoName;
+ }
+
+ public synchronized void resolve()
+ {
+ if (!injected)
+ {
+ if (server.isRegistered(pojoName))
+ {
+ try
+ {
+ // Get the mbean entry
+ MBeanEntry entry = (MBeanEntry)server.invoke(new ObjectName("JMImplementation:type=MBeanRegistry"), "get", new Object[]{pojoName}, new String[]{ObjectName.class.getName()});
+
+ //
+ if (entry != null)
+ {
+ // Get the managed resource (aka the service)
+ Object pojo = entry.getInvoker().getResource();
+
+ // Replace the proxy by the service
+ setter.getArgs()[0] = pojo;
+
+ // Dispatch the invocation finally
+ dispatcher.invoke(setter);
+
+ //
+ this.injected = true;
+ }
+ }
+ catch (InstanceNotFoundException ignore)
+ {
+ // It means that between the registration check and the get
+ // the service was removed
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ else
+ {
+ if (!server.isRegistered(pojoName))
+ {
+ try
+ {
+ // Replace the proxy by the service
+ setter.getArgs()[0] = null;
+
+ // Dispatch the invocation finally
+ dispatcher.invoke(setter);
+
+ //
+ this.injected = false;
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjector.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjector.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/as/system/POJOInjector.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.as.system;
+
+import javax.management.MBeanServerNotification;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class POJOInjector implements NotificationListener
+{
+
+ /** . */
+ private final Map injections;
+
+ public POJOInjector()
+ {
+ this.injections = new HashMap();
+ }
+
+ public void addInjection(POJOInjection injection)
+ {
+ injections.put(injection.getPOJOName(), injection);
+
+ //
+ injection.resolve();
+ }
+
+ public void handleNotification(Notification notification, Object object)
+ {
+ String type = notification.getType();
+ if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(type) || MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(type))
+ {
+ MBeanServerNotification msn = (MBeanServerNotification)notification;
+ ObjectName name = msn.getMBeanName();
+ POJOInjection injection = (POJOInjection)injections.get(name);
+ if (injection != null)
+ {
+ injection.resolve();
+ }
+ }
+ }
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvoker.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvoker.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvoker.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,245 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.ha;
+
+import org.jboss.ha.singleton.HASingletonSupport;
+import org.jboss.invocation.Invocation;
+import org.jboss.naming.Util;
+
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class HASingletonInvoker extends HASingletonSupport implements HASingletonInvokerMBean
+{
+ /** The proxy factory. */
+ private ObjectName proxyFactory;
+
+ /** The cached proxy. */
+ private Proxy proxy;
+
+ /** Where is bound the ha proxy. */
+ private String jndiName;
+
+ /** The callback service which this service depends on. */
+ private Callback callback;
+
+ /** The JNDI properties. */
+ private Properties jndiProperties;
+
+ /** How many time we retry on fail over. */
+ private int maxRetries;
+
+ /** How long we wait before trying a jndi lookup during fail over. */
+ private long retryWaitingTimeMS;
+
+ public long getRetryWaitingTimeMS()
+ {
+ return retryWaitingTimeMS;
+ }
+
+ public void setRetryWaitingTimeMS(long retryWaitingTimeMS)
+ {
+ this.retryWaitingTimeMS = retryWaitingTimeMS;
+ }
+
+ public int getMaxRetries()
+ {
+ return maxRetries;
+ }
+
+ public void setMaxRetries(int maxRetries)
+ {
+ this.maxRetries = maxRetries;
+ }
+
+ public Properties getJNDIProperties()
+ {
+ return jndiProperties;
+ }
+
+ public void setJNDIProperties(Properties jndiProperties)
+ {
+ this.jndiProperties = jndiProperties;
+ }
+
+ public ObjectName getProxyFactory()
+ {
+ return proxyFactory;
+ }
+
+ public void setProxyFactory(ObjectName proxyFactory)
+ {
+ this.proxyFactory = proxyFactory;
+ }
+
+ public Callback getCallback()
+ {
+ return callback;
+ }
+
+ public void setCallback(Callback callback)
+ {
+ this.callback = callback;
+ }
+
+ public String getJNDIName()
+ {
+ return jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Proxy lookupProxy()
+ {
+ if (proxy == null)
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext(jndiProperties);
+ proxy = (Proxy)ctx.lookup(jndiName);
+ }
+ catch (NamingException e)
+ {
+ log.error("Proxy " + jndiName + " not bound");
+ }
+ }
+ return proxy;
+ }
+
+ public Object invoke(String methodName, Class[] types, Object[] args) throws Exception
+ {
+ int retries = maxRetries;
+ while (retries-- > 0)
+ {
+ try
+ {
+ Proxy proxy = lookupProxy();
+ return proxy.invoke(methodName, types, args);
+ }
+ catch (Throwable t)
+ {
+ if (!(t instanceof Error))
+ {
+ proxy = null;
+ if (retries > 0)
+ {
+ log.error("Cannot invoke proxy will retry " + retries + " times", t);
+ try
+ {
+ log.debug("Sleeping for " + retryWaitingTimeMS + " before trying to fail over");
+ Thread.sleep(retryWaitingTimeMS);
+ }
+ catch (InterruptedException ignore)
+ {
+ // Get out of the loop
+ retries = 0;
+ }
+ }
+ else
+ {
+ log.error("Cannot invoke proxy will no more retry", t);
+ }
+ }
+ else
+ {
+ throw (Error)t;
+ }
+ }
+ }
+ // Todo : throw exception
+ return null;
+ }
+
+ protected void startService() throws Exception
+ {
+ callback.setInvoker(this);
+
+ //
+ super.startService();
+ }
+
+ protected void stopService() throws Exception
+ {
+ super.stopService();
+
+ //
+ callback.setInvoker(null);
+ }
+
+ public void startSingleton()
+ {
+ String name = callback.getDisplayName();
+
+ //
+ try
+ {
+
+ // Start the service.
+ log.debug("Starting singleton " + name);
+ callback.startSingleton();
+ log.debug("Singleton " + name + " started");
+
+ //
+ log.debug("Binding singleton proxy " + name);
+ Object proxy = server.getAttribute(proxyFactory, "Proxy");
+ Util.bind(new InitialContext(), jndiName, proxy);
+ log.debug("Singleton proxy " + name + " bound");
+ }
+ catch (Exception e)
+ {
+ log.error("Not able to start singleton " + name + " bound", e);
+ }
+ }
+
+ public void stopSingleton()
+ {
+ // Stop the singleton
+ if (callback != null)
+ {
+ //
+ String name = callback.getDisplayName();
+
+ //
+ log.debug("Stopping singleton proxy " + name);
+ callback.stopSingleton();
+ log.debug("Singleton " + name + " stopped");
+ }
+ }
+
+ public Object invoke(Invocation mi) throws Exception
+ {
+ Method m = mi.getMethod();
+ Object[] args = mi.getArguments();
+ return callback.invoke(m.getName(), m.getParameterTypes(), args);
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvoker.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvokerMBean.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvokerMBean.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvokerMBean.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.ha;
+
+import org.jboss.ha.singleton.HASingletonMBean;
+
+import javax.management.ObjectName;
+import java.util.Properties;
+
+/**
+ * The ha singleton invoker service extends the ha singleton service and adds the capability to invoke the singleton
+ * service from the cluster.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface HASingletonInvokerMBean extends HASingletonMBean
+{
+
+ /** Get the callback of the invoker. */
+ HASingletonInvoker.Callback getCallback();
+
+ /** @see #getCallback() */
+ void setCallback(HASingletonInvoker.Callback callback);
+
+ /** Return the JNDI name under which the proxy is bound. */
+ String getJNDIName();
+
+ /** @see #getJNDIName() */
+ void setJNDIName(String jndiName);
+
+ /** Return the name of the proxy factory to use. */
+ ObjectName getProxyFactory();
+
+ /** @see #getProxyFactory() */
+ void setProxyFactory(ObjectName proxyFactory);
+
+ /** Return the JNDI configuration to lookup the proxy. */
+ Properties getJNDIProperties();
+
+ /** @see #getJNDIProperties() */
+ void setJNDIProperties(Properties jndiProperties);
+
+ /** Return the max number of retries when an invocation is done. */
+ int getMaxRetries();
+
+ /** @see #getMaxRetries() */
+ void setMaxRetries(int maxRetries);
+
+ /** Return the time that the thread will sleep before looking up a proxy during fail over. */
+ long getRetryWaitingTimeMS();
+
+ /** @see #getRetryWaitingTimeMS() */
+ void setRetryWaitingTimeMS(long retryWaitingTimeMS);
+
+ /** Return the proxy, if it is cached then it will return the cached proxy otherwise it will perform a JNDI lookup. */
+ HASingletonInvoker.Proxy lookupProxy();
+
+ /**
+ * Invoke the service through the invoker. When the service proxy throws an exception the invoker waits for a
+ * specific duration and then perform a new lookup for a certain amount of time.
+ */
+ Object invoke(String methodName, Class[] types, Object[] args) throws Exception;
+
+ /** Contract layer that defines the interactions between the service and the ha invoker. */
+ interface Callback
+ {
+ /**
+ * Set the invoker on the client, if the invoker is not null then the invoker is available otherwise if it is null
+ * then the invoker is not available.
+ */
+ void setInvoker(HASingletonInvoker invoker);
+
+ /** Start the singleton. */
+ void startSingleton();
+
+ /** Stop the singleton. */
+ void stopSingleton();
+
+ /** Invocation callback */
+ Object invoke(String methodName, Class[] types, Object[] args) throws Exception;
+
+ /** Provide a simple display name for logging purpose. */
+ String getDisplayName();
+ }
+
+ /** The proxy interface bound in JNDI. */
+ interface Proxy
+ {
+ Object invoke(String methodName, Class[] types, Object[] args) throws Exception;
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/ha/HASingletonInvokerMBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ByteArrayBlob.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ByteArrayBlob.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ByteArrayBlob.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,161 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Blob;
+import java.sql.SQLException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public final class ByteArrayBlob implements Blob
+{
+
+ /** . */
+ byte[] _bytes;
+
+ public ByteArrayBlob(InputStream in) throws IOException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ IOTools.copy(in, out);
+ _bytes = out.toByteArray();
+ }
+
+ public ByteArrayBlob(ByteArrayBlob that)
+ {
+ _bytes = that.getBytes(0, that._bytes.length);
+ }
+
+ public ByteArrayBlob(byte[] _bytes)
+ {
+ this._bytes = _bytes;
+ }
+
+ public ByteArrayBlob(Blob blob) throws SQLException
+ {
+ _bytes = blob.getBytes(1, (int)blob.length());
+ }
+
+ public long length()
+ {
+ return _bytes.length;
+ }
+
+ public byte[] getBytes(long pos, int length)
+ {
+ byte[] bytes = new byte[length];
+ // Why are we passing in 'pos'? It results in AOOBE.
+ //System.arraycopy(_bytes, (int)pos, bytes, 0, length);
+ System.arraycopy(_bytes, 0, bytes, 0, length);
+ return bytes;
+ }
+
+ public InputStream getBinaryStream()
+ {
+ return new ByteArrayInputStream(_bytes);
+ }
+
+ /*
+ * For JDK 1.6
+ * @see java.sql.Blob#getBinaryStream()
+ */
+ public InputStream getBinaryStream(long pos, long length)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * For JDK 1.6
+ * @see java.sql.Blob#free()
+ */
+ public void free()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int setBytes(long pos, byte[] bytes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int setBytes(long pos, byte[] bytes, int offset, int len)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public OutputStream setBinaryStream(long pos)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long position(byte pattern[], long start)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long position(Blob pattern, long start)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void truncate(long len)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public static ByteArrayBlob get(Blob blob) throws IOException, SQLException
+ {
+ if (blob instanceof ByteArrayBlob)
+ {
+ return (ByteArrayBlob)blob;
+ }
+ else
+ {
+ InputStream binaryStream = blob.getBinaryStream();
+ return new ByteArrayBlob(binaryStream);
+ }
+ }
+
+ public static ByteArrayBlob create(Blob blob) throws IOException, SQLException
+ {
+ if (blob instanceof ByteArrayBlob)
+ {
+ return new ByteArrayBlob((ByteArrayBlob)blob);
+ }
+ else
+ {
+ InputStream binaryStream = blob.getBinaryStream();
+ return new ByteArrayBlob(binaryStream);
+ }
+ }
+
+
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ByteArrayBlob.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/CacheableBlobUserType.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/CacheableBlobUserType.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/CacheableBlobUserType.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+import java.io.Serializable;
+import java.sql.Blob;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class CacheableBlobUserType implements UserType
+{
+
+ /** . */
+ private static final int[] SQL_TYPES = {Types.BLOB};
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass()
+ {
+ return Blob.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ if (x != null && y != null)
+ {
+ try
+ {
+ ByteArrayBlob _x = ByteArrayBlob.get((Blob)x);
+ ByteArrayBlob _y = ByteArrayBlob.get((Blob)y);
+ return java.util.Arrays.equals(_x._bytes, _y._bytes);
+ }
+ catch (Exception e)
+ {
+ throw new HibernateException(e);
+ }
+ }
+ return false;
+ }
+
+ public int hashCode(Object object) throws HibernateException
+ {
+ return object.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ Blob blob = rs.getBlob(names[0]);
+ return rs.wasNull() ? null : new ByteArrayBlob(blob);
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value == null)
+ {
+ st.setNull(index, Types.BLOB);
+ }
+ else
+ {
+ st.setBlob(index, (Blob)value);
+ }
+// if (value==null) {
+// st.setNull(index, Types.BLOB);
+// }
+// else {
+//
+// if (value instanceof SerializableBlob) {
+// value = ( (SerializableBlob) value ).getWrappedBlob();
+// }
+//
+// final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() &&
+// (value instanceof BlobImpl);
+//
+// if ( useInputStream ) {
+// BlobImpl blob = (BlobImpl) value;
+// st.setBinaryStream( index, blob.getBinaryStream(), (int) blob.length() );
+// }
+// else {
+// st.setBlob(index, (Blob) value);
+// }
+//
+// }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ try
+ {
+ return ByteArrayBlob.create((Blob)value);
+ }
+ catch (Exception e)
+ {
+ throw new HibernateException(e);
+ }
+ }
+
+ public boolean isMutable()
+ {
+ return true;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ return ((ByteArrayBlob)value)._bytes;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
+ {
+ if (cached == null)
+ {
+ return null;
+ }
+ return new ByteArrayBlob((byte[])cached);
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException
+ {
+ return original;
+ }
+
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/CacheableBlobUserType.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ContextObject.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ContextObject.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ContextObject.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+/**
+ * The contract interface for an object to obtain a context.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface ContextObject
+{
+ void setContext(Object context);
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ContextObject.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/DialectFactory.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/DialectFactory.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/DialectFactory.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.HibernateException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Ripped off hibernate 3.1 that is not in 3.0. A factory for generating Dialect instances.
+ *
+ * @author Steve Ebersole
+ * @version $Revision: 11473 $
+ */
+public class DialectFactory
+{
+
+
+ private DialectFactory()
+ {
+ }
+
+ /**
+ * Determine the appropriate Dialect to use given the database product name and major version.
+ *
+ * @param databaseName The name of the database product (obtained from metadata).
+ * @param databaseMajorVersion The major version of the database product (obtained from metadata).
+ * @return An appropriate dialect instance.
+ */
+ public static String determineDialect(String databaseName, int databaseMajorVersion)
+ {
+ if (databaseName == null)
+ {
+ throw new HibernateException("Hibernate Dialect must be explicitly set");
+ }
+
+ DatabaseDialectMapper mapper = (DatabaseDialectMapper)MAPPERS.get(databaseName);
+ if (mapper == null)
+ {
+ throw new HibernateException("Hibernate Dialect must be explicitly set for database: " + databaseName);
+ }
+
+ return mapper.getDialectClass(databaseMajorVersion);
+ }
+
+ /**
+ * For a given database product name, instances of DatabaseDialectMapper know which Dialect to use for different
+ * versions.
+ */
+ public static interface DatabaseDialectMapper
+ {
+ public String getDialectClass(int majorVersion);
+ }
+
+ /** A simple DatabaseDialectMapper for dialects which are independent of the underlying database product version. */
+ public static class VersionInsensitiveMapper implements DatabaseDialectMapper
+ {
+ private String dialectClassName;
+
+ public VersionInsensitiveMapper(String dialectClassName)
+ {
+ this.dialectClassName = dialectClassName;
+ }
+
+ public String getDialectClass(int majorVersion)
+ {
+ return dialectClassName;
+ }
+ }
+
+ private static final Map MAPPERS = new HashMap();
+
+ static
+ {
+ // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
+ MAPPERS.put("HSQL Database Engine", new VersionInsensitiveMapper("org.hibernate.dialect.HSQLDialect"));
+ MAPPERS.put("DB2/NT", new VersionInsensitiveMapper("org.hibernate.dialect.DB2Dialect"));
+ MAPPERS.put("MySQL", new VersionInsensitiveMapper("org.hibernate.dialect.MySQLDialect"));
+ MAPPERS.put("PostgreSQL", new VersionInsensitiveMapper("org.hibernate.dialect.PostgreSQLDialect"));
+ MAPPERS.put("Microsoft SQL Server Database", new VersionInsensitiveMapper("org.hibernate.dialect.SQLServerDialect"));
+ MAPPERS.put("Microsoft SQL Server", new VersionInsensitiveMapper("org.hibernate.dialect.SQLServerDialect"));
+ MAPPERS.put("Sybase SQL Server", new VersionInsensitiveMapper("org.hibernate.dialect.SybaseDialect"));
+ MAPPERS.put("Informix Dynamic Server", new VersionInsensitiveMapper("org.hibernate.dialect.InformixDialect"));
+
+ MAPPERS.put(
+ "Oracle",
+ new DatabaseDialectMapper()
+ {
+ public String getDialectClass(int majorVersion)
+ {
+ return majorVersion > 8
+ ? "org.hibernate.dialect.Oracle9Dialect"
+ : "org.hibernate.dialect.OracleDialect";
+ }
+ }
+ );
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/DialectFactory.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/HibernateProvider.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/HibernateProvider.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/HibernateProvider.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface HibernateProvider
+{
+ Configuration getConfig();
+
+ SessionFactory getSessionFactory();
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/HibernateProvider.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProvider.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProvider.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProvider.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.jboss.cache.TreeCache;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JBossTreeCacheProvider extends AbstractJBossService implements TreeCacheProvider, JBossTreeCacheProviderMBean
+{
+
+ private ObjectName cacheName;
+
+ public ObjectName getCacheName()
+ {
+ return cacheName;
+ }
+
+ public void setCacheName(ObjectName cacheName)
+ {
+ this.cacheName = cacheName;
+ }
+
+ public TreeCache getTreeCache()
+ {
+ try
+ {
+ return (TreeCache)server.getAttribute(cacheName, "Instance");
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot get cache instance", e);
+ return null;
+ }
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProviderMBean.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProviderMBean.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProviderMBean.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.jboss.cache.TreeCache;
+
+import javax.management.ObjectName;
+
+/**
+ */
+public interface JBossTreeCacheProviderMBean
+{
+
+ public ObjectName getCacheName();
+
+ public void setCacheName(ObjectName cacheName);
+
+ public TreeCache getTreeCache();
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JBossTreeCacheProviderMBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.apache.log4j.Logger;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheProvider;
+import org.hibernate.cache.OptimisticTreeCache;
+import org.hibernate.cache.TreeCache;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 9317 $
+ */
+public class JMXTreeCacheProvider implements CacheProvider
+{
+
+ /** Our logger. */
+ private static final Logger log = Logger.getLogger(JMXTreeCacheProvider.class);
+
+ public boolean isMinimalPutsEnabledByDefault()
+ {
+ return true;
+ }
+
+ public Cache buildCache(String regionName, Properties properties) throws CacheException
+ {
+ try
+ {
+ String objectNameAsString = properties.getProperty("hibernate.cache.object_name");
+ log.debug("Uses tree cache provider with object name " + objectNameAsString);
+
+ //
+ ObjectName providerName = ObjectName.getInstance(objectNameAsString);
+
+ //
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ TreeCacheProvider provider = (TreeCacheProvider)MBeanProxy.get(TreeCacheProvider.class, providerName, server);
+ org.jboss.cache.TreeCache cache = provider.getTreeCache();
+
+ //Select the proper type of hibernate cache to be used
+ Cache hibernateCache = null;
+ if(cache.getNodeLockingScheme().equalsIgnoreCase("OPTIMISTIC"))
+ {
+ log.debug("Selecting Optimistic Cache");
+ hibernateCache = new OptimisticTreeCache(cache, regionName);
+ }
+ else
+ {
+ log.debug("Selecting regular Tree Cache");
+ hibernateCache = new TreeCache(cache, regionName, cache.getTransactionManager());
+ }
+
+ return hibernateCache;
+ }
+ catch (Exception e)
+ {
+ throw new CacheException(e);
+ }
+ }
+
+ public long nextTimestamp()
+ {
+ return System.currentTimeMillis() / 100;
+ }
+
+ public void start(Properties properties) throws CacheException
+ {
+ }
+
+ public void stop()
+ {
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/JMXTreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/MagicString.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/MagicString.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/MagicString.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * An hibernate custom type that handles the fact that oracle stores an empty string as null. That types changes the
+ * semantic of string with the fact that a returned null string is equals to an empty string.
+ * <p/>
+ * I did not found a good name for that class so I choosed MagicString but it has nothing magic.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class MagicString implements UserType, Serializable
+{
+
+ private static final int[] TYPES = {Types.VARCHAR};
+
+ public int[] sqlTypes()
+ {
+ return TYPES;
+ }
+
+ public Class returnedClass()
+ {
+ return String.class;
+ }
+
+ public boolean equals(Object x, Object y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ if (x == null)
+ {
+ return ((String)y).length() == 0;
+ }
+ else if (y == null)
+ {
+ return ((String)x).length() == 0;
+ }
+ return x.equals(y);
+ }
+
+ public Object deepCopy(Object value)
+ {
+ return value;
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ String value = (String)Hibernate.STRING.nullSafeGet(resultSet, names[0]);
+ if (value != null)
+ {
+ return value;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
+ {
+ Hibernate.STRING.nullSafeSet(statement, value, index);
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
+ {
+ return cached;
+ }
+
+ public Serializable disassemble(Object value)
+ {
+ return (Serializable)value;
+ }
+
+ public int hashCode(Object object) throws HibernateException
+ {
+ return object.hashCode();
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException
+ {
+ return original;
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/MagicString.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ObjectContextualizer.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ObjectContextualizer.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ObjectContextualizer.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.event.EventListeners;
+import org.hibernate.event.PostLoadEvent;
+import org.hibernate.event.PostLoadEventListener;
+import org.hibernate.impl.SessionFactoryImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ObjectContextualizer
+{
+
+ public Object context;
+
+ public ObjectContextualizer(Object context)
+ {
+ this.context = context;
+ }
+
+ public void attach(SessionFactory sessionFactory)
+ {
+ EventListeners listeners = ((SessionFactoryImpl)sessionFactory).getEventListeners();
+ PostLoadEventListener[] lels1 = listeners.getPostLoadEventListeners();
+ PostLoadEventListener[] lels2 = new PostLoadEventListener[lels1.length + 1];
+ System.arraycopy(lels1, 0, lels2, 1, lels1.length);
+ lels2[0] = new PostLoadEventListener()
+ {
+ public void onPostLoad(PostLoadEvent postLoadEvent)
+ {
+ Object entity = postLoadEvent.getEntity();
+ if (entity instanceof ContextObject)
+ {
+ ContextObject object = (ContextObject)entity;
+ object.setContext(context);
+ }
+ }
+ };
+ listeners.setPostLoadEventListeners(lels2);
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/ObjectContextualizer.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/OracleStringUserType.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/OracleStringUserType.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/OracleStringUserType.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.OracleDialect;
+import org.hibernate.usertype.UserType;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class OracleStringUserType implements UserType
+{
+
+ private static final int[] SQL_TYPES = {Types.VARCHAR};
+
+ private static final String EMPTY_STRING = "__EMPTY_STRING__";
+
+ public Object assemble(Serializable arg0, Object arg1) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (Serializable)value;
+ }
+
+ public boolean equals(Object arg0, Object arg1) throws HibernateException
+ {
+ if (arg0 == arg1)
+ {
+ return true;
+ }
+ if ((arg0 == null) || (arg1 == null))
+ {
+ return false;
+ }
+ return arg0.equals(arg1);
+ }
+
+ public int hashCode(Object arg0) throws HibernateException
+ {
+ return arg0.hashCode();
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ String dbValue = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
+
+ if (dbValue == null)
+ {
+ return null;
+ }
+ else if (dbValue.equals(EMPTY_STRING))
+ {
+ return "";
+ }
+ else
+ {
+ return dbValue;
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value.equals(""))
+ {
+ Hibernate.STRING.nullSafeSet(st, EMPTY_STRING, index);
+ }
+ else
+ {
+ Hibernate.STRING.nullSafeSet(st, value, index);
+ }
+ }
+
+ public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Class returnedClass()
+ {
+ return String.class;
+ }
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+}
+
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/QNameUserType.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/QNameUserType.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/QNameUserType.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,138 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * An hibernate user type to persist the <code>javax.xml.namespace.QName</code> class on two database columns.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class QNameUserType implements UserType
+{
+
+ /** . */
+ private static final int[] SQL_TYPES = {Hibernate.STRING.sqlType()};
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass()
+ {
+ return QName.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ else if (x == null || y == null)
+ {
+ return false;
+ }
+ else
+ {
+ return x.equals(y);
+ }
+ }
+
+ public int hashCode(Object x) throws HibernateException
+ {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ // Test nullity
+ String value = resultSet.getString(names[0]);
+ if (resultSet.wasNull())
+ {
+ return null;
+ }
+
+ //
+ int pos = value.indexOf(':');
+ if (pos == -1)
+ {
+ return new QName(value);
+ }
+ else
+ {
+ String namespaceURI = value.substring(0, pos);
+ String localPart = value.substring(pos + 1);
+ return new QName(namespaceURI, localPart);
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value == null)
+ {
+ statement.setNull(index, SQL_TYPES[0]);
+ }
+ else
+ {
+ QName qname = (QName)value;
+ statement.setString(index, qname.getNamespaceURI() + ":" + qname.getLocalPart());
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (QName)value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
+ {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException
+ {
+ return original;
+ }
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,449 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.exception.SQLGrammarException;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.util.CLResourceLoader;
+import org.jboss.portal.common.util.LoaderResource;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Configures and binds the hibernate session factory.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 12426 $
+ */
+public class SessionFactoryBinder extends AbstractJBossService implements HibernateProvider
+{
+
+ /** doCheck result - schema ok */
+ private static final int RESULT_NONE = 0;
+
+ /** doCheck result - schema need updates */
+ private static final int RESULT_UPDATE = 1;
+
+ /** doCheck result - schema not exist */
+ private static final int RESULT_CREATE = 2;
+
+ /** . */
+ private String configLocation;
+
+ /** . */
+ private String setupLocation;
+
+ /** If true checks the schema existence on start and create it if necessary. */
+ private boolean doChecking;
+
+ /** The session factory. */
+ private SessionFactory sessionFactory;
+
+ /** Where we configure hibernate. */
+ private URL configURL;
+
+ /** . */
+ private LoaderResource setupResource;
+
+ /** The hibernate configuration object. */
+ protected Configuration config;
+
+ /**
+ *
+ */
+ private String dialectName;
+
+ /**
+ *
+ */
+ protected String jndiName;
+
+ public boolean getDoChecking()
+ {
+ return doChecking;
+ }
+
+ public void setDoChecking(boolean doChecking)
+ {
+ this.doChecking = doChecking;
+ }
+
+ public String getConfigLocation()
+ {
+ return configLocation;
+ }
+
+ public void setConfigLocation(String configLocation)
+ {
+ this.configLocation = configLocation;
+ }
+
+ public String getSetupLocation()
+ {
+ return setupLocation;
+ }
+
+ public void setSetupLocation(String setupLocation)
+ {
+ this.setupLocation = setupLocation;
+ }
+
+ public URL getConfigURL()
+ {
+ return configURL;
+ }
+
+ public LoaderResource getSetupResource()
+ {
+ return setupResource;
+ }
+
+ public Configuration getConfig()
+ {
+ return config;
+ }
+
+ public SessionFactory getSessionFactory()
+ {
+ return sessionFactory;
+ }
+
+ public String getDialectName()
+ {
+ return dialectName;
+ }
+
+ public String getJNDIName()
+ {
+ return jndiName;
+ }
+
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ /** During this step the hibernate configuration is created. */
+ protected void createService() throws Exception
+ {
+ // Setup URLs
+ if (configLocation == null)
+ {
+ throw new Exception("The config location is null");
+ }
+ configURL = Thread.currentThread().getContextClassLoader().getResource(configLocation);
+ if (configURL == null)
+ {
+ throw new Exception("The config " + configLocation + " does not exist");
+ }
+ if (!URLTools.exists(configURL))
+ {
+ throw new Exception("The config " + configURL + " does not exist");
+ }
+
+ //
+ if (setupLocation != null)
+ {
+ setupResource = new CLResourceLoader().getResource(setupLocation);
+ }
+
+ // Perform configuration
+ config = new Configuration();
+ config.configure(configURL);
+
+ // Force transaction manager lookup class and JTA env
+ setPropertyIfAbsent("transaction.auto_close_session", "true");
+ setPropertyIfAbsent("transaction.flush_before_completion", "true");
+ setPropertyIfAbsent("hibernate.transaction.flush_before_completion", "true");
+ setPropertyIfAbsent("hibernate.transaction.factory_class", "org.hibernate.transaction.JTATransactionFactory");
+ setPropertyIfAbsent("hibernate.transaction.manager_lookup_class", "org.hibernate.transaction.JBossTransactionManagerLookup");
+
+ // Set JNDI name if present and absent
+ if (jndiName != null)
+ {
+ setPropertyIfAbsent("hibernate.session_factory_name", jndiName);
+ }
+ }
+
+ private void setPropertyIfAbsent(String name, String value)
+ {
+ if (config.getProperty(name) == null)
+ {
+ config.setProperty(name, value);
+ }
+ }
+
+ /** During this step the session factory is created and the content creation is triggered. */
+ protected void startService() throws Exception
+ {
+ // Detect the dialect if necessary
+ dialectName = config.getProperty(Environment.DIALECT);
+ if (dialectName == null)
+ {
+ String dataSourceJNDI = config.getProperty(Environment.DATASOURCE);
+ log.debug("Detecting dialect with datasource " + dataSourceJNDI + " ...");
+ DataSource ds = (DataSource)new InitialContext().lookup(dataSourceJNDI);
+ Connection conn = null;
+ try
+ {
+ conn = ds.getConnection();
+ DatabaseMetaData meta = conn.getMetaData();
+ String databaseName = meta.getDatabaseProductName();
+ int databaseMajorVersion = getDatabaseMajorVersion(meta);
+ dialectName = DialectFactory.determineDialect(databaseName, databaseMajorVersion);
+ config.setProperty(Environment.DIALECT, dialectName);
+ log.debug("Detected dialect " + dialectName + ", database is (" + databaseName + "," + databaseMajorVersion + ")");
+ }
+ finally
+ {
+ IOTools.safeClose(conn);
+ }
+ }
+ log.debug("Using dialect " + dialectName);
+ if ("org.hibernate.dialect.HSQLDialect".equals(dialectName))
+ {
+ log.warn("You are using the file based HSQL database, this is not recommended on a production environment and will not work properly on a clustered environment.");
+ }
+
+ //
+ createSessionFactory();
+
+ if (doChecking)
+ {
+ //check the schema
+ int check = doCheck();
+ switch (check)
+ {
+ case RESULT_NONE:
+ break;
+ case RESULT_UPDATE:
+ updateSchema();
+ break;
+ case RESULT_CREATE:
+ createSchema();
+ createContent();
+ break;
+ }
+ }
+ }
+
+ /** During this step the session factory is destroyed. */
+ protected void stopService() throws Exception
+ {
+ destroySessionFactory();
+ }
+
+ /** During this step the hibernate config is unreferenced. */
+ protected void destroyService() throws Exception
+ {
+ config = null;
+ }
+
+ public int doCheck()
+ {
+ Session session = null;
+ int numOfChecks = 0;
+ int bad = 0;
+ try
+ {
+ session = sessionFactory.openSession();
+ Collection values = sessionFactory.getAllClassMetadata().values();
+ numOfChecks = values.size();
+ for (Iterator i = values.iterator(); i.hasNext();)
+ {
+ ClassMetadata cmd = (ClassMetadata)i.next();
+ Query query = session.createQuery("from " + cmd.getEntityName());
+ query.setFirstResult(0);
+ query.setMaxResults(0);
+ try
+ {
+ query.list();
+ }
+ catch (SQLGrammarException e)
+ {
+ // We consider that exception means that the schema does not exist
+ bad++;
+ }
+ }
+ }
+ finally
+ {
+ IOTools.safeClose(session);
+ }
+ // There was no sql grammar exception - schema is ok!
+ if (bad == 0)
+ {
+ log.debug("The schema was checked as valid");
+ //do nothing
+ return RESULT_NONE;
+ }
+ // There is no existing valid schema;
+ else if (bad == numOfChecks)
+ {
+ log.debug("The schema was checked as not exists");
+ // Totaly invalid schema
+ return RESULT_CREATE;
+ }
+ // Schema is partialy corrupted
+ else if (bad < numOfChecks)
+ {
+ // Schema needs updates;
+ log.debug("The schema was checked as need updates");
+ return RESULT_UPDATE;
+ }
+
+ // If here something gone wrong...
+ log.debug("The schema was checked as need to be created");
+ return RESULT_CREATE;
+ }
+
+
+ public void createSchema()
+ {
+ log.debug("Creating database schema");
+ try
+ {
+ SchemaExport export = new SchemaExport(config);
+ export.create(false, true);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot create schema", e);
+ }
+ }
+
+ public void destroySchema()
+ {
+ log.debug("Destroying database schema");
+ try
+ {
+ SchemaExport export = new SchemaExport(config);
+ export.drop(false, true);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot destroy schema", e);
+ }
+ }
+
+ public void createContent()
+ {
+ if (setupResource != null)
+ {
+ if (setupResource.exists())
+ {
+ try
+ {
+ log.info("Creating database content");
+ String script = setupResource.asString("UTF-8");
+
+ // Create an interpreter and configures it
+ Interpreter interpreter = new Interpreter();
+ interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
+ interpreter.setOut(System.out);
+ interpreter.set("SessionFactory", sessionFactory);
+ interpreter.eval(script);
+ }
+ catch (EvalError e)
+ {
+ log.error("Error in the bsh script", e);
+ }
+ catch (IllegalStateException e)
+ {
+ log.error("Cannot load setup script", e);
+ }
+ }
+ else
+ {
+ log.warn("There is a setup URL but the not valid " + setupResource);
+ }
+ }
+ }
+
+ public void updateSchema()
+ {
+ log.debug("Updating database schema");
+ SchemaUpdate update = new SchemaUpdate(config);
+ update.execute(false, true);
+ }
+
+ /** Create the session factory. */
+ protected void createSessionFactory() throws Exception
+ {
+ sessionFactory = config.buildSessionFactory();
+ }
+
+ /** Close the session factory if it is not null. */
+ protected void destroySessionFactory()
+ {
+ if (sessionFactory != null)
+ {
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ else
+ {
+ log.debug("No session factory to close");
+ }
+ }
+
+ private int getDatabaseMajorVersion(DatabaseMetaData meta)
+ {
+ try
+ {
+ Method gdbmvMethod = DatabaseMetaData.class.getMethod("getDatabaseMajorVersion", null);
+ return ((Integer)gdbmvMethod.invoke(meta, null)).intValue();
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ return 0;
+ }
+ catch (Throwable t)
+ {
+ log.debug("could not get database version from JDBC metadata");
+ return 0;
+ }
+ }
+
+}
+
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/SessionFactoryBinder.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/StringWrapperUserType.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/StringWrapperUserType.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/StringWrapperUserType.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.UserType;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public abstract class StringWrapperUserType implements UserType, Serializable
+{
+
+ private static final int[] SQL_TYPES = {Types.VARCHAR};
+
+ public Object fromNull()
+ {
+ return null;
+ }
+
+ public String toNull()
+ {
+ return null;
+ }
+
+ public abstract Object fromString(String name);
+
+ public abstract String toString(Object value);
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ else if (x == null || y == null)
+ {
+ return false;
+ }
+ else
+ {
+ return x.equals(y);
+ }
+ }
+
+ public int hashCode(Object x) throws HibernateException
+ {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ String string = resultSet.getString(names[0]);
+
+ //
+ if (resultSet.wasNull())
+ {
+ return fromNull();
+ }
+ else
+ {
+ return fromString(string);
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
+ {
+ String string = value == null ? toNull() : toString(value);
+
+ //
+ if (string == null)
+ {
+ statement.setNull(index, Types.VARCHAR);
+ }
+ else
+ {
+ statement.setString(index, string);
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (Serializable)value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
+ {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException
+ {
+ return original;
+ }
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/StringWrapperUserType.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/TreeCacheProvider.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/TreeCacheProvider.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/TreeCacheProvider.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import org.jboss.cache.TreeCache;
+
+/**
+ * Provide a tree cache. <code>org.jboss.cache.TreeCache</code> is a concrete class and cannot be proxy injected. This
+ * interface enable injection and gives a way to the dependant to retrieve the cache.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface TreeCacheProvider
+{
+ TreeCache getTreeCache();
+}
Property changes on: modules/jems/trunk/jems/src/main/java/org/jboss/portal/jems/hibernate/TreeCacheProvider.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/ClassicService.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/ClassicService.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/ClassicService.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.jems;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassicService extends AbstractJBossService
+{
+
+ /** . */
+ private String string;
+
+ protected void createService()
+ {
+ System.out.println("create callback");
+ }
+
+ protected void startService()
+ {
+ System.out.println("start callback");
+ }
+
+ protected void stopService()
+ {
+ System.out.println("stop callback");
+ }
+
+ protected void destroyService()
+ {
+ System.out.println("destroy callback");
+ }
+
+ public void operation()
+ {
+ System.out.println("operation called");
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+
+ public void setString(String string)
+ {
+ this.string = string;
+ }
+}
Added: modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/POJOService.java
===================================================================
--- modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/POJOService.java (rev 0)
+++ modules/jems/trunk/jems/src/main/java/org/jboss/portal/test/jems/POJOService.java 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.jems;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class POJOService
+{
+
+ /** . */
+ private String string;
+
+ public void create()
+ {
+ System.out.println("create callback");
+ }
+
+ public void start()
+ {
+ System.out.println("start callback");
+ }
+
+ public void stop()
+ {
+ System.out.println("stop callback");
+ }
+
+ public void destroy()
+ {
+ System.out.println("destroy callback");
+ }
+
+ public void operation()
+ {
+ System.out.println("operation called");
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+
+ public void setString(String string)
+ {
+ this.string = string;
+ }
+}
Added: modules/jems/trunk/jems/src/main/resources/pojo-service-sar/META-INF/jboss-service.xml
===================================================================
--- modules/jems/trunk/jems/src/main/resources/pojo-service-sar/META-INF/jboss-service.xml (rev 0)
+++ modules/jems/trunk/jems/src/main/resources/pojo-service-sar/META-INF/jboss-service.xml 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<server>
+
+ <!-- -->
+ <mbean
+ code="org.jboss.portal.test.jems.POJOService"
+ name="portal.test:service=POJO"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <!-- -->
+ <mbean
+ code="org.jboss.portal.test.jems.ClassicService"
+ name="portal.test:service=Classic"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+</server>
Added: modules/jems/trunk/pom.xml
===================================================================
--- modules/jems/trunk/pom.xml (rev 0)
+++ modules/jems/trunk/pom.xml 2009-07-01 16:12:36 UTC (rev 13511)
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.jems</groupId>
+ <artifactId>module-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Portal JEMS support</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <url>http://www.jboss.org/jbossportal</url>
+
+ <dependencies/>
+
+ <!--Repository definition needed to deploy artifacts into JBoss maven repositories-->
+ <distributionManagement>
+ <repository>
+ <!--Copy the distribution jar file to a local checkout of the maven repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ <uniqueVersion>true</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <modules>
+ <module>build</module>
+ <module>jems</module>
+ </modules>
+
+
+</project>
\ No newline at end of file
14 years, 11 months
JBoss Portal SVN: r13509 - jbossexo.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2009-07-01 05:51:08 -0400 (Wed, 01 Jul 2009)
New Revision: 13509
Added:
jbossexo/branches/
Log:
Branches
14 years, 11 months