Author: chris.laprun(a)jboss.com
Date: 2011-09-16 18:33:32 -0400 (Fri, 16 Sep 2011)
New Revision: 7459
Added:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/LastModifiedMixinHolder.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/MixinHolder.java
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java
Log:
- Mutualized some mixin code.
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java 2011-09-16
22:31:51 UTC (rev 7458)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java 2011-09-16
22:33:32 UTC (rev 7459)
@@ -30,6 +30,7 @@
import org.chromattic.api.annotations.PrimaryType;
import org.chromattic.api.annotations.Property;
import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
+import org.gatein.wsrp.jcr.mapping.mixins.MixinHolder;
import org.gatein.wsrp.jcr.mapping.mixins.WSSEndpointEnabled;
/**
@@ -37,7 +38,7 @@
* @version $Revision$
*/
@PrimaryType(name = EndpointInfoMapping.NODE_NAME)
-public abstract class EndpointInfoMapping
+public abstract class EndpointInfoMapping extends MixinHolder<WSSEndpointEnabled>
{
public static final String NODE_NAME = "wsrp:endpointinfo";
@@ -62,12 +63,12 @@
public void setWSSEnabled(boolean wssEnabled)
{
- getCreatedWSSEndpointEnabledMixin().setWSSEnabled(wssEnabled);
+ getCreatedMixin().setWSSEnabled(wssEnabled);
}
public boolean isWSSEnabled()
{
- return getCreatedWSSEndpointEnabledMixin().getWSSEnabled();
+ return getCreatedMixin().getWSSEnabled();
}
public void initFrom(EndpointConfigurationInfo info)
@@ -85,15 +86,21 @@
return initial;
}
- private WSSEndpointEnabled getCreatedWSSEndpointEnabledMixin()
+ @Override
+ public WSSEndpointEnabled getMixin()
{
- WSSEndpointEnabled wssEndpointEnabledMixin = getWSSEndpointEnabledMixin();
- if (wssEndpointEnabledMixin == null)
- {
- wssEndpointEnabledMixin = createWSSEndpointEnabledMixin();
- setWSSEndpointEnabledMixin(wssEndpointEnabledMixin);
- wssEndpointEnabledMixin.initializeValue();
- }
- return wssEndpointEnabledMixin;
+ return getWSSEndpointEnabledMixin();
}
+
+ @Override
+ protected void setMixin(WSSEndpointEnabled mixin)
+ {
+ setWSSEndpointEnabledMixin(mixin);
+ }
+
+ @Override
+ protected WSSEndpointEnabled createMixin()
+ {
+ return createWSSEndpointEnabledMixin();
+ }
}
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java 2011-09-16
22:31:51 UTC (rev 7458)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java 2011-09-16
22:33:32 UTC (rev 7459)
@@ -37,7 +37,7 @@
import org.gatein.wsrp.consumer.RegistrationInfo;
import org.gatein.wsrp.consumer.spi.ConsumerRegistrySPI;
import org.gatein.wsrp.jcr.mapping.BaseMapping;
-import org.gatein.wsrp.jcr.mapping.mixins.LastModified;
+import org.gatein.wsrp.jcr.mapping.mixins.LastModifiedMixinHolder;
import org.gatein.wsrp.jcr.mapping.mixins.ModifyRegistrationRequired;
/**
@@ -45,7 +45,7 @@
* @version $Revision$
*/
@PrimaryType(name = ProducerInfoMapping.NODE_NAME)
-public abstract class ProducerInfoMapping implements BaseMapping<ProducerInfo,
ConsumerRegistrySPI>
+public abstract class ProducerInfoMapping extends LastModifiedMixinHolder implements
BaseMapping<ProducerInfo, ConsumerRegistrySPI>
{
public static final String NODE_NAME = "wsrp:producerinfo";
@@ -80,15 +80,6 @@
@OneToOne(type = RelationshipType.EMBEDDED)
@Owner
- public abstract LastModified getLastModifiedMixin();
-
- protected abstract void setLastModifiedMixin(LastModified lastModifiedMixin);
-
- @Create
- protected abstract LastModified createLastModifiedMixin();
-
- @OneToOne(type = RelationshipType.EMBEDDED)
- @Owner
public abstract ModifyRegistrationRequired getModifyRegistrationRequiredMixin();
protected abstract void setModifyRegistrationRequiredMixin(ModifyRegistrationRequired
mmr);
@@ -111,16 +102,6 @@
return getCreatedModifyRegistrationRequiredMixin().isModifyRegistrationRequired();
}
- public void setLastModified(long lastModified)
- {
- getCreatedLastModifiedMixin().setLastModified(lastModified);
- }
-
- public long getLastModified()
- {
- return getCreatedLastModifiedMixin().getLastModified();
- }
-
public void initFrom(ProducerInfo producerInfo)
{
setActive(producerInfo.isActive());
@@ -165,18 +146,6 @@
return info;
}
- private LastModified getCreatedLastModifiedMixin()
- {
- LastModified lm = getLastModifiedMixin();
- if (lm == null)
- {
- lm = createLastModifiedMixin();
- setLastModifiedMixin(lm);
- lm.initializeValue();
- }
- return lm;
- }
-
private ModifyRegistrationRequired getCreatedModifyRegistrationRequiredMixin()
{
ModifyRegistrationRequired mmr = getModifyRegistrationRequiredMixin();
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java 2011-09-16
22:31:51 UTC (rev 7458)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java 2011-09-16
22:33:32 UTC (rev 7459)
@@ -23,13 +23,10 @@
package org.gatein.wsrp.consumer.registry.mapping;
-import org.chromattic.api.RelationshipType;
import org.chromattic.api.annotations.Create;
import org.chromattic.api.annotations.OneToMany;
-import org.chromattic.api.annotations.OneToOne;
-import org.chromattic.api.annotations.Owner;
import org.chromattic.api.annotations.PrimaryType;
-import org.gatein.wsrp.jcr.mapping.mixins.LastModified;
+import org.gatein.wsrp.jcr.mapping.mixins.LastModifiedMixinHolder;
import java.util.List;
import java.util.Map;
@@ -39,7 +36,7 @@
* @version $Revision$
*/
@PrimaryType(name = ProducerInfosMapping.NODE_NAME)
-public abstract class ProducerInfosMapping
+public abstract class ProducerInfosMapping extends LastModifiedMixinHolder
{
public static final String NODE_NAME = "wsrp:producerinfos";
@@ -51,37 +48,4 @@
@Create
public abstract ProducerInfoMapping createProducerInfo(String producerId);
-
- @OneToOne(type = RelationshipType.EMBEDDED)
- @Owner
- public abstract LastModified getLastModifiedMixin();
-
- protected abstract void setLastModifiedMixin(LastModified lastModifiedMixin);
-
- @Create
- protected abstract LastModified createLastModifiedMixin();
-
- public void setLastModified(long lastModified)
- {
- getCreatedLastModifiedMixin().setLastModified(lastModified);
- }
-
- public long getLastModified()
- {
- return getCreatedLastModifiedMixin().getLastModified();
- }
-
- private LastModified getCreatedLastModifiedMixin()
- {
- LastModified lm = getLastModifiedMixin();
- if (lm == null)
- {
- lm = createLastModifiedMixin();
- setLastModifiedMixin(lm);
- lm.initializeValue();
- }
- return lm;
- }
-
-
}
Added:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/LastModifiedMixinHolder.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/LastModifiedMixinHolder.java
(rev 0)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/LastModifiedMixinHolder.java 2011-09-16
22:33:32 UTC (rev 7459)
@@ -0,0 +1,69 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.gatein.wsrp.jcr.mapping.mixins;
+
+import org.chromattic.api.RelationshipType;
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Owner;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class LastModifiedMixinHolder extends MixinHolder<LastModified>
+{
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ @Owner
+ public abstract LastModified getLastModifiedMixin();
+
+ protected abstract void setLastModifiedMixin(LastModified lastModifiedMixin);
+
+ @Create
+ protected abstract LastModified createLastModifiedMixin();
+
+ public void setLastModified(long lastModified)
+ {
+ getCreatedMixin().setLastModified(lastModified);
+ }
+
+ public long getLastModified()
+ {
+ return getCreatedMixin().getLastModified();
+ }
+
+ @Override
+ public LastModified getMixin()
+ {
+ return getLastModifiedMixin();
+ }
+
+ @Override
+ protected void setMixin(LastModified mixin)
+ {
+ setLastModifiedMixin(mixin);
+ }
+
+ @Override
+ protected LastModified createMixin()
+ {
+ return createLastModifiedMixin();
+ }
+}
Added:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/MixinHolder.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/MixinHolder.java
(rev 0)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/MixinHolder.java 2011-09-16
22:33:32 UTC (rev 7459)
@@ -0,0 +1,45 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.gatein.wsrp.jcr.mapping.mixins;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public abstract class MixinHolder<M extends BaseMixin>
+{
+ protected M getCreatedMixin()
+ {
+ M mixin = getMixin();
+ if (mixin == null)
+ {
+ mixin = createMixin();
+ setMixin(mixin);
+ mixin.initializeValue();
+ }
+ return mixin;
+ }
+
+ public abstract M getMixin();
+
+ protected abstract void setMixin(M mixin);
+
+ protected abstract M createMixin();
+}